class: center, middle, inverse, title-slide .title[ # Integration and integral calculus ] .author[ ###
MACS 33000
University of Chicago ] --- # Misc * Gradescope! * HMWK due * Preceptor meetings * CAMP(S)! -- * US (MACSS) * ECON * Poli Sci -- * Exams: * US (math camp!) * US (boot camp!) * **OPTIONAL**: [see MPCS website for more information](https://mpcs-internal.cs.uchicago.edu/page/mpcs-placement-exams) * MPCS: math * MPCS: programming (re: 30121) * MPCS: (advanced) programming (subsequent coursework) --- # Learning objectives * Summarize areas, slices, and integrals * Apply common rules to calculate definite integrals * Define the fundamental theorem of calculus * Calculate antiderivatives and integrals using integration by substitution and integration by parts * Evaluate improper integrals: * Infinite integrals * Function not defined at some point in integral * Evaluate multivariate integrals --- # Indefinite integration * Calculate the derivative `\(f=F'\)` of a function `\(F\)` * Reverse operation: find the function `\(F\)` for which `\(f\)` is its derivative * Antiderivative -- I think of the integral as undoing (hence *antiderivative*) of a derivative. You can move back and forth between the function, its derivative, and the antiderivative. Just try to think about what you are doing. Effectively, what we are trying to do is ADD UP all the changes. Think about this as adding up slices and that can help provide intuition (graphics coming in a few slides!). --- # Indefinite integration `$$f(x) = \frac{1}{x^2}=x^{-2}$$` -- $$ `\begin{aligned} \int \frac{1}{x^2} dx &= -\frac{1}{x} + c \\ \frac{d}{dx} \left[ -\frac{1}{x} + c \right] &= \frac{1}{x^2} \end{aligned}` $$ Note: you can always take the derivative of your answer to check yourself! -- `$$F(x) = \int f(x) \,dx$$` Note: you will also often see this notation with `\(f\)` as the derivative of the original `\(F\)` function. --- # Many possible antiderivatives Because we're only looking at the rate of change, we lose our intercept. This means that there are multiple original functions that all produce the same end derivative. Going back, this means that one function can have many antiderivatives. -- `$$f(x) = x^2-4; \text{ } F(x) = \int\limits f(x) \,dx = \frac{x^3}{3}-4x+c$$` -- <img src="08-integration_files/figure-html/integralc-1.png" width="864" style="display: block; margin: auto;" /> * Multiple antiderivatives for an arbitrary constant `\(c\)` --- # Common rules of integration 1. Constants are allowed to slip out: `\(\int a f(x)\,dx = a\int f(x)\,dx\)` -- 1. Integration of the sum is sum of integrations: `\(\int [f(x)+g(x)]\,dx=\int f(x)\,dx + \int g(x)\,dx\)` -- 1. Reverse Power-rule: `\(\int x^n \,dx = \frac{1}{n+1} x^{n+1} + c\)` -- 1. Exponents are still exponents: `\(\int e^x \,dx = e^x +c\)` -- 1. Recall the derivative of (natural) `\(\log(x)\)` is one over `\(x\)`, and so: `\(\int \frac{1}{x} \,dx = \log x + c\)` -- 1. Reverse chain-rule: `\(\int e^{f(x)}f^\prime(x)\,dx = e^{f(x)}+c\)` -- 1. More generally: `\(\int [f(x)]^n f'(x)\,dx = \frac{1}{n+1}[f(x)]^{n+1}+c\)` -- 1. Remember the derivative of a natural log of a function: `\(\int \frac{f^\prime(x)}{f(x)}\,dx=\log f(x) + c\)` --- # Simplify the indefinite integrals 1. `\(\int 3x^2 \,dx\)` 1. `\(\int (2x+1) \,dx\)` 1. `\(\int e^x e^{e^x} \,dx\)` -- Answers: 1. `\(\int 3x^2 \,dx=\mathbf{x^3 + c}\)` 1. `\(\int (2x+1) \,dx = \mathbf{x^2 + x + c}\)` 1. `\(\int e^x e^{e^x} \,dx = \mathbf{e^{e^x}+c}\)` --- # Definite integral * Indefinite integral `\(\leadsto\)` definite integral * Different objective: find the area under a function -- * Determine the area `\(A(R)\)` of a region `\(R\)` defined by a curve `\(f(x)\)` and some interval `\(a\le x \le b\)` * Approximation with rectangles * Divide the interval `\(a\le x\le b\)` into `\(n\)` subintervals of length `\(\Delta x\)` * Base of each rectangle is `\(\Delta x\)` * Height is `\(f(x)\)` at the midpoint of that interval `$$A(R) \approx S(f,\Delta x)=\sum\limits_{i=1}^n f(x_i)\Delta x$$` * Riemann sum --- # Riemann sum: area under the curve **(HI LIMITS!!!)** `$$A(R)=\lim\limits_{\Delta x\to 0}\sum\limits_{i=1}^n f(x_i)\Delta x$$` <div class="figure" style="text-align: center"> <img src="08-integration_files/figure-html/defintfig5-1.png" alt="The Riemann Integral as a Sum of Evaluations" width="864" /> <p class="caption">The Riemann Integral as a Sum of Evaluations</p> </div> --- # Riemann sum: smaller rectangles <div class="figure" style="text-align: center"> <img src="08-integration_files/figure-html/defintfig2-1.png" alt="The Riemann Integral as a Sum of Evaluations" width="864" /> <p class="caption">The Riemann Integral as a Sum of Evaluations</p> </div> --- # Riemann sum `$$A(R)=\lim\limits_{\Delta x\to 0}\sum\limits_{i=1}^n f(x_i)\Delta x$$` <div class="figure" style="text-align: center"> <img src="08-integration_files/figure-html/defintfig-1.gif" alt="The Riemann Integral as a Sum of Evaluations" /> <p class="caption">The Riemann Integral as a Sum of Evaluations</p> </div> --- # Definite integral * Riemann integral of `\(f\)` from `\(a\)` to `\(b\)` `$$\lim\limits_{\Delta x\to 0} \sum\limits_{i=1}^n f(x_i)\Delta x = \int\limits_a^b f(x) \,dx$$` * Suppose `\(f:[a,b] \rightarrow \Re\)` is a continuous function. Then `\(f\)` is integrable * Suppose `\(f:[a,b]\rightarrow \Re\)` is a monotonic function. Then `\(f\)` is integrable --- # Counterexamples * Suppose `\(f:[0,1]\rightarrow \frac{1}{x}\)` `$$\int_{0}^{1} \frac{1}{x} \,dx$$` * `\(\frac{1}{x}\)` is not integrable on `\([a,b]\)` -- ---------------------------- `$$\begin{aligned}f(x) &= 1 \text{ if } x \text{ rational} \\ &= 0 \text{ if } x \text{ irrational} \end{aligned}$$` * Not integrable - discontinuity --- # Fundamental theorem of calculus Helps make all the math we're about to do that much easier (!). -- * Riemann sum = antiderivative -- * Function `\(f\)` bounded on `\([a,b]\)` and continuous on `\((a,b)\)` -- * `\(F(x)\)` denotes the definite integral from `\(a\)` to `\(x\)`: `$$F(x)=\int\limits_a^x f(t) \,dt, \quad a\le x\le b$$` * `\(F(x)\)` has a derivative at each point in `\((a,b)\)` `$$F^\prime(x)=f(x), \quad a<x<b$$` * Differentiation is the inverse of integration --- # Fundamental theorem of calculus (cont'd) * Calculating indefinite integrals -- * Function `\(f\)` bounded on `\([a,b]\)` and continuous on `\((a,b)\)` -- * `\(F\)` is any function that is continuous on `\([a,b]\)` such that `\(F'(x)=f(x)\)` on `\((a,b)\)`. Then `$$\int\limits_a^bf(x)\,dx = F(b)-F(a)$$` -- ### Estimation procedure for definite integral `$$\int\limits_a^b f(x)\,dx$$` 1. Find the indefinite integral `\(F(x)\)` 2. Evaluate `\(F(b)-F(a)\)` --- # Uniform distribution (continuous) Suppose `\(f:\Re \rightarrow \Re\)`, with $$ `\begin{aligned} f(x) &= 1 \text{ if } x \in [0,1] \\ f(x) &= 0 \text{ otherwise } \end{aligned}` $$ -- What is the area under `\(f(x)\)` from `\([0, 1/2]\)`? -- `$$\begin{aligned}\int_{0}^{1/2} f(x)\,dx &= \int_{0}^{1/2} 1 \,dx \\ &= x|_{0}^{1/2} \\ &= (1/2) - (0 ) \\ &= 1/2 \end{aligned}$$` --- # Area under a line Suppose `\(f:\Re \rightarrow \Re\)`, with `$$f(x) = x$$` -- Evaluate the `\(\int_{2}^{t}f(x)\,dx\)` -- `$$\begin{aligned}\int_{2}^{t}f(x)\,dx &= \int_{2}^{t} x \,dx \\ &= \frac{x^{2} }{2} |_{2}^{t} \\ &= \frac{t^2}{2} - \frac{2^2}{2} \\ &= \frac{t^2}{2} - \frac{4}{2} = \frac{t^2}{2} - 2\end{aligned}$$` --- # Area under a curve Solve `\(\int\limits_1^3 3x^2 \,dx\)` -- `$$f(x)= 3x^2 \\F(x) = x^3 + c$$` -- `$$\begin{aligned}\int\limits_1^3 3x^2 \,dx &= F(3) - F(1) \\&= (3^3 + c) - (1^3 + c) \\&= 27 + c - 1 - c \\&= 26\end{aligned}$$` --- # Common rules for definite integrals 1. There is no area 'under' a point `$$\int_a^a f(x)\,dx=0$$` -- 1. Reversing the limits changes the sign of the integral `$$\int_a^b f(x)\,dx=-\int_b^a f(x)\,dx$$` -- 1. Sums can be separated into their own integrals `$$\int_a^b [\alpha f(x)+\beta g(x)]\,dx = \alpha \int_a^b f(x)\,dx + \beta \int_a^b g(x)\,dx$$` -- 1. Areas can be combined as long as limits are linked `$$\int_a^b f(x) \,dx +\int_b^c f(x)\,dx = \int_a^c f(x)\,dx$$` --- # Challenge problems 1. `\({\displaystyle \int\limits_1^1 3x^2 \,dx}\)` 1. `\({\displaystyle \int\limits_0^4 (2x+1) \,dx}\)` 1. `\({\displaystyle \int\limits_{-2}^0 e^x e^{e^x} dx + \int\limits_0^2 e^x e^{e^x} \,dx}\)` --- # Challenge problems 1. `\({\displaystyle \int\limits_1^1 3x^2 \,dx}\)` `\(\mathbf{0}\)` (area under a point) -- 1. `\({\displaystyle \int\limits_0^4 (2x+1) \,dx}\)` `\(\mathbf{x^2+x|_0^4=20}\)` -- 1. `\({\displaystyle \int\limits_{-2}^0 e^x e^{e^x} dx + \int\limits_0^2 e^x e^{e^x} \,dx}=\)` `\(\mathbf{e^{e^x}|_{-2}^2} \mathbf{\approx 1617.03}\)` --- class: middle # Integration: increasing the challenge level! * Integration by substitution * Integration by parts * Infinite integrals --- # Integration by substitution * Tricky integrands * Alternative methods * Related to the chain rule -- ## Integration by substitution: How-to 1. Take your function you are trying to integrate: `\(\int g(x)\,dx\)` -- 1. Generate a new function `\(u(x)\)` such that `\(g(x)=f[u(x)]u'(x)\)` (track your pieces--we will do an example!!) -- 1. Find the antiderivative of `\(f\)` as `\(F\)`: -- `$$\frac{d}{dx} F[u(x)]=f[u(x)]u'(x)$$` -- `$$\int g(x) \,dx= \int f[u(x)]u'(x)\,dx = \int \frac{d}{dx} F[u(x)]\,dx = F[u(x)]+c$$` --- # Example `$$\int \frac{x}{x^2 + 1} \,dx$$` -- Reexpress as `$$\frac{1}{2} \int \frac{2x}{x^2 + 1} \,dx$$` -- `$$\begin{aligned}u &= x^2 + 1 \\du &= 2x \,dx \end{aligned}$$` `$$\begin{aligned}\int \frac{x}{x^2 + 1} \,dx &= \frac{1}{2} \int \frac{2x}{x^2 + 1} \,dx \\&= \frac{1}{2} \int \frac{1}{u} \,du \\&= \frac{1}{2} \log(u) + c \\&= \frac{1}{2} \log(x^2 + 1) + c \end{aligned}$$` --- # Integration by substitution 1. Identify some part of `\(g(x)\)` that might be simplified by substituting in a single variable `\(u\)` (which will then be a function of `\(x\)`) 1. Determine if `\(g(x)\,dx\)` can be reformulated in terms of `\(u\)` and `\(du\)` 1. Solve the indefinite integral 1. Substitute back in for `\(x\)` --- # Example: try it out: `$$f(x) = \int \frac{x^2+1}{x^3 + 3x} \,dx$$` -- Our `\(u\)` in this instance would be the denominator: `\(x^3+3x\)`. -- Then, we would expect `\(du=3x^2+3\)`. BUT! we have: `\({\displaystyle \int \frac{\frac{1}{3}du}{u}}\)`. -- Rework it: `\(\frac{1}{3}\int \frac{1}{u} du\)` -- We can solve: `\(\frac{1}{3}\, log(u)+c\)` and sub back in our `\(u\)`: `\(\frac{1}{3}log(x^3+3x) + c\)`. --- # Additional practice: integration by substitution Try: `\({\displaystyle{\int (20x^3+20)(x^4+4x)^{-0.5}}}\)` -- `\(u= x^4+4x, du=4x^3+4\)` `\(5{\displaystyle{\int u^{-0.5} \,du}}\)` -- `\(=\frac{5u^{0.5}}{0.5}+c\)` -- `\(=10(x^4+4x)^{0.5}+c\)` -- I like to think of this as a way to reduce clutter when working through a problem. BE SURE TO TAKE GOOD NOTES! --- # Integration by parts In some circumstances, you won't be able to separate things as easily. Basically, if you're dealing with a situation that is a bit tricky, you can break it into chunks by somewhat 'undoing' the product rule. -- * Recall the product rule: `$$\begin{aligned}\frac{d}{dx} f(x) g(x) &= f(x) g'(x) + g(x) f'(x) \\\frac{d}{dx}(uv) &= u\frac{dv}{dx}+v\frac{du}{dx}\end{aligned}$$` --- # Integration by parts * Integrating the product rule and rearrange `$$\int u\frac{dv}{dx}\,dx= u v - \int v \frac{du}{dx}\,dx$$` -- `$$\int u(x) v'(x)\,dx=u(x)v(x) - \int v(x)u'(x)\,dx$$` -- `$$\int u \,dv = u v - \int v \,du$$` where `\(du=u'(x)\,dx\)` and `\(dv=v'(x)\,dx\)` * Find expressions for `\(u\)` and `\(dv\)` that yield an expression that're more easily evaluated --- # Integration by parts: COLOR CODED Suppose you start with a function: `\(\int\)` <span style="color: red;">u</span> `\(\,\)` <span style="color: blue;">dv</span>. -- We can transform this to: ### <span style="color: red;">u</span><span style="color: blue;">v</span> - `\(\int\)` <span style="color: darkblue;">v</span> <span style="color: pink;">du</span> -- ### Alternatively, I think about this as our table of options when we write things out like this: ## <span style="color: red;">u</span> `\(\,\)` <span style="color: blue;">dv</span> (start with this row) ## <span style="color: pink;">du</span> `\(\,\)` <span style="color: darkblue;">v</span> (subtract this row) --- # Integration by parts: example `$$\int x \log(x) \,dx$$` -- $$ `\begin{aligned} u &= \log(x) & \quad dv & = x \, dx \\ du &= \frac{1}{x} \,dx & \quad v &= \frac{1}{2}x^2 \end{aligned}` $$ -- `\(\int x \log(x) \, dx = u v - \int v \,du\)` -- `$$\begin{aligned} &= \log(x) \times \frac{1}{2} x^2 - \int (\frac{1}{2} x^2) (\frac{1}{x} \, dx) \\ &= \frac{1}{2} x^2 \log(x) - \int \frac{1}{2}x \,dx \\ &= \frac{1}{2} x^2 \log(x) - \frac{1}{2} \int x \,dx \\ &= \frac{1}{2} x^2 \log(x) - \frac{1}{2} \left( \frac{1}{2}x^2 \right) + c \\ &= \frac{1}{2} x^2 \log(x) - \frac{1}{4} x^2 + c \end{aligned}$$` --- # Integration by parts: your turn! Suppose we have: `\(\int 15x (x+1)^{0.5}\)`. -- We can look at this and see that it's not just taking the derivative of one thing and rescaling it. Then, the question becomes which is `\(u\)` and which is `\(v\)`? Recall that we want to start with `\(\int u \, dv\)`. So, which thing is going to be easier to integrate and which is going to be easier to take the derivative of? -- In our situation, suppose we start with `\(u=15x\)`. Then, `\(dv=(x+1)^{0.5}\)`, `\(du=15\)`, and `\(v=\frac{2}{3}(x+1)^{1.5}\)`. -- Using our formula, we get: `\(uv-\int v \, du = (15x)(\frac{2}{3}(x+1)^{1.5})-\int \frac{2}{3}(x+1)^{1.5} \, 15dx\)`. -- Simplifying, we get: `\((10x)((x+1)^{1.5})-10 \int (x+1)^{1.5} \, dx\)` `\(= (10x)((x+1)^{1.5})-10(\frac{2}{5})(x+1)^{2.5}\)` -- Reworking this, we get: `\(\mathbf{(10x)((x+1)^{1.5})-4(x+1)^{2.5}}\)`. If we wanted, we could keep simplifying -- *(we don't want...)*. --- # Tricky questions: when to use substitution over parts It really is a bit of an art to know. Basically, if it looks like you have (loosely) some function to a higher power with its own derivative mixed in there, then you are likely dealing with a situation where substitution would improve things. If it looks to you like you have a two separate functions comingling, then it's probably time for integration by parts. --- class: middle # Infinite integrals: when the fun has no bounds! * Convergence vs divergence * MORE LIMITS! --- # Infinite integrals `$$\begin{aligned} \int_1^X x^{-2} \,dx &= -\frac{1}{x} |_1^X \\ &= -\frac{1}{X} - -\frac{1}{1} \\ &= -\frac{1}{X} + 1 \\ &= 1 - X^{-1} \end{aligned}$$` -- As `\(X \rightarrow \infty, \frac{1}{X} \rightarrow 0\)` `$$\lim_{X \rightarrow \infty} \int_1^X x^{-2} \,dx = 1$$` -- `$$\int_1^\infty x^{-2} \,dx = 1$$` --- # Infinite integrals <img src="08-integration_files/figure-html/int-x-2-1.png" width="864" style="display: block; margin: auto;" /> --- # Infinite integrals * Over an infinite domain * Still has a finite value for the **definite** integral -- ## Convergence of integrals * Continuous function `\(f(x)\)` defined for all `\(x \geq a\)` * Integral `\(\int_a^X f(x)\,dx\)` approaches a finite limit `\(L\)` as `\(X \rightarrow \infty\)` `$$\int_a^\infty f(x)\,dx = L$$` * Indefinite integral **converges** * If `\(\int_a^X f(x)\,dx\)` does not approach a finite limit as `\(X \rightarrow \infty\)`, then infinite integral **diverges** --- # Diverging integral `$$f(x) = \frac{1}{x}$$` -- `$$\begin{aligned}\int_{1}^{\infty} \frac{1}{x} \,dx &= \lim_{t \rightarrow \infty} \int_{1}^{t} \frac{1}{x} \,dx \\ &= \lim_{t \rightarrow \infty} (\log x)|_{1}^{t} \\ &= \lim_{t \rightarrow \infty} (\log t) - \lim_{t \rightarrow \infty} (\log 1) \end{aligned}$$` --- # Plotting Natural log: diverges <img src="08-integration_files/figure-html/int-lnx-1.png" width="864" style="display: block; margin: auto;" /> --- # Two-sided infinite integrals If `\(f(x)\)` is a continuous function defined for all `\(x \leq a\)`, and if the definite integral `\(\int_Y^a f(x) \,dx\)` approaches a finite limit as `\(Y \rightarrow -\infty\)`, we denote the limit by `$$\int_{-\infty}^a f(x) \,dx$$` -- If the integrals `\(\int_{-\infty}^a f(x) \,dx\)` and `\(\int_a^\infty f(x) \,dx\)` both exist, we denote their sum by `$$\int_{-\infty}^\infty f(x) \,dx$$` -- * Extremely important for probability distributions `$$\int_{-\infty}^\infty f(x) \,dx = 1$$` --- class: Middle # Fun with multiple variables: multivariate integration * logic is the same * need to think about multiple dimensions / space --- # Multivariate integration * Function `\(f:X \rightarrow \Re^{1}\)`, with `\(X \subset \Re^{2}\)` * Integrate a function over an area --- # Multivariate integration `$$A = \{x, y : x \in[0,1], y \in [0,1] \}$$` <img src="08-integration_files/figure-html/a-2d-rect-1.png" width="864" style="display: block; margin: auto;" /> --- # Multivariate integration `$$A = \{x, y: x^2 + y^2 \leq 1 \}$$` <img src="08-integration_files/figure-html/a-2d-circle-1.png" width="864" style="display: block; margin: auto;" /> --- # Multivariate integration `$$A = \{ x, y: x< y, x, y \in (0,2) \}$$` <img src="08-integration_files/figure-html/a-2d-triangle-1.png" width="864" style="display: block; margin: auto;" /> --- # Multivariate integration * `\(f:X \rightarrow \Re\)` where `\(X \subset \Re^{n}\)` * `\(f\)` is integrable over `\(A \subset X\)` if we are able to calculate its area with refined partitions of `\(A\)` * Write the integral `\(I =\int_{A} f(\boldsymbol{x}) d\boldsymbol{A}\)` --- # Fubini's theorem * Suppose `\(A = [a_{1}, b_{1}] \times [a_{2}, b_{2} ] \times \ldots \times [a_{n}, b_{n}]\)` * `\(f:A \rightarrow \Re\)` is integrable `$$\int_{A} f(\boldsymbol{x}) d\boldsymbol{A} = \int_{a_{n}}^{b_{n}} \int_{a_{n-1}}^{b_{n-1}} \ldots \int_{a_{2}}^{b_{2}} \int_{a_{1}}^{b_{1}} f(\boldsymbol{x})\,dx_{1} \,dx_{2} \ldots \,dx_{n-1} \,dx_{n}$$` * Start with the inside integral `\(x_{1}\)` is the variable, everything else a constant * Work inside to out, iterating * At the last step, we should arrive at a number --- # Multivariate uniform distribution * Suppose `\(f:[0,1] \times [0,1] \rightarrow \Re\)` and `\(f(x_{1}, x_{2}) = 1\)` for all `\(x_{1}, x_{2} \in [0,1]\times[0,1]\)` * What is `\(\int_{0}^{1}\int_{0}^{1} f(x) \,dx_{1} \,dx_{2}\)`? -- `$$\begin{aligned}\int_{0}^{1}\int_{0}^{1} f(x) \,dx_{1} \,dx_{2} &= \int_{0}^{1} \int_{0}^{1} 1 \,dx_{1} \,dx_{2} \nonumber \\ &= \int_{0}^{1} x_{1}|_{0}^{1} \,dx_{2} \\ &= \int_{0}^{1} (1 - 0) \,dx_{2} \\ &= \int_{0}^{1} 1 \,dx_{2} \\ &= x_{2}|_{0}^{1} \\ &= 1 \end{aligned}$$` --- # Another example * Suppose `\(f:[a_{1}, b_{1} ] \times [a_{2}, b_{2} ] \rightarrow \Re\)` is given by `$$f(x_{1}, x_{2} ) = x_{1} x_{2}$$` * Find `\(\int_{a_{2}}^{b_{2}} \int_{a_{1}}^{b_{1}} f(x_{1}, x_{2} )\,dx_{1} \,dx_{2}\)` -- `$$\begin{aligned}\int_{a_{2}}^{b_{2}} \int_{a_{1}}^{b_{1}} f(x_{1}, x_{2} )\,dx_{1} \,dx_{2} &= \int_{a_{2}}^{b_{2}} \int_{a_{1}}^{b_{1}} x_{1} x_{2} \,dx_{1} \,dx_{2} \\ &= \int_{a_{2}}^{b_{2}} \frac{x_{1}^2}{2} x_{2} |_{a_{1}}^{b_{1}} \,dx_{2} \\ &= \frac{b_{1}^{2} - a_{1}^{2} }{2} \int_{a_{2}}^{b_{2}} x_{2} \,dx_{2} \\ &= \frac{b_{1}^{2} - a_{1}^{2} }{2} \left( \frac{x_{2}^{2} }{2} |_{a_{2}}^{b_{2}} \right ) \\ &= \frac{b_{1}^{2} - a_{1}^{2} }{2} \frac{b_{2}^{2} - a_{2}^{2} }{2}\end{aligned}$$` --- # More complicated bounds of integration <img src="08-integration_files/figure-html/a-2d-triangle-1.png" width="864" style="display: block; margin: auto;" /> --- # Example: more complicated region * Suppose `\(f:[0,1] \times [0,1] \rightarrow \Re\)`, `\(f(x_{1}, x_{2}) = x_{1} + x_{2}\)`. Find area of function where `\(x_{1} < x_{2}\)`. -- * Determine the bound - if `\(x_{1}< x_{2}\)`, `\(x_{1}\)` can take on any value from `\(0\)` to `\(x_{2}\)` -- `$$\begin{aligned}\iint_{x_{1}< x_{2}} f(\boldsymbol{x}) &= \int_{0}^{1} \int_{0}^{x_{2}} x_{1} + x_{2} \,dx_{1} \,dx_{2} \\&= \int_{0}^{1} x_{2} x_{1} |_{0}^{x_{2}} \,dx_{2} + \int_{0}^{1} \frac{x_{1}^{2} }{2} |_{0}^{x_{2} } \\&= \int_{0}^{1} x_{2}^{2} \,dx_{2} + \int_{0}^{1} \frac{x_{2}^2}{2} \\&= \frac{x_{2}^{3} }{3}|_{0}^{1} + \frac{x_{2}^{3}}{6}|_{0}^{1} \\&= \frac{1}{3} + \frac{1}{6} \\&= \frac{3}{6} = \frac{1}{2} \end{aligned}$$` --- # Switch the bounds: start with `\(dx_2\)` -- `$$\begin{aligned}\iint_{x_{1}<x_{2}} f(\boldsymbol{x}) &= \int_{0}^{1} \int_{x_{1}}^{1} x_{1} + x_{2} \,dx_{2} \,dx_{1} \\ &= \int_{0}^{1} x_{1}x_{2}|_{x_{1}}^{1} + \int_{0}^{1} \frac{x_{2}^{2}}{2} |_{x_{1}}^{1}\,dx_{1} \\ &= \int_{0}^{1} x_{1} - x_{1}^2 + \int_{0}^{1} \frac{1}{2} - \frac{x_{1}^2}{2} \,dx_{1} \\ &= \frac{x_{1}^2}{2}|_{0}^{1} - \frac{x_{1}^{3}}{3}|_{0}^{1} + \frac{x_{1}}{2}|_{0}^{1} - \frac{x_{1}^{3}}{6}|_{0}^{1} \\ &= \frac{1}{2} - \frac{1}{3} + \frac{1}{2} - \frac{1}{6} \\ &= 1 - \frac{3}{6} \\ &= \frac{1}{2} \end{aligned}$$` --- # Big ol' Recap: Integrating builds on our work so far. Try to pay attention to things as it can get tricky. -- * Definite integrals: integrating over a range * Indefinite integrals: general integral (remember constant!) * Ways to deal with complicated integrals: * Integration by substitution `\(\frac{d}{dx} F[u(x)]=f[u(x)]u'(x)\)` * Integration by parts: `\(\int v(x) \, u'(x) (dx)=u(x)v(x) - \int v(x)u'(x)\,dx\)` * Infinite integrals: to infinity! (and maybe beyond) * Multivariate integrals * role of bounds (pay attention!): x vs y for integration