@@ -27,7 +27,7 @@ Pkg.add("MeshIntegrals")
2727Usage of ** MeshIntegrals.jl** typically also involves using ** Meshes.jl** and ** Unitful.jl** ,
2828so all three packages will be used in this example.
2929
30- ``` julia
30+ ``` @example tutorial
3131using Meshes
3232using MeshIntegrals
3333using Unitful
@@ -56,7 +56,7 @@ f(x, y, z) = \frac{1}{\sqrt{1 + \cos^2(x/\text{m})}} ~ \Omega/\text{m}
5656Integrand functions are expected to provide a method that takes a single
5757` Meshes.Point ` argument, so this can be written in Julia as
5858
59- ``` julia
59+ ``` @example tutorial
6060# Integrand function that outputs in units of Ohms/meter
6161function f(p::Meshes.Point)
6262 x, y, z = Meshes.to(p)
6565```
6666
6767Alternatively, this could be written in the user-friendly notation
68- ``` julia
68+ ``` @example tutorial
6969f(x, y, z) = (1 / sqrt(1 + cos(x / u"m")^2)) * u"Ω/m"
7070f(p::Meshes.Point) = f(Meshes.to(p)...)
7171```
@@ -74,14 +74,14 @@ where the required `f(Meshes.Point)` method simply maps to the method `f(x, y, z
7474### Integrating
7575
7676This function can be integrated using recommended defaults simply by calling
77- ``` julia
77+ ``` @example tutorial
7878integral(f, curve) # -> Approximately 2π Ω
7979```
8080
8181The alias function ` lineintegral ` works for this geometry since it has one
8282parametric dimension. However, the aliases ` surfaceintegral ` and ` volumeintegral `
8383will throw an ` ArgumentError ` since the geometry is not a surface or volume.
84- ``` julia
84+ ``` @example tutorial
8585lineintegral(f, curve) # -> Approximately 2π Ω
8686
8787surfaceintegral(f, curve) # -> throws ArgumentError
@@ -93,7 +93,7 @@ An `IntegrationRule` with settings can also be manually specified. The following
9393example uses the adaptive Gauss-Kronrod method with a loosened absolute tolerance
9494setting of $10^{-4}~ \Omega$, which speeds up integration by sacrificing some
9595accuracy.
96- ``` julia
96+ ``` @example tutorial
9797integral(f, curve, GaussKronrod(atol = 1e-4u"Ω")) # -> Approximately (2π ± 1e-4) Ω
9898```
9999
@@ -102,7 +102,7 @@ The `integral` function and its aliases also support Julia's
102102code block to define a single-use anonymous function and then injects it as a
103103first argument to the preceding call. This can be useful if the integrand
104104function will not be used outside this integration call.
105- ``` julia
105+ ``` @example tutorial
106106integral(curve) do p
107107 x, y, z = Meshes.to(p)
108108 (1 / sqrt(1 + cos(x / u"m")^2)) * u"Ω/m"
0 commit comments