Replacement of Variables

Introduction

The ReplaceVariables package provides a tool for performing of functional 
replacement of dependent and independent variables in systems of (partial) 
differential equations. The replacements are supplied by the user in the form 
of Mathematica rules. The package is accompanied by the palette notebook ReplaceVariables.nb.

Location of Package and its Initialisation

The package itself can be put in any directory (not only into 
AddOns/ExtraPackages) which is important for UNIX users not having the 
superuser privileges. The accompanying notebook ReplaceVariables.nb can be put into your working directory or into the 
SystemFiles/FrontEnd/Palettes/ directory (you must have the superuser 
privileges in order to make it in any UNIX system).

The simplest way to initialize the package is to open the palette notebook 
ReplaceVariables.nb. A simple palette will appear on the screen.

Click on the Load ReplaceVariables button. This invokes search of the package in the file system and its  automatic loading. Note that this behavior is operating system specific and may not work for all operating systems (it works for UNIX).  If it does not work for your operating system, follow the instructions below instead.

The alternative way is to load the package manually. At first add the 
directory containing it to the $Path variable (Note that MS Windows system needs a different directory 
separator)

AppendTo[$Path, "~/Here is the path to the required directory"];

and load the package.

Get["ReplaceVariables`"]

Now you can look at short description of the only function ReplaceVariables.

?ReplaceVariables

The second button in the palette pastes its content into an active notebook. It provides you  a simplest form of the function call suitable for functional replacement for a single function of a single variable. Below several examples of function usage are shown.

Simple Cases of Ordinary Differential Equations

The most simple case of the function usage is the case of an ordinary 
differential equation of a single function of a single variable. In order to 
demonstrate usage of the function ReplaceVariables[ ] we take some examples 
from the book of Kamke on ordinary differential equations.

Example 1

Consider a Ricatti equation  y'[x]+(x^(-a - 1)) y[x]^2==(x^a). Here two replacements can be used. The first one is a replacement for  both independent (x) and dependent (y) variables in the form: y[x]->η[ξ], and ξ -> -((x^a)/a), which leads to the Ricatti equation

ReplaceVariables[y'[x]+(x^(-a - 1)) y[x]^2==(x^a),ξ -> -((x^(-a))/a),y[x] -> η[ξ],η[ξ]]

Another replacement for dependent variable only will lead to a linear equation:

ReplaceVariables[y'[x]+(x^(-a - 1)) y[x]^2==(x^a),x -> x,y[x]->(((x^(a + 1)) η'[x])/(η[x])),η[x]]

Please note that in second case we should write a trivial replacement of  the independent variable x -> x.

Example 2

Here we demonstrate reduction of the original nonlinear equation to the  linear one by two consequent applications of the function ReplaceVariables[  ]. The equation reads as y'[x]+3 a y[x]^3+6 a x y[x]^2==0, and it is recommended to use the following replacement of the dependent  variable: y[x] -> u'[x].

r1=ReplaceVariables[y'[x]+3 a y[x]^3+6 a x y[x]^2==0,x -> x,y[x]->u'[x],u[x]]

The resulting equation now can be converted into the linear one if new dependent variable u is taken as independent one, and hence, the independent variable x is assumed to be dependent. It is made as follows:

ReplaceVariables[r1, x -> η[ξ], u[x] -> ξ, 

      η[ξ]]

More Examples of Ordinary Differential Equations

Integral Replacement

Here we consider a linear second order equation y''[x]+f[x] y'[x]+(\(f[x]\^2\/4\)+((f'[x])/2)+a) y[x]==0 which can be drastically simplified by means of a nontrivial integral  replacement of the dependent variable

ReplaceVariables[y''[x]+f[x] y'[x]+(\(f[x]\^2\/4\)+((f'[x])/2)+a) y[x]==0,x -> x,y[x] -> 

          u[x] Exp[-(1/2) ∫f[x] \[DifferentialD]x],u[x]]

Trigonometric Replacement

Trigonometric functions also can be used for simplifications:

ReplaceVariables[(x^2) y''[x]-(2 x Tan[x] - 1) x y'[x]-(x Tan[x] + a) y[x]==0,x -> x,y[x] -> u[x]/Cos[x],u[x]]

Usage of Complex Variables

In some case a complex valued substitution converts a nonlinear equation into the linear one:

ReplaceVariables[4 (x^2) y''[x]+4 x y'[x]-(4 (x^2) + 1) y[x]-4 (x^(3/2)) Exp[x]==0,x -> 2 I (Sqrt[ξ]),y[x] -> (1/(Sqrt[x])) η[ξ],η[ξ]]

Lowering of the Equation's Order

In the following example a derivative of the dependent variable y'[x] is replaced by a new variable p[y], leading to the first-order equation:

ReplaceVariables[y''[x]+f[y[x]] ((y'[x])^2)+g[y[x]] y'[x]+h[y[x]]==0,x -> ∫(1/p)[y] \[DifferentialD]y,y[x] -> y,p[y]]

Replacement of old dependent variable by a new independent one

Consider a second-order equation y''[x] == a (Sqrt[((y'[x])^2)+1]). It doesn't contain explicitely neither dependent (y), nor independent  (x) variables, but only derivatives. In this case y can be taken as new  independent variable: y[x]→ y. The same time we set y'[x] -> Sqrt[p[y]],  where a new dependent variable p is introduced.

ReplaceVariables[y''[x]==a (Sqrt[((y'[x])^2)+1]),x -> ∫(1/(Sqrt[p]))[y] \[DifferentialD]y,y[x] -> y,p[y]]

Examples of Partial Differential Equations

The function ReplaceVariables[ ] enables to work with partial differential equations and their systems. 
In the latter case the first argument of the function must be a list of 
equations. When the dependent variable has several arguments one need to 
specify replacement rules for all of them (or in some cases only for part of 
them).

Heat and Mass Transfer Problem

Consider a single PDE arising in heat-mass transfer problem. In spherical  coordinates ρ and μ = Cos[θ] the problem reads: 
(∇^2) H[ρ, μ]==u (μ ∂H[ρ, μ]/∂ρ+(1-(μ^2))/ρ ∂H[ρ, μ]/
                        ∂μ) , 
where the Laplacian (∇^2) has the form 
(∇^2)= (1/(ρ^2))(∂/∂)ρ(ρ^2)(∂/∂)ρ + (1/(ρ^2))(∂/∂)μ(1 - (μ^2))(∂/∂)μ, and u is constant.

Here is the equation

eq = 
      (∂_ρ)((((ρ^2) (∂_ρ) H[ρ, μ])
                )/(ρ^2)) + 
          (∂_μ)(((
                (1 - (μ^2)) (∂_μ) H[ρ, μ])
                )/(ρ^2)) == 
        u (μ (∂_ρ) H[ρ, μ] + 
              (((1 - (μ^2)) 
                  (∂_μ) H[ρ, μ])/ρ))

Assuming that the solution dependence on, say, ρ is known - H[ρ, μ] = 1/ρ Exp[u ρ f[μ]], and having in mind to produce an  ordiary equation for unknown function f[μ], we call the function  ReplaceVariables[ ] as follows:

ReplaceVariables[eq, μ -> μ, 
      H[ρ, μ] -> Exp[u ρ f[μ]]/ρ, f[μ]]

More general form of the solution is processed like that:

ReplaceVariables[eq, {ρ -> ρ, μ -> μ}, 
      H[ρ, μ] -> Exp[u G[ρ, μ]]/ρ, 
      G[ρ, μ]]

The most simple form of the transformed equation can be recovered by the following replacement:

ReplaceVariables[eq, {ρ -> ρ, μ -> μ}, 
      H[ρ, μ] -> 
        G[ρ, μ] Exp[((u ρ μ)/2)], G[ρ, μ]]

It can be easily checked that the resulting equation is a Poisson equation for new dependent variable G in spherical coordinates.

Similarity Solution of the Heat Equation

A well-known heat equation in case spherical symmetry reads (∂/∂)tf[ρ, t] == (a^2) (1/(ρ^2))(∂/∂)ρ(ρ^2)(∂/∂)ρf[ρ, t].

he = 
      (∂_t) f[ρ, t] == 
        (((a^2) (∂_ρ)(
                (ρ^2) (∂_ρ) f[ρ, t]))/(ρ^2))

The similarity solution is sought as a function of a single variable u presented as combination of old independent variables u -> ρ/Sqrt[t].

ReplaceVariables[he, u -> (ρ/(Sqrt[t])), f[ρ, t] -> g[u], 
      g[u]]

It can be easily checked now that the resulting equation above can be 
written as linear ODE for independent variable u.

References

Kamke E. "Differentialgleichungen, L(Overscript[o, ¨])sungmethoden und L(Overscript[o, ¨])sungen, Band 1, Gew(Overscript[o, ¨])nliche Differentialgleichungen.", Leipzig, 1959.