edits
This commit is contained in:
@@ -39,13 +39,13 @@ Now we turn our attention to the implications of the *product rule*: $[uv]' = u'
|
||||
By the fundamental theorem of calculus:
|
||||
|
||||
$$
|
||||
[u(x)\cdot v(x)]\big|_a^b = \int_a^b [u(x) v(x)]' dx = \int_a^b u'(x) \cdot v(x) dx + \int_a^b u(x) \cdot v'(x) dx.
|
||||
[u(x)\cdot v(x)]\Big|_a^b = \int_a^b [u(x) v(x)]' dx = \int_a^b u'(x) \cdot v(x) dx + \int_a^b u(x) \cdot v'(x) dx.
|
||||
$$
|
||||
|
||||
Or,
|
||||
|
||||
$$
|
||||
\int_a^b u(x) v'(x) dx = [u(x)v(x)]\big|_a^b - \int_a^b v(x) u'(x)dx.
|
||||
\int_a^b u(x) v'(x) dx = [u(x)v(x)]\Big|_a^b - \int_a^b v(x) u'(x)dx.
|
||||
$$
|
||||
:::
|
||||
|
||||
@@ -58,16 +58,16 @@ The following visually illustrates integration by parts:
|
||||
#| label: fig-integration-by-parts
|
||||
#| fig-cap: "Integration by parts figure ([original](http://en.wikipedia.org/wiki/Integration_by_parts#Visualization))"
|
||||
let
|
||||
## parts picture
|
||||
## parts picture
|
||||
gr()
|
||||
u(x) = sin(x*pi/2)
|
||||
v(x) = x
|
||||
xs = range(0, stop=1, length=50)
|
||||
a,b = 1/4, 3/4
|
||||
|
||||
p = plot(u, v, 0, 1, legend=false, axis=([], false))
|
||||
plot!([0, u(1)], [0,0], line=(:black, 3))
|
||||
plot!([0, 0], [0, v(1) ], line=(:black, 3))
|
||||
plot!(p, zero, 0, 1)
|
||||
p = plot(u, v, 0, 1; legend=false, axis=([], false), line=(:black,2))
|
||||
plot!([0, u(1)], [0,0]; line=(:gray, 1), arrow=true, side=:head)
|
||||
plot!([0, 0], [0, v(1) ]; line=(:gray, 1), arrow=true, side=:head)
|
||||
|
||||
xs′ = range(a, b, length=50)
|
||||
plot!(Shape(vcat(u.(xs′), reverse(u.(xs′))),
|
||||
@@ -81,21 +81,28 @@ plot!(p, [u(a),u(a),0, 0, u(b),u(b),u(a)],
|
||||
[0, v(a), v(a), v(b), v(b), 0, 0],
|
||||
linetype=:polygon, fill=(:brown3, 0.25))
|
||||
|
||||
annotate!(p, [(0.65, .25, "A"),
|
||||
(0.4, .55, "B"),
|
||||
(u(a),v(a) + .08, "(u(a),v(a))"),
|
||||
(u(b),v(b)+.08, "(u(b),v(b))"),
|
||||
(u(a),0, "u(a)",:top),
|
||||
(u(b),0, "u(b)",:top),
|
||||
(0, v(a), "v(a) ",:right),
|
||||
(0, v(b), "v(b) ",:right)
|
||||
annotate!(p, [(0.65, .25, text(L"A")),
|
||||
(0.4, .55, text(L"B")),
|
||||
(u(a),v(a), text(L"(u(a),v(a))", :bottom, :right)),
|
||||
(u(b),v(b), text(L"(u(b),v(b))", :bottom, :right)),
|
||||
(u(a),0, text(L"u(a)", :top)),
|
||||
(u(b),0, text(L"u(b)", :top)),
|
||||
(0, v(a), text(L"v(a)", :right)),
|
||||
(0, v(b), text(L"v(b)", :right)),
|
||||
(0,0, text(L"(0,0)", :top))
|
||||
])
|
||||
end
|
||||
```
|
||||
|
||||
```{julia}
|
||||
#| echo: false
|
||||
plotly()
|
||||
nothing
|
||||
```
|
||||
|
||||
@fig-integration-by-parts shows a parametric plot of $(u(t),v(t))$ for $a \leq t \leq b$..
|
||||
|
||||
The total shaded area, a rectangle, is $u(b)v(b)$, the area of $A$ and $B$ combined is just $u(b)v(b) - u(a)v(a)$ or $[u(x)v(x)]\big|_a^b$. We will show that $A$ is $\int_a^b v(x)u'(x)dx$ and $B$ is $\int_a^b u(x)v'(x)dx$ giving the formula.
|
||||
The total shaded area, a rectangle, is $u(b)v(b)$, the area of $A$ and $B$ combined is just $u(b)v(b) - u(a)v(a)$ or $[u(x)v(x)]\Big|_a^b$. We will show that $A$ is $\int_a^b v(x)u'(x)dx$ and $B$ is $\int_a^b u(x)v'(x)dx$ giving the formula.
|
||||
|
||||
We can compute $A$ by a change of variables with $x=u^{-1}(t)$ (so $u'(x)dx = dt$):
|
||||
|
||||
@@ -109,6 +116,7 @@ $$
|
||||
|
||||
$B$ is similar with the roles of $u$ and $v$ reversed.
|
||||
|
||||
----
|
||||
|
||||
Informally, the integration by parts formula is sometimes seen as $\int udv = uv - \int v du$, as well can be somewhat confusingly written as:
|
||||
|
||||
@@ -131,10 +139,10 @@ Consider the integral $\int_0^\pi x\sin(x) dx$. If we let $u=x$ and $dv=\sin(x)
|
||||
$$
|
||||
\begin{align*}
|
||||
\int_0^\pi x\sin(x) dx &= \int_0^\pi u dv\\
|
||||
&= uv\big|_0^\pi - \int_0^\pi v du\\
|
||||
&= x \cdot (-\cos(x)) \big|_0^\pi - \int_0^\pi (-\cos(x)) dx\\
|
||||
&= uv\Big|_0^\pi - \int_0^\pi v du\\
|
||||
&= x \cdot (-\cos(x)) \Big|_0^\pi - \int_0^\pi (-\cos(x)) dx\\
|
||||
&= \pi (-\cos(\pi)) - 0(-\cos(0)) + \int_0^\pi \cos(x) dx\\
|
||||
&= \pi + \sin(x)\big|_0^\pi\\
|
||||
&= \pi + \sin(x)\Big|_0^\pi\\
|
||||
&= \pi.
|
||||
\end{align*}
|
||||
$$
|
||||
@@ -166,8 +174,8 @@ Putting together gives:
|
||||
$$
|
||||
\begin{align*}
|
||||
\int_1^2 x \log(x) dx
|
||||
&= (\log(x) \cdot \frac{x^2}{2}) \big|_1^2 - \int_1^2 \frac{x^2}{2} \frac{1}{x} dx\\
|
||||
&= (2\log(2) - 0) - (\frac{x^2}{4})\big|_1^2\\
|
||||
&= (\log(x) \cdot \frac{x^2}{2}) \Big|_1^2 - \int_1^2 \frac{x^2}{2} \frac{1}{x} dx\\
|
||||
&= (2\log(2) - 0) - (\frac{x^2}{4})\Big|_1^2\\
|
||||
&= 2\log(2) - (1 - \frac{1}{4}) \\
|
||||
&= 2\log(2) - \frac{3}{4}.
|
||||
\end{align*}
|
||||
@@ -204,7 +212,7 @@ Were this a definite integral problem, we would have written:
|
||||
|
||||
|
||||
$$
|
||||
\int_a^b \log(x) dx = (x\log(x))\big|_a^b - \int_a^b dx = (x\log(x) - x)\big|_a^b.
|
||||
\int_a^b \log(x) dx = (x\log(x))\Big|_a^b - \int_a^b dx = (x\log(x) - x)\Big|_a^b.
|
||||
$$
|
||||
|
||||
##### Example
|
||||
@@ -214,14 +222,14 @@ Sometimes integration by parts is used two or more times. Here we let $u=x^2$ an
|
||||
|
||||
|
||||
$$
|
||||
\int_a^b x^2 e^x dx = (x^2 \cdot e^x)\big|_a^b - \int_a^b 2x e^x dx.
|
||||
\int_a^b x^2 e^x dx = (x^2 \cdot e^x)\Big|_a^b - \int_a^b 2x e^x dx.
|
||||
$$
|
||||
|
||||
But we can do $\int_a^b x e^xdx$ the same way:
|
||||
|
||||
|
||||
$$
|
||||
\int_a^b x e^x = (x\cdot e^x)\big|_a^b - \int_a^b 1 \cdot e^xdx = (xe^x - e^x)\big|_a^b.
|
||||
\int_a^b x e^x = (x\cdot e^x)\Big|_a^b - \int_a^b 1 \cdot e^xdx = (xe^x - e^x)\Big|_a^b.
|
||||
$$
|
||||
|
||||
Combining gives the answer:
|
||||
@@ -229,8 +237,8 @@ Combining gives the answer:
|
||||
|
||||
$$
|
||||
\int_a^b x^2 e^x dx
|
||||
= (x^2 \cdot e^x)\big|_a^b - 2( (xe^x - e^x)\big|_a^b ) =
|
||||
e^x(x^2 - 2x + 2) \big|_a^b.
|
||||
= (x^2 \cdot e^x)\Big|_a^b - 2( (xe^x - e^x)\Big|_a^b ) =
|
||||
e^x(x^2 - 2x + 2) \Big|_a^b.
|
||||
$$
|
||||
|
||||
In fact, it isn't hard to see that an integral of $x^m e^x$, $m$ a positive integer, can be handled in this manner. For example, when $m=10$, `SymPy` gives:
|
||||
@@ -247,14 +255,29 @@ The general answer is $\int x^n e^xdx = p(x) e^x$, where $p(x)$ is a polynomial
|
||||
##### Example
|
||||
|
||||
|
||||
The same technique is attempted for this integral, but ends differently. First in the following we let $u=\sin(x)$ and $dv=e^x dx$:
|
||||
The same technique is attempted for the integral of $e^x\sin(x)$, but ends differently.
|
||||
|
||||
First we let $u=\sin(x)$ and $dv=e^x dx$, then
|
||||
|
||||
$$
|
||||
du = \cos(x)dx \quad \text{and}\quad v = e^x.
|
||||
$$
|
||||
|
||||
So:
|
||||
|
||||
|
||||
$$
|
||||
\int e^x \sin(x)dx = \sin(x) e^x - \int \cos(x) e^x dx.
|
||||
$$
|
||||
|
||||
Now we let $u = \cos(x)$ and again $dv=e^x dx$:
|
||||
Now we let $u = \cos(x)$ and again $dv=e^x dx$, then
|
||||
|
||||
|
||||
$$
|
||||
du = -\sin(x)dx \quad \text{and}\quad v = e^x.
|
||||
$$
|
||||
|
||||
So:
|
||||
|
||||
|
||||
$$
|
||||
@@ -301,7 +324,7 @@ $$
|
||||
This is called a reduction formula as it reduces the problem from an integral with a power of $n$ to one with a power of $n - 2$, so could be repeated until the remaining indefinite integral required knowing either $\int \cos(x) dx$ (which is $-\sin(x)$) or $\int \cos(x)^2 dx$, which by a double angle formula application, is $x/2 + \sin(2x)/4$.
|
||||
|
||||
|
||||
`SymPy` is quite able to do this repeated bookkeeping. For example with $n=10$:
|
||||
`SymPy` is able and willing to do this repeated bookkeeping. For example with $n=10$:
|
||||
|
||||
|
||||
```{julia}
|
||||
@@ -350,7 +373,7 @@ Using right triangles to simplify, the last value $\cos(\sin^{-1}(x))$ can other
|
||||
The [trapezoid](http://en.wikipedia.org/wiki/Trapezoidal_rule) rule is an approximation to the definite integral like a Riemann sum, only instead of approximating the area above $[x_i, x_i + h]$ by a rectangle with height $f(c_i)$ (for some $c_i$), it uses a trapezoid formed by the left and right endpoints. That is, this area is used in the estimation: $(1/2)\cdot (f(x_i) + f(x_i+h)) \cdot h$.
|
||||
|
||||
|
||||
Even though we suggest just using `quadgk` for numeric integration, estimating the error in this approximation is still of some theoretical interest.
|
||||
Even though we suggest just using `quadgk` for numeric integration, estimating the error in this approximation is of theoretical interest.
|
||||
|
||||
|
||||
Recall, just using *either* $x_i$ or $x_{i-1}$ for $c_i$ gives an error that is "like" $1/n$, as $n$ gets large, though the exact rate depends on the function and the length of the interval.
|
||||
@@ -359,18 +382,18 @@ Recall, just using *either* $x_i$ or $x_{i-1}$ for $c_i$ gives an error that is
|
||||
This [proof](http://www.math.ucsd.edu/~ebender/20B/77_Trap.pdf) for the error estimate is involved, but is reproduced here, as it nicely integrates many of the theoretical concepts of integration discussed so far.
|
||||
|
||||
|
||||
First, for convenience, we consider the interval $x_i$ to $x_i+h$. The actual answer over this is just $\int_{x_i}^{x_i+h}f(x) dx$. By a $u$-substitution with $u=x-x_i$ this becomes $\int_0^h f(t + x_i) dt$. For analyzing this we integrate once by parts using $u=f(t+x_i)$ and $dv=dt$. But instead of letting $v=t$, we choose to add - as is our prerogative - a constant of integration $A$, so $v=t+A$:
|
||||
First, for convenience, we consider the interval $x_i$ to $x_i+h$. The actual answer over this is just $\int_{x_i}^{x_i+h}f(x) dx$. By a $u$-substitution with $u=x-x_i$ this becomes $\int_0^h f(t + x_i) dt$. For analyzing this we integrate once by parts using $u=f(t+x_i)$ and $dv=dt$. But instead of letting $v=t$, we choose to add--as is our prerogative--a constant of integration $A$, so $v=t+A$:
|
||||
|
||||
|
||||
$$
|
||||
\begin{align*}
|
||||
\int_0^h f(t + x_i) dt &= uv \big|_0^h - \int_0^h v du\\
|
||||
&= f(t+x_i)(t+A)\big|_0^h - \int_0^h (t + A) f'(t + x_i) dt.
|
||||
\int_0^h f(t + x_i) dt &= uv \Big|_0^h - \int_0^h v du\\
|
||||
&= f(t+x_i)(t+A)\Big|_0^h - \int_0^h (t + A) f'(t + x_i) dt.
|
||||
\end{align*}
|
||||
$$
|
||||
|
||||
|
||||
We choose $A$ to be $-h/2$, any constant is possible, for then the term $f(t+x_i)(t+A)\big|_0^h$ becomes $(1/2)(f(x_i+h) + f(x_i)) \cdot h$, or the trapezoid approximation. This means, the error over this interval - actual minus estimate - satisfies:
|
||||
We choose $A$ to be $-h/2$, any constant is possible, for then the term $f(t+x_i)(t+A)\Big|_0^h$ becomes $(1/2)(f(x_i+h) + f(x_i)) \cdot h$, or the trapezoid approximation. This means, the error over this interval - actual minus estimate - satisfies:
|
||||
|
||||
|
||||
$$
|
||||
@@ -392,7 +415,7 @@ Again we added a constant of integration, $B$, to $v$. The error becomes:
|
||||
|
||||
|
||||
$$
|
||||
\text{error}_i = -(\frac{(t+A)^2}{2} + B)f'(t+x_i)\big|_0^h + \int_0^h (\frac{(t+A)^2}{2} + B) \cdot f''(t+x_i) dt.
|
||||
\text{error}_i = -\left(\frac{(t+A)^2}{2} + B\right)f'(t+x_i)\Big|_0^h + \int_0^h \left(\frac{(t+A)^2}{2} + B\right) \cdot f''(t+x_i) dt.
|
||||
$$
|
||||
|
||||
With $A=-h/2$, $B$ is chosen so $(t+A)^2/2 + B = 0$ at endpoints, or $B=-h^2/8$. The error becomes
|
||||
@@ -406,14 +429,14 @@ Now, we assume the $\lvert f''(t)\rvert$ is bounded by $K$ for any $a \leq t \le
|
||||
|
||||
|
||||
$$
|
||||
\lvert \text{error}_i \rvert \leq K \int_0^h \lvert (\frac{(t-h/2)^2}{2} - \frac{h^2}{8}) \rvert dt.
|
||||
\lvert \text{error}_i \rvert \leq K \int_0^h \lVert \left(\frac{(t-h/2)^2}{2} - \frac{h^2}{8}\right) \rVert dt.
|
||||
$$
|
||||
|
||||
But what is the function in the integrand? Clearly it is a quadratic in $t$. Expanding gives $1/2 \cdot (t^2 - ht)$. This is negative over $[0,h]$ (and $0$ at these endpoints, so the integral above is just:
|
||||
|
||||
|
||||
$$
|
||||
\frac{1}{2}\int_0^h (ht - t^2)dt = \frac{1}{2} (\frac{ht^2}{2} - \frac{t^3}{3})\big|_0^h = \frac{h^3}{12}
|
||||
\frac{1}{2}\int_0^h (ht - t^2)dt = \frac{1}{2} \left(\frac{ht^2}{2} - \frac{t^3}{3}\right)\Big|_0^h = \frac{h^3}{12}
|
||||
$$
|
||||
|
||||
This gives the bound: $\vert \text{error}_i \rvert \leq K h^3/12$. The *total* error may be less, but is not more than the value found by adding up the error over each of the $n$ intervals. As our bound does not depend on the $i$, we have this sum satisfies:
|
||||
|
||||
Reference in New Issue
Block a user