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


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

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

Started byTomas Garza <tgarza10@msn.com>
First post2012-03-10 11:18 +0000
Last post2012-03-13 08:03 +0000
Articles 2 — 2 participants

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


Contents

  Re: Dr. Lynchs book Dynamical Systems with Applications using Mathematica Tomas Garza <tgarza10@msn.com> - 2012-03-10 11:18 +0000
    Re: Dr. Lynchs book Dynamical Systems with Applications using Mathematica "pennsylvaniajake@gmail.com" <pennsylvaniajake@gmail.com> - 2012-03-13 08:03 +0000

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

FromTomas Garza <tgarza10@msn.com>
Date2012-03-10 11:18 +0000
SubjectRe: Dr. Lynchs book Dynamical Systems with Applications using Mathematica
Message-ID<jjfd9a$7vc$1@smc.vnet.net>
Perhaps a simple example will shed some light: think of an equation, like x^2 -x-3 = 0, which you wish to numerically solve for x. You will use the function NSolve with the appropriate syntax, and get the two solutions -1.30278 and 2.30278, but they appear in terms of rules (cf. the OnLine Help for NSolve, and see in More Information: NSolve gives solutions in terms of rules of the form x->sol). What you actually get is then {{x -> -1.30278}, {x-> 2.30278}}. This is a list of the solutions, in this case real numbers. Call this sol, for example:
sol = NSolve[x^2 - x - 3 == 0, x]. The evaluation of this yields {{x -> -1.30278}, {x -> 2.30278}}
Then sol[[1]] is {x -> -1.30278}; and sol[[1, 1]] is x -> -1.30278 .Then, if you say y = x/.sol[[1,1]] what you get is that y has been set to the value -1.3027, which is what you will usually need.
The same reasoning applies to you problem. ode1[[1,1]] is the first of the list of solutions, and it comes in terms of a parameter, t. {x[t], y[t]} /. sol[i] says "take the x[t], y[t] which appear in ode1[[i, 1]]". This is the input to ParametricPlot. And so on.
I hope this will help.
-Tomas

> Date: Fri, 9 Mar 2012 06:11:02 -0500
> From: pennsylvaniajake@gmail.com
> Subject: Re: Dr. Lynchs book Dynamical Systems with Applications using Mathematica
> To: mathgroup@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]


#8983

From"pennsylvaniajake@gmail.com" <pennsylvaniajake@gmail.com>
Date2012-03-13 08:03 +0000
Message-ID<jjmv11$cfb$1@smc.vnet.net>
In reply to#8947
On Saturday, March 10, 2012 6:18:02 AM UTC-5, Tomas Garza wrote:
> Perhaps a simple example will shed some light: think of an equation, like x^2 -x-3 = 0, which you wish to numerically solve for x. You will use the function NSolve with the appropriate syntax, and get the two solutions -1.30278 and 2.30278, but they appear in terms of rules (cf. the OnLine Help for NSolve, and see in More Information: NSolve gives solutions in terms of rules of the form x->sol). What you actually get is then {{x -> -1.30278}, {x-> 2.30278}}. This is a list of the solutions, in this case real numbers . Call this sol, for example:
> sol = NSolve[x^2 - x - 3 == 0, x]. The evaluation of this yields {{x -> -1.30278}, {x -> 2.30278}}
> Then sol[[1]] is {x -> -1.30278}; and sol[[1, 1]] is x -> -1.30278 .Then, if you say y = x/.sol[[1,1]] what you get is that y has been set to the value -1.3027, which is what you will usually need.
> The same reasoning applies to you problem. ode1[[1,1]] is the first of the list of solutions, and it comes in terms of a parameter, t. {x[t], y[t]} 
/. sol[i] says "take the x[t], y[t] which appear in ode1[[i, 1]]". This is the input to ParametricPlot. And so on.
> I hope this will help.
> -Tomas
>
> > Date: Fri, 9 Mar 2012 06:11:02 -0500
> > From: pennsylvaniajake@gmail.com
> > Subject: Re: Dr. Lynchs book Dynamical Systems with Applications using Mathematica
> > To: mathgroup@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]
> >

Thank you for the great reply in a simple manner. Sorry for the errors.  I did not know how to copy and paste from Mathematica.  Your response was extremely helpful to me.

Thanks again
Jake

[toc] | [prev] | [standalone]


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


csiph-web