3
$\begingroup$

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?

$\endgroup$
  • 2
    $\begingroup$ You should use DSolve. RSolve is not for differential equations. $\endgroup$ – m0nhawk Apr 13 '13 at 13:24
  • 2
    $\begingroup$ Right. RSolve[] is for difference equations; DSolve[] is for differential equations. A matter of continuous versus discrete. $\endgroup$ – J. M. is away Apr 13 '13 at 13:52
7
$\begingroup$

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
$\endgroup$
  • $\begingroup$ You could also elect to use the two-argument form of MatrixExp[]: MatrixExp[{{a, b}, {c, d}} t, {x1, x2}] $\endgroup$ – J. M. is away Apr 13 '13 at 17:21
  • $\begingroup$ @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. $\endgroup$ – Jens Jensen Apr 17 '13 at 15:21
  • $\begingroup$ @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. $\endgroup$ – Nikolaj-K Apr 17 '13 at 17:54
  • $\begingroup$ @NickKidman What if $\dot{x_1} = \dot{x_2}(0)=0$ is given? And you only have the matrix A? $\endgroup$ – Jens Jensen Apr 17 '13 at 17:57
  • $\begingroup$ @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. $\endgroup$ – Nikolaj-K Apr 17 '13 at 18:00
5
$\begingroup$
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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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