2.6 Integration

So far we have focused on finding derivatives, i.e. given $f(X)$, we find the its derivative $f'(X)$.

We have seen that functions that we have names for, like $X^n, \sin(X), e^X, \ln(X),...$, their derivatives are also functions that have names and can be find using various "rules".

What about the reverse process? i.e. given a function $f(x)$, find a function $F(x)$ whose derivative $F'(X)$ is $f(X)$

An anti-derivative of $f(X)$ is a function $F(X)$ whose derivative is $f(X)$.

Of course, when the given function is obviously the derivative of another function, it is easy to find an anti-derivative.

For example, if $f(t) = 2t$, then we recognize $F(t)=t^2$ is an anti-derivative of $f(t)$ just because we remember the derivative of $t^2$ with respect to $t$ is $2t$.

Note that $F(t)=t^2$ is not the only function whose derivative is $2t$. For example, $t^2-3$ is another one. In fact, $t^2 +c$, where $c$ is any constant. is an anti-derivative of $2t$.

With a bit more work, one can show that every anti-derivative of $2t$ is of the form $t^2 + c$ where $c$ is a constant.

We denote this by

$$ \int 2t\ dt = t^2 +C$$

More generally, we write

$$ \int f(t) dt $$

for the class of anti-derivatives of $f(t)$. We call this class the indefinite integral of $f(t)$ or the anti-derivative of $f(t)$.

It can be shown that if $f(t)$ is a function defines on an interval and $F(t)$ is an anti-derivative of $f(t)$ then

$$\int f(t) dt = F(t)+C$$

That means if $F(t)$ is an anti-derivative of $f(t)$ then every anti-derivative of $f(t)$ is of the from $F(t)$ plus a constant (strictly speaking a locally constant function)

Exercise 2.6.1 Find $\dfrac{d}{dt}(t^2+5)$ and $\dfrac{d}{dt}(t^2-1)$ and answer why the $+C$ is necessary.

Ans Both $\dfrac{d}{dt}(t^2+5)$ and $\dfrac{d}{dt}(t^2-1)$ is $2t$. This suggests that $\displaystyle \int 2t dt$ contains $t^2 +C$, that is the class of functions of the form $t^2$ + a constant.

In fact, as we pointed out above that the indefinite integral $\int 2t dt^2$ (i.e. the class of all antiderivatives of $2t$) is exactly the class $t^2 + C$.

Exercise 2.6.2 Find the antiderivative of $f'(X)=3X^2$

Fact

It turns out that the anti-derivative of many "common functions" do not have a common name.

That makes "finding" (expressing) anti-derivatives hard.

Why do we care about finding indefinite integrals?

Read p.100

One important class of cases involves a given function $f'(t)$ as a rate of something, and we want to figure out the total amount of the something deposited by that rate.

For example, suppose we are given the speed (or more precisely, the velocity) $V(t)$ of a car from a recording of the speedometer. So we have $V(t)$.

But $V(t)$ is just $X'(t)$, where $X$ is the car’s position (or more precisely displacement) at time $t$, assuming it starts at position $0$ (which makes the constant $c$ in the antiderivative to be 0).

Can we recover $X(t)$ from $V(t)$?

For another example, we might know $D'(t)$, the rate of drug delivery to a patient. This is the readout of the flow meter attached to the intravenous drip.

But what we want to know is not $D'(t)$, but rather $D(t)$, the cumulative amount of drug that was delivered to the patient up to time $t$

Euler and Riemann: Adding up little rectangle

Area "under" the curve

$$ X(t) \approx X(0)+ \sum_{k=0}^{n} V(k \cdot \Delta t)\Delta t$$

Exercise 2.6.4 Compute:

a) $\sum_{k=0}^{k=3} 2k$

b) $\sum_{k=0}^{k=4} k^3$

c) $\sum_{k=0}^{k=3} 6k+2$

In [3]:
''' a '''
n=3
summand =lambda k : 2*k
sum([summand(k) for k in range(n+1)]) # range(n+1) is the list [0,1,...,n] so range(4) = [0,1,2,3] (which has 4 numbers)
Out[3]:
12
In [4]:
'''b'''
n=4
summand = lambda k : k**3
sum([summand(k) for k in range(n+1)])
Out[4]:
100
In [5]:
'''c'''
n = 3
summand = lambda k : 6*k+2
sum([summand(k) for k in range(n+1)])
Out[5]:
44

Procedure for finding a Riemann Sum

(1) Break down the total elapsed time into many small $\Delta t$’s.

(2) Assume that $V(t)$ is constant over each small interval $\Delta t$.

(3) Use the equation “distance = velocity × time” to calculate the distance traveled in that $\Delta t$.

(4) Add up the little distances.

$$ X(t) = X(0)+ \lim_{\Delta t \to 0} \sum_{k=0}^{k=n} V(k \cdot \Delta t)\Delta t$$

$$ X(t) = X(0) + \int_0^t X' dt $$

or

$$X(t)-X(0) = \int_0^t X' dt$$

In [6]:
"""
Left Riemann Sum
Input: a function 'func', lower, upper, step_size
Output: the left Riemann Sum of func from lower to upper with step_size
"""
def rs(func,lower,upper,step_size):
    num_of_steps = round((upper - lower)/step_size) # round makes the quotient to an integer
    return(sum([func(lower+k*step_size)*step_size for k in range(num_of_steps)]))
In [7]:
"""
Input: a function `func`, a number `lower`, a number `upper` and an integer `n` 
       and optionally a number `asr` (aspect_ratio) between 0 and 1, the default value is 1
Output the rectangles that represent the left Riemann sum of the `func` from `lower` to `upper` using `n` equal width rectangles.
"""
def riemann_rec(func,lower,upper,n,asr=1):
    width = (upper-lower)/n
    rects = [[[pt,0],[pt,func(pt)],[pt+width,func(pt)],[pt+width,0]] for pt in srange(lower,upper,width)]
    return(sum([polygon2d(rect,alpha=0.5, aspect_ratio=asr, edgecolor='black') for rect in rects]))

2.6.5 Find the Riemann sum for $f(X) = X^2 +5$ between $X=0$ and $X=2$ using a step size of $0.5$.

In [14]:
f = lambda X : X^2 + 5
a = 0; b = 2; dt =0.5
rs(f,a,b,dt)
Out[14]:
11.7500000000000
In [13]:
riemann_rec(f,0,2,4,0.5)+plot(f,0,2)
Out[13]:
No description has been provided for this image

2.6.6 Find the distance traveled by a car in $8$ seconds if it velocity $V(t)$ as a function of time is given by $V(t) = 4\sqrt{600-t^3}$. Use a step size of $0.5$.

In [10]:
step_size = 0.5
lower =0
upper = 8
V = lambda t: 4*sqrt(600-t^3)
rs(V,lower,upper,step_size)
Out[10]:
698.546343504087
In [11]:
riemann_rec(V,0,8,16,0.1)+plot(V,0,8)
Out[11]:
No description has been provided for this image

Fundamental Theorem of Calculus

The signed area underneath the curve $y=f(t)$ between $t=a$ to $t=b$ is

$$ F(b)-F(a) = \int_a^b f(t) dt$$

where $F(t)$ is an antiderivative of $f(t)$.

Exercise 2.6.7 According to CDC data, the average American six-year-old girl weighs $42.5$ pounds, and the average ten-year-old girl weighs $75$ pounds. What is the area under the growth (rate of change of weight) function between $t = 6$ and $t = 10$?

Ans. Since the area under the growth is the rate of change of weight, i.e. the weight function is an antiderivative of the growth function, hence the area under the growth function between $t=6$ and $t=10$ is the difference $w(10) - w(6) = 75-42.5 = 32.5$,