many edits
This commit is contained in:
@@ -147,8 +147,8 @@ Incorporating parameters is readily done. For example to solve $f(x) = \cos(x) -
|
||||
|
||||
```{julia}
|
||||
f(x, p) = @. cos(x) - x/p
|
||||
u0 = (0, pi/2)
|
||||
p = 2
|
||||
u0 = (0.0, pi/2)
|
||||
p = 2.0
|
||||
prob = IntervalNonlinearProblem(f, u0, p)
|
||||
solve(prob, Bisection())
|
||||
```
|
||||
@@ -410,6 +410,7 @@ could be similarly approached:
|
||||
y = Area/x # from A = xy
|
||||
P = 2x + 2y
|
||||
@named sys = OptimizationSystem(P, [x], [Area]);
|
||||
sys = structural_simplify(sys)
|
||||
|
||||
u0 = [x => 4.0]
|
||||
p = [Area => 25.0]
|
||||
@@ -730,6 +731,6 @@ For a trivial example, we have:
|
||||
|
||||
```{julia}
|
||||
f(x, p) = [x[1], x[2]^2]
|
||||
prob = IntegralProblem(f, [0,0],[3,4], nout=2)
|
||||
prob = IntegralProblem(f, [0,0],[3,4])
|
||||
solve(prob, HCubatureJL())
|
||||
```
|
||||
|
||||
@@ -34,7 +34,6 @@ We begin by loading the main package and the `norm` function from the standard `
|
||||
```{julia}
|
||||
using GLMakie
|
||||
import LinearAlgebra: norm
|
||||
|
||||
```
|
||||
|
||||
The `Makie` developers have workarounds for the delayed time to first plot, but without utilizing these the time to load the package is lengthy.
|
||||
@@ -317,13 +316,13 @@ xs = 1:5
|
||||
pts = Point2.(xs, xs)
|
||||
scatter(pts)
|
||||
annotations!("Point " .* string.(xs), pts;
|
||||
textsize = 50 .- 2*xs,
|
||||
fontsize = 50 .- 2*xs,
|
||||
rotation = 2pi ./ xs)
|
||||
|
||||
current_figure()
|
||||
```
|
||||
|
||||
The graphic shows that `textsize` adjusts the displayed size and `rotation` adjusts the orientation. (The graphic also shows a need to manually override the limits of the `y` axis, as the `Point 5` is chopped off; the `ylims!` function to do so will be shown later.)
|
||||
The graphic shows that `fontsize` adjusts the displayed size and `rotation` adjusts the orientation. (The graphic also shows a need to manually override the limits of the `y` axis, as the `Point 5` is chopped off; the `ylims!` function to do so will be shown later.)
|
||||
|
||||
|
||||
Attributes for `text`, among many others, include:
|
||||
@@ -331,7 +330,7 @@ Attributes for `text`, among many others, include:
|
||||
|
||||
* `align` Specify the text alignment through `(:pos, :pos)`, where `:pos` can be `:left`, `:center`, or `:right`.
|
||||
* `rotation` to indicate how the text is to be rotated
|
||||
* `textsize` the font point size for the text
|
||||
* `fontsize` the font point size for the text
|
||||
* `font` to indicate the desired font
|
||||
|
||||
|
||||
@@ -1151,5 +1150,3 @@ current_figure()
|
||||
```
|
||||
|
||||
The slider value is "lifted" by its `value` component, as shown. Otherwise, the above is fairly similar to just using an observable for `h`.
|
||||
|
||||
|
||||
|
||||
@@ -1,21 +1,8 @@
|
||||
---
|
||||
format:
|
||||
html:
|
||||
header-includes: |
|
||||
<script src="https://cdn.plot.ly/plotly-2.11.0.min.js"></script>
|
||||
---
|
||||
|
||||
# JavaScript based plotting libraries
|
||||
|
||||
|
||||
{{< include ../_common_code.qmd >}}
|
||||
|
||||
:::{.callout-note}
|
||||
## Plotly and Quarto
|
||||
There are some oddities working with `Plotly`, `Julia`, and Quarto that require some hand editing of an HTML file. If the images are not shown below, there was an oversight. A reported issue would be welcome.
|
||||
|
||||
:::
|
||||
|
||||
This section uses this add-on package:
|
||||
|
||||
|
||||
@@ -23,12 +10,6 @@ This section uses this add-on package:
|
||||
using PlotlyLight
|
||||
```
|
||||
|
||||
```{julia}
|
||||
#| echo: false
|
||||
PlotlyLight.src!(:none)
|
||||
nothing
|
||||
```
|
||||
|
||||
To avoid a dependence on the `CalculusWithJulia` package, we load two utility packages:
|
||||
|
||||
|
||||
|
||||
@@ -501,10 +501,11 @@ d, r = polynomial_coeffs(ex, (x,))
|
||||
r
|
||||
```
|
||||
|
||||
To find the degree of a monomial expression, the `degree` function is available. Here it is applied to each monomial in `d`:
|
||||
To find the degree of a monomial expression, the `degree` function is available, though not exported. Here it is applied to each monomial in `d`:
|
||||
|
||||
|
||||
```{julia}
|
||||
import Symbolics: degree
|
||||
[degree(k) for (k,v) ∈ d]
|
||||
```
|
||||
|
||||
@@ -773,6 +774,11 @@ Symbolics.jacobian(eqs, [x,y])
|
||||
|
||||
### Integration
|
||||
|
||||
::: {.callout-note}
|
||||
#### This area is very much WIP
|
||||
|
||||
The use of `SymbolicNumericIntegration` below is currently broken.
|
||||
:::
|
||||
|
||||
The `SymbolicNumericIntegration` package provides a means to integrate *univariate* expressions through its `integrate` function.
|
||||
|
||||
@@ -904,18 +910,27 @@ v = factor_rational(u)
|
||||
|
||||
As such, the integrals have numeric differences from their mathematical counterparts:
|
||||
|
||||
::: {.callout-note}
|
||||
#### Errors ahead
|
||||
|
||||
These last commands are note being executed, as there are errors.
|
||||
:::
|
||||
|
||||
|
||||
```{julia}
|
||||
a,b,c = integrate(u)
|
||||
#| eval: false
|
||||
a,b,c = integrate(u) # not
|
||||
```
|
||||
|
||||
We can see a bit of how much through the following, which needs a tolerance set to identify the rational numbers of the mathematical factorization correctly:
|
||||
|
||||
|
||||
```{julia}
|
||||
#| eval: false
|
||||
cs = [first(arguments(term)) for term ∈ arguments(a)] # pick off coefficients
|
||||
```
|
||||
|
||||
```{julia}
|
||||
rationalize.(cs; tol=1e-8)
|
||||
#| eval: false
|
||||
rationalize.(cs[2:end]; tol=1e-8)
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user