       Re: Dr. Lynchs book Dynamical Systems with Applications using Mathematica

• To: mathgroup at smc.vnet.net
• Subject: [mg125377] Re: Dr. Lynchs book Dynamical Systems with Applications using Mathematica
• From: Bob Hanlon <hanlonr357 at gmail.com>
• Date: Sat, 10 Mar 2012 06:17:58 -0500 (EST)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com

```Equations must use Equal ( == ) rather than Set ( = ).  Further, in
order to use NDSolve, C5 must be given a numerical value.
Alternatively, you can DSolve and let C5 be a parameter.

ode1 is the solution of the differential equation for the given
initial values (t = 0)

ode1[x0_, y0_, C5_: 1] =
DSolve[{x'[t] == C5 2 x[t] + y[t], y'[t] == C5 x[t] + 2 y[t], x == C5 x0,
y == C5 y0}, {x[t], y[t]}, t][] // FullSimplify

{x[t] -> (1/Sqrt[1 + (-1 + C5)*C5])*(C5*E^(t + C5*t)*
(Sqrt[1 + (-1 + C5)*C5]*x0*Cosh[Sqrt[1 + (-1 + C5)*C5]*t] +
((-1 + C5)*x0 + y0)*Sinh[Sqrt[1 + (-1 + C5)*C5]*t])),
y[t] -> (1/Sqrt[1 + (-1 + C5)*C5])*(C5*E^(t + C5*t)*
(Sqrt[1 + (-1 + C5)*C5]*y0*Cosh[Sqrt[1 + (-1 + C5)*C5]*t] +
(C5*(x0 - y0) + y0)*Sinh[Sqrt[1 + (-1 + C5)*C5]*t]))}

The default value of 1 for C5 is chosen to provide a simple form.

ode1[x0, y0]

{x[t] -> E^(2 t) (x0 Cosh[t] + y0 Sinh[t]),
y[t] -> E^(2 t) (y0 Cosh[t] + x0 Sinh[t])}

sol = ode1[1, 1]; sol = ode1[1, -1]; sol = ode1[-1, -1];
sol = ode1[-1, 1]; sol = ode1[3, 1]; sol = ode1[1, 3];
sol = ode1[-1, -3]; sol = ode1[-3, -1];

These merely store in sol[k] specific solutions for the specified
initial conditions.

?? sol

Bob Hanlon

On Fri, Mar 9, 2012 at 6:11 AM,  <pennsylvaniajake at gmail.com> wrote:
> Could some one please explain the code?
>
> The line starts with sol and ends with ode1[-3,-4];
>
> I have looked through all my books on Mathematica and cannot find
> anything like it.
>
>  p1=VectorPlot[{2x+y,x+2y},{x,-3,3},{y,-3,3}] ;
>  ode1[x0_,y0_]:=NDSolve[{x'[t]=C5 2x[t]+y[t],y'[t]=C5 x[t]+2y[t],x=C5 x0,y=C5 y0},{x[t],y[t]},{t,-3,3}];
>
>  sol=ode1[1,1];sol=ode1[1,-1];sol=ode1[-1,-1];sol=ode1[-1,1];sol=ode1[3,1];sol=ode1[1,3];sol=ode1[-1,-3];sol=ode1[-3,-1];
>
>  p2=ParametricPlot[Evaluate[Table[{x[t],y[t]}/.sol[i],{i,8}]],{t,-3,3},
>  PlotRange=C2=AE{{-3,3},{-3,3}},PlotPoints=C2=AE100,AxesLabel=C2=AE{"x","y"}];
>
>  Show[{p1,p2},PlotRange=C2=AE{{-3,3},{-3,3}},AxesLabel=C2=AE{"x","y"},Axes=C2==AETrue]

```

• Prev by Date: Re: Dr. Lynchs book Dynamical Systems with Applications using Mathematica
• Next by Date: Re: Dr. Lynchs book Dynamical Systems with Applications using Mathematica
• Previous by thread: Re: Dr. Lynchs book Dynamical Systems with Applications using Mathematica
• Next by thread: Re: Dr. Lynchs book Dynamical Systems with Applications using Mathematica