RE: Manipulating differential equations
- To: mathgroup at smc.vnet.net
- Subject: [mg18626] RE: [mg18552] Manipulating differential equations
- From: "Ersek, Ted R" <ErsekTR at navair.navy.mil>
- Date: Tue, 13 Jul 1999 01:01:41 -0400
- Sender: owner-wri-mathgroup at wolfram.com
Martin Heimann wrote: ----------------------- I would like to insert test functions into an expression that contains differentials: dg1 = c''[x] + g c'[x] I would like e.g. to replace c[x] by Exp[-a x]: dg1/.c[x]->Exp[-a x] but this doesn't work; one has to put substitution rules for each of the derivatives explicitly. Is there a more elegant way to achieve this? ------------------------ Back on 6 March 96, Robby Villegas answered essentially the same question in this group. Robby gives two methods of doing what you want (see below). In[1]:= dg1=c''[x]+g c'[x]; Method 1: Use Block to temporarily define c[x_] ---------------------------------------- In[2]:= Block[{c},c[x_]:=Exp[-a x];dg1]//InputForm Out[2]//InputForm= a^2/E^(a*x) - (a*g)/E^(a*x) Method 2: Change "c" to a pure function. ----------------------------------------- In[3]:= dg1/.c->(Exp[a#]& ) //InputForm Out[3]//InputForm= a^2*E^(a*x) + a*E^(a*x)*g -------------------------------- As Robby wrote: Method 1 works because if the is a definition for c in effect, and you evaluate an expression containing derivatives of c, the derivative will automatically differentiate the formula for c. Method 2 works because any derivative operator such, the Derivative[1] and Derivative[2] that act on c will automatically act on a pure function. So why doesn't the method Martin used work? Below we see dg1 doesn't contain the expression c[x]. InputForm[dg1] shows how it's actually represented. In[5]:= Position[dg1,c[x]] Out[5]= {} In[6]:= InputForm[dg1] Out[6]//InputForm= g*Derivative[1][c][x] + Derivative[2][c][x] ----------- Regards, Ted Ersek