Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #15261 > unrolled thread

Re: Variable transformations

Started byAlexei Boulbitch <Alexei.Boulbitch@iee.lu>
First post2013-07-30 03:18 +0000
Last post2013-09-08 06:52 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Re: Variable transformations Alexei Boulbitch <Alexei.Boulbitch@iee.lu> - 2013-07-30 03:18 +0000
    Re: Variable transformations Youngjoo Chung <ychung12@gmail.com> - 2013-09-08 06:52 +0000

#15261 — Re: Variable transformations

FromAlexei Boulbitch <Alexei.Boulbitch@iee.lu>
Date2013-07-30 03:18 +0000
SubjectRe: Variable transformations
Message-ID<kt7b9o$dkf$1@smc.vnet.net>
Say I have some differential equation in terms of the independent variable 
x and dependent variable f(x). Now say I want to do a coordinate/variable transformation where x=x(u) and I want to write my equation in terms of only u and f(u). By pencil & paper, you can do this by applying the chain rule, but I have a complicated equation and I want to check if I've made an algebra slip-up (it involves several dependent and independent variables and up to 4th order derivatives). Is there any way to automate something like this in Mathematica? I've messed around with replacement rules, but I can't get Mathematica to do things quite how I want.

Thanks!

Hi, Nicholas,

This problem has been discussed few times, and I copy-paste here one of the answers, the one I like most. I do not remember, however, who gave it:

The rule has the form:
y->(y[g[#]]&)
the round parentheses are important. It does not work without.

(* The task is to substitute x->z^2 *)
y'[x] /. y -> (y[#^2] &) /. x -> z
y''[x] /. y -> (y[#^2] &) /. x -> z

2 z Derivative[1][y][z^2]

2 Derivative[1][y][z^2] + 4 z^2 (y^\[Prime]\[Prime])[z^2]

(* The task is to substitute x->Sin[z] into the fourth order derivative *)

y''''[x] /. y -> (y[Sin[#]] &) /. x -> z

Sin[z] Derivative[1][y][Sin[z]] -
 4 Cos[z]^2 (y^\[Prime]\[Prime])[Sin[z]] +
 2 Sin[z]^2 (y^\[Prime]\[Prime])[Sin[z]] - 5 Cos[z]^2 Sin[z]
\!\(\*SuperscriptBox[\(y\),
TagBox[
RowBox[{"(", "3", ")"}],
Derivative],
MultilineFunction->None]\)[Sin[z]] -
 Sin[z] (-Sin[z] (y^\[Prime]\[Prime])[Sin[z]] + Cos[z]^2
\!\(\*SuperscriptBox[\(y\),
TagBox[
RowBox[{"(", "3", ")"}],
Derivative],
MultilineFunction->None]\)[Sin[z]]) + Cos[z]^4
\!\(\*SuperscriptBox[\(y\),
TagBox[
RowBox[{"(", "4", ")"}],
Derivative],
MultilineFunction->None]\)[Sin[z]]

This method applies also to substitute a function into an expression containing derivatives, such that these derivatives would be calculated as well as the function itself:

Clear[expr, rule];
expr = (r[\[CurlyPhi]]^2 + 2 Derivative[1][r][\[CurlyPhi]]^2 -
    r[\[CurlyPhi]] (
      r^\[Prime]\[Prime])[\[CurlyPhi]])^2/(r[\[CurlyPhi]]^2 +
    Derivative[1][r][\[CurlyPhi]]^2)^2;

rule = r -> (r0 + r1*Cos[#] &);
expr /. rule

(r1 Cos[\[CurlyPhi]] (r0 + r1 Cos[\[CurlyPhi]]) + (r0 +
    r1 Cos[\[CurlyPhi]])^2 +
  2 r1^2 Sin[\[CurlyPhi]]^2)^2/((r0 + r1 Cos[\[CurlyPhi]])^2 +
  r1^2 Sin[\[CurlyPhi]]^2)^2

Have fun, Alexei

Alexei BOULBITCH, Dr., habil.
IEE S.A.
ZAE Weiergewan,
11, rue Edmond Reuter,
L-5326 Contern, LUXEMBOURG

Office phone :  +352-2454-2566
Office fax:       +352-2454-3566
mobile phone:  +49 151 52 40 66 44

e-mail: alexei.boulbitch@iee.lu



[toc] | [next] | [standalone]


#15381

FromYoungjoo Chung <ychung12@gmail.com>
Date2013-09-08 06:52 +0000
Message-ID<l0h6s2$7hr$1@smc.vnet.net>
In reply to#15261
Dear Alexei,

You can use SCTransDeriv in the SymbolicComputing package (http://symbcomp.gist.ac.kr, WTC 2011) for the variable transformation of derivatives as shown below. All functions with the prefix SC are package functions. It is still a beta version, but it might help.

The result of the variable transformation is shown in Out[236] below. Out[242] shows verification by inverse transformation. Copying the textual form of the input into Mathematica may not work since it does not faithfully reproduce the standard form of the input.

Sorry I cannot explain all the details here. Please refer to the homepage http://symbcomp.gist.ac.kr about the package.

<<SymbolicComputing`

In[235]:= SCTotalDeriv[y, {x, 4}]
SCMAF[%, SCTransDeriv, {All, TransVar -> {x, z, x == Sin[z]}},
 SCCollectDerivs, {All, y, Apply -> {PowerExpand, Simplify}},
 SCTrigToHalf, {Cos[2 z], Cos},
 SCCollectDerivs, {All, y, Apply -> {Factor, Expand}},
 SCFactor, {All, Sec[z]^4}]

Out[235]= \[DifferentialD]^4y/\[DifferentialD]x^4

During evaluation of In[235]:= Sec[z]^4 \[DifferentialD]^4y/\[DifferentialD]z^4+Sec[z]^4 (-11+15 Sec[z]^2) \[DifferentialD]^2y/\[DifferentialD]z^2+6 Sec[z]^4 Tan[z] \[DifferentialD]^3y/\[DifferentialD]z^3+3 Sec[z]^4 (-2+5 Sec[z]^2) Tan[z] \[DifferentialD]y/\[DifferentialD]z

Out[236]=
Sec[z]^4 (\[DifferentialD]^4y/\[DifferentialD]z^4 + (-11 +
      15 Sec[z]^2) \[DifferentialD]^2y/\[DifferentialD]z^2 +
   6 Tan[z] \[DifferentialD]^3y/\[DifferentialD]z^3 +
   3 (-2 + 5 Sec[z]^2) Tan[z] \[DifferentialD]y/\[DifferentialD]z)

Verification by inverse transformation:

In[241]:=
Sec[z]^4 (\[DifferentialD]^4y/\[DifferentialD]z^4 + (-11 +
       15 Sec[z]^2) \[DifferentialD]^2y/\[DifferentialD]z^2 +
    6 Tan[z] \[DifferentialD]^3y/\[DifferentialD]z^3 +
    3 (-2 + 5 Sec[z]^2) Tan[z] \[DifferentialD]y/\[DifferentialD]z);
SCMAF[%, SCTransDeriv, {All, TransVar -> {z, x, z == ArcSin[x]}},
 SCCollectDerivs -> {y, Apply -> Simplify}]

Out[242]= \[DifferentialD]^4y/\[DifferentialD]x^4

Sincerely,
Youngjoo Chung

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web