# First order linear differential equations

## Numerical method to solve DE

So far we have learnt how to solve by means of direction field and we learnt how to solve analytically some kinds of DE.

Not all differential equations can be solved analytically and we might obtain satisfying results by numerical solution. The most simple method is Euler's method.

This method is not accurate, but its principle is obvious. For its inaccuracy is not practically used. There exist software, which use Runge-Kutta methods.

The curve in blue color is an unknown solution $f(x)$ to be found and $h$ is a step width chosen. Since we are solving DE, we can also express from DE slope $y'$ as a function of $x, y$.
From initial value $[x_0,y_0]$ we can move on the slope to $[x_1, y_1]$ and from that point continue to $[x_2, y_2]$, ...

In numerical solutions, it is usually desirable to construct a table in which all relevant computations are systematically recorded.

### Example

Solve DE $y'=x^2 + y$ for initial condition y(0) = 1: find solution by Euler's method at

• x = 0.1,
• x = 0.2,
• x = 0.3

with steps

1. h = 0.1
2. h = 0.05

and compare with algebraic solution $y = 3e^x -x^2 -2x-2$.

A. Solved with step $h = \Delta x_n = 0.1$:

Numerical method Algebraic m.
$x_n$ $y_n$ $y'(x_n,y_n)$ $\times$ $\Delta x_n$ $=$ $\Delta y_n$ $y_n$

0 1 1 0.1 0.1
0.1 1.1 1.11 0.1 0.111 1.1055
0.2 1.211 1.251 0.1 0.1251     1.2242
0.3   1.336         1.3596

B. Solved with step $h = \Delta x_n = 0.05$:

Numerical method Algebraic m.
$x_n$ $y_n$ $y'(x_n,y_n)$ $\times$ $\Delta x_n$ $=$ $\Delta y_n$ $y_n$

0 1 1 0.05 0.05
0.05 1.05 1.0525 0.05 0.05263
0.1 1.1026 1.1126 0.05 0.0556 1.1055
0.15 1.1582 1.1807 0.05 0.0590
0.2 1.2172 1.2572 0.05 0.0629     1.2242
0.25 1.2801 1.3426 0.05 0.0671
0.3   1.3472         1.3596

In general the accuracy of the method increases as the step $h$ decreases. But not indefinitely: if the step is too small, rounding errors come into play.

List of chapters