# Integration Using Euler's Method

## Key Questions

• Estimating Definite Integral by Euler's Method

Example

Use Euler's Method to approximate the definite integral

${\int}_{- 1}^{2} \left(4 - {x}^{2}\right) \mathrm{dx}$.

For simplicity, let us use the step size $\Delta x = 1$.

Let

$I \left(t\right) = {\int}_{- 1}^{t} \left(4 - {x}^{2}\right) \mathrm{dx}$.

So, we wish to approximate

$I \left(2\right) = {\int}_{- 1}^{2} \left(4 - {x}^{2}\right) \mathrm{dx}$

Note that by Fundamental Theorem of Calculus I,

$I ' \left(t\right) = 4 - {t}^{2}$

Now, let us start approximating.

$I \left(- 1\right) = \setminus {\int}_{- 1}^{- 1} \left(4 - {x}^{2}\right) \mathrm{dx} = 0$

By linear approximation,

$I \left(0\right) \approx I \left(- 1\right) + I ' \left(- 1\right) \cdot \Delta x = 0 + 3 \cdot 1 = 3$

$I \left(1\right) \approx I \left(0\right) + I ' \left(0\right) \cdot \Delta x \approx 3 + 4 \cdot 1 = 7$

$I \left(2\right) \approx I \left(1\right) + I ' \left(1\right) \cdot \Delta x \approx 7 + 3 \cdot 1 = 10$

Hence,

$I \left(2\right) = {\int}_{- 1}^{2} \left(4 - {x}^{2}\right) \mathrm{dx} \approx 10$

I hope that this was helpful.

• To approximate an integral like $\setminus {\int}_{a}^{b} f \left(x\right) \setminus \mathrm{dx}$ with Euler's method, you first have to realize, by the Fundamental Theorem of Calculus, that this is the same as calculating $F \left(b\right) - F \left(a\right)$, where $F ' \left(x\right) = f \left(x\right)$ for all $x \setminus \in \left[a , b\right]$. Also note that you can take $F \left(a\right) = 0$ and just calculate $F \left(b\right)$.

In other words, since Euler's method is a way of approximating solutions of initial-value problems for first-order differential equations, we want to calculate $\setminus {\int}_{a}^{b} f \left(x\right) \setminus \mathrm{dx} = F \left(b\right)$ by approximating the unique solution of $\frac{\mathrm{dy}}{\mathrm{dx}} = f \left(x\right) , y \left(a\right) = 0$ at $x = b$.

This can be done with an "iteration scheme". Pick a positive integer $n$ to be the number of steps of Euler's method you want to use and then let $\Delta x = \frac{b - a}{n}$. Once this is done, let ${x}_{0} = a$ and ${y}_{0} = 0$ and use the recursive equations ${x}_{k + 1} = {x}_{k} + \Delta x$, ${y}_{k + 1} = {y}_{k} + \Delta y = {y}_{k} + f \left({x}_{k}\right) \setminus \cdot \Delta x$ to generate a sequence of $n + 1$ points $\left({x}_{0} , {y}_{0}\right) , \left({x}_{1} , {y}_{1}\right) , \setminus \ldots \left({x}_{n} , {y}_{n}\right)$ that approximate the unique solution of the initial-value problem.

The final result is that $\setminus {\int}_{a}^{b} f \left(x\right) \setminus \mathrm{dx} = F \left(b\right) \setminus \approx {y}_{n}$.

This can be implemented fairly easily on a calculator or computer, though you'd have to be somewhat experienced with such programming.

As an example, suppose that you want to estimate $\setminus {\int}_{0}^{3} {x}^{2} \setminus \mathrm{dx}$ (which we already know is 9). The relevant initial-value problem is $\frac{\mathrm{dy}}{\mathrm{dx}} = f \left(x\right) = {x}^{2} , y \left(0\right) = 0$ and we want to approximate $y \left(3\right)$. Let's choose $n = 4$ so that $\Delta x = \setminus \frac{3}{4} = 0.75$. Then ${x}_{0} = 0 , {x}_{1} = 0.75 , {x}_{2} = 1.5 , {x}_{3} = 2.25$, and ${x}_{4} = 3$. Also ${y}_{1} = {y}_{0} + f \left(0\right) \setminus \cdot 0.75 = 0 + 0 = 0$, ${y}_{2} = {y}_{1} + f \left(0.75\right) \setminus \cdot 0.75 = 0 + 0.5625 \setminus \cdot 0.75 = 0.421875$, ${y}_{3} = {y}_{2} + f \left(1.5\right) \setminus \cdot 0.75 = 0.421875 + 2.25 \setminus \cdot 0.75 = 2.109375$, and ${y}_{4} = {y}_{3} + f \left(2.25\right) \setminus \cdot 0.75 = 2.109375 + 3.796875 = 5.90625$ as our approximate answer for the integral.

This would get to be a better approximation (though very slowly) as $n$ increases (and $\Delta x = \frac{b - a}{n}$ decreases). For instance, if $n = 100$ and $\Delta x = \frac{3}{100} = 0.03$, the approximation for the integral is $8.86545$.

• Estimating Definite Integral by Euler's Method

Example

Use Euler's Method to approximate the definite integral

${\int}_{- 1}^{2} \left(4 - {x}^{2}\right) \mathrm{dx}$.

For simplicity, let us use the step size $\Delta x = 1$.

Let

$I \left(t\right) = {\int}_{- 1}^{t} \left(4 - {x}^{2}\right) \mathrm{dx}$.

So, we wish to approximate

$I \left(2\right) = {\int}_{- 1}^{2} \left(4 - {x}^{2}\right) \mathrm{dx}$

Note that by Fundamental Theorem of Calculus I,

$I ' \left(t\right) = 4 - {t}^{2}$

Now, let us start approximating.

$I \left(- 1\right) = \setminus {\int}_{- 1}^{- 1} \left(4 - {x}^{2}\right) \mathrm{dx} = 0$

By linear approximation,

$I \left(0\right) \approx I \left(- 1\right) + I ' \left(- 1\right) \cdot \Delta x = 0 + 3 \cdot 1 = 3$

$I \left(1\right) \approx I \left(0\right) + I ' \left(0\right) \cdot \Delta x \approx 3 + 4 \cdot 1 = 7$

$I \left(2\right) \approx I \left(1\right) + I ' \left(1\right) \cdot \Delta x \approx 7 + 3 \cdot 1 = 10$

Hence,

$I \left(2\right) = {\int}_{- 1}^{2} \left(4 - {x}^{2}\right) \mathrm{dx} \approx 10$

I hope that this was helpful.