update 4 files
some typos.
This commit is contained in:
@@ -220,6 +220,7 @@ function euler(F, x0, xn, y0, n)
|
||||
xs[i + 1] = xs[i] + h
|
||||
ys[i + 1] = ys[i] + h * F(ys[i], xs[i])
|
||||
end
|
||||
xs[end] = xn
|
||||
linterp(xs, ys)
|
||||
end
|
||||
```
|
||||
@@ -288,7 +289,6 @@ We graphically compare our approximate answer with the exact one:
|
||||
|
||||
|
||||
```{julia}
|
||||
plot(f, x0, xn)
|
||||
𝒐ut = dsolve(D(u)(x) - F(u(x),x), u(x), ics = Dict(u(x0) => y0))
|
||||
plot(rhs(𝒐ut), x0, xn)
|
||||
plot!(f, x0, xn)
|
||||
@@ -348,7 +348,7 @@ The [Brachistochrone problem](http://www.unige.ch/~gander/Preprints/Ritz.pdf) wa
|
||||
imgfile = "figures/bead-game.jpg"
|
||||
caption = """
|
||||
|
||||
A child's bead game. What shape wire will produce the shortest time for a bed to slide from a top to the bottom?
|
||||
A child's bead game. What shape wire will produce the shortest time for a bead to slide from a top to the bottom?
|
||||
|
||||
"""
|
||||
#ImageFile(:ODEs, imgfile, caption)
|
||||
@@ -464,11 +464,11 @@ The race is on. An illustration of beads falling along a path, as can be seen, s
|
||||
ImageFile(imgfile, caption)
|
||||
```
|
||||
|
||||
Now, the natural question is which path is best? The solution can be [reduced](http://mathworld.wolfram.com/BrachistochroneProblem.html) to solving this equation for a positive $c$:
|
||||
Now, the natural question is which path is best? The solution can be [reduced](http://mathworld.wolfram.com/BrachistochroneProblem.html) to solving this equation for a positive $C$:
|
||||
|
||||
|
||||
$$
|
||||
1 + (y'(x))^2 = \frac{c}{y}, \quad c > 0.
|
||||
1 + (y'(x))^2 = \frac{C}{y}, \quad C > 0.
|
||||
$$
|
||||
|
||||
Reexpressing, this becomes:
|
||||
@@ -482,7 +482,7 @@ This is a separable equation and can be solved, but even `SymPy` has trouble wit
|
||||
|
||||
|
||||
$$
|
||||
x(u) = c\cdot u - \frac{c}{2}\sin(2u), \quad y(u) = \frac{c}{2}( 1- \cos(2u)), \quad 0 \leq u \leq U.
|
||||
x(u) = C\cdot u - \frac{C}{2}\sin(2u), \quad y(u) = \frac{C}{2}( 1- \cos(2u)), \quad 0 \leq u \leq U.
|
||||
$$
|
||||
|
||||
The values of $U$ and $c$ must satisfy $(x(U), y(U)) = (B, A)$.
|
||||
@@ -495,7 +495,7 @@ The equation can be written in terms of $y'=F(y,x)$, where
|
||||
|
||||
|
||||
$$
|
||||
F(y,x) = \sqrt{\frac{c-y}{y}}.
|
||||
F(y,x) = \sqrt{\frac{C-y}{y}}.
|
||||
$$
|
||||
|
||||
But as $y_0 = 0$, we immediately would have a problem with the first step, as there would be division by $0$.
|
||||
@@ -609,7 +609,7 @@ u_{n+1} &= u_n + h v_n,\\
|
||||
v_{n+1} &= v_n - h \cdot g/l \cdot \sin(u_n).
|
||||
\end{align*}
|
||||
|
||||
Here we need *two* initial conditions: one for the initial value $u(t_0)$ and the initial value of $u'(t_0)$. We have seen if we start at an angle $a$ and release the bob from rest, so $u'(0)=0$ we get a sinusoidal answer to the linearized model. What happens here? We let $a=1$, $L=5$ and $g=9.8$:
|
||||
Here we need *two* initial conditions: one for the initial value $u(t_0)$ and the initial value of $u'(t_0)$. We have seen if we start at an angle $a$ and release the bob from rest, so $u'(0)=0$ we get a sinusoidal answer to the linearized model. What happens here? We let $a=1$, $l=5$ and $g=9.8$:
|
||||
|
||||
|
||||
We write a function to solve this starting from $(x_0, y_0)$ and ending at $x_n$:
|
||||
@@ -624,12 +624,12 @@ function euler2(x0, xn, y0, yp0, n; g=9.8, l = 5)
|
||||
xs[i+1] = xs[i] + h
|
||||
us[i+1] = us[i] + h * vs[i]
|
||||
vs[i+1] = vs[i] + h * (-g / l) * sin(us[i])
|
||||
end
|
||||
linterp(xs, us)
|
||||
end
|
||||
linterp(xs, us)
|
||||
end
|
||||
```
|
||||
|
||||
Let's take $a = \pi/4$ as the initial angle, then the approximate solution should be $\pi/4\cos(\sqrt{g/l}x)$ with period $T = 2\pi\sqrt{l/g}$. We try first to plot then over 4 periods:
|
||||
Let's take $a = \pi/4$ as the initial angle, then the approximate solution should be $\pi/4\cos(\sqrt{g/l}x)$ with period $T = 2\pi\sqrt{l/g}$. We try first to plot them over 4 periods:
|
||||
|
||||
|
||||
```{julia}
|
||||
|
||||
@@ -88,7 +88,7 @@ Again, we can integrate to get an answer for any value $t$:
|
||||
|
||||
|
||||
\begin{align*}
|
||||
x(t) - x(t_0) &= \int_{t_0}^t \frac{dv}{dt} dt \\
|
||||
x(t) - x(t_0) &= \int_{t_0}^t \frac{dx}{dt} dt \\
|
||||
&= (v_0t + \frac{1}{2}a t^2 - at_0 t) |_{t_0}^t \\
|
||||
&= (v_0 - at_0)(t - t_0) + \frac{1}{2} a (t^2 - t_0^2).
|
||||
\end{align*}
|
||||
@@ -216,7 +216,7 @@ Let $F(y) = \int_{y_0}^y du/g(u)$, then a solution to the above is $F(y) = x - x
|
||||
[Toricelli's Law](http://tinyurl.com/hxvf3qp) describes the speed a jet of water will leave a vessel through an opening below the surface of the water. The formula is $v=\sqrt{2gh}$, where $h$ is the height of the water above the hole and $g$ the gravitational constant. This arises from equating the kinetic energy gained, $1/2 mv^2$ and potential energy lost, $mgh$, for the exiting water.
|
||||
|
||||
|
||||
An application of Torricelli's law is to describe the volume of water in a tank over time, $V(t)$. Imagine a cylinder of cross sectional area $A$ with a hole of cross sectional diameter $a$ at the bottom, Then $V(t) = A h(t)$, with $h$ giving the height. The change in volume over $\Delta t$ units of time must be given by the value $a v(t) \Delta t$, or
|
||||
An application of Torricelli's law is to describe the volume of water in a tank over time, $V(t)$. Imagine a cylinder of cross sectional area $A$ with a hole of cross sectional area $a$ at the bottom, Then $V(t) = A h(t)$, with $h$ giving the height. The change in volume over $\Delta t$ units of time must be given by the value $a v(t) \Delta t$, or
|
||||
|
||||
|
||||
$$
|
||||
@@ -511,7 +511,7 @@ $$
|
||||
Here, the solution is in terms of sines and cosines, with period given by $T = 2\pi/\sqrt{k} = 2\pi\cdot\sqrt{l/g}$. The answer does not depend on the mass, $m$, of the bob nor the amplitude of the motion, provided the small-angle approximation is valid.
|
||||
|
||||
|
||||
If we pull the bob back an angle $a$ and release it then the initial conditions are $\theta(0) = a$ and $\theta'(a) = 0$. This gives the solution:
|
||||
If we pull the bob back an angle $a$ and release it then the initial conditions are $\theta(0) = a$ and $\theta'(0) = 0$. This gives the solution:
|
||||
|
||||
|
||||
```{julia}
|
||||
@@ -652,10 +652,12 @@ Furthermore, we can solve for $t$ from $x(t)$, to get an equation describing $y(
|
||||
```{julia}
|
||||
#| hold: true
|
||||
@syms x0::real y0::real v0::real alpha::real g::real
|
||||
@syms t x u()
|
||||
a1 = dsolve(D2(u)(x) ~ 0, u(x), ics=Dict(u(0) => x0, D(u)(0) => v0 * cos(alpha)))
|
||||
a2 = dsolve(D2(u)(x) ~ -g, u(x), ics=Dict(u(0) => y0, D(u)(0) => v0 * sin(alpha)))
|
||||
ts = solve(t - rhs(a1), x)[1]
|
||||
@syms t::positive x u()
|
||||
Dₜ = Differential(t)
|
||||
D2ₜ = Dₜ ∘ Dₜ
|
||||
a1 = dsolve(D2ₜ(u)(t) ~ 0, u(t), ics=Dict(u(0) => x0, Dₜ(u)(0) => v0 * cos(alpha)))
|
||||
a2 = dsolve(D2ₜ(u)(t) ~ -g, u(t), ics=Dict(u(0) => y0, Dₜ(u)(0) => v0 * sin(alpha)))
|
||||
ts = solve(x - rhs(a1), t)[1]
|
||||
y = simplify(rhs(a2)(t => ts))
|
||||
sympy.Poly(y, x).coeffs()
|
||||
```
|
||||
@@ -676,9 +678,9 @@ We now attempt to solve these.
|
||||
|
||||
|
||||
```{julia}
|
||||
@syms alpha::real, γ::postive, t::positive, v()
|
||||
@syms alpha::real, γ::postive, v()
|
||||
@syms x_0::real y_0::real v_0::real
|
||||
Dₜ = Differential(t)
|
||||
|
||||
eq₁ = Dₜ(Dₜ(u))(t) ~ - γ * Dₜ(u)(t)
|
||||
eq₂ = Dₜ(Dₜ(v))(t) ~ -g - γ * Dₜ(v)(t)
|
||||
|
||||
@@ -931,7 +933,7 @@ The differential equation with boundary values
|
||||
|
||||
|
||||
$$
|
||||
\frac{r^2 \frac{dc}{dr}}{dr} = 0, \quad c(1)=2, c(10)=1,
|
||||
\frac{d(r^2 \frac{dc}{dr})}{dr} = 0, \quad c(1)=2, c(10)=1,
|
||||
$$
|
||||
|
||||
can be solved with `SymPy`. What is the value of $c(5)$?
|
||||
|
||||
Reference in New Issue
Block a user