The Mathematica Journal
Departments
Download This Issue
Home
Feature Articles
Graphics Gallery
Tricks of the Trade
In and Out
Columns
The Mathematica Programmer
New Products
New Publications
Classifieds
Calendar
News Bulletins
Editor's Pick
Mailbox
Letters
Write Us
About the Journal
Staff and Contributors
Submissions
Subscriptions
Advertising
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.

[Graphics:../Images/index_gr_50.gif]
[Graphics:../Images/index_gr_51.gif]

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.

[Graphics:../Images/index_gr_57.gif]

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

[Graphics:../Images/index_gr_61.gif]
[Graphics:../Images/index_gr_62.gif]

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].

[Graphics:../Images/index_gr_65.gif]
[Graphics:../Images/index_gr_66.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

[Graphics:../Images/index_gr_67.gif]
[Graphics:../Images/index_gr_68.gif]

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

[Graphics:../Images/index_gr_78.gif]
[Graphics:../Images/index_gr_79.gif]

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

[Graphics:../Images/index_gr_80.gif]
[Graphics:../Images/index_gr_81.gif]

This is because this computation essentially involves

[Graphics:../Images/index_gr_82.gif]
[Graphics:../Images/index_gr_83.gif]

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.

[Graphics:../Images/index_gr_87.gif]

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

[Graphics:../Images/index_gr_88.gif]
[Graphics:../Images/index_gr_89.gif]

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

[Graphics:../Images/index_gr_92.gif]
[Graphics:../Images/index_gr_93.gif]

and all higher derivatives are computed automatically, as in

[Graphics:../Images/index_gr_94.gif]
[Graphics:../Images/index_gr_95.gif]

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

[Graphics:../Images/index_gr_100.gif]
[Graphics:../Images/index_gr_101.gif]

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

[Graphics:../Images/index_gr_104.gif]
[Graphics:../Images/index_gr_105.gif]

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.

[Graphics:../Images/index_gr_106.gif]

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

[Graphics:../Images/index_gr_107.gif]
[Graphics:../Images/index_gr_108.gif]

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

[Graphics:../Images/index_gr_110.gif]
[Graphics:../Images/index_gr_111.gif]

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

[Graphics:../Images/index_gr_113.gif]


Converted by Mathematica      September 30, 1999

[Prev Page][Next Page]