The Mathematica Journal
Download This Issue
Feature Articles
Graphics Gallery
Tricks of the Trade
In and Out
The Mathematica Programmer
New Products
New Publications
News Bulletins
Editor's Pick
Write Us
About the Journal
Staff and Contributors
Back Issues

Change of Variables in Differential Operators

There is no command or standard package for computing the effect of a change of variables in integrals or differential equations. However, all the necessary tools exist as built-in functions and hence the required functionality can be obtained through a straightforward combination of a few simple commands.

As a concrete example, consider [Graphics:../Images/index_gr_44.gif], where [Graphics:../Images/index_gr_45.gif] and [Graphics:../Images/index_gr_46.gif] are implicit functions of [Graphics:../Images/index_gr_47.gif] and [Graphics:../Images/index_gr_48.gif]. Using the chain rule, differentiation with respect to [Graphics:../Images/index_gr_49.gif] leads to the following equality.


On the left-hand side we use partial differentiation, but on the right we need to use total differentiation because [Graphics:../Images/index_gr_52.gif] and [Graphics:../Images/index_gr_53.gif] are implicit functions of [Graphics:../Images/index_gr_54.gif] and [Graphics:../Images/index_gr_55.gif].

The Jacobian matrix, [Graphics:../Images/index_gr_56.gif], is easily computed using Outer.


For example, with the change of variables [Graphics:../Images/index_gr_58.gif] and [Graphics:../Images/index_gr_59.gif], [Graphics:../Images/index_gr_60.gif], reads


When this matrix is invertible, the change of variables is (locally) invertible, and its Jacobian matrix, [Graphics:../Images/index_gr_63.gif], can be directly equated to the (matrix) inverse of [Graphics:../Images/index_gr_64.gif].


Evaluate is required so that the assignments are made--not to JacobianMatrix itself--but on an element-by-element basis to the matrix generated by JacobianMatrix. The identity generated by the chain rule becomes


which is an example of the sort of computation required for an arbitrary change of variables in a partial differential equation.

To compute [Graphics:../Images/index_gr_69.gif] and [Graphics:../Images/index_gr_70.gif] we have used pattern-matching: HoldPattern prevents the total differentiation of the pattern on the left-hand side, and delayed replacement ([Graphics:../Images/index_gr_71.gif]) delays the evaluation of the pattern on the right-hand side until after [Graphics:../Images/index_gr_72.gif] and [Graphics:../Images/index_gr_73.gif] have been matched. We need to use total differentiation because [Graphics:../Images/index_gr_74.gif] and [Graphics:../Images/index_gr_75.gif] are expressed as implicit functions of [Graphics:../Images/index_gr_76.gif] and [Graphics:../Images/index_gr_77.gif].

Computing higher derivatives this way is tedious. Also, there is another more subtle problem: because the first derivatives have been computed and stored


higher-partial derivatives are computed directly from this, and an incorrect result is obtained.


This is because this computation essentially involves


which vanishes because [Graphics:../Images/index_gr_84.gif] is not explicitly dependent upon [Graphics:../Images/index_gr_85.gif] and [Graphics:../Images/index_gr_86.gif].

Using Clear[Derivative] to clear all saved partial derivatives (which are assignments attached to Derivative), we modify the above steps to make the dependency of the functions on all variables explicit and combine them into a procedure.


Through[new@@old] and Thread[new->explicit] make explicit the dependency of the new variables upon the old variables.


Note that Clear[Derivative] has the unfortunate side-effect of removing any extra definitions for Derivative that have been defined during the current session. However, it is required so that the matrix of (inverse) partial derivatives, JacobianMatrix[explicit, old], can be computed without Set errors. It is rather more difficult to modify ChangeVariables so as to only Clear rules for Derivative generated by ChangeVariables itself.

Recomputing the (inverse) Jacobian matrix for the change of variables [Graphics:../Images/index_gr_90.gif] and [Graphics:../Images/index_gr_91.gif], we now obtain


and all higher derivatives are computed automatically, as in


where the result has been simplified by removing the explicit dependence on [Graphics:../Images/index_gr_96.gif] and [Graphics:../Images/index_gr_97.gif] using the replacement rule [Graphics:../Images/index_gr_98.gif].

We now compute the Laplacian, [Graphics:../Images/index_gr_99.gif], in spherical polar coordinates. The inverse Jacobian matrix reads


so the Laplacian acting on a function [Graphics:../Images/index_gr_102.gif], [Graphics:../Images/index_gr_103.gif], is


We use f_Function to restrict this rule to pure functions. We extend this specific rule to compute the Laplacian of any (explicit or implicit) function by converting f into a pure function as follows.


As examples, we compute the Laplacian of a spherically symmetric function


and a function with azimuthal symmetry (i.e., independent of [Graphics:../Images/index_gr_109.gif]).


We conclude by clearing ChangeVariables, [Graphics:../Images/index_gr_112.gif], and Derivative.


Converted by Mathematica      September 30, 1999

[Prev Page][Next Page]