       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:=
dg1=c''[x]+g c'[x];

Method 1:  Use Block to temporarily define c[x_]
----------------------------------------
In:=
Block[{c},c[x_]:=Exp[-a x];dg1]//InputForm

Out//InputForm=
a^2/E^(a*x) - (a*g)/E^(a*x)

Method 2:  Change "c" to a pure function.
-----------------------------------------
In:=
dg1/.c->(Exp[a#]& ) //InputForm

Out//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 and
Derivative 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:=
Position[dg1,c[x]]

Out=
{}

In:=
InputForm[dg1]

Out//InputForm=
g*Derivative[c][x] + Derivative[c][x]

-----------
Regards,
Ted Ersek

```

• Prev by Date: Re: Problem with "Run" command on WindowsNT
• Next by Date: Re: Re: Simplifying constants...bug?
• Previous by thread: Re: Manipulating differential equations
• Next by thread: Re: Manipulating differential equations