       Re: Extracting DSolve[]'s solution

• To: mathgroup at christensen.cybernetics.net
• Subject: [mg369] Re: [mg359] Extracting DSolve[]'s solution
• From: wmm at chem.wayne.edu (Martin McClain)
• Date: Tue, 27 Dec 94 18:02:28 EST

```>How do you extract the solution for DSolve[] ?
>
>---------------------------------------
>In:= DSolve[y'[t]==a y[t], y[t], t]
>                   a t
>Out= {{y[t] -> E    C}}
>---------------------------------------
>
>I desire y[t_] := Some_MMA_Function[Out] to be C Exp[a t].
>
>I know this is probably very simple and well known, so be gentle.
>
>Joseph McWilliams                Wagner's music is better than it sounds.
>Nacogdoches, TX                           -- Mark Twain --
>mcwilljg at euler.sfasu.edu

If you want to see an expression as the answer, do this:

In:=        DSolve[y'[t]==a y[t],y[t],t];
y[t]  /.  Flatten[%]  //  InputForm

(*Flatten gets rid of the extra pair of braces,
% means "last output (even if suppressed)",
and // InputForm is just for e-mail *)

Out =  E^(a*t)*C

If you really want to go directly to a function definition, you can do
this:

In:=    Clear[y];
DSolve[y'[t]==a y[t], y[t], t];
y[t_]:=Evaluate[ y[t] /. Flatten[%] ]

There is no screen output from this, but a function definition was stored
under y.
To see it:

In:=        ??y

Out:=      Global`y
y[t_] := E^(a*t)*C

or perhaps more to the point, use it:

In:=    y[r] // InputForm

Out =  E^(a*r)*C

Regards to everybody in Nacogdoches-  Martin McClain

```

• Prev by Date: Re: Simple Solve Question
• Next by Date: Re: Simple Solve Question
• Previous by thread: Extracting DSolve[]'s solution
• Next by thread: Mutiple delete in lists