MathGroup Archive 1994

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Extracting DSolve[]'s solution

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

>How do you extract the solution for DSolve[] ?
>In[1]:= DSolve[y'[t]==a y[t], y[t], t] 
>                   a t
>Out[1]= {{y[t] -> E    C[1]}}
>I desire y[t_] := Some_MMA_Function[Out[1]] to be C[1] 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             

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

In[34]:=        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[34] =  E^(a*t)*C[1]

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

In[35]:=    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[36]:=        ??y

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

or perhaps more to the point, use it:

In[37]:=    y[r] // InputForm

Out[37] =  E^(a*r)*C[1]

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