update
some typos.
This commit is contained in:
@@ -129,7 +129,7 @@ This problem can also be solved using a bracketing method. The package has both
|
||||
|
||||
```{julia}
|
||||
u0 = (1.0, 2.0)
|
||||
prob = NonlinearProblem(f, u0)
|
||||
prob = IntervalNonlinearProblem(f, u0)
|
||||
```
|
||||
|
||||
And
|
||||
@@ -149,7 +149,7 @@ Incorporating parameters is readily done. For example to solve $f(x) = \cos(x) -
|
||||
f(x, p) = @. cos(x) - x/p
|
||||
u0 = (0, pi/2)
|
||||
p = 2
|
||||
prob = NonlinearProblem(f, u0, p)
|
||||
prob = IntervalNonlinearProblem(f, u0, p)
|
||||
solve(prob, Bisection())
|
||||
```
|
||||
|
||||
@@ -159,7 +159,7 @@ The *insignificant* difference in stopping criteria used by `NonlinearSolve` and
|
||||
|
||||
|
||||
```{julia}
|
||||
an = solve(NonlinearProblem{false}(f, u0, p), Bisection())
|
||||
an = solve(IntervalNonlinearProblem{false}(f, u0, p), Bisection())
|
||||
ar = solve(Roots.ZeroProblem(f, u0), Roots.Bisection(); p=p)
|
||||
nextfloat(an[]) == ar, f(an[], p), f(ar, p)
|
||||
```
|
||||
@@ -418,7 +418,7 @@ prob = OptimizationProblem(sys, u0, p; grad=true, hess=true)
|
||||
soln = solve(prob, LBFGS())
|
||||
```
|
||||
|
||||
We used an initial guess of $x=4$ above. The `LBFGS` method is a computationally efficient modification of the Broyden-Fletcher-Goldfarb-Shanno algorithm ... It is a quasi-Newton method that updates an approximation to the Hessian using past approximations as well as the gradient." On this problem it performs similarly to `Newton`, though in general may be preferable for higher-dimensional problems.
|
||||
We used an initial guess of $x=4$ above. The `LBFGS` method is a computationally efficient modification of the Broyden-Fletcher-Goldfarb-Shanno algorithm. It is a quasi-Newton method that updates an approximation to the Hessian using past approximations as well as the gradient. On this problem it performs similarly to `Newton`, though in general may be preferable for higher-dimensional problems.
|
||||
|
||||
|
||||
### Two dimensional
|
||||
@@ -515,7 +515,7 @@ For a simple definite integral, such as $\int_0^\pi \sin(x)dx$, we have:
|
||||
|
||||
```{julia}
|
||||
f(x, p) = sin(x)
|
||||
prob = IntegralProblem(f, 0.0, pi)
|
||||
prob = IntegralProblem(f, 0.0, 1pi)
|
||||
soln = solve(prob, QuadGKJL())
|
||||
```
|
||||
|
||||
@@ -546,7 +546,7 @@ The `Integrals` solution is a bit more verbose, but it is more flexible. For exa
|
||||
|
||||
```{julia}
|
||||
f(x, p) = sin.(x)
|
||||
prob = IntegralProblem(f, [0.0], [pi])
|
||||
prob = IntegralProblem(f, [0.0], [1pi])
|
||||
soln = solve(prob, HCubatureJL())
|
||||
```
|
||||
|
||||
@@ -574,7 +574,7 @@ Consider $d/dp \int_0^\pi \sin(px) dx$. We can do this integral directly to get
|
||||
\frac{d}{dp} \int_0^\pi \sin(px)dx
|
||||
&= \frac{d}{dp}\left( \frac{-1}{p} \cos(px)\Big\rvert_0^\pi\right)\\
|
||||
&= \frac{d}{dp}\left( -\frac{\cos(p\cdot\pi)-1}{p}\right)\\
|
||||
&= \frac{\cos(p\cdot \pi) - 1)}{p^2} + \frac{\pi\cdot\sin(p\cdot\pi)}{p}
|
||||
&= \frac{\cos(p\cdot \pi) - 1}{p^2} + \frac{\pi\cdot\sin(p\cdot\pi)}{p}
|
||||
\end{align*}
|
||||
|
||||
Using `Integrals` with `QuadGK` we have:
|
||||
@@ -583,7 +583,7 @@ Using `Integrals` with `QuadGK` we have:
|
||||
```{julia}
|
||||
f(x, p) = sin(p*x)
|
||||
function ∫sinpx(p)
|
||||
prob = IntegralProblem(f, 0.0, pi, p)
|
||||
prob = IntegralProblem(f, 0.0, 1pi, p)
|
||||
solve(prob, QuadGKJL())
|
||||
end
|
||||
```
|
||||
@@ -614,7 +614,7 @@ The power of a common interface is the ability to swap backends and the uniformi
|
||||
#### $f: R^n \rightarrow R$
|
||||
|
||||
|
||||
The area under a surface generated by $z=f(x,y)$ over a rectangular region $[a,b]\times[c,d]$ can be readily computed. The two coding implementations require $f$ to be expressed as a function of a vector–*and* a parameter–and the interval to be expressed using two vectors, one for the left endpoints (`[a,c]`) and on for the right endpoints (`[b,d]`).
|
||||
The area under a surface generated by $z=f(x,y)$ over a rectangular region $[a,b]\times[c,d]$ can be readily computed. The two coding implementations require $f$ to be expressed as a function of a vector–*and* a parameter–and the interval to be expressed using two vectors, one for the left endpoints (`[a,c]`) and one for the right endpoints (`[b,d]`).
|
||||
|
||||
|
||||
For example, the area under the function $f(x,y) = 1 + x^2 + 2y^2$ over $[-1/2, 1/2] \times [-1,1]$ is computed by:
|
||||
@@ -664,7 +664,7 @@ To compute this transformed integral, we might have:
|
||||
```{julia}
|
||||
function vol_sphere(ρ)
|
||||
f(rθ, p) = sqrt(ρ^2 - rθ[1]^2) * rθ[1]
|
||||
ls = [0,0]
|
||||
ls = [0.0,0.0]
|
||||
rs = [ρ, 2pi]
|
||||
prob = IntegralProblem(f, ls, rs)
|
||||
solve(prob, HCubatureJL())
|
||||
@@ -677,7 +677,7 @@ If it is possible to express the region to integrate as $G(R)$ where $R$ is a re
|
||||
|
||||
|
||||
$$
|
||||
\iint_{G(R)} f(x) dA = \iint_R (f\circ G)(u) |det(J_G(u)| dU
|
||||
\iint_{G(R)} f(x) dA = \iint_R (f\circ G)(u) |det(J_G(u))| dU
|
||||
$$
|
||||
|
||||
turns the integral into the non-rectangular domain $G(R)$ into one over the rectangular domain $R$. The key is to *identify* $G$ and to compute the Jacobian. The latter is simply accomplished with `ForwardDiff.jacobian`.
|
||||
|
||||
Reference in New Issue
Block a user