Skip to content

Commit

Permalink
rewritten in some places
Browse files Browse the repository at this point in the history
  • Loading branch information
h-milz committed Dec 8, 2024
1 parent 6e878c5 commit 0a6ad6d
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions docs/scipy-integrate.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,19 @@
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Motivation\n",
"\n",
"Why would we need multiple integration algorithms at all? The main reason is that all of these have their individual uses in numerical math. quad for example can handle integrands that have singularities which simpson cannot, while simpson is good enough for simple polynomials, if you choose the number of steps carefully. \n",
"\n",
"In any case, before you use numerical integration, be sure you understand the algorithms' individual strengths, weaknesses, and limits. A good starting point is the paper found in https://www.genivia.com/qthsh.html, from which all of these algorithms were ported. \n",
"\n",
"Also note that these algorithms do not support complex numbers. "
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -242,7 +255,7 @@
"\n",
"`scipy`: https://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.quad.html \n",
"\n",
"Implements an optimized Tanh-Sinh, Sinh-Sinh and Exp-Sinh quadrature algorithm, ported from code found in https://www.genivia.com/qthsh.html. It is especially applied where singularities or infinite derivatives exist at one or both endpoints. The method uses hyperbolic functions in a change of variables to transform an integral on the interval x ∈ (−1, 1) to an integral on the entire real line t ∈ (−∞, ∞), the two integrals having the same value. After this transformation, the integrand decays with a double exponential rate, and thus, this method is also known as the double exponential (DE) formula (https://en.wikipedia.org/wiki/Tanh-sinh_quadrature). Please check the paper above for a comprehensive discussion.\n",
"Implements an optimized Tanh-Sinh, Sinh-Sinh and Exp-Sinh quadrature algorithm. It is especially applied where singularities or infinite derivatives exist at one or both endpoints. The method uses hyperbolic functions in a change of variables to transform an integral on the interval x ∈ (−1, 1) to an integral on the entire real line t ∈ (−∞, ∞), the two integrals having the same value. After this transformation, the integrand decays with a double exponential rate, and thus, this method is also known as the double exponential (DE) formula (https://en.wikipedia.org/wiki/Tanh-sinh_quadrature). \n",
"\n",
"The function takes three to five positional arguments: \n",
"\n",
Expand Down Expand Up @@ -290,10 +303,9 @@
"\n",
"`scipy`: https://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.romberg.html \n",
"\n",
"Implements the Romberg quadrature algorithm, ported from code found in https://www.genivia.com/qthsh.html. Romberg's method is a Newton–Cotes formula – it evaluates the integrand at equally spaced points. The integrand must have continuous derivatives, though fairly good results may be obtained if only a few derivatives exist. If it is possible to evaluate the integrand at unequally spaced points, then other methods such as Gaussian quadrature and Clenshaw–Curtis quadrature are generally more accurate (https://en.wikipedia.org/wiki/Romberg%27s_method). Please check the paper above for a comprehensive discussion.\n",
"Implements the Romberg quadrature algorithm. Romberg's method is a Newton–Cotes formula – it evaluates the integrand at equally spaced points. The integrand must have continuous derivatives, though fairly good results may be obtained if only a few derivatives exist. If it is possible to evaluate the integrand at unequally spaced points, then other methods such as Gaussian quadrature and Clenshaw–Curtis quadrature are generally more accurate (https://en.wikipedia.org/wiki/Romberg%27s_method). \n",
"\n",
"Please note: This function is deprecated as of SciPy 1.12.0 and will be removed in SciPy 1.15.0. Please use scipy.integrate.quad instead. \n",
"Please note that this function does not support complex numbers. \n",
"\n",
"The function takes three to five positional arguments: \n",
"\n",
Expand Down Expand Up @@ -336,9 +348,7 @@
"\n",
"`scipy`: https://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.simpson.html \n",
"\n",
"Implements an Adaptive Simpson quadrature algorithm, ported from code found in https://www.genivia.com/qthsh.html. Adaptive Simpson's method, also called adaptive Simpson's rule, is a method of numerical integration proposed by G.F. Kuncir in 1962. It is probably the first recursive adaptive algorithm for numerical integration to appear in print, although more modern adaptive methods based on Gauss–Kronrod quadrature and Clenshaw–Curtis quadrature are now generally preferred (https://en.wikipedia.org/wiki/Adaptive_Simpson%27s_method). Please check the paper above for a comprehensive discussion.\n",
"\n",
"Please note that this function does not support complex numbers. \n",
"Implements an Adaptive Simpson quadrature algorithm. Adaptive Simpson's method, also called adaptive Simpson's rule, is a method of numerical integration proposed by G.F. Kuncir in 1962. It is probably the first recursive adaptive algorithm for numerical integration to appear in print, although more modern adaptive methods based on Gauss–Kronrod quadrature and Clenshaw–Curtis quadrature are now generally preferred (https://en.wikipedia.org/wiki/Adaptive_Simpson%27s_method). \n",
"\n",
"The function takes three to five positional arguments: \n",
"\n",
Expand Down Expand Up @@ -373,7 +383,7 @@
"\n",
"`scipy`: https://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.quadgk.html \n",
"\n",
"Implements an Adaptive Gauss-Kronrod (G10,K21) quadrature algorithm, ported from code found in https://www.genivia.com/qthsh.html. The Gauss–Kronrod quadrature formula is an adaptive method for numerical integration. It is a variant of Gaussian quadrature, in which the evaluation points are chosen so that an accurate approximation can be computed by re-using the information produced by the computation of a less accurate approximation (https://en.wikipedia.org/wiki/Gauss%E2%80%93Kronrod_quadrature_formula). Please check the paper above for a comprehensive discussion.\n",
"Implements an Adaptive Gauss-Kronrod (G10,K21) quadrature algorithm. The Gauss–Kronrod quadrature formula is a variant of Gaussian quadrature, in which the evaluation points are chosen so that an accurate approximation can be computed by re-using the information produced by the computation of a less accurate approximation (https://en.wikipedia.org/wiki/Gauss%E2%80%93Kronrod_quadrature_formula). \n",
"\n",
"The function takes three to five positional arguments: \n",
"\n",
Expand Down Expand Up @@ -406,9 +416,9 @@
"source": [
"# Note to Package Builders\n",
"\n",
"Numerical integration makes little sense with float32 math. For compilation, please be sure to set `MICROPY_OBJ_REPR_A` and `MICROPY_FLOAT_IMPL_DOUBLE`, otherwise compilation will fail. \n",
"Numerical integration makes little sense with float32 math. For compilation, please be sure to set `MICROPY_OBJ_REPR_A` and `MICROPY_FLOAT_IMPL_DOUBLE`, otherwise compilation may fail. \n",
"\n",
"The submodule can be enabled by setting `ULAB_SCIPY_HAS_INTEGRATE_MODULE`. As for the individual integration algorithms, you can select which to include by setting one or more of `ULAB_INTEGRATE_HAS_QUAD`, `ULAB_INTEGRATE_HAS_ROMBERG`, `ULAB_INTEGRATE_HAS_SIMPSON`, and `ULAB_INTEGRATE_HAS_QUADGK`. \n"
"The submodule can be enabled by setting `ULAB_SCIPY_HAS_INTEGRATE_MODULE`. As for the individual integration algorithms, you can select which to include by setting one or more of `ULAB_INTEGRATE_HAS_QUAD`, `ULAB_INTEGRATE_HAS_ROMBERG`, `ULAB_INTEGRATE_HAS_SIMPSON`, and `ULAB_INTEGRATE_HAS_QUADGK`. The latter will only be built with `MICROPY_FLOAT_IMPL_DOUBLE` enabled. \n"
]
}
],
Expand Down

0 comments on commit 0a6ad6d

Please sign in to comment.