[Date Index]
[Thread Index]
[Author Index]
Re: what is the general theory of extracting solutions from DSolve (and similar) functions
*To*: mathgroup at smc.vnet.net
*Subject*: [mg45574] Re: what is the general theory of extracting solutions from DSolve (and similar) functions
*From*: "Peter Pein" <nospam at spam.no>
*Date*: Wed, 14 Jan 2004 01:26:36 -0500 (EST)
*References*: <bu0dma$an4$1@smc.vnet.net>
*Sender*: owner-wri-mathgroup at wolfram.com
"steve_H" <nma124 at hotmail.com> schrieb im Newsbeitrag
news:bu0dma$an4$1 at smc.vnet.net...
> 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
>
Hi Steve,
you could use maping of an anonymous function:
In[1]:=
Off[Solve::ifun];
In[2]:=
sol=DSolve[{y'[x]^2==1-y[x]^2,y[0]==0},y[x],x]
Out[2]=
{y[x] -> -Sin[x], y[x] -> Sin[x]}
In[3]:=
y[x]/.#&/@sol
Out[3]=
{-Sin[x], Sin[x]}
--
Peter Pein, Berlin
petsie at arcAND.de
replace && by || to write to me
"The ultimate goal of mathematics is to eliminate any need for intelligent
thought."
-Alfred N. Whitehead
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:
**Re: what is the general theory of extracting solutions from DSolve (and similar) functions**
| |