When you take an integral, the function in it can be in terms of any variable. This is just notation and it does not affect the result of the integration:
\[\int f(x) dx = \int f(t) dt = \int f(u) du.\]
EDS 212: Day 2, Lecture 2
Integration and differential equations
How do we find the area under this curve?
How do we find the area under this curve?
Areas of rectangles are easy to find (base times height!). We can approximate the area by adding the area of rectangles under the curve.
Example
Approximate the area under the curve from \([-3,3]\) with \(\Delta x=2\) and \(k=3\).
✏️
| x | y |
|---|---|
| -3 | 71 |
| -1 | 73 |
| 1 | 51 |
| 3 | 53 |

Riemann sums
Divide the interval \([a,b]\) into \(k\) subintervals of width \(\Delta x\).
The endpoints of those intervals will give you a series of \(x\) values: \(x_0, x_1, \ldots, x_k\).
Multiply \(f(x_1)\Delta x\) to get the the area of the first rectangle.
Repeat the same steps above, now starting with \(x_2\) as the bottom right corner of the next rectangle. Repeat until you cover the area with rectangles of width \(\Delta x\).
Sum up the area of all \(k\) rectangles.
\[ R(f(x), \Delta x)= \underbrace{f(x_1)\Delta x+f(x_2)\Delta x+...f(x_k)\Delta x}_{\text{Sum of area of rectangles with width $\Delta(x)$} } \]
This is called a Riemann Sum.
Finer and finer Riemann sums
What if we try to make \(\Delta x\) (the width of the rectangles) really small? So we let \(\Delta x \to 0\). This will make the number of rectangles under the curve go to infinity.
Our estimation of the area will get better and better with more rectangles.

Finer and finer Riemann sums
What if we try to make \(\Delta x\) (the width of the rectangles) really small? So we let \(\Delta x \to 0\). This will make the number of rectangles under the curve go to infinity.
Our estimation of the area will get better and better with more rectangles.

Take the area calculation we did before, but let \(\Delta x \to 0\) \[ \large \begin{align} \text{True Area} &= \lim_{\Delta x \to 0}R(f(x),\Delta x) \\ &= \int^b_af(x)dx \end{align} \]
We formally call this the integral of \(f(x)\) from \(a\) to \(b\) with respect to \(x\).
How do we calculate integrals?
Taking infinite sums is impossible by hand
Luckily, integrals and derivatives are related in a very useful way:
How do we calculate integrals?
Taking infinite sums is impossible by hand
Luckily, integrals and derivatives are related in a very useful way:
If we integrate a derivative, we should get the same function back as the original vice-versa:
\[ \begin{align} \frac{d}{dx}\left[\int f(x)dx\right]&=f(x) &\text{Differentiation is the inverse of integration} \end{align} \]
\[ \begin{align} \int f'(x)&=f(x)+C &\text{Integration is the inverse of differentiation} \end{align} \]
To find the integral of \(\int f(t) dt\) we need to find a function \(F(x)\) whose derivative is \(f(x)\).
Where did that \(C\) come from?
Example
✏️

Where did that \(C\) come from?
Example
Find \(\int 2x-4\).
To find \(\int 2x-4\) we need to find a function whose derivative is \(2x-4\). What could it be?
If we integrate, we’ll have \(\int 2x-4 = x^2-4x+C\).
There is no way of knowing what the \(C\) should be without additional information
\(C\) is the \(x\)-intercept and we would have we have to solve for it with an initial value problem.

What is integration useful for?
Solving differential equations
But also… integration can be tough
Before integrating ask yourself:

Notation
When you take an integral, the function in it can be in terms of any variable. This is just notation and it does not affect the result of the integration:
\[\int f(x) dx = \int f(t) dt = \int f(u) du.\]
Integration rules (1)
Sum and Difference Rules
✏️
Integration rules (1)
Sum and Difference Rules
The integral of a sum is equal to the sum of the integrals:
\[ \int[f(x)+g(x)]dx=\int f(x)dx+\int g(x)dx \]
The integral of the difference is equal to the difference of the integrals:
\[\int[f(x)-g(x)]dx=\int f(x)dx-\int g(x)dx \]
Integration rules (2)
Constant Rule
✏️
Integration rules (2)
Constant Rule
When a function is mulitplied by a constant, the constant can be taken out to multiply the integral:
\[ \int cf(x)dx=c\int f(x)dx \]
Integration rules (3)
Power Rule
✏️
Integration rules (3)
\(\int x^n dx\) is a function whose derivative is \(x^n\).
What could \(\int x^n dx\) be?
Power Rule
\[ \int x^ndx=\frac{x^{n+1}}{n+1}+C \text{, n}\ne -1 \]
Examples
✏️ Evaluate the following integrals.
Example solutions
Initial value problems
To find the \(C\) term in the integral, we need extra information
Often times that comes from being given an initial value
This means being given some value of the function, e.g. \(y(0)=a\) or \(y(12)=b\)
We use this information to solve for what \(C\) should be

Example
✏️ The marginal cost of producing \(x\) units of a product is:
\[ \frac{dC}{dx}=25-0.02x \]
Where \(C\) is the cost (in dollars), and \(x\) is the number of units produced. Given that producing 2 units of product costs $10, what is the complete cost equation?
Example
✏️ The marginal cost of producing \(x\) units of a product is:
\[ \frac{dC}{dx}=25-0.02x \]
Where \(C\) is the cost (in dollars), and \(x\) is the number of units produced. Given that producing 2 units of product costs $10, what is the complete cost equation?
We can integrate to find the original cost function \(C\):
\[C(x) = \int \frac{dC}{dx} dx = \int 25-0.02x.\]
Then: \[ \begin{align} \int 25-0.02x =&25x-\frac{.02x^2}{2}+D & \text{Solve with Power Rule}\\ 10&=25(2)-\frac{0.02(2)^2}{2}+D &\text{ Sub in $x=2$}\\ -39.96&=D\\ C(x)&=25x-\frac{0.2x^2}{2}-39.96 \end{align} \]
Let’s take a 5 minute break
image: Flaticon.com
Indefinite vs. definite integrals
✏️
Indefinite vs. definite integrals
\[ \int f(x)dx \]
This means there are no integration bounds and we need initial values to find integration constants.
\[\int_a^b f(x) dx.\]
To find the area under the curve along an interval \([a,b]\), evaluate the antiderivative at the endpoints and subtract them.
✏️ Example
\[ \begin{align} \int^b_axdx &= \frac{1}{2}x^2\Big|^b_a\\ &= \frac{1}{2}(b)^2-\frac{1}{2}(a)^2 \end{align} \]

Example
✏️ Evaluate the following integral.
\[\int^2_{-1}3x^2dx\]
Example
✏️ Evaluate the following integral.
\[\int^2_{-1}3x^2dx\]
We have that: \[ \begin{align} \int^2_{-1}3x^2dx &= x^3\Big|^2_{-1}\\ &=(2)^3-(-1)^3 \\ &=9 \end{align} \]
Area between two curves
Example
✏️ Find the area of the shaded region in the graph below.


Example
We need to compute
\[\int^1_0 \sqrt{x} - \int^1_0 x^2.\]
Compute each piece carfully:
\[ \small \begin{align} \int^1_0 \sqrt{x} &=\frac{2}{3}x^\frac{3}{2} \Big|_0^1\\ &= \frac{2}{3}(1)^{\frac{3}{2}}-\frac{2}{3}(0)^{\frac{3}{2}} \\ &= \frac{2}{3}. \end{align} \]
\[ \small \begin{align} \int^1_0 x^2 &=\frac{1}{3}x^3\Big|_0^1 \\ &= \frac{1}{3}(1)^3-\frac{1}{3}(0)^3 \\ &= \frac{1}{3}. \end{align} \]
Then subtract the upper from the lower:
\[ \small \frac{2}{3}-\frac{1}{3}=\frac{1}{3} \]
Exercises 1
\[y'=\frac{3}{x^2}, y(3)=2\]
\[g(t)=3t^5-2t^3+16t-7\]
Solution (A)
We have that
\[ \begin{aligned} \int \frac{3}{x^2}\,dx &= 3 \int x^{-2}\,dx \\[6pt] &= 3 \left( \frac{x^{-1}}{-1} \right) + C \\[6pt] &= -\frac{3}{x} + C \end{aligned} \]
With the initial value \(y(3)=2\) we obtain
\[ \begin{align} 2 &= y(3) \\ &= -\frac{3}{3} + C \\ &= -1 + C \\ 3 &= C. \end{align} \]
Therefore the solution is \(-\frac{3}{x} +3\).
Solution (B)
We have that
\[\begin{aligned} \int \bigl(3t^{5}-2t^{3}+16t-7\bigr)\,dt &= \int 3t^{5}\,dt - \int 2t^{3}\,dt + \int 16t\,dt - \int 7\,dt \\[6pt] &= 3\frac{t^{6}}{6} - 2\frac{t^{4}}{4} + 16\frac{t^{2}}{2} - 7t + C \\[6pt] &= \frac{t^{6}}{2} - \frac{t^{4}}{2} + 8t^{2} - 7t + C \end{aligned}\]
Solution (C)
We get that
\[\begin{aligned} \int_{2}^{4} \frac{1}{2}x\,dx &= \frac{1}{2}\int_{2}^{4} x\,dx \\[6pt] &= \frac{1}{2}\left[\frac{x^{2}}{2}\right]_{2}^{4} \\[6pt] &= \frac{1}{4}\bigl(4^{2}-2^{2}\bigr) \\[6pt] &= \frac{1}{4}(16-4) \\[6pt] &= 3 \end{aligned}\]
Exercises 2

Both models are valid for \(0 \le t \le 6\). What is the total additional carbon sequestered by the restored wetland over the 6-year period?
Write your answers as full sentences with units!
Solution (2)
✏️
Solution (2)
Given:
\[\frac{dC}{dt} = 2t + 20\]
Integrate:
\[\int dC = \int (2t + 20)\,dt\]
\[C(t) = t^{2} + 20t + D\]
Initial condition:
\[C(2)=30 \ \ \text{(since 1964 is 2 years after 1962)}\]
\[30 = 2^{2} + 20\cdot 2 + D\]
\[D = 30 - 44 = -14\]
Thus:
\[C(t) = t^{2} + 20t - 14\]
Evaluate at \(t=20\) (1982):
\[C(20) = 20^{2} + 20\cdot 20 - 14\]
\[= 400 + 400 - 14\]
\[= 786 \text{ ppm}\]
Solution (3)

Both models are valid for \(0 \le t \le 6\). What is the total additional carbon sequestered by the restored wetland over the 6-year period?
✏️
Solution (3)
✏️
Solution (3)
The toal carbon sequestered in each scenario is given by the area under the curve of the corresponding sequestration rate.
So the total additional carbon sequesterd is represented by the area between the two sequestration rate curves.
Integrate:
\[\int_0^6 \big[R(t) - B(t)\big]\, dt = \int_0^6 (6t - t^2)\, dt\]
\[= \left[3t^2 - \frac{t^3}{3}\right]_0^6 = (3(36) - \tfrac{216}{3}) - 0 = 108 - 72 = 36\]
Over the 6-year period, restoring the wetland sequesters an additional 36 tons of CO₂ compared to leaving it degraded.
What is a differential equation?
A differential equation is any equation which contains derivatives.
The goal of the differential equation is to find a function that satisfies the equation.
Example
The equation
\[ y' = y + x \]
is a differential equation in which we want to find a function \(y(x)\) such that its derivative equals the function plus \(x\).
✏️ 1. How would you check that \(y(x) = -x -1\) is a solution for this differential equation?
Differential equations: terms
\[\frac{df}{dt}=3.2-f(t)\]
Sometimes functions have more than one variable and we can take partial derivatives with respect to each variable.
\[\frac{\partial B}{\partial t}= \alpha B+0.31x-21.6\]
Order of an ODE
Order: The order of a differential equation is the highest order for any differential expression in the equation
Example:
\(\frac{df}{dt}=3.2-f(t)\) is a first order ordinary differential equation
Example:
\(\frac{\partial^3x}{\partial t^3}=2x-4.5\frac{\partial x}{\partial t}\) is a third order partial differential equation
Practice:
Use the terms from the previous slide to describe the following different equations:
\[2.9t^2 - \alpha B=\frac{dB}{dt}\]
\[\frac{\partial^2f }{\partial x^2}=1.4\times10^{-3}f(x)+5.2\]
\[\frac{dC}{dt}=4.1C-8.0\]
Differential equations help us understand changing environments
For some natural phenomena it can be easier to describe them in terms of derivatives than give an explicit function.
By specifying how something changes, we are describing a process or behavior over time.
Examples:


Example: Lotka-Volterra (predator-prey) equations
Prey: \(\frac{dV}{dt}=r V-\alpha VP\)
Predator: \(\frac{dP}{dt}=\beta VP - qP\)
Where:
What do the different pieces of the equation mean?
Interpretation of prey equation:
\[\frac{dV}{dt}=r V-\alpha VP\]
The pieces:
Interpretation of predator equation:
\[\frac{dP}{dt}=\beta VP - q P\]
The pieces:
Or, in pictures:
Adapted frrom Christopher Rackauckas, Scientific machine learning: interpretable neural networks that accurately extrapolate from small data. from the Stochastic Lifestyle blog.
Finding \(V(t)\) and \(P(t)\)?
Integration to find approximate solutions. Image: Modelica by Example
Some differential equations can be solved analytically:
✏️
Some differential equations can be solved analytically:
\[\frac{dy}{dx}=y\]
Separate variables and integrate both sides:
\[\int\frac{1}{y}dy=\int1dx\]
Yielding:
\(ln(y)=x\) or \(y=e^x\)
Solving differential equations numerically
Find approximate solutions to differential equations when finding an analytical solution would be really challenging (…which is pretty often).
Instead, computers can numerically approximate solutions by predicting nearby values based on the slope.
There are many methods for solving differential equations numerically. You’ll do it programatically later on.
What we covered today