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


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

Re: Variable transformations

From Alexei Boulbitch <Alexei.Boulbitch@iee.lu>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Variable transformations
Date 2013-07-30 03:18 +0000
Message-ID <kt7b9o$dkf$1@smc.vnet.net> (permalink)
Organization Time-Warner Telecom

Show all headers | View raw


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



Back to comp.soft-sys.math.mathematica | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

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

csiph-web