Re: Periodic Rebirth of Hyperbolic Functions by ODE in Mathematica
- To: mathgroup at smc.vnet.net
- Subject: [mg66183] Re: Periodic Rebirth of Hyperbolic Functions by ODE in Mathematica
- From: Maxim <m.r at inbox.ru>
- Date: Wed, 3 May 2006 02:45:07 -0400 (EDT)
- References: <e2i7qg$8tg$1@smc.vnet.net><e2nds9$3a7$1@smc.vnet.net> <e36v68$n5p$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
On Tue, 2 May 2006 06:45:28 +0000 (UTC), Narasimham <mathma18 at hotmail.com> wrote: > Thanks. So in effect there is no way except using first order ODE ? and > BTW, why does not integ(r' r '' ) = r'^2 /2 work for tanh? > Yes, ultimately this method is just a reduction of order, but used in an indirect way. Note that if we simply tried to feed the invariant to NDSolve it wouldn't work: In[1]:= inv = Integrate[(r''[th] - r[th]*(1 - 2*r[th]^2))*r'[th], th]; r[1] /. NDSolve[{inv == 0, r[0] == 1}, r, {th, 0, 100}] Out[2]= {1., 1.} because NDSolve would only find the solution to the system {r'[th] == 0, r[0] == 1}. To make it work for your second example, we need to increase WorkingPrecision: In[3]:= ode = r''[th] - 2*(r[th]^3 - r[th]); inv = Integrate[ode*r'[th], th]; sol = First@ NDSolve[{ode == 0, r[0] == 0, r'[0] == 1}, r, {th, 0, 100}, Method -> {Projection, Invariants -> inv}, MaxStepFraction -> .001, WorkingPrecision -> 100, PrecisionGoal -> 10]; Plot[r[th] - Tanh[th] /. sol, {th, 0, 100}, PlotRange -> All] I don't know how to get an accurate solution from NDSolve without using this additional information about the invariant. Here's how to obtain the exact solution: In[7]:= r[th] /. DSolve[{inv == 1/2, r[0] == 0, r'[0] == 1}, r, th] // FullSimplify Out[7]= {Tanh[th]} Another standard method is to introduce the new variable p[r] = r': In[8]:= ode2 = ode //. Derivative[k_][r][th] :> D[p[r[th]], {th, k - 1}] /. r[th] :> r Out[8]= -2*(-r + r^3) + p[r]*Derivative[1][p][r] In[9]:= sol = First@ DSolve[{ode2 == 0, p[0] == 1}, p, r] out[9]= {p -> Function[{r}, Sqrt[1 - 2*r^2 + r^4]]} In[10]:= r[th] /. DSolve[ {r'[th]^2 == (p[r]^2 /. sol /. r -> r[th]), r[0] == 0, r'[0] == 1}, r, th] // FullSimplify Out[10]= {Tanh[th]} Maxim Rytin m.r at inbox.ru