Re: NDSolve and Lane-Emden
- To: mathgroup at smc.vnet.net
- Subject: [mg42535] Re: [mg42512] NDSolve and Lane-Emden
- From: Selwyn Hollis <selwynh at earthlink.net>
- Date: Sat, 12 Jul 2003 20:53:15 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Hi Fred, Try this: LEeq[n_] := 1/x^2*D[x^2D[y[x], x], x] == -Sign[y[x]]Abs[y[x]]^n soln = y /. First @ NDSolve[{LEeq[3.3], y'[1] == 0, y[1] == 1}, y, {x, 1, 10}] Plot[soln[x], {x, 1, 10}] The second step could also be done this way: Clear[soln]; soln[x_] = y[x] /. First @ NDSolve[{LEeq[3.3], y'[1] == 0, y[1] == 1}, y[x], {x, 1, 10}] That's mainly a matter of taste. (I've written the right side of the equation that way to avoid complex values when y[x] becomes negative, which I'm not sure you want to do.) ----- Selwyn Hollis http://www.math.armstrong.edu/faculty/hollis On Saturday, July 12, 2003, at 05:19 AM, fedgingt at fandm.edu wrote: > Hi. I have not worked extensively with Mathematica in the past. I am > working > with the Lane-Emden equation for a polytropic gas: > -y[x]^N=1/x^2*D[x^2D[y[x],x],x]. N is the polytropic index. I have > been using > NDSolve to find a solution to this equation when N=3.3, 3.35 and 3.4 > for x > starting a 1. However, I am have trouble with the InterpolatingFunction > Mathematica gives me. It does not give numerical answers (for > example, when I > type y[2]/.% the output Mathematica gives is {y[2]}.) At the same > time, I am > able to plot this function. Is there some way to get a result for the > Lane-Emden that will produce numerical answers? Thanks, Fred > >