# Thread: Numerical solution of differential equations (Euler method)

1. ## 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 $\displaystyle x' = 1 + x^2$ where $\displaystyle x(0)=1$.
Answer 1: This exercise is not the problem (I think). Anyway, the answer is:

$\displaystyle 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 $\displaystyle x_n = x_{n-1} + h*(1 + x_{n-1}^2)$ where $\displaystyle h=0.1 \land x_0=1$, but it doesn't make any sense. The "exact" values for x'(t) are

$\displaystyle 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...

2. 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 $\displaystyle x' = 1 + x^2$ where $\displaystyle x(0)=1$.
Answer 1: This exercise is not the problem (I think). Anyway, the answer is:

$\displaystyle 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 $\displaystyle x_n = x_{n-1} + h*(1 + x_{n-1}^2)$ where $\displaystyle h=0.1 \land x_0=1$, but it doesn't make any sense. The "exact" values for x'(t) are

$\displaystyle 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!

3. Hehe, good point. Sorry about that. Ok, I use the formula

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

I get

$\displaystyle 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.