Re: Re: How to NDSolve the differential equation
- To: mathgroup at smc.vnet.net
- Subject: [mg19656] Re: [mg19625] Re: How to NDSolve the differential equation
- From: "Carl K.Woll" <carlw at fermi.phys.washington.edu>
- Date: Tue, 7 Sep 1999 00:28:45 -0400
- Organization: Department of Physics
- References: <7qulo3$2r5@smc.vnet.net> <199909060820.EAA04788@smc.vnet.net.>
- Sender: owner-wri-mathgroup at wolfram.com
Kevin & Chee, An alternate possibility in Kevin's second approach is to use an auxilliary function which handles the special case x=0. separately, as follows: In[16]:= f[0.] := 1 f[x_?NumericQ] := Sin[x]/x In[18]:= NDSolve[{y''[x] + f[x]*y'[x] + 2*y[x] == 0, y[0] == 0, y'[0] == 1}, y, {x, 0, 2}] Out[18]= {{y -> InterpolatingFunction[{{0., 2.}}, <>]}} Carl Woll Physics Dept U of Washington "Kevin J. McCann" wrote: > Chee Lim, > > Look at your DE when x=0 with your IC. The whole thing is zero. When this > happens NDSolve can't get any traction on the problem. Maybe you could try > something like this instead: > > NDSolve[{x y''[x] + Sin[x] y'[x] + 2 x y[x] == 0, y[0.001] == 0, > y'[0.001] == 1}, y, > {x, 0.001, 2}] > > Alternatively, divide through by x and solve this DE: > > y''[x] + y'[x] Sin[x]/x + 2 y[x] == 0 > > again you will have problems at x=0, this time because of the Sin[x]/x; so, > why not expand it: > > s[x_] = Normal[Series[Sin[x]/x, {x, 0, 12}]] > > This gives about 9-place accuracy over the [0,2] range. Then: > > q=y/.NDSolve[{y''[x] + y'[x] s[x]+ 2 y[x] == 0 > , y[0] == 0, > y'[0] == 1}, y, > {x, 0, 2},WorkingPrecision->20][[1]] > > This gives a solution which satisfies the original DE to about 7 places. > > Plot[x q''[x] + q'[x]Sin[x] + 2x q[x], {x, 0, 2}, > PlotRange -> {-0.000001, 0.000001}, > PlotStyle -> RGBColor[1, 0, 0]]; > > Kevin > > Chee Lim Cheung <cheelc at mbox2.singnet.com.sg> wrote in message > news:7qulo3$2r5 at smc.vnet.net... > > Dear Mathematica gurus & users, > > > > I encountered error messages with the tag Power::infy when I tried to do > > the following: > > > > NDSolve[{x y''[x] + Sin[x] y'[x] + 2 x y[x] == 0,y[0]==0, y'[0]==1}, y, > > {x,0,2}] > > > > Can anyone help me in getting Mathematica to produce an answer? I am using > > Mathematica 4.0 & Mathematica 3.0. > > > > Thanks > > Chee > >
- References:
- Re: How to NDSolve the differential equation
- From: "Kevin J. McCann" <kevinmccann@Home.com>
- Re: How to NDSolve the differential equation