Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I have the following equation :

$$\frac{dx}{dt} = -5(x-2)$$

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

How do I change this differential equation to a difference equation ? Do I use Euler forward method ? I remember taking this before but I have totally forgotten about it. I tried reading online to refresh my memory but I did not really grasp the idea. I would really appreciate if someone can solve this particular equation step by step so that I can fully understand the solution, along with supporting key concept points to grasp the idea. Thanks.

share|improve this question
    
Why do you want to change this differential equation into a difference equation? There are difference equations "approximating" the given differential equation, but there is no (finite) difference equation equivalent to it. –  Christian Blatter Feb 6 '13 at 19:27
    
@ChristianBlatter Yes, I want to approximate it because I want to later on discretize the model and simulate it in Python. So I want a difference equation. –  NLed Feb 6 '13 at 19:41

5 Answers 5

up vote 1 down vote accepted

You seem to be interested in the general techniques for solving differential equations numerically.

Given $x'(t), y'(t)$ there are many ways you can come up with a differencing equation to approximate the solution on a discretized domain. Most of these are derived from Taylor series expansions.

$$x(t+\Delta t) = x(t) + x'(t) \Delta t + \ldots$$

Truncating the expansion here gives you forward differencing. As this is a problem rooted in time integration, this is most likely the kind of thing you would want to do.

However, as often as not one prefers more sophisticated approaches. Euler's method is simple but also not very good. 4th order Runge-Kutta is often used, as it strikes a balance between simplicity and accuracy that is usually pretty good. This too can, in principle, be derived from Taylor series expansions, but that's a bit more involved.

share|improve this answer

$\frac{dx}{dt}=-5(x-2)$ then $\frac{dx}{(x-2)}=-5dt$ :integrate both side$$ln(x-2)=-5t+c $$$$x=e^{-5t+c}+2$$ and $y(t)=2t+c$

share|improve this answer
    
The OP wants to change the differential equation to a difference equation. He/she is asking about it not about solving the OE. ;-) –  Babak S. Feb 6 '13 at 18:59
    
@Babak sorouh:hi thanks i dont understand question perfectly –  Maisam Hedyelloo Feb 6 '13 at 19:02
    
Thanks for the info though –  NLed Feb 6 '13 at 20:54

You can put $y$ in terms of $x$ by noting $dy/dx = (dy/dt) / (dx / dt)$.

For your first question, $dy/dx = (0) / (-5(x-2)) = 0$, so integrating, $y = C$ for some constant $C$.

Your second question is more complicated as it has both $x$ and $y$ in it, so I'm not sure this method will apply for that equation.

share|improve this answer
    
Can you please elaborate and structure your answer better ? So that I can actually mark this as correct... –  NLed Feb 6 '13 at 19:13

I will consider the first equation:

$$\frac{dx}{dt} = -5 (x-2)$$

There are many schemes for discretization. In my experience, centered difference works because the error is second order and the computation relatively light. In this, we assume that we have a vector of sample points $x_k$, $k \in \{1,2,3,\ldots,n\}$, each $x_k$ corresponding to a value of $t_k = (k-1) \Delta t$. The discrete equation then reads

$$\frac{x_{k+1/2} - x_{k-1/2}}{\Delta t} = - 5 (x_k - 2)$$

Why the half-steps? Again, it is a centered difference whose symmetry cancels out 1st-order error. We may compute the values of $x$ on the half steps by, e.g., averaging (so that $x_{k+1/2} = (1/2) (x_k + x_{k+1})$.

Now, in order to use this equation, you need an initial value, i.e., $x(0) = x_0$. Assume $x_{-1/2}=0$. You now have enough to propagate a solution through all of the $x_k$.

share|improve this answer
    
Thanks for the response, can you also explain how the Forward Difference method can be used instead of the centered difference method ? –  NLed Feb 6 '13 at 20:13
    
It would be used exactly the same way, but the left side replaced by $x_{k+1}-x_k$, which is fine, but you have a larger error. –  Ron Gordon Feb 6 '13 at 20:22

So you have $$ \dot{x}=-5x+10. $$ Add to this initial condition $x(0)=x_0$.

Solving, you will find $$ x(t)=x_0e^{-5t}-2e^{-5t}+2. $$ Your $1$-operator is then $$ x(1)=x_0e^{-5}-2e^{-5}+2. $$ Hence the difference equation, whose solution coincides with the solution of the differential equation is $$ x_{t+1}=x_te^{-5}-2e^{-5}+2. $$

share|improve this answer
    
Why did you make 10 into 2exp(-5) instead of just exp(-10) ? –  NLed Feb 6 '13 at 20:30
    
@NLed, I do not get your question. I just solved the original equation. –  Artem Feb 6 '13 at 20:33
    
Can you explain your solving procedure in your answer please ? –  NLed Feb 6 '13 at 20:35
    
@NLed, What exactly is not clear in my answer? –  Artem Feb 6 '13 at 20:36
    
@NLed, Do you know how to solve first order linear differential equations? –  Artem Feb 6 '13 at 20:37

Your Answer

 
discard

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.