After reading this chapter you know:

  • what an integral is,

  • what definite and indefinite integrals are,

  • what an anti-derivative is and how it is related to the indefinite integral,

  • what the area under a curve is and how it is related to the definite integral,

  • how to solve some integrals and

  • how integrals can be applied, with specific examples in convolution and the calculation of expected value.

7.1 Introduction to Integrals

There are many applications of integrals in everyday scientific work, including data and statistical analysis, but also in fields such as physics (see Sect. 7.7). To enable understanding of these applications we will explain integrals from two different points of view. Several examples will be provided along the way to clarify both.

Firstly, integrals can be considered as the opposite from derivatives, or as ‘anti-derivatives’. This point of view will lead to the definition of indefinite integrals . Viewing integrals as the opposite of derivatives reflects that by first performing integration and then differentiation or vice versa, you basically get back to where you started. In other words, integration can be considered as the inverse operation of differentiation. However, while it is possible to calculate or find the derivative for any function, determining integrals is not always as easy. In fact, many useful indefinite integrals are not solvable, that is, they cannot be given as an analytic expression! In those cases, numerical integration may sometimes help, but that topic is outside the scope of this book.

Secondly, integrals (of functions of one variable) can be considered as the area under a curve. This point of view will lead to the definition of definite integrals. Integration can also be performed for functions of multiple variables and we will only briefly touch upon this topic in this chapter.

7.2 Indefinite Integrals: Integrals as the Opposite of Derivatives

As we mentioned before, one way to think about integrals is as the opposite or the reverse of derivatives; some people like to think about integrals as anti-derivatives. In other words, by integration you aim to find out what f(x) is, given its derivative f?>′(x), or more formally

f(x) =  ∫ f?>′(x)dx

Here, the symbol for the indefinite integral ∫ is introduced. In contrast to the definite integral that will be introduced in Sect. 7.3 the integral is here defined for the entire domain of the function. An important part of the integral is dx, the differential of the variable x. It denotes an infinitesimally small change in the variable (see Sect. 6.12), and shows that the variable of integration is x. The meaning of dx will become more clear when we explain definite integrals in Sect. 7.3.

Example 7.1

If f?>′(x) = nx n − 1, what is f(x)?

We thus need to find f(x) =  ∫ f?>′(x)dx =  ∫ nx n − 1 dx. Since we know that \( \frac{d}{dx}{x}^n={nx}^{n-1} \), for this example we find that f(x) = x n.

For ease of notation, we denote F(x) as the integral of a function f(x):

F(x) =  ∫ f(x)dx

The function f(x) that is integrated is also referred to as the integrand.

7.2.1 Indefinite Integrals Are Defined Up to a Constant

Since the derivative of a constant is zero, indefinite integrals are only defined up to a constant. This means that in practice, after finding the anti-derivative (also known as the primitive) of a function, you can add any constant to this anti-derivative and it will still fulfill the requirement that its derivative is equal to the function you were trying to find the anti-derivative for. An intuitive understanding of this property of indefinite integrals is provided by Example 7.2 and Fig. 7.1.

Fig.7.1
figure 1

The function f(x) = x 2 is plotted when different constants are added. It illustrates that the tangent at a specific value of x (black lines) has the same slope for all depicted functions.

Example 7.2

If f(x) = x 2, then f?>′(x) = 2x, but f?>′(x) = 2x is also true for f(x) = x 2 + 3 or f(x) = x 2 − 5. Figure 7.1 helps to understand this more intuitively: by adding a constant to a function of x, the function is shifted along the y-axis, but otherwise does not change shape. Hence, the derivative (the slope of the black lines in Fig. 7.1, see also Sect. 6.8) for a certain value of x, remains the same.

Example 7.3

Revisiting our Example 7.1, if f(x) = nx n − 1, then the integral

F(x) =  ∫ f(x)dx =  ∫ nx n − 1 dx = x n + C

where C is any constant.

7.2.2 Basic Indefinite Integrals

Similar to what we did for derivatives in Sect. 6.9, we here provide several basic indefinite integrals that are useful to remember. Note that when you know derivatives of functions, you actually already know a lot of indefinite integrals , as well, by thinking about the inverse operation (from the derivative back to the original function). Thus, Tables 7.1 and 6.1 bear many similarities as the derivative of the integral of a function is this function again. For example, differentiating a power function involves lowering the power by one, whereas integrating a power function involves increasing the power by one. There is an exception though, when the power is −1 (see Tables 6.1 and 7.1). Probably, the concept of indefinite integrals as anti-derivatives is becoming clearer now.

Table 7.1 Indefinite integrals ∫f(x)dx for basic functions f(x). More basic indefinite integrals can be found at https://en.wikipedia.org/wiki/Lists_of_integrals

Example 7.4

Determine the integral of \( f(x)=\frac{3}{\sqrt{5x}} \)

It is easier to determine this integral once you realize that f(x) is actually a power function: \( (x)=\frac{3}{\sqrt{5x}}=3\cdot {(5x)}^{-\frac{1}{2}}={3.5}^{-\frac{1}{2}}{x}^{-\frac{1}{2}} \). Now, we can determine the integral using Table 7.1:

$$ F(x)=\int f(x) dx=\int 3\cdot {5}^{-\frac{1}{2}}{x}^{-\frac{1}{2}} dx=3\cdot {5}^{-\frac{1}{2}}\int {x}^{-\frac{1}{2}} dx=3\cdot {5}^{-\frac{1}{2}}\frac{x^{-\frac{1}{2}+1}}{-\frac{1}{2}+1}+C=\frac{6}{\sqrt{5}}\sqrt{x}+C $$

Before providing more examples and practicing integration yourself, we first present some basic rules of integration in Box 7.1:

Box 7.1 Basic rules of integration

  1. 1.

    \( \frac{d}{dx}\int f(x) dx=f(x) \)

  2. 2.

    \( \int \frac{d}{dx}f(x) dx=f(x)+C \)

  3. 3.

    af(x)dx = a ∫ f(x)dx, if a is a constant

  4. 4.

    ∫[af(x) ± bg(x)]dx = a ∫ f(x)dx ± b ∫ g(x)dx, if a and b are constants (linearity).

Example 7.5

Determine the following integrals:

  1. a.

    \( {\displaystyle \begin{array}{l}\int \sqrt{x\sqrt{x\sqrt{x}}}\mathrm{dx}=\int \sqrt{x\sqrt{x^{\frac{3}{2}}}} dx=\int \sqrt{x\cdot {x}^{\frac{3}{2}\cdot \frac{1}{2}}} dx=\int \sqrt{x^{1+\frac{3}{4}}} dx=\int {x}^{\frac{7}{4}\cdot \frac{1}{2}} dx=\\ {}\int {x}^{7/8} dx=\frac{8{x}^{15/8}}{15}+C\end{array}} \)

  2. b.

    \( \int \left(\frac{3}{x}+\sin 5x\right) dx=\int \frac{3}{x} dx+\int \sin 5 xdx=3\ln \left|x\right|-\frac{1}{5}\cos 5x+C \)

  3. c.

    ∫(sin5x − sin 5α)dx =  ∫ sin 5xdx −  ∫ sin 5αdx=\( -\frac{1}{5}\cos 5x-x\sin 5\alpha +C \). Note that since the integration is over x, sin5α should be considered as a constant.

  4. d.

    \( \int \left({e}^{- i\omega t}+{e}^{i\omega t}\right) dt=\int {e}^{- i\omega t} dt+\int {e}^{i\omega t} dt=-\frac{1}{i\omega}{e}^{- i\omega t}+\frac{1}{i\omega}{e}^{i\omega t}+C \)

Exercise

  1. 7.1

    Determine the following indefinite integrals :

    1. a.

      ∫(e 3t + 2 sin 2t)dt

    2. b.

      \( \int \frac{3}{x^2} dx \)

    3. c.

      ∫4x −1 dx

    4. d.

      \( \int \sqrt{4x} dx \)

    5. e.

      \( \int \left(\sqrt{4{x}^{-3}}+5\right) dx \)

    6. f.

      ∫(3x + tan x)dx

7.3 Definite Integrals : Integrals as Areas Under a Curve

So far, we considered integrals as anti-derivatives, thereby introducing indefinite integrals . Here, we view integrals in a different way, as areas under a curve, bounded by a lower and an upper limit. The curve is thus a graph of a function on a specific domain. Let’s discuss this link between integrals and area under a curve in more detail. Suppose you want to know the area under the curve for the graph of the function f(x) =  − x 2 + 5 between x =  − 2 and x = 2 (Fig. 7.2, left). A very rough approximation of the area under the curve would be to calculate the sum of the areas of the rectangles with a base of 1 and a height of f(x) for all integer values of x from x =  − 2 to x = 1 (Fig. 7.2, middle). Now you can probably imagine that when we decrease the base of these rectangles by doubling the number of rectangles, the sum of their areas will better approach the area under the curve (Fig. 7.2, right). If we increase the number of rectangles even further to n and denote the base of these rectangles by Δx we find that the approximation of the area under the curve for this specific example equals

$$ \sum \limits_{i=0}^{n-1}f\left(-2+i\cdot \Delta x\right)\cdot \Delta x $$
Fig.7.2
figure 2

Illustration of calculation of area under the curve for the function f(x) =  − x 2 + 5 for x ∈ (−2, 2). Left: graph of the function, vertical lines at x =  − 2 and x = 2 indicate the boundaries of the domain. Middle: approximation of the area under the curve when using rectangles of base 1. Right: improved approximation of the area under the curve when using rectangles of base 0.5.

Now, if we let the number of rectangles between two general limits a and b (instead of −2 and 2) go to ∞ by letting Δx go to 0, we arrive at the definition of the definite integral

\( \underset{a}{\overset{b}{\int \limits }}f(x) dx \)

where a is the lower limit and b the upper limit. It should now be clear to you that this expression is equal to the area under the curve given by the graph of the function f(x) between x = a and x = b. More formally, the sum and integral that were used here are known as the Riemann sum and Riemann integral. Now, you may also understand that the differential dx can be understood as the limit of Δx when it goes to 0.

Also in the definition of the definite integral using the Riemann sum, we can retrace that integration is the inverse of differentiation. Remember that the formal definition of a derivative (Sect. 6.8, Eq. 6.1, replacing y by f(x)) was:

\( \frac{df(x)}{dx}=\underset{\Delta x\to 0}{\lim \limits}\frac{\Delta f(x)}{\Delta x} \)

Here, we also considered small changes in x and in f(x) as Δf(x) = f(x + Δx) − f(x). Hence, in derivation we subtract function values and divide the difference by Δx, while in integration we add function values and multiply the sum by Δx.

To calculate the definite integral you need to determine the anti-derivative or primitive function and subtract its values at the two limits:

$$ \mathrm{If}\kern0.5em F(x)=\int f(x) dx\kern0.5em \mathrm{then}\ \underset{a}{\overset{b}{\int \limits }}f(x) dx=F(b)-F(a) $$
(7.1)

Sometimes a slightly different notation is used:

\( \underset{a}{\overset{b}{\int \limits }}f(x) dx={\left.F(x)\right|}_{x=a}-{\left.F(x)\right|}_{x=b} \)

where F(x)| x = a should be read as F(x) for x=a.

Example 7.6

Calculate \( \underset{2\pi }{\overset{3\pi }{\int \limits }}\sin xdx \).

We know that (Table 7.1)

∫ sin xdx =  − cos x + C

By following rule (7.1), we can now calculate that:

$$ \underset{2\pi }{\overset{3\pi }{\int \limits }}\sin xdx=\left(-\cos 3\pi \right)-\left(-\cos 2\pi \right)=-\left(-1\right)+1=2 $$

We now present some important rules for definite integrals in Box 7.2:

Box 7.2 Important rules for definite integrals

  1. 1.

    \( \underset{a}{\overset{a}{\int \limits }}f(x) dx=0 \)

  2. 2.

    \( \underset{a}{\overset{b}{\int \limits }}f(x) dx=-\underset{b}{\overset{a}{\int \limits }}f(x) dx \)

  3. 3.

    If c ∈ (a, b) then \( \underset{a}{\overset{b}{\int \limits }}f(x) dx=\underset{a}{\overset{c}{\int \limits }}f(x) dx+\underset{c}{\overset{b}{\int \limits }}f(x) dx \)

These rules concern the limits of an integral. Thus, clearly any definite integrals with the same upper and lower limits are equal to zero. Swapping the upper and lower limits swaps the sign of the result. The third rule in Box 7.2 is the most interesting as it can sometimes come in quite handy when calculating definite integrals, as illustrated in the next example.

Example 7.7

Calculate

$$ \underset{2\pi }{\overset{2\frac{1}{8}\pi }{\int \limits }}\sin xdx+\underset{2\frac{1}{8}\pi }{\overset{3\pi }{\int \limits }}\sin xdx $$

Here it would be pretty hard to calculate \( \cos \left(2\frac{1}{8}\pi \right) \) without a calculator, whereas when we use the third rule in Box 7.2 and employ the answer to Example 7.3, we find that

$$ \underset{2\pi }{\overset{2\frac{1}{8}\pi }{\int \limits }}\sin xdx+\underset{2\frac{1}{8}\pi }{\overset{3\pi }{\int \limits }}\sin xdx=\underset{2\pi }{\overset{3\pi }{\int \limits }}\sin xdx=2 $$

Notice that the solution to definite integrals, in contrast to indefinite integrals , does not contain a constant (C). Let’s now see how definite integrals can be used to calculate the area under a complex curve (Example 7.8) and how a practical—albeit simple—problem (Example 7.9) can give us more insight in why we calculate definite integrals the way we do.

Example 7.8

Consider the function

f(x) = 4 cos(x + 0.1) − 0.5x

in Fig. 7.3 and determine the area under its graph between the two (approximate) roots x − 1.9122 and x = 5.3439.

Fig.7.3
figure 3

Plot of the function f(x) = 4 cos(x + 0.1) − 0.5x for x ∈ (−2, 5.5). The area under its graph consists of a positive (A1) and a negative (A2) part.

Between x =  − 1.9122 and x = 5.3439 the function is first positive, then negative. It changes sign at (approximately) x =  − 1.9122 and x = 1.3067 and then at x = 5.3439. Thus, the area A under the curve will be

A = A 1 − A 2

which is the so called signed area as illustrated in Fig. 7.4.

Fig.7.4
figure 4

Area under the curve (blue) for the function f(x) = 4 cos(x + 0.1) − 0.5x between x =  − 1.9122 and x = 5.3439.

We now know that \( {A}_1=\underset{-1.9122\kern0.5em }{\overset{1.3067}{\int \limits }}f(x) dx \) and \( {A}_2=\underset{1.3067}{\overset{5.3439}{\int \limits }}f(x) dx \). Thus, the area under the curve for f(x) between x =  − 1.9122 and x = 5.3439 is

$$ \mathrm{A}=\underset{-1.9122\kern0.5em }{\overset{1.3067}{\int \limits }}f(x) dx-\underset{1.3067}{\overset{5.3439}{\int \limits }}f(x) dx $$

We can now apply the rules in Table 7.1 to find the primitive or anti-derivative F of f(x) and calculate A. The primitive is \( F(x)=4\sin \left(x+0.1\right)-\frac{0.5}{2}{x}^2 \) and thus

$$ {\displaystyle \begin{array}{l}A=\left(F(1.3067)-F\left(-1.9122\right)\right)-\left(F(5.3439)-F(1.3067)\right)\\ {}\kern7em =4\sin \left(1.3067+0.1\right)\\ {}\kern7em -4\sin \left(-1.9122+0.1\right)-\frac{0.5}{2}{1.3067}^2+\frac{0.5}{2}{\left(-1.9122\right)}^2\\ {}\kern7em -4\sin \left(5.3439+0.1\right)\\ {}\kern7em +4\sin \left(1.3067+0.1\right)+\frac{0.5}{2}{5.3439}^2-\frac{0.5}{2}{(1.3067)}^2\approx 21.9529\end{array}} $$

Example 7.9

Marianne is speed walking at a constant velocity of 2 m/s. What distance will she cover within 9 s if she keeps walking at the same speed?

We can approach this problem in two different ways. Let’s first do it in a way which does not require integrals and uses our knowledge of physics. We know that distance travelled equals velocity times duration, thus Marianne covers 2 m/s × 9 s = 18 m within 9 s. A more complex way, that helps us understand why we calculate definite integrals the way we do, is the following. We know that the duration Δt = 9s. Let’s assume that we determine the distance travelled between start time t 0 = 1s and end time t END  = 10s. We also know that velocity is the derivative of distance travelled in time:\( v=\frac{dx}{dt}\approx \frac{\Delta x}{\Delta t} \) or Δx = v ⋅ Δt. Now v ⋅ Δt is the area of a rectangle with base Δt and height v which is the area under the curve of the constant function v = 2 m/s as displayed in the figure, or

$$ x=\underset{t_0}{\overset{t_{\mathrm{END}}}{\int \limits }}v(t) dt={\left. vt\right|}_{t_0}^{t_{\mathrm{END}}}=\frac{2m}{s}\left(10-1\right)s=18m $$

We now also see that subtracting the two values of the primitive is equal to subtracting the distance travelled in 1 s from the distance travelled in 10 s, which is the distance travelled in 9 s. Anyway, Marianne thus covers 18 m in 9 s. Is that fast enough for speed-walking?

Exercise

  1. 7.2.

    Determine the following definite integrals:

    1. a.

      \( \underset{0}{\overset{1}{\int \limits }}\sqrt{x^3} dx \)

    2. b.

      \( {\int \limits}_0^{\frac{T}{2}}\sin \left(\frac{2\pi t}{T}\right) dt \)

    3. c.

      \( \underset{0}{\overset{1}{\int \limits }}{\left({e}^x-1\right)}^2{e}^x dx \)

7.3.1 Multiple Integrals

Just as we can differentiate functions of multiple variables by partial differentiation (see Sect. 6.10), we can also integrate functions of multiple variables. Such (definite) integrals are called multiple integrals. And like definite integrals of one variable are associated with area under a curve, definite integrals of two variables are associated with volume under a surface, defined by the domain that is integrated over. To integrate functions of multiple variables, you start from the inner most integral and work your way out, always considering the variables you are not integrating over as constant, again similar to partial differentiation, where you consider the variables you do not differentiate for as constant. Let’s make this clearer by an example.

Example 7.10

Calculate \( \underset{1}{\overset{2}{\int \limits }}\underset{2}{\overset{4}{\int \limits }}\left({xy}^2+3{x}^3y\right)\ dx\ dy \)

This integral should be read as \( \underset{1}{\overset{2}{\int \limits }}\left(\underset{2}{\overset{4}{\int \limits }}{xy}^2+3{x}^3y\ dx\right)\ dy \) and thus, to calculate it, we have to integrate the function f(x, y) = xy 2 + 3x 3 y for x between 2 and 4 and y between 1 and 2. Executing this step-by-step, we find that:

$$ {\displaystyle \begin{array}{l}{\left.\underset{1}{\overset{2}{\int \limits }}\underset{2}{\overset{4}{\int \limits }}{xy}^2+3{x}^3y\ dx\ dy=\underset{1}{\overset{2}{\int \limits }}\left(\frac{1}{2}{x}^2{y}^2+\frac{3}{4}{x}^4y\right)\right|}_2^4\ dy=\underset{1}{\overset{2}{\int \limits }}\left(8{y}^2+192y\right)-\\ {}\kern7.7em {\left.\left(2{y}^2+12y\right) dy=\underset{1}{\overset{2}{\int \limits }}6{y}^2+180y\ dy=\left(2{y}^3+90{y}^2\right)\right|}_1^2\\ {}\kern7.7em =\left(16+360\right)-\left(2+90\right)=284\end{array}} $$

In this example, we calculated a double integral . Similarly, an integral with three variables of integration is called a triple integral .

7.4 Integration Techniques

So far, we only considered integrals of relatively simple functions. However, not all integration of relatively simple functions is simple. For example, how do we integrate functions such as

\( f(x)=\sqrt{x}\left(1+x\right) \) or f(x) = x sin 2x? There are numerous integration techniques that can help. Some of them are universal for all types of integrals. Some are more suited for definite integrals. Here, we will only explain some of these techniques, and illustrate them with examples. The goal of this section is to get you familiarized with the practice of integration. For more practice, we recommend starting with Jordan and Smith 2010, Mathematical techniques, and advance with Chap. 7 of Demidovich et al. (1966) available online in English.

7.4.1 Integration by Parts

Integration by parts is a method that relies on the product rule for differentiation (see also Table 6.2) that states that if

y(x) = f(x)g(x)

then

$$ {y}^{\prime }(x)={f}^{\prime }(x)g(x)+f(x){g}^{\hbox{'}}(x). $$

If we now apply anti-derivation to the first equation and substitute the second equation, we get:

f(x)g(x) = y(x) =  ∫ y?>′(x)dx =  ∫ (f?>′(x)g(x) + f(x)g?>′(x) )dx

By rearranging the most outer terms, we find that:

$$ \int f(x){g}^{\hbox{'}}(x) dx=f(x)g(x)-\int {f}^{\prime }(x)g(x) dx $$
(7.2)

This means, that if a function is the product of one function with the derivative of another function, we have a method to determine the integral of this product.

Example 7.11

Determine the integral

y(x) =  ∫ x 2 e x dx

To solve this integral, we first consider the simpler integral

y 1(x) =  ∫ xe x dx

Careful consideration of this function shows that integration by parts according to Eq. 7.2 can be applied for f(x) = x and g?>′(x) = e x. To perform integration by parts we now need to determine f '(x) and g(x), which is relatively simple as these are simple functions. Thus f '(x) = 1 and g(x) =  ∫ e x dx = e x and after integration by parts of y 1 we find that:

y 1(x) =  ∫ xe x dx = xe x −  ∫ 1 ⋅ e x dx = xe x − e x + C = e x(x − 1) + C

Simple, right? This is how integration by parts works. Now let’s go back to the original function y(x). For this function, we choose f(x) = x 2 and g?>′(x) = e x and thus f?>′(x) = 2x and g(x) = e x. Applying integration by parts according to Eq. 7.2 we now find:

y(x) =  ∫ x 2 e x dx = x 2 e x −  ∫ 2xe x dx

We have just determined that ∫xe x dx = e x(x − 1) + C and thus:

$$ y(x)={x}^2{e}^x-2\Big({e}^x\left(x-1\Big)+C\right)={e}^x\left({x}^2-2x+2\right)+C $$

For integration by parts to be applicable you should be able to assign f(x) and g?>′(x) such that

  1. 1.

    f?>′( x ) is simpler than f ( x )

  2. 2.

    g ( x ) is not more complicated than g ′( x )

Example 7.12

Determine ∫x ln xdx.

Here we consider the two functions x and lnx that form the product. Is one of them simpler after derivation? Is the second one not more complicated after integration? The derivative of f(x) = ln x is in fact simpler than the function itself:

$$ {f}^{\prime }(x)=\frac{1}{x} $$

Thus, we have identified one function that is simpler after differentiation. But does the second function in the product have an integral that is not more complicated than the function itself? So, let’s assign g′(x) = x. Then \( g(x)=\int xdx=\frac{x^2}{2} \). This integral is not much more complicated, but is it sufficiently simple? Let’s try and find out:

Applying integration by parts according to Eq. 7.2, using our choice of f(x) and g′(x) we find that:

$$ \int x\ln xdx=\frac{x^2}{2}\ln x-\int \frac{1}{x}\frac{x^2}{2} dx=\frac{x^2}{2}\ln x-\frac{x^2}{4}+C=\frac{x^2}{2}\left(\ln x-\frac{1}{2}\right)+C $$

Example 7.13

Determine ∫e x cos xdx.

Now we consider the two functions e x and cosx that form the product. Is one of them simpler after derivation ? Is the second one not more complicated after integration?

We know that e x is not more complicated after integration. But is cosx simpler after derivation? Let’s give it a try and assign f(x) = cos x, g?>′(x) = e x. Then f?>′(x) =  − sin x and g(x) = e x. When we now apply integration by parts according to Eq. 7.2 we find that:

$$ \int {e}^x\cos xdx=\cos {xe}^x+\int \sin {xe}^x dx $$

The integral on the right-hand side actually does not look much simpler. But let’s keep at it and apply integration by parts one more time to the integral on the right-hand side. This time we assign f(x) = sin x, g?>′(x) = e x. Then f?>′(x) = cos x and g(x) = e x and we find that:

$$ \int {e}^x\cos xdx=\cos {xe}^x+\sin {xe}^x-\int {e}^x\cos xdx $$

Now we recognise the integral that we want to determine (∫e x cos xdx) on both sides of the equation. By rearranging the terms, we get:

2 ∫ e x cos xdx = cos xe x + sin xe x + C

and thus:

$$ \int {e}^x\cos xdx=\frac{e^x}{2}\left(\cos x+\sin x\right)+C $$

Exercise

  1. 7.3

    Determine the following integrals using integration by parts:

    1. a.

      ∫(x −1)2 e x dx

    2. b.

      \( \underset{0}{\overset{\pi }{\int \limits }}x\sin 2 xdx \)

    3. c.

      ∫(lnx)2 dx

7.4.2 Integration by Substitution

Another, probably much more often used method to determine integrals is (u-)substitution. In short, the aim is to make the integrand as simple as possible to determine the integral. To determine integrals by rewriting them to “easier” forms the following steps need to be taken:

  1. 1.

    For an integral ∫f(x)dx find a part of the function that can be substituted by u(x)

  2. 2.

    Differentiate to express dx in terms of du: dx = x?>′(u)du

Check if the new integral ∫f(x)dx =  ∫ f(x(u))x '(u)dx is easier to solve and if not try another substitution.

  1. 3.

    Once you have finished the calculus, substitute back to the initial variable x to find an indefinite integral or also substitute the limits to find a definite integral.

As this explanation probably sounds rather abstract, let’s try to get a better understanding by some examples.

Example 7.14

Determine ∫x(x + 5)5 dx.

First, we determine a likely suitable substitution u(x). It seems appropriate to simplify the function by substituting

u(x) = x + 5

We can find the differential du as follows:

du = d(x + 5) = dx + 0 = dx

We also know that:

x = u − 5

Now we can rewrite the integral as follows:

$$ \int x{\left(x+5\right)}^5 dx=\int \left(u-5\right){(u)}^5 du $$

This is easy to solve for u:

$$ \int \left(u-5\right){(u)}^5 du=\int \left({u}^6-5{u}^5\right) du=\int {u}^6 du-5\int {u}^5 du=\frac{u^7}{7}-\frac{5{u}^6}{6}+C $$

To determine the original integral in terms of x, all we should do now is substitute u again. Thus, the integral is:

$$ \int x{\left(x+5\right)}^5 dx=\frac{{\left(x+5\right)}^7}{7}-\frac{5{\left(x+5\right)}^6}{6}+C $$

Example 7.15

Determine \( \int \left(3{x}^2+10x+7\right){e}^{-\left(5{x}^2+7x+{x}^3\right)} dx \)

At first sight, the integrand looks too complex to be able to determine the integral. But let’s try to find a suitable substitute u(x). As the biggest problem seems to be in the complex exponent, we first try to define this as a substitute:

$$ u(x)=5{x}^2+7x+{x}^3 $$

As we know that ∫e x dx =  − e x + C, this might be a sensible approach to this integral.

Next, we determine the differential du by derivation:

$$ \frac{du}{dx}=10x+7+3{x}^2 $$

or

$$ du=\left(3{x}^2+10x+7\right) dx $$

Now substitution results in a very simple integrand and integration becomes a piece of cake:

$$ \int \left(3{x}^2+10x+7\right){e}^{-\left(5{x}^2+7x+{x}^3\right)} dx=\int {e}^{-u} du=-{e}^{-u}+C $$

Finally, substituting u(x) results in:

$$ \int \left(3{x}^2+10x+7\right){e}^{-\left(5{x}^2+7x+{x}^3\right)} dx=-{e}^{-\left(5{x}^2+7x+{x}^3\right)}+C $$

Example 7.16

Determine \( \int \sqrt{5x+3} dx \).

The most obvious choice for substitution is:

$$ u(x)=5x+3 $$

Then

$$ \frac{du(x)}{dx}=5 $$
$$ dx=\frac{1}{5} du $$

We can now rewrite the integral to:

$$ \int \sqrt{5x+3} dx=\int \sqrt{u}\frac{1}{5} du=\frac{1}{5}\frac{2}{3}{u}^{\frac{3}{2}}+C $$

For the final step, substitution gives:

$$ \int \sqrt{5x+3} dx=\frac{2}{15}\sqrt{{\left(5x+3\right)}^3}+C $$

Example 7.17

Determine \( \int \frac{3{x}^4}{x^5+6} dx. \)

There is no obvious choice for substitution now: we could either choose the numerator or the denominator as a candidate for substitution. However, the denominator has a higher order polynomial than the numerator. Thus, if the denominator is differentiated it will be closer to the numerator. For this reason, we choose the denominator for u- substitution:

$$ u(x)={x}^5+6 $$
$$ \frac{du(x)}{dx}=5{x}^4 $$
$$ dx=\frac{1}{5{x}^4} du $$

We can now rewrite the integral to:

$$ \int \frac{3{x}^4}{x^5+6} dx=\int \frac{3{x}^4}{u}\frac{1}{5{x}^4} du=\frac{3}{5}\int \frac{du}{u}=\frac{3}{5}\ln \left|u\right|+C $$

So finally, substituting u again yields:

$$ \int \frac{3{x}^4}{x^5+6} dx=\frac{3}{5}\ln \left|{x}^5+6\right|+C $$

Example 7.18

Determine ∫cos6 x sin xdx.

If we again choose to substitute the part of the product with the higher power, similar to Example 7.16, we can write :

$$ u(x)=\cos x $$
$$ \frac{du(x)}{dx}=-\sin x $$
$$ dx=\frac{-1}{\sin x} du $$

We can now rewrite the integral to:

$$ \int {\mathrm{cos}}^6x\sin xdx=\int {u}^6\sin x\frac{-1}{\sin x} du=-\int {u}^6 du=-\frac{1}{7}{u}^7+C $$

Final substitution of u gives:

$$ \int {\mathrm{cos}}^6x\sin xdx=-\frac{1}{7}{\left(\cos x\right)}^7+C $$

Exercise

  1. 7.4

    Determine the following integrals using substitution:

    1. a.

      \( \int {x}^2{e}^{-4{x}^3} dx \)

    2. b.

      \( \int \frac{3\sin x}{2+\cos x} dx \)

    3. c.

      \( \int \frac{{\left(\sqrt{x}+2\right)}^6}{\sqrt{x}} dx \)

    4. d.

      \( \int \frac{3}{x\ln x} dx \)

    5. e.

      \( \underset{0}{\overset{1}{\int \limits }}\sqrt{1+x} dx \)

7.4.3 Integration by the Reverse Chain Rule

Just like integration by parts employed the product rule for differentiation, we can use the chain rule for differentiation to our advantage for integration. One could say that the “reverse chain rule” makes implementation of u-substitution easier as, in a way, it is the same rule. Remember that for a composite function f(x) = g(h(x)) (Table 6.2):

$$ \frac{df(x)}{dx}=\frac{dg\left(h(x)\right)}{dx}=\frac{dg}{dh}\frac{dh}{dx}={h}^{\prime }(x){g}^{\hbox{'}}\left(h(x)\right) $$

Applying integration, we find that:

$$ \int {h}^{\prime }(x){g}^{\hbox{'}}\left(h(x)\right) dx=g\left(h(x)\right)+C $$
(7.3)

In general, this rule is used for integration of trigonometric, logarithmic, rational/power and exponential functions. To apply the reverse chain rule in case of some composite function (e.g. sin(3x + 5), or log5|sinx|), one should try to recognise the derivative of the function inside the composite function (thus h(x)). For example, let’s consider the integrand:

x sin x 2

Note that sinx 2 = sin(x 2), whereas sin2 x = sin x sin x. In this case 2x is the derivative of x 2 and we recognize that the sinusoidal function is multiplied by half the derivative of the function that is inside the sinusoidal function. We can thus write:

\( x\sin {x}^2=2x\cdot \frac{1}{2}\sin {x}^2={h}^{\prime }(x){g}^{\hbox{'}}\left(h(x)\right) \)

Once we have recognized this structure in the integrand, the next step is to determine h(x) and g(h):

$$ h(x)={x}^2,\kern2em {h}^{\hbox{'}}(x)=2x $$
$$ {g}^{\hbox{'}}(h)=\frac{1}{2}\sin h,\kern2em g(h)=-\frac{1}{2}\cos h $$

We then know how to determine the integral of this composite function, by applying the reverse chain rule Eq. 7.3:

\( \int x\sin {x}^2 dx=-\frac{1}{2}\cos {x}^2+C \)

Example 7.19

Determine ∫3x 2 sin x 3 dx.

We recognize that 3x 2 is the derivative of x 3 and hence apply the reverse chain rule (Eq. 7.3) as follows:

$$ h(x)={x}^3,\kern2em {h}^{\hbox{'}}(x)=3{x}^2, $$
$$ {g}^{\prime }(h)=\sin h,\kern2em g(h)=-\cos h $$

We thus find that:

$$ \int 3{x}^2\sin {x}^3 dx=-\cos {x}^3+C $$

Exercise

  1. 7.5

    Determine the following integrals using the reverse chain rule:

    1. a.

      \( \int {x}^3{e}^{x^4} dx \)

    2. b.

      x 3(1 + x 4)3 dx

7.4.4 Integration of Trigonometric Functions

Although the integration techniques introduced in Sects. 7.4.1 to 7.4.3 allow integration of many different functions, there will still be integrals left that cannot be determined. For specific types of integrands, such as rational or transcendental functions, several additional useful methods exist to determine their integrals (see for example Bronshtein et al. 2007). Here, we will only briefly cover some integration methods for trigonometric integrands so that you get a feeling of how integration is done in general. We direct you to more specialized literature for broader and more advanced methods of integration (e.g. Jordan and Smith (2010)). An overview can also be found on https://en.wikipedia.org/wiki/List_of_integrals_of_trigonometric_functions.

The following methods can be used to determine some integrals of trigonometric functions:

  1. 1.

    If the integral contains a rational function of sines and cosines, the following substitution is often useful:

    \( \tan \frac{x}{2}=t \) which implies that \( \sin x=\frac{2t}{1+{t}^2} \), \( \cos x=\frac{1-{t}^2}{1+{t}^2} \) and \( dx=\frac{2 dt}{1+{t}^2} \). Here we use that \( \sin x=2\sin \frac{x}{2}\cos \frac{x}{2} \) and \( \cos x={\mathrm{cos}}^2\frac{x}{2}-{\mathrm{sin}}^2\frac{x}{2} \). By this substitution, the integrand becomes a rational function of t.

  2. 2.

    If the integrand is a positive power of a trigonometric function, recurrent formulas can be used to determine the integral:

$$ \int {\mathrm{sin}}^n xdx=\frac{1}{n}{\mathrm{sin}}^{n-1}x\cos x+\frac{n-1}{n}\int {\mathrm{sin}}^{n-2} xdx $$
$$ \int {\mathrm{cos}}^n xdx=\frac{1}{n}{\mathrm{cos}}^{n-1}x\sin x+\frac{n-1}{n}\int {\mathrm{cos}}^{n-2} xdx $$
  1. 3.

    If the integrand is a negative power of a trigonometric function, such as \( \int \frac{1}{{\mathrm{sin}}^nx} dx \) or \( \int \frac{1}{{\mathrm{cos}}^n} xdx \) (n ∈ N, n > 1), the integral can be determined by using the following recurrent formulas:

$$ \int \frac{1}{{\mathrm{sin}}^nx} dx=\frac{1}{n-1}\frac{\cos x}{{\mathrm{sin}}^{n-1}x}+\frac{n-2}{n-1}\int \frac{1}{{\mathrm{sin}}^{n-2}x} dx $$
$$ \int \frac{1}{cos^nx} dx=\frac{1}{n-1}\frac{\sin x}{cos^{n-1}x}+\frac{n-2}{n-1}\int \frac{1}{cos^{n-2}x} dx $$
  1. 4.

    Integrals of the form ∫sinm xcosn xdx, (n, m ∈ Z, >0), can be determined using the following recurrent formulas:

$$ \int {\mathrm{sin}}^nx{\mathrm{cos}}^m xdx=\frac{{\mathrm{sin}}^{n+1}x{\mathrm{cos}}^{m-1}x}{m+n}+\frac{m-1}{m+n}\int {\mathrm{sin}}^nx{\mathrm{cos}}^{m-2} xdx $$

or

$$ \int {\mathrm{sin}}^nx{\mathrm{cos}}^m xdx=-\frac{{\mathrm{sin}}^{n-1}x{\mathrm{cos}}^{m+1}x}{m+n}+\frac{n-1}{n+m}\int {\mathrm{sin}}^{n-2}x{\mathrm{cos}}^m xdx $$

(see also https://en.wikipedia.org/wiki/List_of_integrals_of_trigonometric_functions#Integrands_involving_both_sine_and_cosine)

  1. 5.

    Integrals of the form ∫ sin nx cos mxdx, (n, m ∈ Z) can be simplified and subsequently determined using the trigonometric identities for multiplication of trigonometric functions:

\( \sin nx\cos mx=\frac{1}{2}\left[\sin \left(n-m\right)x+\sin \left(n+m\right)x\right] \)

Example 7.20

Determine \( \int \frac{dx}{5+4 cosx} \)

This integral can be determined using the first method in this section by substituting\( \tan \frac{x}{2}=t \), \( \cos x=\frac{1-{t}^2}{1+{t}^2} \) and \( dx=\frac{2 dt}{1+{t}^2} \):

$$ \int \frac{dx}{5+4 cosx}=\int \frac{\frac{2 dt}{1+{t}^2}}{5+4\frac{1-{t}^2}{1+{t}^2}}=\int \frac{2 dt}{9+{t}^2} $$

We know how to determine this integral as it is similar to the integral of \( \frac{1}{x^2+1} \) (Table 7.1)

$$ \int \frac{dx}{5+4 cosx}=\frac{2}{9}\int \frac{dt}{1+\frac{t^2}{9}} $$

If we substitute \( \frac{t^2}{9}={u}^2 \), then dt = 3du and thus

$$ \int \frac{dx}{5+4 cosx}=\frac{6}{9}\int \frac{du}{1+{u}^2}=\frac{6}{9}\arctan u+C=\frac{6}{9}\arctan \frac{t}{3}+C=\frac{6}{9}\arctan \frac{\tan \frac{x}{2}}{3}+C $$

7.5 Scientific Examples

7.5.1 Expected Value

The expected value 〈x〉 of a stochastic variable x is frequently encountered in statistics. It refers to the value one expects to get for x on average if an experiment would be run many times. For example, if you toss a coin 10 times, you expect to get 5 heads and 5 tails. You expect this value because the probability of getting heads is 0.5 and if you toss 10 times you anticipate that you will get heads 5 times. The expected value is also called the expectation value, the mean, the mean value, the mathematical expectation and, in statistics, it is known as the first moment.

If the probability distribution P(x), which describes the probability of getting a specific value of x is known, the expected value can be calculated by multiplying each of the possible outcomes by the probability that each outcome will occur, and by integrating all products:

a = 〈x〉 =  ∫ xP(x)dx

The expected value can be viewed as the weighted average value, where the weight is given by the probability distribution. This is easier to understand in the case of a discrete distribution. Note that nowadays almost all measurements are discrete, even when measuring continuous events, as our digital devices sample the values at a specific frequency, e.g. at 2 Hz (every 0.5 s). As explained in Sect. 7.3, in the case of n discrete values, we can replace the integral by a sum

\( a=\sum \limits_{i=1}^{i=n}{x}_iP\left({x}_i\right) \)

Example 7.21

The most frequently used example of expected value concerns throwing a dice. If a dice is of good quality, the probability of the dice landing on any of the 6 sides is equal. Thus, the probability of getting a 5 is 1/6, as is the probability of getting any of the other possible values:

$$ P\left({x}_i\right)=\frac{1}{6},\kern0.5em {x}_i=\left\{1,2,3,4,5,6\right\} $$

The expected value when throwing a dice is thus:

$$ a=\sum \limits_{i=1}^n{x}_iP\left({x}_i\right)=\frac{\left(1+2+3+4+5+6\right)}{6}=3.5 $$

This is the same as the average of the values on a six-sided dice.

In most cases the probability will not be equal for all values of x. To calculate the expected value, it is then convenient to have a functional description of the probability distribution.

Example 7.22

A frequently encountered distribution is the Gaussian distribution. Any stochastic variable that is determined by many independent factors will follow such a distribution. Examples are height and weight of humans. The Gaussian probability distribution function is:

\( G(x)=\frac{1}{\sqrt{2\pi}\sigma }{e}^{\frac{{\left(x-\mu \right)}^2}{2{\sigma}^2}} \)

Here, μ is the mean value of the distribution and σ is its standard deviation. Let’s see if μ is indeed the same as the expected value:

$$ \left\langle x\right\rangle =\underset{-\infty }{\overset{\infty }{\int \limits }} xP(x) dx=\underset{-\infty }{\overset{\infty }{\int \limits }}x\frac{1}{\sqrt{2\pi}\sigma }{e}^{\frac{{\left(x-\mu \right)}^2}{2{\sigma}^2}} dx $$

To determine this integral is beyond the scope of this book, but we will here describe some important steps. For a more detailed explanation we refer to Reif (1965, the Berkley Physics course Volume 5, Appendix 1; https://en.wikipedia.org/wiki/List_of_integrals_of_exponential_functions).

The integral can be solved using substitution and then incorporating some of the characteristics of the Gaussian distribution. In this manner, the expected value can be rewritten using:

u = x − μ

du = dx

resulting in:

$$ \left\langle x\right\rangle =\frac{1}{\sqrt{2\pi}\sigma}\underset{-\infty }{\overset{\infty }{\int \limits }}{ue}^{\frac{u^2}{2{\sigma}^2}} du+\frac{1}{\sqrt{2\pi}\sigma}\underset{-\infty }{\overset{\infty }{\int \limits }}\mu {e}^{\frac{u^2}{2{\sigma}^2}} du $$

The first integral vanishes as the integrand is odd:

$$ \underset{-\infty }{\overset{0}{\int \limits }}{ue}^{\frac{u^2}{2{\sigma}^2}} du=-\underset{0}{\overset{\infty }{\int \limits }}{ue}^{\frac{u^2}{2{\sigma}^2}} du $$

The second integral can be rewritten as (Reif 1965, Berkley Physics course, Volume 5, Appendix 1, Equations 11 and 12)

\( \underset{-\infty }{\overset{\infty }{\int \limits }}\mu {e}^{\frac{u^2}{2{\sigma}^2}} du=\mu \underset{-\infty }{\overset{\infty }{\int \limits }}{e}^{\frac{u^2}{2{\sigma}^2}} du=\mu \sqrt{2\pi}\upsigma \)

Thus, the expected value of a Gaussian distribution is indeed equal to its mean.

7.5.2 Convolution

Convolution is a very important mathematical operation in the analysis of time series. It can be viewed as a type of filter. If you have one function or time series f(t), convolution with another function g(t) yields the amount by which g(t) overlaps with f(t) when g(t) is shifted in time. Convolution is expressed by an integral, as follows:

$$ \left[f\ast g\right](t)=\underset{-\infty }{\overset{\infty }{\int \limits }}f\left(\tau \right)g\left(t-\tau \right) d\tau $$

In other words, convolution is a mathematical operation on two functions, resulting in a third function that represents the overlap between the two functions as a function of the translation of one of the original functions with respect to the other. The effect of convolution will become clearer in some examples. Note that in all figures belonging to the examples below both the convolution and f(t) were normalized to the maximum of g(t), for illustration purposes.

Example 7.23

The convolution of a rectangular function and a linear function results in a saw-tooth function. When the rectangular function is shifted, the maximum of the convolution, that indicates where both functions have maximum overlap, also shifts (Fig. 7.5).

Fig.7.5
figure 5

Left: Convolution (red) of a rectangular function (blue) with a linear function (green). Right: Convolution of the same functions when f(x) is shifted along the x-axis. Note that the convolution and f(x) were normalized for illustration purposes.

Example 7.24

The convolution of a rectangular and a saw-tooth function is similar to Example 7.23. If the order of the convolution between saw-tooth and rectangular function is reversed, we see that the resulting function is shifted along the x-axis (Fig. 7.6).

Fig.7.6
figure 6

Left: Convolution (red) of a rectangular function (blue) with a saw-tooth function (green). Right: Convolution of the same functions in reverse order. Note that the convolution and f(x) were normalized for illustration purposes.

Example 7.25

The convolution of a rectangular and a Gaussian function is again a Gaussian function (Fig. 7.7).

Fig.7.7
figure 7

Convolution (red) of a rectangular function (blue) with a Gaussian function (green).

Example 7.26

It is not true that the convolution of any function with a Gaussian function is again a Gaussian function, as is illustrated with this example of the convolution of a saw-tooth function with a Gaussian function (Fig. 7.8).

Fig.7.8
figure 8

Convolution (red) of a saw-tooth function (blue) with a Gaussian function (green). The convolution is skewed just like the saw-tooth function.

Example 7.27

In behavioral neuroscience, functional magnetic resonance imaging (fMRI) is often used to determine brain activation during tasks. It employs the local relative increase in oxygenated blood (the blood oxygen-level-dependent or BOLD-response) that develops when a brain area is involved in such a task. The general linear modeling (GLM) approach to analyze fMRI data was introduced in Chap. 5, and the BOLD response and hemodynamic response function (HRF) were introduced in Chap. 6 (Sect. 6.13.3). General linear modeling involves modeling the BOLD response in a brain area that is involved in a task. The simplest model assumes that there is (constant) activity in such a brain area during the task and no activity during rest, in between task blocks, resulting in a so-called block model (see Fig. 4.16, top and cf. Example 4.4). Such a model does not take the sluggish BOLD-response into account, however, which becomes maximal only seconds after the brain has been stimulated. To compensate for this sluggishness and model the specific physiological response as well as possible the block model is convoluted with a model of the BOLD response, the HRF (see Fig. 7.9 middle and bottom).

Fig.7.9
figure 9

fMRI data analysis preparation. The input time series (top) are convoluted with the HRF (middle) to create a predictor for the GLM analysis (bottom). This is done for each condition, task or any other experimental manipulation.

Example 7.28

Since a few decades, we mostly only make digital photos, which allows easy manipulation using computer programs such as Photoshop or Paint. Most of us have used these programs to beautify ourselves and we have become quite used to ‘photoshopped’ pictures of celebrities in magazines. Oftentimes, convolution is used to enhance photos digitally. For example, the pixelated photo on the left in Fig. 7.10 can be convoluted with a 2D Gaussian function to blur or smoothen it, so that the pixels (and thereby the wrinkles!) are not recognizable any more (Fig. 7.10, right).

Fig.7.10
figure 10

Left: A pixelated picture. Right: The same picture after 2D Gaussian smoothing (over 4 × 4 pixels) has been applied. Wrinkles have disappeared and facial features have changed.

Example 7.29

Cross-correlation provides a beautiful example of convolution in everyday science. Cross-correlation provides a measure of the similarity between two functions as a function of a time-lag applied to one of them. This is also known as the sliding dot product or sliding inner-product (cf. Sect. 4.2.2.1). For continuous functions f(t) and g(t) the cross-correlation is given by

\( f\ast g\left(\tau \right)=\underset{-\infty }{\overset{\infty }{\int \limits }}{f}^{\ast }(t)g\left(t+\tau \right) dt \)

Here, f (t) denotes the complex conjugate of f(t). You can see that cross-correlation is the same as convolution for f(−t). Thus, the cross-correlation is a function of τ, which has the same range as t.