MathGroup Archive 2004

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

Search the Archive

Re: what is the general theory of extracting solutions from DSolve (and similar) functions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg45561] Re: what is the general theory of extracting solutions from DSolve (and similar) functions
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Wed, 14 Jan 2004 01:26:15 -0500 (EST)
  • Organization: Universitaet Leipzig
  • References: <bu0dma$an4$1@smc.vnet.net>
  • Reply-to: kuska at informatik.uni-leipzig.de
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

if you remove First[] from
> sol = DSolve[{y'[x] == a y[x], y[0] == 1}, y[x], x]
> y = First[y[x] /. sol]

and change it to 

allY=y[x] /. sol;

you get a list of all solutions. Plot[] can handle such list of 
functions in its first argument with

Plot[Evaluate[allY],{x,0,1}]

But you may also use Map[] 

Plot[#,{x,0,1}] & /@ allY

to get a new plot for every solution.

Regards
  Jens

steve_H wrote:
> 
> hello,
> 
> I am learning Mathematica (Mathematica 5.0) and I am having hard time finding
> a general method that works everytime to extract solutions
> from output of DSolve and other Mathematica functions that generates
> solutions in the same format.
> 
> I have seen examples that work when the solution contains
> only one result.
> 
> I have read that the output of DSolve is in triple nested
> format.
> 
> I have seen examples that Flattens the output of DSolve before doing
> anything on it to remove the extra nesting.
> 
> Now, Assuming I want to do this in a script (i.e. without looking
> at the output of DSolve), so I need to assume there is more
> than one solution.
> 
> I tried to write
> 
>    [r,c]=Dimensions[sol]
> 
> to see how many solutions there are, but this failed when there is only one
> solution. (sol above is the result of calling DSolve).
> 
> I've seen things written like this:
> 
> sol = DSolve[{y'[x] == a y[x], y[0] == 1}, y[x], x]
> y = First[y[x] /. sol]
> 
> but this assume there is one solution. right?
> 
> I am interested in plotting all the solutions, so I guess I need to
> have a loop that extracts each solution in turn from the output
> of DSolve and plots each in turn.
> 
> is there a good way to do this? A general generic approach which
> works everytime regardless of the number of solutions?
> 
> thanks,
> Steve


  • Prev by Date: Re: List arguments to functions
  • Next by Date: Re: List arguments to functions
  • Previous by thread: Re: what is the general theory of extracting solutions from DSolve (and similar) functions
  • Next by thread: [Q] Translate Mathematica -> Java