# 3- dimensional plot of 2-dimensional systems of differential equations

Let's take this first example of a 2D output:

sol = DSolve[
{y''[t] + y'[t] + y[t] == 3 Sin[t] - 4 Cos[t],
y[0] == a, y'[0] == 0},
y[t], t
];
toplot = Table[ sol[[1, 1, 2]] /. a -> i, {i, 0, 3, 0.5}];
Plot[Tooltip[toplot], {t, 0, 2 \[Pi]}]


How can I visualize these solutions with a 3-D output like the ones obtainable by ListSurfacePlot3D , the independant variable (a) of my example being the 3d coordinate? Here I would like to see 7 parallel curves.

Also another example this time for a system of two differential equations:

sol = DSolve[
{x'[t] == x[t]/8 - y[t]  ,
y'[t] == x[t]   + y[t]/8,
x[0] == 0,
y[0] == 1},
{x[t], y[t]}, t
];
ParametricPlot[{x[t], y[t]} /. sol, {t, -2 \[Pi], 2 \[Pi]}]


How can I get a 3D output of these solutions, the 3d coordinate being the variable t (and I expect to get a helix)? Thanks

-

Simplest solution I think would be just using ParametricPlot3D. For other techniques please see this questions:

Now let's look at specifically to your examples and ParametricPlot3D.

Your 1st example can be simplified a bit:

sol = DSolve[{y''[t] + y'[t] + y[t] == 3 Sin[t] - 4 Cos[t],y[0] == a,y'[0] == 0}, y[t], t];
toplot = Table[{t, sol[[1, 1, 2]], a}, {a, 0, 3, 0.5}];

ParametricPlot3D[toplot, {t, 0, 2 Pi}]


And 2nd example is fine as it is - just add time as 3rd variable to ParametricPlot3D:

ParametricPlot3D[{x[t], y[t], t} /. sol, {t, -2 Pi, 2 Pi}]


-

Also,

ClearAll[sol];
sol[a_?NumericQ] := sol[a] = DSolve[{y''[t] + y'[t] + y[t] == 3 Sin[t] - 4 Cos[t],
y[0] == a, y'[0] == 0}, y[t], t];

Plot3D[Evaluate[y[t] /. sol[x]][[1]] /. t -> u, {u, 0, 2 Pi}, {x, 0, 10}]


Please note that you have to Evaluate[] before injecting the (valued) variable u for the Solve[] function to work.

Edit

The above plot was done with:

Plot3D[Evaluate[y[t] /. sol[x]][[1]] /. t -> u, {u, 0, 2 Pi}, {x, 0, 5},
MeshFunctions -> (#2 &), ColorFunction -> "BlueGreenYellow",
AxesLabel -> {Style[t, Large, Bold], Style[InputForm[y[0]], Large, Bold]},
PlotStyle -> Directive[Opacity[.7], Specularity[.5]], BoxRatios -> 1]

-
The second solution gives an error message: –  Sigis K Aug 7 '12 at 13:13
@SigismondKmiecik Works OK here. Try to run it on a fresh kernel, or insert a ClearAll before executing, because a previous definition of sol[] spoils it –  belisarius Aug 7 '12 at 13:16
@SigismondKmiecik Answer updated with ClearAll –  belisarius Aug 7 '12 at 13:22
It's ok after ClearAll["Global*"]`. Thanks –  Sigis K Aug 7 '12 at 13:26
With your solution how you can you store in a table the equations of all the plotted solutions? Is it possible to use the Tooltip function in order to display the specific solutions on the output area? Thanks –  Sigis K Aug 12 '12 at 14:16