# Differential to Difference equation with two variables?

For the following information :

$$\frac{dx}{dt} = -10x+3y$$

$$\frac{dy}{dt} = 2$$

How do I convert this to a difference equation ?? I want to use a simple discretisation technique (first order) rather than higher order (4th order Rung Kutta ). I prefer the usage of Euler's forward method.

I tried using Euler formula but I really can't get my head around solving this, im stuck at the first step. I basically want to convert the differential equation to a difference equation to plug in t values and interpolate future values to create a graph at continuous time. I would appreciate a sound reply with an informative step by step solution, I wish to learn this rather than just see the final outcome.

Regards.

EDIT

The equations here consider Newton's temperature rules. Where x is the room temperature and y is heater temperature. dy/dt is the rate of change of the heater's temperature with time when it is turned on. dx/dt is the rate of change of room's temperature according to the difference between room and heater temperatures. -- I will actually add this in question.

-
How do you mean to 'convert this to a difference equation'? Is the word "a" (one) emphasized here? Because it is already a system of differential equations, $x$ being $x(t)$ and $y$ being $y(t)$. And the 2nd equation just says $y(t)=2t+C$. –  Berci Feb 7 '13 at 18:00
@Berci Well if you want to plot this to interpolate future data points against time, aren't you supposed to end up with one equation in terms of t ? I am not sure that's why I wanted a difference equation, using the given data above. –  NLed Feb 7 '13 at 18:12
Should the second equation be $\frac {dy}{dt}=2y$? –  Ross Millikan Feb 7 '13 at 18:35
@RossMillikan nope, the information I currently have is as given here. For more info, this is taking Newton's temeprature rules in consideration. Where x is the room temperature and y is heater temperature. dy/dt is the rate of change of the heater's temperature with time when it is turned on. dx/dt is the rate of change of room's temperature according to the difference between room and heater temperatures. -- I will actually add this in question. –  NLed Feb 7 '13 at 18:37
Then as Berci said $y=2t+c$ which you can substitute into the $x$ equation. –  Ross Millikan Feb 7 '13 at 19:17

Let $f: \mathbb{R}^2 \to \mathbb{R}^2$ be given by $f(x) = f(\begin{pmatrix}x_1\\x_2\end{pmatrix})= \begin{pmatrix}-10x_1+3x_2\\2\end{pmatrix}$. Then the differential equation can be written as $\dot{x} = f(x)$. Euler's forward method just approximates $\dot{x}$ on an interval $[t_0,t_0+h)$ by taking it to be the value $\dot{x}(t_0)$ on this interval. This gives the approximation $x(t) \approx x(t_0)+(t-t_0) f(x(t_0))$.

So, if we consider the time points $t_0 + kh$, $k=0,1,...$, then this gives the difference equation $$\tilde{x}(t_0+(k+1)h) = \tilde{x}(t_0+kh)+hf(\tilde{x}(t_0+kh)$$ subject to $\tilde{x}(t_0) = x_0$. This is typically written as $x_{k+1} = x_k+h f(x_k)$, where $x_k = \tilde{x}(t_0+kh)$.

Euler's forward method is convergent and conditionally stable. Loosely, convergent means that as the step size $h$ gets smaller, the solutions of the difference equations converge to the differential equation solution in some sense. Conditionally stable means that the step size needs to small enough to avoid the numerics 'going wild'.

(As an aside, the equations can be solved explicitly without any need for discretization.)

Addendum: To clarify, expanding the above for a step size $h$ gives (in the question's notation): \begin{eqnarray} x_{k+1} &=& x_k + h(-10 x_k + 3 y_k) \\ y_{k+1} &=& y_k + h(2) \end{eqnarray}

-
Okay I am a bit confused now, can you please look at Ross Millikan's answer ? Why does it look simpler and easier to understand rather than yours, while you're both using Euler's forward method. Which one is correct ? –  NLed Feb 7 '13 at 19:20
@NLed: My answer and Ross' are the same. You asked for an explanation, which was the intent behind the above; clearly I failed :-(. –  copper.hat Feb 7 '13 at 19:41
Nope you did make sense, but I it was a bit harder due to all the symbols used !! But I did ask for a thorough explanation, so thank you :) –  NLed Feb 7 '13 at 20:10
The approach is just like a single equation. For the forward Euler you have $$x_{n+1}=x_n+(-10x_n+3y_n)\Delta t \\ y_{n+1}=y_n +2\Delta t$$
@NLed: right. You recalculate the derivative at each step. That is why short steps are more accurate. The error in each step goes as $\Delta t^2$ –  Ross Millikan Feb 7 '13 at 19:25