       Re: NDSolve and Parametric Plot

• To: mathgroup at smc.vnet.net
• Subject: [mg85445] Re: [mg85430] NDSolve and Parametric Plot
• From: Bob Hanlon <hanlonr at cox.net>
• Date: Mon, 11 Feb 2008 06:03:20 -0500 (EST)

```Delete the outer braces

solution =
NDSolve[{x'[t] == 2 p[t], x == 2, p'[t] == -2 x[t],
p == Sqrt[-3]}, {x, p}, {t, 0, Pi}][];

repart[t_] := Re[x[t] /. solution]
impart[t_] := Im[x[t] /. solution]

ParametricPlot[{repart[t], impart[t]}, {t, 0, Pi},
PlotRange -> {{-2, 2}, {-2, 2}}]

This can also be solved exactly

solution =
DSolve[{x'[t] == 2 p[t], x == 2, p'[t] == -2 x[t], p ==
= Sqrt[-3]}, {x,
p}, t][]

{x -> Function[{t}, 2*Cos[2*t] + I*Sqrt*Sin[2*t]],
p -> Function[{t}, I*(Sqrt*Cos[2*t] +
2*I*Sin[2*t])]}

Bob Hanlon

---- Alex Cloninger <acloninger at wustl.edu> wrote:
> So I'm trying to run a simple program that will solve this series of diff=
erential equations and plot the the x[t] function in the complex plane.  He=
re's my code.
>
> solution = NDSolve[{x'[t] == 2p[t], x == 2, p'[t] == -2x=
[t], p == Sqrt[-3]}, {x, p}, {t, 0, 2*=CF=80}]
>
> repart[t_] := Re[x[t] /. solution]
> impart[t_] := Im[x[t] /. solution]
>
> ParametricPlot[{repart[t], impart[t]}, {t, 0, 2=CF=80}, PlotRange -> {{-2=
, 2}, {-2,2}}]
>
> For some reason, when I go to plot the curve, I get an error saying
> ParametricPlot::pptr: {repart[t], impart[t]} does not evaluate to a pair =
of real numbers at t=2.617993877991494`*^-7
>