       RE: change the solution to a differential equation into a user defined function - question.nb (0/1)

• To: mathgroup at smc.vnet.net
• Subject: [mg15595] RE: [mg15566] change the solution to a differential equation into a user defined function - question.nb (0/1)
• From: "Ersek, Ted R" <ErsekTR at navair.navy.mil>
• Date: Thu, 28 Jan 1999 04:23:25 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

```You can use the line at In to define a function from the soln to a
DE. At Out we see it works.

In:=
sol=DSolve[y'[x]==x,y[x],x];

In:=
y[x_]=(y[x]/.Part[sol,1])
Out=
\!\(x\^2\/2 + C\)

In:=
y[r]
Out=
\!\(r\^2\/2 + C\)

BUT BEWARE:
When you (lhs=rhs) and (lhs) contains  a pattern (e.g.  x_ ) you must
make sure  the pattern doesn't have a global value.

To show what can go wrong I define
h[t_]=3+Sin[t]
when t=12 below.

In:=
t=12;

In:=
h[t_]=3+Sin[t]
Out=
3+Sin

Note the line above would work if I used: Block[{t}, h[t_]=3+Sin[t]]

Cheers,
Ted Ersek

-----Original Message-----
From: yc10 at acpub.duke.edu [mailto:yc10 at acpub.duke.edu] To:
mathgroup at smc.vnet.net
Subject: [mg15595] [mg15566] change the solution to a differential equation into a
user defined function - question.nb (0/1)

I probably have to apologize for the awkward name for the subject.

My question is

In:=
sol=DSolve[y'[x]==x,y[x],x]
Out=
\!\({{y[x] \[Rule] x\^2\/2 + C}}\)

In:=
FullForm[sol]
Out//FullForm=
List[List[Rule[y[x],Plus[Times[Rational[1,2],Power[x,2]],C]]]]

After I type in the command to solve the differential equation, I am
given a replacement rule of y[x], which can be applied as a rule when
the argument inside y is x, nothing else.

In:=
y[x_]:=x^2/2+c
In:=
FullForm[y[x_]]
Out//FullForm=
Plus[c,Times[Rational[1,2],Power[Pattern[x,Blank[]],2]]]

When I define the same function for y[x] by myself, it is evidently  a
pattern where x can be taken in any value.

Then comes the question: how can we use the solution given in a
differential equation which itself is a function as a function for
later use?

It seems to be straightforward, but I have looked through the
Mathematica Book and found no clue. Your help will be greatly
appreciated.

```

• Prev by Date: Re: nb file from mac to windows
• Next by Date: Re: harder parts of list
• Previous by thread: Re: change the solution to a differential equation into a user defined function - question.nb (0/1)
• Next by thread: Re: change the solution to a differential equation into a user defined function - question.nb (0/1)