Re: NDSolve Percision

*To*: mathgroup at smc.vnet.net*Subject*: [mg85531] Re: NDSolve Percision*From*: danl at wolfram.com*Date*: Wed, 13 Feb 2008 04:22:00 -0500 (EST)*References*: <fopbtt$c4m$1@smc.vnet.net>

On Feb 11, 5:35 am, Alex Cloninger <aclonin... at wustl.edu> wrote: > So I'm running a program that is trying to use NDSolve and parametrically plot the results. The result is periodic, so it should cycle back on itself with a period of 2Pi. It does that, but if I run from {t,0,20Pi} is starts to miss the initial point by more and more. Basically, it's spiraling outward at a slow but unwanted rate. This will be a problem for when I increase the difficulty of the function. > > How do I increase the precision of NDSolve to make it keep more decimals and make the answer more accurate? > > The function is > > solution = NDSolve[{x'[t] == 2p[t], x[0] == 2, > p'[t] == -2x[t],p[0] == N[Sqrt[-3], 50]}, {x, p}, {t,0,20Pi}] > > If you could help me out, I'd really appreciate it. Thanks. Might want to consider a DAE or other conserved-quantity approach. One might be simplectic Ringe-Kutta. Documentation in the Help Browser is located under tutorial/NDSolveSPRK. Under subsection "Symplectic method" I see an example quite similar to yours. I suspect a projection approach might also be applicable. See tutorial/ NDSolveProjection. There, too, I see a harmonic oscillator example. Daniel Lichtblau Wolfram Research