Re: Replace in operators once again
- To: mathgroup at smc.vnet.net
- Subject: [mg103352] Re: Replace in operators once again
- From: dh <dh at metrohm.com>
- Date: Thu, 17 Sep 2009 06:19:20 -0400 (EDT)
- References: <h8qc70$cn7$1@smc.vnet.net>
Hi Alexei, If you want to transform the variables in derivative you can not simply replace names, but you need to take care of the chain rule. E.g. Say we have D[f1[x1],x1] and want to write this as a function of x2: x1=g[x2]. Then, instead of f1 we will have a new function: f2[x2] with the definition: f2[x2]== f1[x1]. With the chain rule we have: D[f1[x1],x1] == D[f2[x2],x2] D[x2[x1],x1] == D[f2[x2],x2] / D[x1[x2],x2] == D[f2[x2],x2] / D[g[x2],x2] Therefore, you will need rules that transform the whole form of a derivative (D[..]) not only names. Daniel Alexei Boulbitch wrote: > Dear Community members, > > I would like to put a question closely related to " Replace in > operators", the one recently discussed here. See > http://forums.wolfram.com/mathgroup/archive/2009/Sep/msg00006.html > and the thread. > It concerns analytical transformations in differential equations. I need > to make a replacement, not just f[x]->g[x] as discussed in , but > a simple rescaling of both the function and the coordinate. To be more > concrete, consider a PDE over two variables time (t) and coordinate (x): > > df/dt=d^2f/dx^2 + k df/dx + F(f) > > Here f is a function f=f(t,x), F=F(f) is another function for instance, > a polynomial in terms of f, and depending upon some parameters. > Finally, k is a constant. In order to reduce the number of parameters in > this equation to the minimum one may wish to rescale both the function > and the both coordinates as follows: > > f[t, x]->a*g[u,v]; t->b*u; x->c*v > > where a, b and c are some constants. What one finds after the rescaling > looks like the following: > > (a/b)dg/du=(a/c^2)d^2g/dv^2 + k(a/c) dg/dv + F'(g) > > where F' is the transformed polynomial. Then this should be manipulated > further, and it is important to be able to hold all these manipulations > on-screen, rather than to go to the paper for intermediate steps. > It is not difficult to make the first substitution f[t, x]->a*g[u,v]. > One does not even need to use Replace: > > In[40]:= SetAttributes[{a, b, c}, Constant]; > > f[t_, x_] := a*g[t, x] > D[f[t, x], x] > D[f[t, x], {x, 2}] > > Out[42]= a > \!\(\*SuperscriptBox["g", > TagBox[ > RowBox[{"(", > RowBox[{"0", ",", "1"}], ")"}], > Derivative], > MultilineFunction->None]\)[t, x] > > Out[43]= a > \!\(\*SuperscriptBox["g", > TagBox[ > RowBox[{"(", > RowBox[{"0", ",", "2"}], ")"}], > Derivative], > MultilineFunction->None]\)[t, x] > > However, I cannot see how to cope with the second and the third > substitutions. Evidently, the simple > > In[45]:= \!\( > \*SubscriptBox[\(\[PartialD]\), \(x\)]\ \(f[t, x]\)\) /. x -> c*v > > Out[45]= a > \!\(\*SuperscriptBox["g", > TagBox[ > RowBox[{"(", > RowBox[{"0", ",", "1"}], ")"}], > Derivative], > MultilineFunction->None]\)[t, c v] > > does not make the job. > > A closely related question: assume we need to make a substitution of the > type x->g[v] into derivative. Say, x->Log[v]. I would like to have the > result in a form > v D[g[v],v]. Instead I get of coarse, > > In[48]:= D[q[x], x] /. x -> Log[v] > > Out[48]= > \!\(\*SuperscriptBox["q", "\[Prime]", > MultilineFunction->None]\)[Log[v]] > > rather than what I need. Could you think of simple solutions for these > cases? > > Thank you, Alexei >