MathGroup Archive 1996

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

Search the Archive

Re: Solution of diff. equation i the form of list?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg5526] Re: [mg5517] Solution of diff. equation i the form of list?
  • From: "w.meeussen" <w.meeussen at solair4b.eunet.be>
  • Date: Thu, 19 Dec 1996 01:02:28 -0500
  • Sender: owner-wri-mathgroup at wolfram.com

At 19:26 14-12-96 -0500, you wrote:
>Hi!
>Can you write how to get the solution of differential 
>equation in the form of list.
>I tried to achievie it in that way: 
>
>DSolve[{z'[x]==-z[x],z[0]==1},z[x],x]
>data=Table[{x,z[x] /. %},{x,0.0,1.5,0.1}]
>
> and I got:
>
>{{z[x]->Exp[-x]}}
>{{{0.0,{1.0}},{0.1,{0.8}}, etc
>       ^   ^       ^   ^
>   
>How to get rid of above extra {}'s? 
>If I use "data" list in "ListPlot[data]" function I got errors.
>
>If you know what to do please post or e-mail.
>
>Thanks in advance.
>
>             Best regards 
>             Wojtek Wlazlo
>             ufwlazlo at kinga.cyf-kr.edu.pl 
>
>
>
hi Wojtek,

simple :
sol=DSolve[{z'[x]==-z[x],z[0]==1},z[x],x]
data=Table[{x,z[x] /.Flatten[sol]},{x,0.0,1.5,0.1}]

does what you need.

What happened? DSolve generally gives a list of lists-of-rules as answer.
Your case is simply a one-element list. The Wolframians wisely see it as the
users task to extract the single element from its enveloping 'packaging'.
Hence the Flatten[sol].
Don't despair, you'll get used to the style, and get to depend on its
consistency.

I wish you many more packaging to unwrap this christmas,


Wouter.
Dr. Wouter L. J. MEEUSSEN
w.meeussen at solair4b.eunet.be



  • Prev by Date: Re: Plotting with a simplex
  • Next by Date: Re: Calculating Sums Of Roots For Trans. Functions
  • Previous by thread: Solution of diff. equation i the form of list?
  • Next by thread: Help