# MIT OCW

## 18.02 Multivariable Calculus

### Line Integral

#### Vector Fields

##### Definition

A (2D) vector field is some vector $\mathbf{F}=M\hat\mathbf{i}+N\hat\mathbf{j}$, where $M,N$ depend on $(x,y)$.

##### Demonstration

Usually, we can draw a vector field with some samples (NOT ALL SAMPLES) in a Cartesian plane to demonstrate its direction.

#### Work

Work with a force $\mathbf{F}$ and a shift $\mathbf{s}$ is $W=\mathbf{F}\cdot \mathbf{s}$, and given a position vector $\mathbf{r}$, the distance in a small range becomes $\Delta\mathbf{r}$.
It only holds when $\mathbf{F}$ is constant and $\Delta\mathbf{r}$ has a fixed direction, so if the force $\mathbf{F}$ is a changing vector field and $\mathbf{r}$ is the position vector of some curve $C$, we can use line integral to solve it.
Basically, the idea is to calculate the sum of small work $W=\sum \mathbf{F}\cdot\Delta\mathbf{r}$, where $\Delta\mathbf{r}$ is set to each piece (with direction) of the curve $C$.
If we parameterize the curve $C$ in the form of $x=x(t),y=y(t)$ and by chain rule we can get $$W=\int_{C}\mathbf{F}\frac{\mathrm{d}\mathbf{r}}{\mathrm{d}t}\mathrm{d}t.$$

# MIT OCW

## 18.02 Multivariable Calculus

### Substitution of Variables

#### Introduction

e.g. Calculate the area of a ellipse $\left(\frac{x}{a}\right)^2+\left(\frac{y}{b}\right)^2=1$ with substitution $u=\frac{x}{a},v=\frac{y}{b}$.
Solution From the substitution, we can find that $$\mathrm{d}x=a\mathrm{d}u,\mathrm{d}y=b\mathrm{d}v,$$
so we can convert it
\begin{aligned}\iint_R\mathrm{d}x\mathrm{dy}&=ab\iint_{R'}\mathrm{d}u\mathrm{d}v\\&=ab\iint_{u^2+v^2\leq 1}\mathrm{d}u\mathrm{d}v\\&=\pi ab.\end{aligned}
e.g. Find the scaling factor between $\mathrm{d}x\mathrm{d}y$ and $\mathrm{d}u\mathrm{d}v$ with $u=3x-2y,v=x+y$.
Solution We can write such transformation in matrix form $$\begin{bmatrix}u\\v\end{bmatrix}=\begin{bmatrix}3&-2\\1&1\end{bmatrix}\begin{bmatrix}x\\y\end{bmatrix}.$$
And note the core here is the matrix $\begin{bmatrix}3&-2\\1&1\end{bmatrix}$, it represents the transformation and its determinant is just the scaling factor but with a sign. So the scaling factor here is $\begin{vmatrix}3&-2\\1&1\end{vmatrix}=5$.

#### Jacobian Matrix

The total differential of a transform $u=u(x,y),v=v(x,y)$ is \begin{aligned}\mathrm{d}u&=u_{x}\mathrm{d}x+u_{y}\mathrm{d}y\\\mathrm{d}v&=v_{x}\mathrm{d}x+u_{v}\mathrm{d}y,\end{aligned}
and write it in matrix form $$\begin{bmatrix}\mathrm{d}u\\\mathrm{d}v\end{bmatrix}=\begin{bmatrix}u_x&u_y\\v_x&v_y\end{bmatrix}\begin{bmatrix}\mathrm{d}x\\\mathrm{d}y\end{bmatrix}.$$
Here, the matrix containing several partial derivatives are called Jacobian matrix, and usually write it as $$\mathbf{J}=\frac{\partial(u,v)}{\partial(x,y)}=\begin{bmatrix}u_x&u_y\\v_x&v_y\end{bmatrix}.$$
And its determinant $|\mathbf{J}|$ is the scaling factor.

#### Validation for Polar-Cartesian Conversion

The transformation here is $x=r\cos(\theta),y=r\sin(\theta)$, the Jacobian determinant is $$\left|\frac{\partial(x,y)}{\partial(r,\theta)}\right|=\begin{vmatrix}x_r&x_\theta\\y_r&y_\theta\end{vmatrix}=\begin{vmatrix}\cos(\theta)&-r\sin(\theta)\\\sin(\theta)&r\cos(\theta)\end{vmatrix}=r,$$
so we have $$\mathrm{d}x\mathrm{d}y=r\mathrm{d}r\mathrm{d}\theta.$$

#### Examples

e.g. Compute $\int_0^1\int_0^1x^2y\mathrm{d}x\mathrm{d}y$ with substitution $u=x,v=xy$.
Solution The Jacobian determinant is $$\left|\frac{\partial(u,v)}{\partial(x,y)}\right|=\begin{vmatrix}u_x&u_y\\v_x&v_y\end{vmatrix}=\begin{vmatrix}1&0\\y&x\end{vmatrix}=x,$$
therefore we have $$\mathrm{d}x\mathrm{d}y=\frac1x\mathrm{d}u\mathrm{d}v.$$
Another thing to consider is the new region, according to the substitution we have $v=y\cdot u$.
In an $uv$ plane, $v=y\cdot u, u\in[0,1]$ is a segment through the origin, and $y$ becomes its slope, and it varies since $y\in[0,1]$, so it becomes a triangular region.
Here's the comparison of two regions.

So the integral becomes \begin{aligned}\int_0^1\int_0^1x^2y\mathrm{d}x\mathrm{d}y&=\iint_{R'}x^2y\frac1x\mathrm{d}u\mathrm{d}v\\&=\iint_{R'}v\mathrm{d}v\mathrm{d}u\\&=\int_0^1\int_0^{u}v\mathrm{d}v\mathrm{d}u\\&=\int_0^1\left[\frac12v^2\right]^u_0\mathrm{d}u\\&=\int_0^1\frac12u^2\mathrm{d}u\\&=\left[\frac16u^3\right]^1_0\\&=\frac16.\end{aligned}
Since the original integral is not difficult to compute, so the answer can be checked easily.

\begin{aligned}\iint_{R_0}x\mathrm{d}A&=S_{R_0}x_0\\\iint_{R_1}x\mathrm{d}A&=S_{R_1}x_1\\\iint_{R_2}x\mathrm{d}A&=S_{R_2}x_2,\end{aligned}

# MIT OCW

## 18.02 Multivariable Calculus

### Double Integrals

#### Geometry and Definition

Like a regular integral, the double integral $\iint_{R}f(x,y)\mathrm{d}A$ represents the volume under the surface on the region $R$ where $\mathrm{d}A$ is a small piece of the region.
So we can have a summation like the following $$\iint_{R}f(x,y)\mathrm{d}A=\lim_{\Delta A_i\to 0}\sum f(x,y)\Delta A_i.$$

#### Convertion to Double "Integral"

In pratice, we will not calculate double integral by definition, and now we try to convert it to two single integrals.
The idea is to divide the volume into several slices along $x$ direction, and the volume of these slices are changing with $x$, so the slice determined by $x$ should be $$S(x)=\int_{y_{\min}(x)}^{y_{\max}(x)}f(x,y)\mathrm{d}y$$, and now we activate $x$, so the double integral becomes \begin{aligned}\iint_{R}f(x,y)\mathrm{d}A&=\int_{x_{\min}}^{x_{\max}}S(x)\mathrm{d}x\\&=\int_{x_{\min}}^{x_{\max}}\int_{y_{\min}(x)}^{y_{\max}(x)}f(x,y)\mathrm{d}y\mathrm{d}x.\end{aligned}
e.g. Calculate the integral of $z=1-x^2-y^2$ on the region $0\leq x\leq 1,0\leq y\leq 1$.
Solution \begin{aligned}\iint_{R}1-x^2-y^2\mathrm{d}y\mathrm{d}x&=\int_0^1\int_0^1 1-x^2-y^2\mathrm{d}y\mathrm{d}x\\&=\int_0^1\left[y-x^2y-\frac13y^3\right]^1_0\mathrm{d}x\\&=\int_0^1\frac23-x^2\mathrm{d}x\\&=\left[\frac23x-\frac13x^3\right]^1_0\\&=\frac13.\end{aligned}
e.g. Calculate the volume of $z=1-x^2-y^2$ above the $xy$ plane.
Solution Here the region is actually $x^2+y^2\leq 1$, and according to symmetric graph, we only need to calculate the quarter of the region and multiply $4$.
\begin{aligned}\iint_{R}1-x^2-y^2\mathrm{d}y\mathrm{d}x&=4\int_0^1\int_0^{\sqrt{1-x^2}} 1-x^2-y^2\mathrm{d}y\mathrm{d}x\\&=4\int_0^1\left[y-x^2y-\frac13y^3\right]^{\sqrt{1-x^2}}_0\mathrm{d}x\\&=4\int_0^1(1-x^2)\sqrt{1-x^2}-\frac13(1-x^2)\sqrt{1-x^2}\mathrm{d}x\\&=4\int_0^1\frac23(1-x^2)\sqrt{1-x^2}\mathrm{d}x\\(x=\sin(\theta))&=\frac83\int_{\frac\pi2}^0\cos^4(\theta)\mathrm{d}\theta\\&=\frac\pi2.\end{aligned}

#### Swap Orders

Last time we converted the volume into slices along $x$ direction, why not the other direction? Actually, it's feasible. And in theory, these two directions both work. The form along the other direction can be written as \begin{aligned}\iint_{R}f(x,y)\mathrm{d}A&=\int_{y_{\min}}^{y_{\max}}T(x)\mathrm{d}x\\&=\int_{y_{\min}}^{y_{\max}}\int_{x_{\min}(y)}^{x_{\max}(y)}f(x,y)\mathrm{d}x\mathrm{d}y.\end{aligned}
e.g. Evaluate $\int_0^1\int_{x}^{\sqrt{x}}\frac{e^y}{y}\mathrm{d}y\mathrm{d}x$.
Solution The region to be integrated is like the following.

Here the expression is to make $y$ dependent on $x$, and now we swap the order and make $x$ dependent on $y$ that is \begin{aligned}\int_0^1\int_{x}^{\sqrt{x}}\frac{e^y}{y}\mathrm{d}y\mathrm{d}x&=\int_0^1\int_{y^2}^{y}\frac{e^y}{y}\mathrm{d}x\mathrm{d}y\\&=\int_0^1\left[\frac{e^y}{y}x\right]^{y}_{y^2}\mathrm{d}y\\&=\int_0^1 e^y(1-y)\mathrm{d}y\\&=\left[2e^y-ye^y\right]^1_0\\&=e-2.\end{aligned}

#### Polar Coordinates

In fact, sometimes it becomes easier when dealing the same problem in polar coordinates. The idea is to express $\mathrm{d}A$ in polar coordinates like the following picture.

From the picture, it can be seen that the small piece of region becomes $$\mathrm{d}A=r\mathrm{d}r\mathrm{d}\theta.$$
e.g. Calculate the volume of $z=1-x^2-y^2$ above the $xy$ plane.
Solution The expression can be converted to $z=1-r^2$ and the region becomes $R:r\leq 1$, so the integral becomes \begin{aligned}\iint_{R}1-r^2\mathrm{d}A&=\int_0^{2\pi}\int_0^1(1-r^2)r\mathrm{d}r\mathrm{d}\theta\\&=\int_0^{2\pi}\left[\frac{r^2}{2}-\frac{r^4}{4}\right]^1_0\mathrm{d}\theta\\&=\int_0^{2\pi}\frac14\mathrm{d}\theta\\&=\left[\frac14\theta\right]^{2\pi}_0\\&=\frac\pi2.\end{aligned}

#### Application

• Get the area of a region on the plane
Given a region $R$ on the plane, we'd like to get its area. It's equivalent to evaluate $\iint_{R}\mathrm{d}A$, where $\mathrm{d}A$ depends on the type.
Variant Get the total mass of a flat object with the density $\delta$ function: $\iint_{r}\delta\mathrm{d}A$.
• Average
Like the single integral, an average of the function $f$ on a region $R$ can be defined as $$\bar{f}=\frac1{S_R}\iint_{R}f\mathrm{d}A,$$ where $S_R$ is the area of the region $R$.
Variant Weighted average: $$\tilde{f}=\frac1{M_R}\iint_{R}f\cdot\delta\mathrm{d}A,$$ where $M_R=\iint_{R}\delta\mathrm{d}A$.
Variant Center of mass of a flat object (in Cartesian plane): $$\bar{x}=\frac1{M_R}\iint_{R}x\cdot\delta\mathrm{d}A,\bar{y}=\frac1{M_R}\iint_{R}y\cdot\delta\mathrm{d}A,$$ where $M_R=\iint_{R}\delta\mathrm{d}A$.
• Moment of inertia
Given a point-like mass, the moment of inertia about some axis is defined $$I=mr^2,$$ where $m$ is the mass and $r$ is the distance to the axis.
Analogy The kinetic energy is $E_k=\frac12mv^2$, when we are push the mass, the kinetic energy will increase. So the larger $m$ is, the more difficult it will be to change the motion of the object, namely $v$. Similarly when the mass is rotating with angular velocity $\omega$, the velocity becomes $v=\omega\cdot r$, where $r$ is the distance to the axis and we get $E_k=\frac12mr^2\omega^2$, so $I=mr^2$ is also an indicator of the difficulty changing the rotation, namely $\omega$.

For a flat object, the moment of inertia becomes $$I=\iint_{R}r^2\cdot\delta\mathrm{d}A$$.
e.g. Compare the moment of inertia of a disk with radius $a$ about the center and about the point on the edge.
Solution When it's about the center, it looks like the following.

Assume $\delta=1$, so just integrate it with polar way
\begin{aligned}I_0&=\iint_{R}r^2\mathrm{d}A\\&=\int_0^{2\pi}\int_0^a r^3\mathrm{d}r\mathrm{d}\theta\\&=\frac\pi2a^4.\end{aligned}
When it's about the edge point, we can change the origin.

And do the same work
\begin{aligned}I_1&=\iint_{R}r^2\mathrm{d}A\\&=\int_0^{2\pi}\int_0^{2a\cos(\theta)} r^3\mathrm{d}r\mathrm{d}\theta\\&=\frac32\pi a^4.\end{aligned}
So $I_1=3I_0$.
Extension Parallel axis theorem

# MIT OCW

## 18.02 Multivariable Calculus

### Non-independent Variables

#### Review of Implicit Differentiation

Like the implicit differentiation in single variable calculus, there are times we cannot solve a variable as a function dependent on others (especially the powers are larger than $2$).
e.g. Given the implicit function $y^3+xy+5=0$, what is $\frac{\mathrm{d}y}{\mathrm{d}x}$?
Solution Apply derivatives at both sides we get $$3y^2\cdot\frac{\mathrm{d}y}{\mathrm{d}x}+\left(1\cdot y+x\cdot\frac{\mathrm{d}y}{\mathrm{d}x}\right)=0,$$ and the answer is $$\frac{\mathrm{d}y}{\mathrm{d}x}=-\frac{y}{3y^2+x}.$$

#### Multivariable Function

When there are not only two variables in a formula, and it's not easy to solve a variable as a function dependent on others, is there similar tricks? The answer is to use the total differential.
e.g. Given an equation $x^3+yz+z^3=8$, find $\frac{\partial z}{\partial x}$ and $\frac{\partial z}{\partial y}$ at point $(2,3,1)$.
Solution Consider a function $f(x,y,z)=x^2+yz+z^3=8$ and its total differential $$\mathrm{d}f=2x\mathrm{d}x+z\mathrm{d}y+(y+3z^2)\mathrm{d}z,$$ since $f(x,y,z)=8$ so $$\mathrm{d}f=2x\mathrm{d}x+z\mathrm{d}y+(y+3z^2)\mathrm{d}z=0.$$
And let's think about the actual meaning of partial derivatives $\frac{\partial z}{\partial x}$ and $\frac{\partial z}{\partial y}$, it keeps a variable active and others constant, so to get $\frac{\partial z}{\partial x}$, we can set $\mathrm{d}y=0$, since $y$ is considered constant and get $$3x^2\mathrm{d}x+(y+3z^2)\mathrm{d}z=0,$$ so plug the point into it and we have $$4\mathrm{d}x+6\mathrm{d}z=0,$$ so $$\frac{\partial z}{\partial x}=-\frac23,$$ and similarly $$\frac{\partial z}{\partial y}=-\frac16.$$

##### Relationship with Implicit Differentiation

When I carefully reviewed the equation above, I was ignited by the meaning of the partial derivative and find a bridge between the method and implicit differentiation.
When we are computing $\frac{\partial z}{\partial x}$, we only care about the variation of $x$ and $z$, so we can treat anything else as constants and the problem is again solved by implicit differentiation that is $$\frac{\mathrm{d}}{\mathrm{d}x}(x^2+yz+z^3)=\frac{\mathrm{d}}{\mathrm{d}x}8,$$ and here $y$ is a number not a variable, we can get $$2x+yz'+3z^2z'=0,$$ so $$z'=-\frac{2x}{3z^2+y},$$ namely $$\frac{\partial z}{\partial x}=-\frac{2x}{3z^2+y}.$$

#### Notation Traps

Consider a function $f(x,y)=x+y$ and set $x=u,y=u+v$, so $f(u,v)=2u+v$. Compute $\frac{\partial f}{\partial x}=1,\frac{\partial f}{\partial u}=2$, but $x=u$, what is the contradiction?
Actually it's a trap from notation, because when we write $\frac{\partial f}{\partial x}$, we are assuming that $x$ is active and $y$ is constant. On the other hand, when we write $\frac{\partial f}{\partial u}$, we are assuming that $u$ is active and $v$ is constant. The common variation of $x=u$ is the same, but what we keep constant is different in these two notations. So here are another notation to clearify what we keep constant: $\left(\frac{\partial f}{\partial x}\right)_y$ indicates that $x$ is active and $y$ is constant.

#### Application

e.g. Given a right triangle with area $A$, like the following:

find $\frac{\partial A}{\partial \theta}$.
Solution We can write the expression $$A=\frac12ab\sin(\theta),$$ the key point here is that we have a constraint: a right triangle. So here exist the notation traps.

• Treat $a,b$ are independent variables
Then the answer is just the partial derivative which keeps both $a$ and $b$ constant: $\left(\frac{\partial A}{\partial \theta}\right)_{a,b}=\frac12ab\cos(\theta).$
• Treat $a,b$ are non-independent
The constraint here is exactly $a=b\cos(\theta)$, and there are another two ways: either $a$ or $b$ is constant.
• Treat $a$ constant
Method 1 (Total Differential) Now we compute the differential \begin{aligned}\mathrm{d}A&=\frac{\partial A}{\partial a}\mathrm{d}a+\frac{\partial A}{\partial b}\mathrm{d}b+\frac{\partial A}{\partial \theta}\mathrm{d}\theta\\&=\frac12b\sin(\theta)\mathrm{d}a+\frac12a\sin(\theta)\mathrm{d}b+\frac12ab\cos(\theta)\mathrm{d}\theta,\end{aligned} and another differential derived from the constraint \begin{aligned}\mathrm{d}a&=\frac{\partial a}{\partial b}\mathrm{d}b+\frac{\partial a}{\partial \theta}\mathrm{d}\theta\\&=\cos(\theta)\mathrm{d}b-b\sin(\theta)\mathrm{d}\theta.\end{aligned}
Here we're keeping $a$ constant, so $\mathrm{d}a=0$, and get the differential relationship between $b$ and $\theta$ that is $$\cos(\theta)\mathrm{d}b-b\sin(\theta)\mathrm{d}\theta=0,$$ namely $$\mathrm{d}b=b\tan(\theta)\mathrm{d}\theta.$$
Substitute $\mathrm{d}b$ and $\mathrm{d}a=0$ into the previous differential, we can get $$\mathrm{d}A=\frac12ab\sin(\theta)\tan(\theta)\mathrm{d}\theta+\frac12ab\cos(\theta)\mathrm{d}\theta,$$
so we have $$\mathrm{d}A=\frac12ab\left(\sin(\theta)\tan(\theta)+\cos(\theta)\right)\mathrm{d}\theta,$$ therefore $$\left(\frac{\partial A}{\partial \theta}\right)_{a}=\frac12ab\sec(\theta).$$
Method 2 (Chain Rule) We can have \begin{aligned}\left(\frac{\partial A}{\partial \theta}\right)_{a}&=\left(\frac{\partial A}{\partial \theta}\right)_{a}\left(\frac{\partial \theta}{\partial \theta}\right)_{a}+\left(\frac{\partial A}{\partial a}\right)_{a}\left(\frac{\partial a}{\partial \theta}\right)_{a}+\left(\frac{\partial A}{\partial b}\right)_{a}\left(\frac{\partial b}{\partial \theta}\right)_{a}\\&=\frac{\partial A}{\partial \theta}+\frac{\partial A}{\partial b}\frac{\partial b}{\partial \theta}=\frac12ab\cos(\theta)+\left(\frac12a\sin(\theta)\right)\cdot\left(a\tan(\theta)\sec(\theta)\right)\\&=\frac12ab\cos(\theta)+\frac12a\sec(\theta)\cdot\sin(\theta)\tan(\theta)\\&=\frac12ab\sec(\theta).\end{aligned}
• Treat $b$ constant
Omitted.

### Partial Differential Equations

Phenomenon in reality is generally governed by partial differential equations, like heat equation in 3D space $$\frac {\partial u}{\partial t}=\alpha \left({\frac {\partial ^{2}u}{\partial x^{2}}}+{\frac {\partial ^{2}u}{\partial y^{2}}}+{\frac {\partial ^{2}u}{\partial z^{2}}}\right).$$