I'm trying to make a phase portrait for the ODE y''-4y'+y=0, I know how to solve this ODE But I don't know how to make a phase portrait out of it. I've looked at something about parametricplot, but still don't know how to deal with it.


3 Answers 3


As porposed by Moo's comment the substitution y'[t]==x[t] leads to x'[t]==4x[t]-y[t]:

StreamPlot[{ 4 x-y,x},{x,-1,1},{y,-1,1}] 

enter image description here

The ode seems to be unstable!


There is no need to do any manual work or substitution to convert the second order ODE to two first order ODE's. You can let Mathematica do that using its StateSpace function which does the conversion for you. Less chance of making an error.

ClearAll[x, y];
ode = y''[x] - 4 y'[x] + y[x] == 0;
vars = {x, y};
ss = StateSpaceModel[{ode}, {{y'[x], 0}, {y[x], 0}}, {{u[x], 0}}, {y[x]}, x];
eqs = ss[[1, 1]] . vars
StreamPlot[eqs, {x, -1, 1}, {y, -1, 1}]

Mathematica graphics


One can use Solve to get the linear vector field and, optionally, its eigenbasis:

ode = {y''[x] - 4 y'[x] + y[x] == 0};
(* get Jacobian amat *)
subs = {y'[x] == p[x], y''[x] == p'[x]};
amat = {y'[x], p'[x]} /. 
   First@Solve[Join[ode, subs], {y'[x], p'[x]}, {y''[x]}];
(* optional *)
evecs = Last@CoefficientArrays[amat, {y[x], p[x]}] // N // 

(* plot *)
 {y[x], -1, 1}, {p[x], -1, 1},
 (* optional *)
 StreamColorFunction -> None,
 StreamPoints -> {Join[
   Thread[{0.8 evecs, Red}], Thread[{-0.8 evecs, Red}], 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.