Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've tried to solve this differential equation system, buy without any luck.

enter image description here

This is my code:

RSolve[{x'[t] == x[t] - y[t], y'[t] == 5 x[t] - 3 y[t], x[0] == 1, y[0] == 2}, {x[t],
y[t]}, t]

Can anyone tell me what I've done wrong?

share|improve this question
You should use DSolve. RSolve is not for differential equations. – m0nhawk Apr 13 '13 at 13:24
Right. RSolve[] is for difference equations; DSolve[] is for differential equations. A matter of continuous versus discrete. – J. M. Apr 13 '13 at 13:52
up vote 5 down vote accepted

I recommend using math: $\ \ \ \dot x=Ax\ \Rightarrow\ x=\text{e}^{At}\ x_0$

 A = {{1, -1}, {5, -3}};
 MatrixExp[A t].{1, 2}   //FullSimplify

gives: $\ \ \ x_1=\text{e}^{-t}\cos{t},\ \ \ x_2=(2+\tan t)\ x_1$

$ $

edit: With one more line, in an intermediate calculation you can can eliminate all six numbers:

 A = {{a, b}, {c, d}};
 MatrixExp[A t].{x1, x2} // FullSimplify

 % /. {a -> 1, b -> -1, c -> 5, d -> -3, x1 -> 1, x2 -> 2} // FullSimplify
share|improve this answer
You could also elect to use the two-argument form of MatrixExp[]: MatrixExp[{{a, b}, {c, d}} t, {x1, x2}] – J. M. Apr 13 '13 at 17:21
@Nick Kidman I wonder how to solve this with your method if $x_1(0)=1$ and $x_2(0)=2$ is not given. You can't multiply Matrix A with to vectors of 0. – Jens Jensen Apr 17 '13 at 15:21
@JensJensen: "You can't multiply Matrix A with to vectors of 0." I'm not sure what you're saying, but if you say you can't use it for initial values $(0,0)$, then you're not right. Of course you can: $\text{e}^{At}\vec 0=\vec 0$. And this is exactly the solution of the differential equation: E.g $\dot x_1(0)=x_1(0)-x_2(0)=0$, then it says that the value starts at $x_1(0)=0$ and doesn't change. – NikolajK Apr 17 '13 at 17:54
@NickKidman What if $\dot{x_1} = \dot{x_2}(0)=0$ is given? And you only have the matrix A? – Jens Jensen Apr 17 '13 at 17:57
@JensJensen: I don't know what you're saying. You read off the matrix $A$ from the differential equation. You exponentiate it. You multiply the resulting matrix $\text{e}^{A t}$ with the initial vector. Now matter what the matrix or the differential equations are, this works. If the vector is $\vec 0$, then the vector will stay this $\vec 0$ no matter what the matrix is. If the matrix is four $0'$s, then $\text{e}^{A t}=E$, where $E$ is the unit matrix. No evolution as the differential equation given via $A$ is trivial. For any "What if" question like that, you can also just ask the code here. – NikolajK Apr 17 '13 at 18:00
s = DSolve[{x'@t == x@t - y@t, y'@t == 5 x@t - 3 y@t, x@0 == 1, y@0 == 2}, {x, y}, t]
ParametricPlot[{x[t], y[t]} /. s, {t, 0, 5}, AspectRatio -> 1, PlotRange -> All]

enter image description here

Animate[Graphics[{PointSize[Large], Point[{x[t], y[t]} /. s]}, 
                  PlotRange -> {{-1, 1}, {-2, 2}}, Axes -> True], {t, 0, 10, .01}]

enter image description here

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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