Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #8940 > unrolled thread

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

Started bypennsylvaniajake@gmail.com
First post2012-03-09 11:13 +0000
Last post2012-03-10 11:19 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.soft-sys.math.mathematica

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Dr. Lynchs book Dynamical Systems with Applications using Mathematica pennsylvaniajake@gmail.com - 2012-03-09 11:13 +0000
    Re: Dr. Lynchs book Dynamical Systems with Applications using Mathematica "Kevin J. McCann" <kjm@KevinMcCann.com> - 2012-03-10 11:19 +0000

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

Frompennsylvaniajake@gmail.com
Date2012-03-09 11:13 +0000
SubjectRe: Dr. Lynchs book Dynamical Systems with Applications using Mathematica
Message-ID<jjcokk$qam$1@smc.vnet.net>
Could some one please explain the code?

The line starts with sol[1] 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[0]=C5 x0,y[0]=C5 y0},{x[t],y[t]},{t,-3,3}];

 sol[1]=ode1[1,1];sol[2]=ode1[1,-1];sol[3]=ode1[-1,-1];sol[4]=ode1[-1,1];sol[5]=ode1[3,1];sol[6]=ode1[1,3];sol[7]=ode1[-1,-3];sol[8]=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]


[toc] | [next] | [standalone]


#8950

From"Kevin J. McCann" <kjm@KevinMcCann.com>
Date2012-03-10 11:19 +0000
Message-ID<jjfdc8$80m$1@smc.vnet.net>
In reply to#8940
You have a fairly large number of syntax issues. I am don't know how you 
put the code into the email. It appears that your C5 and =C2=AE are 
really something else. Here is the cleaned up code that works. I suggest 
that when you copy Mathematica code for emailing purposes that you 
highlight the code, right-click, and choose Copy As ->Input Text.

The code numerically solves the coupled DE with x0 and y0 as variable 
IC's. sol[1], etc are the solutions in InterpolationFunctions. The 
/.sol[i] uses rules to replace x and y in the ParametricPlot.

My suggestion is that you need to learn Mathematica before you read the 
book.

Kevin

p1 = VectorPlot[{2 x + y, x + 2 y}, {x, -3, 3}, {y, -3, 3}];

ode1[x0_, y0_] :=
   NDSolve[{x'[t] == 2 x[t] + y[t], y'[t] == x[t] + 2 y[t], x[0] == x0,
      y[0] == y0}, {x[t], y[t]}, {t, -3, 3}];



sol[1] = ode1[1, 1]; sol[2] = ode1[1, -1]; sol[3] = ode1[-1, -1];
sol[4] = ode1[-1, 1];
sol[5] = ode1[3, 1]; sol[6] = ode1[1, 3]; sol[7] = ode1[-1, -3];
sol[8] = ode1[-3, -1];

p2 = ParametricPlot[
    Evaluate[Table[{x[t], y[t]} /. sol[i], {i, 8}]], {t, -3, 3},
    PlotRange -> {{-3, 3}, {-3, 3}}, PlotPoints -> 100,
    AxesLabel -> {"x", "y"}];



Show[{p1, p2}, PlotRange -> {{-3, 3}, {-3, 3}},
  AxesLabel -> {"x", "y"}, Axes -> True]


On 3/9/2012 6:13 AM, pennsylvaniajake@gmail.com wrote:
> Could some one please explain the code?
>
> The line starts with sol[1] 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[0]=C5 x0,y[0]=C5 y0},{x[t],y[t]},{t,-3,3}];
>
>   sol[1]=ode1[1,1];sol[2]=ode1[1,-1];sol[3]=ode1[-1,-1];sol[4]=ode1[-1,1];sol[5]=ode1[3,1];sol[6]=ode1[1,3];sol[7]=ode1[-1,-3];sol[8]=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]
>
>
>

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web