## Thursday, May 03, 2018

### Numerical Integration Basics

Consider the equation $$y = 4$$. If we plot this on two axes, x and y, it has no slope; it's just a horizontal line. We could also write the equation as $$y = 0x + 4$$ because the value of y is unaffected by the value of x. We could also write it as $$y = f(x)$$.

The integral of a function can be used to find the area between the function and the x-axis and is written $$I = \int_a^b f(x) dx$$. It's essentially the sum of tiny changes in x ($$dx$$) multiplied by their corresponding y values ($$f(x)$$). The equation reminds us that we need to restrict ourselves to a lower and an upper value of x (otherwise the area would be infinite).

Let's choose a = x = 0 (the y-axis) and b = x = 3 as those two bounds.

$$I = \int_0^3 4 dx$$
$$I = \left[4 x\right]_0^3$$
$$I = \left(4\times3\right) - \left(4\times0\right)$$
$$I = 12$$

We're not restricted to 0 as the lower bound, but it exposes an interesting property: the area under a-to-b is equal to the area under 0-to-b less the area under 0-to-a. Let's try the same integral as above, but from 0-to-1.

$$I = \int_0^1 4 dx$$
$$I = \left[4 x\right]_0^1$$
$$I = \left(4\times1\right) - \left(4\times0\right)$$
$$I = 4$$

We might then subtract 4 from 12 to arrive at 8, but why not do this in one go?

$$I = \int_1^3 4 dx$$
$$I = \left[4 x\right]_1^3$$
$$I = \left(4\times3\right) - \left(4\times1\right)$$
$$I = 8$$