# Numerical solution of differential equations (Euler method)

• Oct 27th 2008, 02:09 PM
kjey
Numerical solution of differential equations (Euler method)
Hello. I'm having problems with solving a pretty straight forward differential equation by using Euler's method.

Exercise 1:
Solve $x' = 1 + x^2$ where $x(0)=1$.
Answer 1: This exercise is not the problem (I think). Anyway, the answer is:

$x(t) = \tan{(t+\frac{\pi}{4})}\Rightarrow x' = 1 + (\tan{(t+\frac{\pi}{4})})^2$.

Exercise 2: Solve the differential equation numerically on the interval [0,0.6] with Euler's method using 6 steps.
Answer 2: I have tried to use $x_n = x_{n-1} + h*(1 + x_{n-1}^2)$ where $h=0.1 \land x_0=1$, but it doesn't make any sense. The "exact" values for x'(t) are

$x'(0.0) = 2, x'(0.1) = 2,4958... , x'(0.2)=3,2755...$ etc.

When I use "my method" the numbers are totally different from them above. Can anyone explain what I do wrong? I must have misunderstand something...
• Oct 27th 2008, 03:00 PM
HallsofIvy
Quote:

Originally Posted by kjey
Hello. I'm having problems with solving a pretty straight forward differential equation by using Euler's method.

Exercise 1:
Solve $x' = 1 + x^2$ where $x(0)=1$.
Answer 1: This exercise is not the problem (I think). Anyway, the answer is:

$x(t) = \tan{(t+\frac{\pi}{4})}\Rightarrow x' = 1 + (\tan{(t+\frac{\pi}{4})})^2$.

Exercise 2: Solve the differential equation numerically on the interval [0,0.6] with Euler's method using 6 steps.
Answer 2: I have tried to use $x_n = x_{n-1} + h*(1 + x_{n-1}^2)$ where $h=0.1 \land x_0=1$, but it doesn't make any sense. The "exact" values for x'(t) are

$x'(0.0) = 2, x'(0.1) = 2,4958... , x'(0.2)=3,2755...$ etc.

When I use "my method" the numbers are totally different from them above. Can anyone explain what I do wrong? I must have misunderstand something...

Since you haven't shown what you did, no, no one can tell what you did wrong!
• Oct 27th 2008, 03:12 PM
kjey
Hehe, good point. Sorry about that. Ok, I use the formula

$x_n = x_{n-1} + h*f(x,y) = x_{n-1} + h*(1 + x_{n-1}^2)$.

I get

$x_1 = x_0 + h*(1 + x_{0}^2) = 1 + 0.1*(1 + 1^2) = 1.2$ and so on.

My point is that I have never solved an exercise with Euler's method before, so I'm wondering if anyone could explain how I can use Euler's method in this one case - maby I will understand much more then.