# Solve the differential equation y'+2y=3x+1 with initial conditions y(1) = -1 using Euler approximation ?

Jan 29, 2017

See below.

#### Explanation:

Making the Euler differences we have

$\frac{{y}_{k} - {y}_{k - 1}}{h} = 1 + 3 {x}_{k - 1} - 2 {y}_{k - 1}$ or

${y}_{k} = \left(1 - 2 h\right) {y}_{k - 1} + h \left(1 + 3 {x}_{k - 1}\right)$. Now beginning with ${x}_{0} = 1 , {y}_{0} = 2$ and knowing that ${x}_{k} = 1 + k h , k = 0 , 1 , \cdots , n$ we can calculate the ${y}_{k}$. Here $n = \left\lfloor \frac{2 - 1}{h} \right\rfloor$

Follow a comparison between the two Euler approximations and the exact solution of the differential equation which is

$y = \frac{1}{4} \left(3 {e}^{2 \left(1 - x\right)} + 6 x - 1\right)$

The coarser approximation is for $h = 0.2$ follows the approximation for $h = 0.1$ and also was included an approximation for $h = 0.02$