Solve a system of differential equations and plot it

236 Views Asked by At

I am trying to get using math, the solution of the following system of equations:

x' = 4x - 3y
y' = 6x - 1y

After using the DSolve command: DSolve[{4 x[t] - 3 y[t] == x'[t], 6 x[t] - 7 y[t] == y'[t]}, {x[t], y[t]}, t]

I get the following output: {{x[t] -> 1/7 E^(-5 t) (-2 + 9 E^(7 t)) C[1] - 3/7 E^(-5 t) (-1 + E^(7 t)) C[2], y[t] -> 6/7 E^(-5 t) (-1 + E^(7 t)) C[1] - 1/7 E^(-5 t) (-9 + 2 E^(7 t)) C[2]}}

I'm trying to plot this solution to get me the phase plane, but I have no idea how to do it.

I would appreciate it if someone told me how to plot this type of equation.

2

There are 2 best solutions below

0
On

What you are getting here is a general solution with two indetermined coefficients C[1] and C[2]. You can not plot it. To plot it you need an exact solution for which you need the boundary values. For example, let's choose the boundary conditions x[0] == 2.3, y[0] == 1.4

sol[t_]={x[t], y[t]} /. DSolve[{4 x[t] - 3 y[t] == x'[t], 6 x[t] - 7 y[t] == y'[t], 
                                x[0] == 2.3, y[0] == 1.4}, {x[t], y[t]}, t]


Plot[Evaluate[sol[t]], {t, 0, 1}, PlotLegends -> Automatic]

enter image description here

1 and 2 are your two solutions. You can call them as sol[t][[1]] and sol[t][[2]].

0
On

I think you are looking for something like this.

eq1 = 4 x[t] - 3 y[t] == x'[t];

eq2 = 6 x[t] - 7 y[t] == y'[t];

sol[x0_?NumericQ] := First@DSolve[{eq1, eq2, x[0] == x0, y[0] == x0}, {x, y}, {t, -3, 3}]

pp = ParametricPlot[Evaluate[{x[t], y[t]} /. sol[#] & /@ Range[-20, 20, 1]], {t, -3, 
    3}, PlotRange -> {{-5, 5}, {-5, 5}}];

sp = StreamPlot[{4 x[t] - 3 y[t], 6 x[t] - 7 y[t]}, {x[t], -5, 5}, {y[t], -5, 5}];

Show[pp, sp]

enter image description here