use quarto, not Pluto to render pages
This commit is contained in:
@@ -18,7 +18,7 @@ const frontmatter = (
|
||||
description = "Calculus with Julia: Fundamental Theorem or Calculus",
|
||||
tags = ["CalculusWithJulia", "integrals", "fundamental theorem or calculus"],
|
||||
);
|
||||
fig_size = (600, 400)
|
||||
fig_size = (800, 600)
|
||||
nothing
|
||||
```
|
||||
|
||||
@@ -107,11 +107,15 @@ definite integral and the derivative we have
|
||||
```math
|
||||
\begin{align*}
|
||||
F'(x) = & \frac{d}{dx} \int_a^x f(u) du \\
|
||||
& \approx \frac{F(x) - F(x-h)}{h} = \frac{\int_a^x f(u) du - \int_a^{x-h} f(u) du}{h}\\
|
||||
& \approx \frac{\left(f(a + 1h)h + f(a + 2h)h + \cdots + f(a + (M-1)h)h + f(a + Mh)h\right)}{h} -
|
||||
& \approx \frac{F(x) - F(x-h)}{h} \\
|
||||
&= \frac{\int_a^x f(u) du - \int_a^{x-h} f(u) du}{h}\\
|
||||
& \approx \frac{\left(f(a + 1h)h + f(a + 2h)h + \cdots + f(a + (M-1)h)h + f(a + Mh)h\right)}{h}\\
|
||||
&- \quad
|
||||
\frac{\left(f(a + 1h)h + f(a + 2h)h + \cdots + f(a + (M-1)h)h \right)}{h} \\
|
||||
& = \left(f(a + 1h) + f(a + 2h) + \cdots + f(a + (M-1)h) + f(a + Mh)\right) -
|
||||
\left(f(a + 1h) + f(a + 2h) + \cdots + f(a + (M-1)h) \right)
|
||||
& = \left(f(a + 1h) + \quad f(a + 2h) + \cdots + f(a + (M-1)h) + f(a + Mh)\right)\\
|
||||
&- \quad
|
||||
\left(f(a + 1h) + f(a + 2h) + \cdots + f(a + (M-1)h) \right) \\
|
||||
&= f(a + Mh).
|
||||
\end{align*}
|
||||
```
|
||||
|
||||
@@ -152,20 +156,15 @@ With these heuristics, we now have:
|
||||
|
||||
|
||||
|
||||
```julia; echo=false
|
||||
note(L"""
|
||||
|
||||
In Part 1, the integral $F(x) = \int_a^x f(u) du$ is defined for any
|
||||
Riemann integrable function, $f$. If the function is not continuous,
|
||||
then it is true the $F$ will be continuous, but it need not be true
|
||||
that it is differentiable at all points in $(a,b)$. Forming $F$ from
|
||||
$f$ is a form of *smoothing*. It makes a continuous function out of an
|
||||
integrable one, a differentiable function from a continuous one, and a
|
||||
$k+1$-times differentiable function from a $k$-times differentiable
|
||||
one.
|
||||
|
||||
""")
|
||||
```
|
||||
!!! note
|
||||
In Part 1, the integral $F(x) = \int_a^x f(u) du$ is defined for any
|
||||
Riemann integrable function, $f$. If the function is not continuous,
|
||||
then it is true the $F$ will be continuous, but it need not be true
|
||||
that it is differentiable at all points in $(a,b)$. Forming $F$ from
|
||||
$f$ is a form of *smoothing*. It makes a continuous function out of an
|
||||
integrable one, a differentiable function from a continuous one, and a
|
||||
$k+1$-times differentiable function from a $k$-times differentiable
|
||||
one.
|
||||
|
||||
## Using the fundamental theorem of calculus to evaluate definite integrals
|
||||
|
||||
@@ -616,7 +615,7 @@ We need to figure out when this is $0$. For that, we use some numeric math.
|
||||
```julia;
|
||||
F(x) = exp(-x^2) * quadgk(t -> exp(t^2), 0, x)[1]
|
||||
Fp(x) = -2x*F(x) + 1
|
||||
cps = find_zeros(Fp, -4,4)
|
||||
cps = find_zeros(Fp, -4, 4)
|
||||
```
|
||||
|
||||
We could take a second derivative to characterize. For that we use
|
||||
@@ -714,14 +713,8 @@ dx``, using linearity, as ``\int_0^{x_0} f(x) dx +
|
||||
\int_{x_{n-1}}^{x_n}f(x)dx``. Then all but the last term could be
|
||||
stored from the previous steps of Newton's method. The last term presumably being less costly as it would typically involve a small interval.
|
||||
|
||||
```julia;echo=false
|
||||
note("""
|
||||
The trick using a closure relies on an internal way of accessing elements in a closure. The same trick could be implemented many different ways which aren't reliant on undocumented internals, this approach was just a tad more convenient. It shouldn't be copied for work intended for distribution, as the internals may change without notice or deprecation.
|
||||
""")
|
||||
```
|
||||
|
||||
|
||||
|
||||
!!! note
|
||||
The trick using a closure relies on an internal way of accessing elements in a closure. The same trick could be implemented many different ways which aren't reliant on undocumented internals, this approach was just a tad more convenient. It shouldn't be copied for work intended for distribution, as the internals may change without notice or deprecation.
|
||||
|
||||
|
||||
##### Example
|
||||
@@ -898,8 +891,8 @@ choices = [
|
||||
"``-x^2\\cos(x) + 2x\\sin(x)``",
|
||||
"``-x^2\\cos(x) + 2x\\sin(x) + 2\\cos(x)``"
|
||||
]
|
||||
ans = 3
|
||||
radioq(choices, ans, keep_order=true)
|
||||
answ = 3
|
||||
radioq(choices, answ, keep_order=true)
|
||||
```
|
||||
|
||||
|
||||
@@ -914,8 +907,8 @@ choices = [
|
||||
"``-(1+x) e^{-x}``",
|
||||
"``-(1 + x + x^2) e^{-x}``"
|
||||
]
|
||||
ans = 3
|
||||
radioq(choices, ans, keep_order=true)
|
||||
answ = 3
|
||||
radioq(choices, answ, keep_order=true)
|
||||
```
|
||||
|
||||
###### Question
|
||||
@@ -978,8 +971,8 @@ choices = [
|
||||
L"Between $0$ and $1$",
|
||||
L"Between $1$ and $5$"
|
||||
]
|
||||
ans = 4
|
||||
radioq(choices, ans, keep_order=true)
|
||||
answ = 4
|
||||
radioq(choices, answ, keep_order=true)
|
||||
```
|
||||
|
||||
* The position of the particle is $0$ at $t=0$ and:
|
||||
@@ -990,8 +983,8 @@ choices = [
|
||||
"``t=2``",
|
||||
"``t=3``",
|
||||
"``t=4``"]
|
||||
ans = 2
|
||||
radioq(choices, ans, keep_order=true)
|
||||
answ = 2
|
||||
radioq(choices, answ, keep_order=true)
|
||||
```
|
||||
|
||||
* The position of the particle at time $t=5$ is?
|
||||
@@ -1010,8 +1003,8 @@ L"The position, $x(t)$, increases with a slope of $1$",
|
||||
L"The position, $x(t)$, increases quadratically from $-1/2$ to $1$",
|
||||
L"The position, $x(t)$, increases quadratically from $0$ to $1$"
|
||||
]
|
||||
ans = 2
|
||||
radioq(choices, ans, keep_order=true)
|
||||
answ = 2
|
||||
radioq(choices, answ, keep_order=true)
|
||||
```
|
||||
|
||||
###### Question
|
||||
@@ -1024,8 +1017,8 @@ choices = [
|
||||
"``-f(t-10)``",
|
||||
"``f(t) - f(t-10)``"
|
||||
]
|
||||
ans = 3
|
||||
radioq(choices, ans, keep_order=true)
|
||||
answ = 3
|
||||
radioq(choices, answ, keep_order=true)
|
||||
```
|
||||
|
||||
###### Question
|
||||
@@ -1037,8 +1030,8 @@ choices = [
|
||||
"At a critical point",
|
||||
L"At the endpoint $0$",
|
||||
L"At the endpoint $1$"]
|
||||
ans = 3
|
||||
radioq(choices, ans, keep_order=true)
|
||||
answ = 3
|
||||
radioq(choices, answ, keep_order=true)
|
||||
```
|
||||
|
||||
###### Question
|
||||
@@ -1058,8 +1051,8 @@ choices = [
|
||||
"The derivative of ``F`` is ``f``, so by the second derivative test, ``x=7``",
|
||||
"The graph of ``f`` has relative maxima at ``x=2,6,8``"
|
||||
]
|
||||
answer = 2
|
||||
radioq(choices, answer)
|
||||
answ = 2
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
|
||||
@@ -1073,8 +1066,8 @@ L"At a critical point, either $0$ or $1$",
|
||||
L"At a critical point, $1/2$",
|
||||
L"At the endpoint $0$",
|
||||
L"At the endpoint $1$"]
|
||||
ans = 2
|
||||
radioq(choices, ans, keep_order=true)
|
||||
answ = 2
|
||||
radioq(choices, answ, keep_order=true)
|
||||
```
|
||||
|
||||
###### Question
|
||||
@@ -1122,8 +1115,8 @@ choices = [
|
||||
"``A(x) / \\lvert Tx \\rvert = A'(x)``",
|
||||
"``A(x) \\cdot A'(x) = f(x)``"
|
||||
]
|
||||
ans = 1
|
||||
radioq(choices, ans, keep_order=true)
|
||||
answ = 1
|
||||
radioq(choices, answ, keep_order=true)
|
||||
```
|
||||
|
||||
The fact that $\lvert PT \rvert$ is tangent says what in terms of $f(x)$, $A(x)$ and $A'(x)$?
|
||||
@@ -1135,8 +1128,8 @@ choices = [
|
||||
"``A(x) / \\lvert Tx \\rvert = A'(x)``",
|
||||
"``A(x) \\cdot A'(x) = f(x)``"
|
||||
]
|
||||
ans = 2
|
||||
radioq(choices, ans, keep_order=true)
|
||||
answ = 2
|
||||
radioq(choices, answ, keep_order=true)
|
||||
```
|
||||
|
||||
Solving, we get:
|
||||
@@ -1148,8 +1141,8 @@ choices = [
|
||||
"``A'(x) = A(x)``",
|
||||
"``A(x) = f(x)``"
|
||||
]
|
||||
ans = 1
|
||||
radioq(choices, ans)
|
||||
answ = 1
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
###### Question
|
||||
@@ -1160,20 +1153,20 @@ According to [Bressoud](http://www.math.harvard.edu/~knill/teaching/math1a_2011/
|
||||
choices = [
|
||||
L"Part 1: $[\int_a^x f(u) du]' = f$",
|
||||
L"Part 2: $\int_a^b f(u) du = F(b)- F(a)$."]
|
||||
ans=1
|
||||
radioq(choices, ans, keep_order=true)
|
||||
answ=1
|
||||
radioq(choices, answ, keep_order=true)
|
||||
```
|
||||
|
||||
|
||||
## More on SymPy's `integrate`
|
||||
|
||||
Finding the value of a definite integral through the fundamental theorem of calculus relies on the algebraic identification of an antiderivative. This is difficult to do by hand and by computer, and is complicated by the fact that not every [elementary ](https://en.wikipedia.org/wiki/Elementary_function)function has an elementary antiderivative.
|
||||
`SymPy`'s documentation on integration indicates that several different means to integrate a function are used internally. As it is of interest here, it is copied with just minor edits below:
|
||||
`SymPy`'s documentation on integration indicates that several different means to integrate a function are used internally. As it is of interest here, it is copied with just minor edits below (from an older version of SymPy):
|
||||
|
||||
|
||||
#### Simple heuristics (based on pattern matching and integral table):
|
||||
|
||||
* most frequently used functions (e.g. polynomials, products of trigonemetric functions)
|
||||
* most frequently used functions (e.g. polynomials, products of trigonometric functions)
|
||||
|
||||
#### Integration of rational functions:
|
||||
|
||||
@@ -1250,4 +1243,4 @@ Finding the value of a definite integral through the fundamental theorem of calc
|
||||
is to implement enough of the Risch and Meijer G-function methods
|
||||
so that this can be deleted.
|
||||
Setting `heurisch=true` will cause `integrate` to use only this
|
||||
method. Set `heurisch=false to not use it.
|
||||
method. Set `heurisch=false` to not use it.
|
||||
|
||||
Reference in New Issue
Block a user