# Intro
Now that we've finished the Gradient, it's time to move on to the next logical step - the multidimensional integral! 
And like everything multidimensional, there are an innumerable number of cheats and hack 'theorems' we can use to get around constraints. A lot of this ain't gonna make sense on the first read - so make sure to hunker down and try your best anyways! 
*Full intellectual credit goes to MecMath for these example problems! For more exercises and the like, get the book! These ones have just been completed as a proof of concept. Notation-wise, aspects of the equations are also borrowed from MecMath, though I've elected to make some improvements wherever possible.*
# Multiple Integrals - Notation 
When it comes to some objects, finding the surface areas can be very difficult! As a result, we can use an **area integral** to solve for these functions. Take the irregular curve: 
![[3D Region.png]]
There's no way we'll be able to find the area enclosed by this, right? Well, there's a way to do that, as you'll see now! If we take horizontal slices across the region, we'll get the integrale: 
$A = \int \int_{R}  f(x,y)\, dx  \, dy$
Which is the equivalent to:
$\int \left[ \int f(x,y) \, dx  \right] \, dy $
And if you're feeling up to it, you can write the $dx \ dy$ term at the end as $dA$: 
$A = \int \int_{R}  f(x,y)\, dA$
Make sure to get those inference skills before anything else! Parse the internal integral before anything! If we take vertical slices across the region:
$A = \int \int_{R}  f(x,y)\, dx  \, dy$
The order of these doesn't matter! For volume integrals, we write: 
$V = \int \int \int_{S} \, dx  \, dy  \, dz $
Where $S$ refers to the solid we're finding the volume of =). 
**TIP:** Remember to order the integrals in the way that makes it most convenient for you to solve (i.e put the one with the most variables first.)
But everyone's different, so I won't press you for longer. Have fun! 
>[!Example]- Example Problem (MecMath 4.1 Exercise 5)
>Evaluate:
>$\int_{0}^1 \int_{1}^2 (1-y)x^2 \, dx  \, dy $
>
>**Solution:**
>Evaluate the first integral: 
>$\int_{0}^1  \left[ \frac{x^3}{3} - \frac{yx^3}{3} \right]^2_{1}\, dy $
>$\int _{0}^1 \frac{7}{3} - \frac{7y}{3}\, dy $
>Then solve this integral to get: 
>$\int _{0}^1 \frac{7}{3} - \frac{7y}{3}\, dy = \left[ \frac{7y}{3} - \frac{7y^2}{6} \right]_{0}^1$
>$\int_{0}^1 \int_{1}^2 (1-y)x^2 \, dx  \, dy = \frac{7}{6}$
>Finished! Easy, huh?
# Line Integrals
*For this one, let's use an example!*
Say we got a particle, with a force $F$ acting on it. This force is variable, and is defined using the function $f(x)$. Now, imagine that this particle travels along a curve, defined with the variable $C$ as shown: 
%%the deets. hehe.%%
Now finding that 'distance travelled' isn't so intuitive, huh? As you'd expect, we'll use the [[Calculus Basics (Maths)#BONUS The Length Integral|arclength integral]] to find an expression for that: 
$ds = \sqrt{ dx^2 + dy^2 }$
We'll sum these small segments over the curve to get our total distance, which gives us: 
$A = \int_{a}^b f(x,y) \, ds $
We can make this easier for us by realising that: 
$ds = \sqrt{ (\frac{dx}{dt})^2 + (\frac{dy}{dt}^2)} \ dt$
Where both of the latter terms are partial derivatives! Ultimately, that lets us simplify our expression in terms of $dt$, $x$, and $y$, and both of the latter variables can also be expressed as functions of $t$: 
$A = \int_{a}^b f(x(t),y(t)) \sqrt{ x'(t)^2 + y'(t)^2 } \, dt $
It is often the case that questions with line integrals have you parametrise the multivariable function with respect to time. In the event that the enclosing path is a circle with radius $r$, these functions will follow the general form: 
$x(t) = r \cos t$$y(t) = r \sin t$Such as the example I'll now show you! 
>[!Example]- Example Problem: The Quintessential Cylinder (MecMath)
>
>Prove that the volume of a cylinder is $2 \pi r h$ with a line integral! 
>
>![[cylinder.png]]
>
>**Solution:**
>We'll be integrating within the bounds of the cylinder, or the height. In the $xy$ plane, the cylinder will appear to be a circle, so the enclosing curve is $f(x,y)$ is $x^2 + y^2 = r^2$, and is bounded from $0$ to $2 \pi$. Therefore: 
>$x'(t) = -r\sin t$
>$y'(t) = r\cos t$
>That's the plane we'll go through, but we're left with an unknown: the height of the cylinder itself! You can think of it as the circle being 'projected' along this height, which, for example: 
>$V = \int_{C} f(x,y) \, ds = \int_{0}^{2\pi} \int_{0}^h (r) \, dh \, dt $
>Where we integrate an infinite number of these circles along the height $r$, which is essentially what a volume is! So: 
>$V = hr \int_{0}^{2\pi} \int (1) \, dt $
>$V = 2\pi rh$ 
>Nice! And that's a crash course to why you can replace $f(x,y)$ with $h$, even when you take the parametrised versions for the derivatives. I hope that cleared out some confusion for you! 
## Applications of the Line Integral: Vector Fields and Polygonal Paths
We can also use the line integral to integrate through vector fields, such as that of gravitational potential! 
Say you have a vector field defined with the arbitrary function: 
$f(x,y) = P(x,y) \imath + Q(x,y) \jmath$
We can let the position vector to an arbitrary point within this field be represented by: 
$r(t) = x(t) \imath + y(t) \jmath$
This means that the line integral along a curve within this vector field is: 
$\int_{C}  \, ds  = \int P(x,y) \, dx + \int Q(x,y) \, dy$
$\int_{C}  \, ds = \int P(x(t),y(t))x'(t) \, dt + \int Q(x(t),y(t))y'(t) \, dt$
Let's take a look at the expression for $r(t)$. Is $r'(t)$ obvious yet? 
That's right! It's $x'(t) \imath + y'(t) \jmath$. This means that the integral is just the dot product between the position vector $r(t)$ and the function itself, or: 
$\int_{C}  \, ds = \int f \cdot{} \, dr $
Finish. How very nice of it! 
>[!Example]- Example Problem - Revisiting the Cylinder (MecMath)
>Use a line integral to find the lateral surface area of the part of the cylinder $x^2+ y^2$= 4 below the plane $x+2y+ z = 6$ and above the $xy$-plane.
>![[IT'S A CYLINDER STUCK IN A PLANE.png]]
>**Solution**:
>Some among you may have noticed that the line integral approach is needlessly complicated when it comes to finding the volume of the cylinder. Now, time to show why it's really useful! 
>
>From the above equation, we get a radius of $2$ for the cylinder's base. This means:
>$\int_{C} f(x,y) \, ds $
>The height is equivalent to the $z$ axis. We can use the plane equation to find an expression for this height, as shown: 
>$z = 6- x - 2y$
>$z = 6 - 2\cos t - 4\sin t$
>This serves as the upper bound for our integral (as we're finding the volume BELOW the plane!), which is: 
>$V = \pi \int_{0}^2\pi \int_{0}^{6 - 2\cos t - 4\sin t}  \, dz  \, dt $
>$V = \pi \int_{0}^2\pi [6 - 2 \cos t - 4 \sin t]\, dt $
>Now all we have to do is plug in the numbers to get: 
>$V = \pi[6t - 2\sin t + 4\cos t]_{0}^2\pi$
>$V = 12\pi + 4 - 4$
>$V = 12\pi$
>Nice! 
>That would've been more difficult with the slices, don't you think? 
## Negative Line Integrals
Now, it's probably obvious to you that: 
$\int_{C} f(x,y) \, ds = \int_{-C} f(x,y)  \, ds  $
Where if you traverse a curve in two different directions, the integral of the function along it will still be the same! An integral's a scalar, is it? 
Wait. But how about when the function's a vector field? If the line integral has a direction, then we'll get: 
$\int_{C} f(x,y) \, ds = -\int_{-C} f(x,y)  \, ds $
Crazy, huh? 
>[!Success]- Proving the Identity
>In a vector field, $x = x(t)$ and $y = y(t)$, as per the $f(x,y) = P(x,y)\imath + Q(x,y) \jmath$ convention for a vector field. In this case, $t$ is the distance across the curve $C$ we travel along to integrate over the vector field. Therefore, when we traverse a curve in the other direction, we're essentially taking the *negative* of the parameter $t$, starting at the point $a + b$, which are the two (invisible!) general form limits of the integral. Therefore, the new parameter for the curve is $a+b - t$, as shown: 
>$\int_{-C} f(x,y)  \, ds = \int_{C} f(x(a+b-t), y(a+b-t)) \, ds $
>$\int_{-C} f(x(a+b-t), y(a+b-t)) \, ds = \int P(x(a+b-t), y(a+b-t)) \, \frac{dx(a+b-t)}{dt} dt + \int Q(x(a+b-t), y(a+b-t)) \, \frac{dy(a+b-t)}{dt} dt$
>A Let's simplify this by calling $a+b-t$ a variable, say, $w$: 
>$\int_{-C} f(x, y) \, ds = \int P(x(w), y(w)) x'(w) \,dw + \int Q(x(w), y(w)) x'(w) \,dw$
>As $\frac{dw}{dt} = -1$, we can write:
>$\int_{-C} f(x, y) \, ds = -\int P(x(w), y(w)) \, dt - \int Q(x(w), y(w)) \,dt $
>Where it becomes obvious (haha, I used it! Tell me if it isn't though.): 
>$\int_{C} f(x,y) \, ds =  -\int_{-C} f(x,y) \, ds$
## Parametrising Line Integrals
In addition, the value of the integral will actually stay the same even with different parametrisations! To prove this, let's take a function $f(x,y)$ with parametrisations in the variable $t$. If we want to take a different parameter, say, the variable $u$, we can define a function $a(u)$, defined as $t = a(u)$, as our parameter. For simplicity's sake, we can reduce this down into the $\hat{x}(u)$ and $\hat{y}(u)$ functions, which we assign the value: 
$x(t) = \hat{x}(u) = x(a(u))$
Now, we can rewrite our generic integral in terms of $u$ (where I show only the $x$ coordinate, because I'm too lazy): 
$\int_{a}^b P(x(t), y(t)) x'(t) \, dt = \int_{c}^d P(x(a(u)), y(a(u))) \hat{x}'(u) \, dt $
To find $\hat{x}'(u)$, we can use the chain rule, where: 
$\hat{x}'u = \frac{dx}{dt} \frac{dt}{du}$
And $\frac{dt}{du}$ can be found by using the function $a$: 
$\frac{dt}{du} = a'(u)$
So the integral becomes: 
$\int_{c}^d P(x(a(u)), y(a(u))) \hat{x}'(u) \, du = \int_{c}^d P(x(a(u)), y(a(u))) x'(t) a'(u) \, dt $
If we do some rearranging of the above equations (again!), we can get a value for $dt$, which is $dt = a'(u) \,du$. Therefore, the expression becomes: 
$\int_{a}^b P(x(t), y(t)) x'(t) \, dt = \int_{c}^d P(x(a(u)), y(a(u))) x'(t) \, du$
Which simplify to the same things (and are therefore equal!!!). 
## Closed Curves and Potential
Now, let's move on to closed curves - essentially, curves which loop back in, then close on themselves. See: 
![[closedcurveoops.png]]
					*A small sacrifice to learn vector calculus!*
That notwithstanding, when we take the line integral over a closed curve, we'll get: 
$\int_C f(x,y) \, ds = 0$
Or, if $f(x,y)$ is a vector field: 
$\int \int f(x,y) \cdot dr = 0 $
>[!Success]- Proving this!
>![[ellipsepath.png]]
>Say we want to find the area under the entire ellipse. Since the curve is closed, the 'limits' are technically at $0, 2\pi$, which offers a result of 0. Easy, huh? 
>
>Alright, alright, I'm NOT going to leave you to dry like that. To perform this line integral, we'll be taking the limits as the points $P1$ and $P2$. To do this, we'll have to take two curves, where if we take the curve $C1$ as our first, which travels over the northern half of the ellipse, we will have to take the negative of the $C2$ curve, which travels from $P1$ to $P2$ through the southern half. We can therefore write this as: 
>
>$0 = \int_{C_{1}} f(x,y) \cdot dr - \int_{C_{2}} \cdot dr $
>
>But let's take a moment to think about this. This simple equation means that, for ANY points on this ellipse, no matter how close or far they are, $\int_{C_{1}} f(x,y) \cdot dr = \int_{C_{2}} \cdot dr$! This means you could also reverse this and still get the same answer, meaning that the line integral is also **path-independent.** 
>
>Perfect!
Finally, let's move on to something that, in hindsight, will be 'obvious'! 
No, I'm not joking. Remember how the integral's an anti-derivative? Well... the line integral is actually the 'anti-gradient', in a sense, where we integrate over the two dimensions of a gradient. So if we take the output of the line integral as a function $F$, we can actually rewrite our integral as: 
$\int_C f(x,y) \cdot dr= \int_{C} \nabla F \cdot dr $
This will mean that, if the limits of the line integral are $a$ and $b$, the integral will evaluate to: 
$\int_{a}^b  f(x,y) \cdot \, dr = F(b) - F(a) $
Which also allows us an easier way of evaluating these integrals in the case that $f(x,y)$ is a vector field, where we can just work backwards! Remember that the dot product between $f(x,y)$ and $dr$ will just give $f(x,y) = P(x,y) \imath \ dx + Q(x,y) \jmath \ dy$, which we can use to find a general expression for the function $F$. Here's an example to help you out! 
Can you tell what the answer will be if the curve is closed? 
>[!Tip] Closed Curve Tips
>Small tip, but you can actually tell the answer of a line integral just from its parametrisations (usually given!). 
>
>If the curve goes from $0$ to $2\pi$, and is parametrised using the trigonometric functions, this usually refers to it being circular/elliptical in nature and has us take the entire (closed!) curve. So remember - look at the parameters first, and before you get your hopes up, look at the limits next! 
# Green's Theorem
If, however, the closed curve doesn't have a potential and is *smooth* (aka, if you split the big curve into smaller curves, the derivatives of the functions would still be continuous), we can use **Green's Theorem** to find the area enclosed within these lines. This theorem is given by: 
$\oint f \cdot dr = \int \int \left( \frac{\delta Q}{\delta x}  - \frac{\delta P}{\delta y}\right)  \, dA  $
Assuming that the curve follows the general form $f(x,y) = P(x,y)\, dx + Q(x,y)\, dy$. 
>[!Success]- Proving Green's Theorem
>
>First, let's take a look at what the expanded integral is. This'll help us get an idea of what we'll have to do: 
>$\oint f \cdot dr = \oint P(x,y) \, dx + \oint Q(x,y) \, dy$
>
>Let's zero in onto the $P(x,y)$ part for now. If we take some region $R$ and split it into two, taking points $x_1$ and $x_2$, the leftmost and rightmost parts of the curve, as the vertices, we can get the following diagram: 
>
>![[greensshape.png]]
>
>The curves $C_1$ and $C_2$ will pass through the $y$ coordinates $y_1$ and $y_2$, which are the minimum and maximum $y$ values on the curve respectively (not to scale!). So the total integral $\oint P(x,y) \, dx$ over the curve can be rewritten using the logical conclusion that $C = C_1 + C_2$: 
>
>$\oint P(x,y) \, dx = \int_{C_{1}} P(x,y) \, dx + \int_{C_{2}} P(x,y) \, dx $
>
>Now, we can substitute with the limits of each curve! The limit will go from start to finish of the line, so: 
>
>$\oint P(x,y) \, dx = \int_{x_{1}}^{x_{2}} P(x,y) \, dx + \int_{x_{2}}^{x_{1}} P(x,y) \, dx $
>
>So the last integral is the complete opposite of the original integral. This gives us: 
>
>$\oint P(x,y) \, dx =- \int_{x_{1}}^{x_{2}} P(x,y_{1}) - P(x,y_{2}) \, dx $ 
>
>Where we can now begin to substitute our values for $y$ into our equation! We can rewrite this internal bit as: 
>
>$\oint P(x,y) \, dx = -\int_{x_{1}}^{x_{2}} [P(x,y)]_{y_{1}}^{y_{2}} \, dx $
>
>The inside of which looks suspiciously like an integral, doesn't it? We can 'break' this integral open by partially differentiating the expression with respect to $y$, as shown: 
>$ -\int_{x_{1}}^{x_{2}} [P(x,y)]_{y_{1}}^{y_{2}} \, dx = -\int_{x_{1}}^{x_{2}} \int_{y_{1}}^{y_{2}} \frac{\delta P}{\delta y} \, dy \, dx$
>
>Which is a double integral over an area $A$: 
>
>$ -\int_{x_{1}}^{x_{2}} \int_{y_{1}}^{y_{2}} \frac{\delta P}{\delta y} \, dy \, dx =  -\iint \frac{\delta P}{\delta y} \, dA$
>
>(And it is about here that I discovered the existence of the \iint command! Oops...)
>
>So that's the first part of the Green's Theorem! Now, we just have to do the same thing for $Q(x,y) \, dy$, where we take edited versions of the $C_1$ and $C_2$ curves: 
>$\oint Q(x,y) \, dy = \int_{C_{1}} Q(x,y) \, dy + \int_{C_{2}} Q(x,y) \, dy$
>
>Now, for the first curve, notice how the curve from $y_1$ to $y_2$ will pass through the point $x_2$, and how the curve from $y_2$ to $y_1$ passes through the point $x_1$. So, we can write the upper and lower bounds of these curves as shown: 
>
>$\int_{C_{1}} Q(x,y) \, dy + \int_{C_{2}} Q(x,y) \, dy = \int_{y_{2}}^{y_{1}} Q(x_{1},y) \, dy + \int_{y_{1}}^{y_{2}} Q(x_{2},y) \, dy$
>
>Ideally, we want $x_2$ to be on the top, which means we'll rewrite our integrals as: 
>$\int_{y_{2}}^{y_{1}} Q(x_{1},y) \, dy + \int_{y_{1}}^{y_{2}} Q(x_{1},y) \, dy = - \int_{y_{1}}^{y_{2}} Q(x_{1},y) \, dy + \int_{x_{1}}^{x_{2}} Q(x_{2},y) \, dy $
>
>$- \int_{y_{1}}^{y_{2}} Q(x_{1},y) \, dy + \int_{y_{1}}^{y_{2}} Q(x_{2},y) \, dy = \int_{y_{1}}^{y_{2}} (Q(x_{2},y) - Q(x_{1},y)) \, dy $
>
>$\int_{y_{1}}^{y_{2}} (Q(x_{2},y) - Q(x_{1},y)) \, dy  = \int_{y_{1}}^{y_{2}}[ Q(x,y)]_{x_{1}}^{x_{2}}\, dy $
> $\int_{y_{1}}^{y_{2}}[ Q(x,y)]_{x_{1}}^{x_{2}}\, dy = \int_{y_{1}}^{y_{2}} \int  \frac{\delta Q}{\delta x} \, dx \, dy$ 
> Which equals to: 
> 
> $ \iint_{R} \frac{\delta Q}{\delta x} \, dA$
> So, going back to the **very** top, using the identity between the total line integral and those of the vector fields, we can rewrite that first expression as: 
> $\oint f(x,y) \cdot dr = \iint_{R} (\frac{\delta Q}{\delta x} - \frac{\delta P}{\delta y}) dA$
>Finished! One final tip before you go, however - look at the function first, before rushing to apply this formula! 
>
>- If the function has a potential $\nabla F(x,y)$ (i.e the integrals $\int P(x,y) \, dx$ and $\int Q(x,y) \, dy$ have constants that do not contradict each other), **the value of the integral is zero!** Then you can skip all the steps you might've once needed. 
>
We can also use Green's Theorem to find the areas of various shapes! One special shape that's good to consider, however, is the **annulus**, or the "2D Donut", defined by the functions $P(x,y) =-\frac{y}{x^2+y^2}$ and $Q(x,y) =\frac{x}{x^2+y^2}$
![[annulus.png]]
So, if we take the outer R1 curve as travelling counterclockwise, and the inner R2 curve as travelling clockwise, we get: 
$\oint f(x,y) \cdot dr = 0$
If we run the above expressions through Green's Theorem, then we get: 
$\frac{\delta Q}{\delta x} = \frac{(x^2+y^2) - (2x^2)}{(x^2+y^2)^2} = \frac{y^2-x^2}{(x^2+y^2)^2}$
$\frac{\delta P}{\delta y} = -\frac{(x^2+y^2) - (2y^2)}{(x^2+y^2)^2} = \frac{y^2-x^2}{(x^2+y^2)^2}$
Which gives us: 
$\iint_{R} \left( \frac{\delta Q}{\delta x} - \frac{\delta P}{\delta y}\right) \, dA = 0$
So, now we know that this type of curve, where **subregions** exist, follow Green's Theorem! This means we can now find the line integrals over odd shapes, which is VERY useful! 
>[!Example]- Proving that $\oint f(x,y) \cdot dr = 0$!
>Now, we'll first have to repackage this question to make it more digestible. We can assume, that if the annular regions $R_1$ and $R_2$ are circular, that they follow the general equation $x^2 + y^2 = r^2$, where $r^2$ is the radius of each region and is therefore constant. This essentially means that for a circular closed curve, we get a region of: 
>
>$\oint_{C} r \, dx + r \, dy$
>As the parametrisations for $x$ and $y$ are $r \cos t$ and $r \sin t$ respectively. And remember, $dr =\sqrt{ dx^2 + dy^2 }$! For the case when the curve is elliptical, we can replace $r$ with $a$ and $b$, which can refer to either the semi-major or semi-minor axis of the ellipse (see [[Conics - Circles, Parabolas & More! (Maths)#Ellipses|Ellipses]]. From here, it's a simple case of finding the possible 'potential' function of the curve: 
>$\int r \, dx = rx + c$
>$\int r \, dy = c + ry$
>This means that the constants for each integral give the other function, so the total potential function is: 
>$F(x,y) = rx + ry$
>As this function exists, $\oint f(x,y) \cdot dr = 0$ for this circular curve! Quick aside - this also means that the curve is **simply joined** - aka, the opposite of a smooth curve. 
>[!Example]- A Triangular Curve - Example Problem (MecMath 4.3 Exercise 4)
>Take the line integral of a function $f(x,y) = \oint_{C} (e^{x^2}+y^2) \, dx + (e^{y^2} + x^2) \, dy$, where $C$ is the boundary of the triangle with vertices (0,0), (4,0), and (0,4). 
>
>**SOLUTION:**
>
>Let's plot the curve before we jump ahead! Remember - don't skip your steps. Believe me, I've been there. 
>![[righttrianglecurve.png]]
>Now, let's plug this equation into Green's Theorem. The $P(x,y)$ and $Q(x,y)$ functions are pretty well-defined, thank god! 
>$\oint_{C} (e^{x^2}+y^2) \, dx + (e^{y^2} + x^2) \, dy = \iint_{R} (2x - 2y) \, dA$
>If we do the $dy$ integration first, we can go back to the sloping curve, which is $y = -x + 4$. Therefore, the limit of the $y$ integral is $-x + 4$, and the limits of the $x$ coordinate are 0 to 4, as shown: 
>$\iint_{R} (2x - 2y) \, dA = \int_{0}^4 \int_{0}^{-x+4} (2x-2y) \, dy  \, dx$
>
>So you get: 
>
>$= \int_{0}^{4} [2xy - y^2]_{0}^{-x+4}  \, dx$
>
>$= \int_{0}^{4} [2x(-x+4) - (-x+4)^2]  \, dx$
>
>$= \int_{0}^{4} [-2x^2+8x - (x^2-8x +16)] \, dx$
>$= \int_{0}^{4} -3x^2 + 16x - 16 \, dx $
>$= [-x^3 + 8x^2 - 16x]_{0}^{4} $
>$= -64 + 128 - 64 = 0$
>
>Finish! Yes, the answer is 0... just like that of a simply-joined closed curve! =) 
# The Divergence Theorem
As it turns out, the line integral is one useful tool. We can also use it to take the **surface integrals** of 3D objects, which I will (ATTEMPT!) to draw now! 
![[paraboloid2.png]]
...I'm not gonna talk about it. Anyhow, this shape is known as a *paraboloid*, which is a concave sheet in the 3D! 
To begin with deriving the Divergence Theorem, let's start off with a review on parametrisations. In the $\mathbb{R}^2$ space, we'll integrate under a curve that takes both $x$ and $y$ as an input. This, however, means that the position vector of a point on this line will be one-dimensional, which we parametrise using the single variable $t$. 
Well, for this 3D shape, we'll have to take TWO parametrisation variables, which I'll call $u$ and $v$. See these two diagrams for more! 
![[2dGrid1.png]]
![[paraboloid1.png]]
The first diagram is a 2D 'map' of the 3D curve - aka, when we COMPLETELY IGNORE the $z$ coordinate. This set of arbitrary coordinates map to the marked point on the paraboloid, and the position vector to reach said point in the 3D space becomes: 
$r(u,v) = x(u,v) \imath + y(u,v) \jmath + z(u,v) k$
This next part is gonna require a LOT of imagination, so buckle up! Remember: our aim is to find the surface area across this 3D shape. What we'll do now is the 2D equivalent to 'summing up the rectangles', in a sense. See: 
![[paraboloidrectangle.png]]
Since we'll take the sum of an infinite number of these small rectangles across the paraboloid, we'll call the dimensions of this $du$ and $dv$ respectively ^[1] , for the $x$ and $y$ axes of the rectangle. Now, introducing these variables to our existing equation is as easy as partially differentiating $r(u,v)$ with respect to $u$ and $v$: 
$\frac{\delta r}{\delta u} = \frac{\delta x}{\delta u}(u,v) + \frac{\delta y}{\delta u}(u,v) + \frac{\delta z}{\delta u} (u,v)$
$\frac{\delta r}{\delta v} = \frac{\delta x}{\delta v}(u,v) + \frac{\delta y}{\delta v}(u,v) + \frac{\delta z}{\delta v} (u,v)$
Notice that we can write these two partial derivatives in the form of the [[Partial Derivatives (Maths)#Fundamental Theorem of Calculus - Multivariable Edition|Fundamental Theorem of Calculus!]] This is the final thread to get us the $du$ and $dv$ variables: 
$\frac{\delta r}{\delta u} = \frac{r(u + \Delta u, v) - r(u,v)}{\Delta u}$
$\frac{\delta r}{\delta v} = \frac{r(u, v + \Delta v) - r(u,v)}{\Delta v}$
So, taking that $\Delta u \times \Delta v$ summed up across the entire surface is the surface integral, we can represent this as: 
$S = \Sigma ((r(u + \Delta u, v) - r(u,v)) \times (r(u, v + \Delta v) - r(u,v))) = \delta u\frac{\delta r}{\delta u} \times \delta v\frac{\delta r}{\delta v}$
Where $S$ is the surface area of our object, This internal part is a cross product between the two tangents to $u$ and $v$, which allows to adjust our function for the 3D component of the $z$ axis (aka, now our function can move up or down). This gets us our final expression for the divergence theorem, at: 
$S = \iint_{R} \mid\mid \frac{\delta r}{\delta u} \times \frac{\delta r}{\delta v} \mid\mid du \, dv$
Where $R$ is the 2D map of the 3D surface! The eleSometimes, you see this expressed as: 
$S = \iint_{\Sigma}  \, d \sigma $
Where $\sigma$ is the surface area derivative element, and $\Sigma$ is our big 3D surface. If there is a vector field $f(x,y,z)$ that travels through the surface (is defined over it), then we can rewrite this function as: 
$\iint_{\Sigma} f(x,y,z) d \sigma = \iint f(x(u,v), y(u,v), z(u,v))\mid\mid \frac{\delta r}{\delta u} \times \frac{\delta r}{\delta v} \mid\mid du \, dv $
So, for a vector field $f(x,y,z) = f_{1}(x,y,z) \imath + f_{2}(x,y,z) \jmath + f_{3}(x,y,z) k$, we can write the complete **Divergence Theorem** as: 
$\iint f \cdot d\sigma = \iiint_{S} \mathrm{div} f \, dV$
Where $dV$ is the volume integral operator, where we crack open the $f$ function to go from the $dA$ operator above (in $du dv$) to $dV$. This is as: 
$\mathrm{div} f = \frac{\delta f_{1}}{\delta x} + \frac{\delta f_{2}}{\delta y} + \frac{\delta f_{3}}{\delta z}$
Which is, if you remember, is the gradient of the vector! This 'div' operator is where the Divergence Theorem gets its name, as it's the **divergence operator!** Looking back at the integral, we can also get that when $\mathrm{div} f = 0$, the surface integral also equals to 0. Remember to look out for those numbers there!
>[!Example]- Example 1: The Surface Area of a Torus (Rewritten from MecMath!)
>Taking the cross sectional area of a torus as a circle, can you try to find an expression for the torus' surface area? 
>
>**SOLUTION:**
>![[crosssectiontorusREAL.png]]
>
>One easy way to start off is by defining some dimensions of said cross-sectional area in the 2D plane. Since the torus is a 'map' of this area along a circular path around the $z$ axis, we can cheese it and assume that it lies on the $y$ axis, as shown on the diagram above! For this first angle, the $u$ parameter is defined as the angle between the point on the circle and the $y$ axis itself, and $a$ and $b$ are the radius of the torus cross section and the y-coordinate of the centre of the circle itself. This gets us the following shape when we map to 3D: 
>
>![[3dsectiontorus.png]]
>Now, $v$ is the angle from the $x$ axis to the cross-section, which allows us to parametrise this torus in terms of $u$ and $v$! First, we take the parametrisation of the original circular cross-section as: 
>$y = a\cos u + b$
>$z = a \sin u$
>Then, we rotate the $y$ axis parametrisation through the $x$ axis - or, in other words, we do the same circular parametrisation, but in the $x$ axis, to get: 
>$x = (a\cos u + b) \cos v$
>$y = (a\cos u + b) \sin v$
>$z = a \sin u$
>Now, we can assemble the position vector $r(u,v) = x(u,v) \imath + y(u,v) \jmath + z(u,v) k$! We will now assemble the parts to the Divergence Theorem as shown: 
>$\frac{\delta r}{\delta u} = -a\cos v\sin u - a\sin v \sin u + a\cos u$
>$\frac{\delta r}{\delta v} = -a\sin v\cos u - b\sin v - a\cos v \cos u + b \cos v$
>Then take the cross product: 
>$\frac{\delta r}{\delta u} \times \frac{\delta r}{\delta v} = \begin{pmatrix} -a\cos v\sin u \\ a\sin v \sin u \\ a\cos u \end{pmatrix} \times \begin{pmatrix} -a\sin v\cos u - b\sin v \\ a\cos v \cos u + b \cos v \\ 0 \end{pmatrix}$
>$\begin{pmatrix} -a\cos v\sin u \\ a\sin v \sin u \\ a\cos u \end{pmatrix} \times \begin{pmatrix} -a\sin v\cos u - b\sin v \\ a\cos v \cos u + b \cos v \\ 0 \end{pmatrix} = \begin{pmatrix} -a\cos u(a\cos v \cos u + b \cos v)\\ a\cos u (-a\sin v\cos u - b\sin v) \\ (-a\cos v\sin u(a\cos v \cos u + b \cos v) \\ - a\sin v \sin u (-a\sin v\cos u - b\sin v )) \end{pmatrix}$
>$\begin{pmatrix} -a\cos u(a\cos v \cos u + b \cos v)\\ a\cos u (-a\sin v\cos u - b\sin v) \\ (-a\cos v\sin u(a\cos v \cos u + b \cos v) \\ - a\sin v \sin u (-a\sin v\cos u - b\sin v )) \end{pmatrix} = \begin{pmatrix} --a(b+a\cos u) \cos v\cos u\\ -a(b+a\cos u) \sin v \cos u \\ -a(b + a\cos u) \sin u \end{pmatrix}$
>Where that last part is minus the fourth row, but I can't write the whole vector without it spilling over its rendering limits! Taking the magnitude of this vector (as per the $\mid \mid \frac{\delta r}{\delta u} \times \frac{\delta r}{\delta v} \mid \mid$), we get: 
>$\mid \mid \frac{\delta r}{\delta u} \times \frac{\delta r}{\delta v} \mid \mid = (-a(b+a\cos u) \cos v\cos u)^2 + (-a(b+a\cos u) \sin v \cos u)^2 \dots$
>Now, believe it or not, all of this will simplify to: 
>$\mid \mid \frac{\delta r}{\delta u} \times \frac{\delta r}{\delta v} \mid \mid = a(b+a\cos u)$
>As all the ends of the angles cancel out through the perennial identity $\sin^2x + \cos^2x = 1$! Now, we can write this as: 
>$S = \int_{0}^2\pi \int_{0}^2\pi a(b+a\cos u) \, du  \, dv $
>$S = \int_{0^2\pi} ab(2\pi) + a^2 \sin (2\pi)\, dv $
>$S = [2\pi ab v]_{0}^{2\pi}$
>$S = 4\pi^2 ab$
>
>Which is our expression for the surface area of the Torus! 
>
>Take a break. Holy cow. 
>[!Example]- Example 2: Using the simplified Divergence Theorem: Part 1 (MecMath 4.4 Q3)
>Evaluate $\iint_{\Sigma} f \cdot d\sigma$ of a vector field $f(x,y,z) = x^3 \imath + y^3 \jmath + z^3k$ along the surface of a unit sphere $x^2 + y^2 + z^2 = 1$. 
>
>**Solution:**
>
>Calculate the divergence: 
>$\mathrm{div} f = 3x^2 + 3y^2 + 3z^2$
>Notice that $x^2+y^2+z^2$ is equal to the radius $r$ of this sphere. We can rewrite this integral as: 
>$\iint 3r^2 \, dV$
>We now need to write our integral in terms of $r^2$. To do this, we can (and, unfortunately, have to!) switch our coordinate system from a cartesian one to that of spherical coordinates, which means employing the [[Jacobian]] function for this transposition here: 
>$\iint 3r^2 \, dV = \int_{0}^{2\pi} \int_{0}^\pi \int_{0}^1 r^2 (r^2) \sin \phi \, dr  \, d\phi  \, d\theta $
>Where $\phi$ and $\theta$ are the azimuthal and polar coordinates respectively. Think of it like [[Celestial Coordinates (Astro)#Right Ascension and Declination|RA and DEC]], where the declination angle is $\theta$ and the right ascension, if transposed onto an angle, would be $\phi$! Allegory notwithstanding, this means we can solve our integral as:
>$\int_{0}^{2\pi} \int_{0}^\pi \int_{0}^1 3r^2 (r^2) \sin \phi \, dr  \, d\phi  \, d\theta = \int_{0}^{2\pi} \int_{0}^\pi \frac{3\sin \phi}{5} \, d\phi  \, d\theta$
>$\int_{0}^{2\pi} \int_{0}^\pi \frac{3\sin \phi}{5} \, d\phi  \, d\theta = \int_{0}^{2\pi} \frac{6}{5} \, d\theta$
>$\int_{0}^{2\pi} \frac{6}{5} \, d\theta = \frac{12\pi}{5}$
>Which is our answer! Phew...
>[!Example]- Example 3: Using the Divergence Theorem: Part 2 (MecMath 4.4 Q4)
>Evaluate $\iint_{\Sigma} f \cdot d\sigma$ of a vector field $f(x,y,z) = 2 \imath + 3 \jmath + 5k$ along the surface of a unit sphere $x^2 + y^2 + z^2 = 1$. 
>
>**Solution:**
>
>Since all of the numbers in the vector field are constants, differentiating them all with give us $\mathrm{div} f = 0$.
>
>So the value of the surface integral is $0$! YIPPEE!!
# Stokes' Theorem
Now, we've ported 2D line integrals to surface integrals, we've represented line integrals on 3D objects as volume integrals, so we've only one edge case to tackle left. It's time to figure out how to solve **3D line integrals**, people, and to do that, we use something called the **Stokes' Theorem.**
Strictly speaking, Stokes' Theorem is given as: 
$\oint f \cdot dr = \iint_{\Sigma} \mathrm{curl} \ f \cdot \, d\sigma$
Where $\Sigma$ is the 3D surface where the line integral is defined, over the vector field $f(x,y,z) = P(x,y,z) + Q(x,y,z) + R(x,y,z)$, and $\mathrm{curl} f= (\frac{\delta R}{\delta y} - \frac{\delta Q}{\delta z}) \imath + (\frac{\delta P}{\delta z} - \frac{\delta R}{\delta x}) \jmath +(\frac{\delta Q}{\delta x} - \frac{\delta P}{\delta y})k$. Don't be intimidated by that 'curl' operator just yet - if you need more prep, see the article on [[More on Multivariable Operators#The Divergence and Curl Operators|The Curl Operator]]!
>[!Success]- Proving the Stokes' Theorem (Thanks, MecMath!)
>*Highly Intuitive, but the maths' a mess. Good luck!*
>
>*This is also an edge case for the Stokes' Theorem. The full one MIGHT come in the future, if my course load says I need it. Judging by this one, however, I'm hoping that it won't come to that.*
>We can use the Stokes' Theorem in the event that we have a curve $z = z(x,y)$, where the $z$ values of the function are a function of $x$ and $y$. So, according to the [[Partial Derivatives (Maths)#Multivariable Chain Rule|Multivariable Chain Rule]], we can write: 
>$\frac{\delta z}{\delta t} = \frac{\delta z}{\delta x} \frac{dx}{dt} + \frac{\delta z}{\delta y} \frac{dy}{dt}$
>So, taking the formula for the solution of a line integral at the very top of this note, we get: 
>$\oint f \cdot dr = \int P(x,y) \, dx + \int Q(x,y) \, dy + \int R(x,y) \, dz$
>$\int P \, dx + \int Q \, dy + \int R \, dz = \int P \frac{dx}{dt}\, dt + \int Q \frac{dy}{dt}\, dt + \int R (\frac{\delta z}{\delta x} \frac{dx}{dt} + \frac{\delta z}{\delta y} \frac{dy}{dt}) \, dt$
>Factorise to get: 
>$ \int P \frac{dx}{dt}\, dt + \int Q \frac{dy}{dt}\, dt + \int R \left( \frac{\delta z}{\delta x} \frac{dx}{dt} + \frac{\delta z}{\delta y} \frac{dy}{dt} \right) \, dt = \int \left( P + \frac{\delta z}{\delta x} \right) \frac{dx}{dt} + \int \left( Q+\frac{\delta z}{\delta y} \right) \frac{dy}{dt}\, dt $
>So far so good, eh? Let's try to simplify this before we continue on. We can define two functions (for now) as: 
>$\dot{{P}}(x,y) = P(x,y,z(x,y)) + R(x,y,z(x,y))\frac{\delta z}{\delta x}$
>$\dot{{Q}}(x,y) = Q(x,y,z(x,y)) + R(x,y,z(x,y))\frac{\delta z}{\delta y}$
>So that integral becomes: 
>$\int \left( P + \frac{\delta z}{\delta x} \right) \frac{dx}{dt} + \int \left( Q+\frac{\delta z}{\delta y} \right) \frac{dy}{dt}\, dt = \int \dot{P}(x,y,z(x,y)) + \dot{Q}(x,y,z(x,y)) \, dt$
>Which matches with the general input of the [[Surface and Line Integrals#Green's Theorem|Green's Theorem]], $\iint \left( \frac{\delta \dot{Q}}{\delta x} - \frac{\delta \dot{P}}{\delta y} \right) \, dA$ Now, we have to find the differential terms, which according to our chain rule is: 
>$\frac{\delta \dot{Q}}{\delta x} = \frac{\delta }{\delta x} (Q(x,y,z(x,y))) + \frac{\delta }{\delta x} (R(x,y,z(x,u)))\frac{\delta z}{\delta y} + R(x,y,z(x,y)) \frac{\delta^2 z}{\delta x \delta y}$
>We write the functions outside because we need to perform a chain rule, given that there is a nested function $z = z(x,y)$ within: 
>$\frac{\delta }{\delta x} (Q(x,y,z(x,y))) = \frac{\delta Q}{\delta x} +  \frac{\delta Q}{\delta z} \frac{d z}{d x}$
>$\frac{\delta }{\delta x} (R(x,y,z(x,y))) = \frac{\delta R}{\delta x} +  \frac{\delta R}{\delta z} \frac{d z}{d x}$
>We can now substitute expressions for this into our original equation: 
>$\frac{\delta \dot{Q}}{\delta x} = \frac{\delta Q}{\delta x} +  \frac{\delta Q}{\delta z} \frac{d z}{d x} +  (\frac{\delta R}{\delta x} + \frac{\delta R}{\delta z} \frac{d z}{d x} ) \frac{\delta z}{\delta y} + R(x,y,z(x,y)) \frac{\delta^2 z}{\delta x \delta y}$
>Let's do the same thing for $\frac{\delta \dot{P}}{\delta y}$: 
>$\frac{\delta \dot{P}}{\delta y} = \frac{\delta P}{\delta y} + \frac{\delta P}{\delta z} \frac{d z}{d y} +  (\frac{\delta R}{\delta y} + \frac{\delta R}{\delta z} \frac{d z}{d y} ) \frac{\delta z}{\delta x} + R(x,y,z(x,y)) \frac{\delta^2 z}{\delta y \delta x}$
>Well, this is already enough of a nightmare. Subtract as according to Green's Theorem, noting that $\frac{d^2z}{dx dy} = \frac{d^2z}{dy dx}$:
>$\frac{\delta \dot{Q}}{\delta x} - \frac{\delta \dot{P}}{\delta y} = (\frac{\delta Q}{\delta z} - \frac{\delta R}{\delta y}) \frac{\delta z}{\delta x} + (\frac{\delta R}{\delta x} -\frac{\delta P}{\delta z})\frac{\delta z}{\delta y} + \left( \frac{\delta Q}{\delta x}-\frac{\delta P}{\delta y} \right)$
>
>...and we gotta integrate this. Or do we? First, let's rewrite the Green's Theorem in terms of what we've found: 
>
>$\oint f \cdot dr = \iint (\frac{\delta Q}{\delta z} - \frac{\delta R}{\delta y}) \frac{\delta z}{\delta x} + (\frac{\delta R}{\delta x} -\frac{\delta P}{\delta z})\frac{\delta z}{\delta y} + \left( \frac{\delta Q}{\delta x}-\frac{\delta P}{\delta y} \right) \, dA$
>
>Then we can look at the Stokes' theorem again. Let's take the normal vector equation, which is: 
>
>$n = \frac{N}{\mid N \mid} = \frac{-\frac{\delta z}{\delta x} \imath -\frac{\delta z}{\delta x} \jmath + k}{\sqrt{ 1 + (\frac{\delta z}{\delta x})^2 + (\frac{\delta z}{\delta y})^2 }}$
>
>Which, if you look closer, is the negative gradient unit vector of the function $z = z(x,y)$. If we take the position vector as $r = x \imath + y \jmath + z(x,y) k$, then we can get: 
>
>$\frac{\delta r}{\delta x} = \imath + \frac{\delta z}{\delta x}$
>$\frac{\delta r}{\delta y} = \jmath + \frac{\delta z}{\delta y}$
>
>So taking the magnitude of the cross product of this gives: 
>
>$\mid \frac{\delta r}{\delta x} \times \frac{\delta r}{\delta y} \mid = \sqrt{  \left( 1^2 + \frac{dz}{dx^2} + \frac{dz}{dy}^2  \right)}$
>
>Which is the magnitude of the normal vector $\mid N \mid$, as we see above. Remembering that Green's Theorem takes 2D 'slices' of an object, we'll have to convert this to 2D, which we can do by multiplying the integral with this cross product: 
>
>$\oint f \cdot dr = \iint_{D} (\frac{\delta Q}{\delta z} - \frac{\delta R}{\delta y}) \frac{\delta z}{\delta x} + (\frac{\delta R}{\delta x} -\frac{\delta P}{\delta z})\frac{\delta z}{\delta y} + \left( \frac{\delta Q}{\delta x}-\frac{\delta P}{\delta y} \right) \cdot n \mid \frac{\delta r}{\delta x} \times \frac{\delta r}{\delta y} \mid \, dA$
>
>Now do you see the curl operator in the equation? This means: 
>
>$\iint_{\Sigma} \mathrm{curl} f \cdot n d\sigma = \iint_{D} (\frac{\delta Q}{\delta z} - \frac{\delta R}{\delta y}) \frac{\delta z}{\delta x} + (\frac{\delta R}{\delta x} -\frac{\delta P}{\delta z})\frac{\delta z}{\delta y} + \left( \frac{\delta Q}{\delta x}-\frac{\delta P}{\delta y} \right) \cdot n \mid \frac{\delta r}{\delta x} \times \frac{\delta r}{\delta y} \mid \, dA$
>
>Which proves our theorem up top! Note that the $\mid \frac{\delta r}{\delta x} \times \frac{\delta r}{\delta y} \mid$ part just allows us to project the integral from the 2D to the 3D space. 
>
>Take a break. Please. Example Questions below.
>[!Example]- Example Question 1 (MecMath 4.5 Question 3)
>Find $\int_{C} f(x,y,z) \, ds$ for $f(x,y,z) = z^2$, $x = t\sin t \ ,y=t\cos t, z = \frac{2\sqrt{ 2 }}{3} t^\frac{3}{2}$
>
>**SOLUTION:**
>
>When we solve these types of questions, remember that we'll first have to find $ds$, that being: 
>$ds^2 = dx^2 + dy^2 + dz^2$
>So let's write the derivatives of the $x$, $y$, and $z$ parametrisations first: 
>$x'(t) = \sin t + t\cos t$
>$y'(t) = \cos t - t\sin t$
>$z'(t) =\sqrt{ 2 }\frac{t^\frac{1}{2}}{2}$
>Which means: 
>$ds = \sqrt{ \sin^2t + t^2\cos^2t + t^2 \sin^2t + \cos^2t + 2t }$
>$ds = \sqrt{ 1 + 2t + t^2 }$
>$ds = t+1$
>Now we just have to solve the integral by substituting in our parametrisation for $z$!: 
>$\int_{C} f(x,y,z) \, ds = \int_{0}^1 \frac{8}{9}t^3 (t+1) \, dt $
>$\int_{C} f(x,y,z) \, ds = \left[ \frac{8}{45} t^5 + \frac{8}{36} t^4 \right]_{0}^1$
>$\int_{C} f(x,y,z) \, ds = \frac{2}{5}$
>What a nice number! 
- # What's Next? 
You're done with the grunt work! Next up are the operators (next year :/). 
Donations keep me going! Click this button to donate: 
Or alternatively, subscribe to my patreon! https://www.patreon.com/c/cheesyminecart/membership