# Plot phase portrait of a system of ODE

I have the following system of 4 differential equations:

x'[t]== f1[x[t],y[t],z[t],u[t]]
y'[t]== f2[x[t],y[t],z[t],u[t]]
z'[t]== f3[x[t],y[t],z[t],u[t]]
u'[t]== f4[x[t],y[t],z[t],u[t]]

Using NDSolve, I've solved it numerically with some given parameters. I want to plot the phase portrait only in the $$y-z$$ plane. How can I do it in a similar way as using StreamPlot?

• Welcome to Mathematica StackExchange! You should provide the whole code, together with your functions f1, f2, f3, f4. Also, there are already several questions here about phase portraits, have you tried searching? Commented Apr 18, 2023 at 18:06
• You want to plot a 2D slice of a 4D space. Do you want to plot a single trajectory from NDSolve or the whole flow field from StreamPlot? If the latter, how should the other two dimensions be treated? Commented Apr 18, 2023 at 18:19

As functions of t you can plot the projections simply by taking two coordinates

V[t_] := {Sin[t]*Cos[3 t], Cos[t] Cos[3 t],
Sin[t]*Sin[3 t],  Cos[t] Sin[3 t]}

Manipulate[ParametricPlot[V[t][[{i, j}]], {t, 0, 2 \[Pi]}],
{{i,2}, Range[1, 4]}, {{j,4}, Range[1, 4]}]

For construction of the 4d vector field one prepares the table of positions and their derivatives with respect to time and tries to expand in an independent set of functions of t

VfieldEquations =
{Equal @@@
({{x1, x2, x3, x4}, V[t]}\[Transpose]),
Equal @@@ ({{v1, v2, v3, v4},D[V[t], t] }\[Transpose])}\[Transpose]
// Flatten // TrigExpand

Eliminate[(VfieldEquation//.
{Cos[t] -> cs, Sin[t] -> sn,cs^n_?Positive :> (1 -sn^2) cs^(n - 2)} // Expand, sn]

v1 == x2 - 3 x3 && v2 == -x1 - 3 x4 && v3 == 3 x1 + x4 &&
v4 == 3 x2 - x3 && x1^2 == 2 cs^2 - 2 cs^2 x2 - 6 cs^2 x3 + x4^2 &&
x1 (1 + 2 x2) == (1 - 2 x3) x4 && x1 x3 == (-1 + x2 + 2 x3) x4 &&
2 cs^2 x2 x3 == -cs^2 x3 - 2 cs^2 x3^2 + x4^2 &&
2 x2^2 + x2 (-1 + 4 x3) == 1 - x3 - 2 x3^2 &&
x1 x4 == -2 cs^2 x3 + x4^2 &&
x2 x4^2 == -2 cs^2 x3^2 + x4^2 - x3 x4^2 &&
4 cs^4 x3^3 - 3 cs^2 x3 x4^2 == -x4^4

So finally fix the plane {x1,x3}={a,b} and StreamPlot the vector field in the {2,4}-plane

DV = {x2 - 3 x3, -x1 - 3 x4, 3 x1 + x4, 3 x2 - x3}

Manipulate[
StreamPlot[
DV[[{2, 4}]] /. {x1 -> a, x3 -> b}, {x2, -1, 1}, {x4, -1,1}],
{a, -1, 1}, {b, -1, 1}]