Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 23 additions & 24 deletions katex.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,46 +27,45 @@
document.addEventListener("DOMContentLoaded", () => {
renderMathInElement(document.body, {
strict: "error",
throwOnError: true,
trust: true,
throwOnError: false,
delimiters: [{left: "$$", right: "$$", display: true}, {left: "$", right: "$", display: false}],
macros: {
// Beta function
"\\B": "\\mathop{\\Beta}",
// absolute value
"\\abs": String.raw`\left| #1 \right|`,

// Beta functions
"\\B": String.raw`\operatorname{\Beta}`,
"\\I": String.raw`\operatorname{I}`,

// error function
"\\erf": "\\mathop{\\mathrm{erf}}",
"\\erfc": "\\mathop{\\mathrm{erfc}}",
"\\erfi": "\\mathop{\\mathrm{erfi}}",
"\\erf": String.raw`\operatorname{\mathrm{erf}}`,
"\\erfc": String.raw`\operatorname{\mathrm{erfc}}`,
"\\erfi": String.raw`\operatorname{\mathrm{erfi}}`,

// sign function
"\\sgn": "\\mathop{\\mathrm{sgn}}",
"\\sgn": "\\operatorname{\\mathrm{sgn}}",

// kelvin functions
"\\ber": "\\mathop{\\mathrm{ber}}",
"\\berp": "\\mathop{\\mathrm{ber}'}",
"\\bei": "\\mathop{\\mathrm{bei}}",
"\\beip": "\\mathop{\\mathrm{bei}'}",
"\\ker": "\\mathop{\\mathrm{ker}}",
"\\kerp": "\\mathop{\\mathrm{ker}'}",
"\\kei": "\\mathop{\\mathrm{kei}}",
"\\keip": "\\mathop{\\mathrm{kei}'}",
"\\ber": String.raw`\operatorname{\mathrm{ber}}`,
"\\bei": String.raw`\operatorname{\mathrm{bei}}`,
"\\ker": String.raw`\operatorname{\mathrm{ker}}`,
"\\kei": String.raw`\operatorname{\mathrm{kei}}`,

// sine and cosine integrals
"\\Si": "\\mathop{\\mathrm{Si}}",
"\\Ci": "\\mathop{\\mathrm{Ci}}",
"\\Shi": "\\mathop{\\mathrm{Shi}}",
"\\Chi": "\\mathop{\\mathrm{Chi}}",
"\\Si": String.raw`\operatorname{\mathrm{Si}}`,
"\\Ci": String.raw`\operatorname{\mathrm{Ci}}`,
"\\Shi": String.raw`\operatorname{\mathrm{Shi}}`,
"\\Chi": String.raw`\operatorname{\mathrm{Chi}}`,

// falling and rising factorials
"\\fpow": "#1^{\\underline{#2}}",
"\\rpow": "#1^{\\overline{#2}}",
"\\fpow": String.raw`\left(#1\right)^{\smash{-}}_{#2}`,
"\\rpow": String.raw`\left(#1\right)^{\smash{+}}_{#2}`,

// hypergeometric functions
"\\hyp": "{}_#1F_#2\\left[{#3 \\atop #4} \\ #5 \\right]",
"\\hyp": String.raw`{}_#1F_#2\left[{#3 \atop #4} \middle| #5 \right]`,

// some missing "physics" tex package commands
"\\dd": "\\,\\mathrm{d}",
"\\dd": String.raw`\,\mathrm{d}`,
},
})
})
Expand Down
82 changes: 41 additions & 41 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,25 +239,25 @@
//!
//! # Gamma and related functions
//!
//! | Function | Description |
//! | ---------------- | ------------------------------------------------------------------- |
//! | [`gamma`] | Gamma function, $\Gamma(z)$ |
//! | [`gammaln`] | Log-gamma function, $\ln \| \Gamma(z) \|$ |
//! | [`loggamma`] | Principal branch of $\ln \Gamma(z)$ |
//! | [`gammasgn`] | Sign of [`gamma`], $\sgn(\Gamma(z))$ |
//! | [`gammainc`] | Regularized lower incomplete gamma function $P(a,x) = 1 - Q(a,x)$ |
//! | [`gammaincinv`] | Inverse of [`gammainc`], $P^{-1}(a,y)$ |
//! | [`gammaincc`] | Regularized upper incomplete gamma function $Q(a,x) = 1 - P(a,x) $ |
//! | [`gammainccinv`] | Inverse of [`gammaincc`], $Q^{-1}(a,y)$ |
//! | [`beta`] | Beta function, $\B(a,b) = \frac{\Gamma(a)\Gamma(b)}{\Gamma(a+b)}$ |
//! | [`betaln`] | Log-Beta function, $\ln \| \B(a,b) \|$ |
//! | [`betainc`] | Regularized incomplete beta function, $I_x(a,b)$ |
//! | [`betaincinv`] | Inverse of [`betainc`], $I_y^{-1}(a,b)$ |
//! | [`digamma`] | The digamma function, $\psi(z)$ |
//! | [`polygamma`] | The polygamma function, $\psi^{(n)}(x)$ |
//! | [`rgamma`] | Reciprocal of the gamma function, $\frac{1}{\Gamma(z)}$ |
//! | [`pow_rising`] | Rising factorial $\rpow{x}{m} = \frac{\Gamma(x+m)}{\Gamma(x)}$ |
//! | [`pow_falling`] | Falling factorial $\fpow{x}{m} = \frac{\Gamma(x+1)}{\Gamma(x+1-m)}$ |
//! | Function | Description |
//! | ---------------- | ----------------------------------------------------------------- |
//! | [`gamma`] | Gamma function, $\Gamma(z)$ |
//! | [`gammaln`] | Log-gamma function, $\ln\abs{\Gamma(z)}$ |
//! | [`loggamma`] | Principal branch of $\ln \Gamma(z)$ |
//! | [`gammasgn`] | Sign of [`gamma`], $\sgn(\Gamma(z))$ |
//! | [`gammainc`] | Regularized lower incomplete gamma function $P(a,x) = 1 - Q(a,x)$ |
//! | [`gammaincinv`] | Inverse of [`gammainc`], $P^{-1}(a,y)$ |
//! | [`gammaincc`] | Regularized upper incomplete gamma function $Q(a,x) = 1 - P(a,x)$ |
//! | [`gammainccinv`] | Inverse of [`gammaincc`], $Q^{-1}(a,y)$ |
//! | [`beta`] | Beta function, $\B(a,b) = {\Gamma(a)\Gamma(b) \over \Gamma(a+b)}$ |
//! | [`betaln`] | Log-Beta function, $\ln\abs{\B(a,b)}$ |
//! | [`betainc`] | Regularized incomplete beta function, $\I_x(a,b)$ |
//! | [`betaincinv`] | Inverse of [`betainc`], $\I_y^{-1}(a,b)$ |
//! | [`digamma`] | The digamma function, $\psi(z)$ |
//! | [`polygamma`] | The polygamma function, $\psi^{(n)}(x)$ |
//! | [`rgamma`] | Reciprocal of the gamma function, $\frac{1}{\Gamma(z)}$ |
//! | [`pow_rising`] | Rising factorial $\rpow x m = {\Gamma(x+m) \over \Gamma(x)}$ |
//! | [`pow_falling`] | Falling factorial $\fpow x m = {\Gamma(x+1) \over \Gamma(x+1-m)}$ |
//!
//! # Error function and Fresnel integrals
//!
Expand Down Expand Up @@ -306,14 +306,14 @@
//!
//! # Hypergeometric functions
//!
//! | Function | Description | Notation |
//! | ---------- | --------------------------------------- | ------------------------------------ |
//! | [`hyp0f0`] | Generalized hypergeometric function | $_0F_0\[\rvert\\, z\]$ |
//! | [`hyp1f0`] | Generalized hypergeometric function | $_1F_0\[a\\, \rvert\\, z\]$ |
//! | [`hyp0f1`] | Confluent hypergeometric limit function | $_0F_1\[b\\, \rvert\\, z\]$ |
//! | [`hypu`] | Confluent hypergeometric function | $U(a,b,x)$ |
//! | [`hyp1f1`] | Confluent hypergeometric function | $\hyp{1}{1}{a}{b}{\big\|\\,z}$ |
//! | [`hyp2f1`] | Gauss' hypergeometric function | $\hyp{2}{1}{a_1,a_2}{b}{\big\|\\,z}$ |
//! | Function | Description | Notation |
//! | ---------- | --------------------------------------- | -------------------------------- |
//! | [`hyp0f0`] | Generalized hypergeometric function | $_0F_0\left[ \middle\| z\right]$ |
//! | [`hyp1f0`] | Generalized hypergeometric function | $_1F_0\left[a\middle\| z\right]$ |
//! | [`hyp0f1`] | Confluent hypergeometric limit function | $_0F_1\left[b\middle\| z\right]$ |
//! | [`hypu`] | Confluent hypergeometric function | $U(a,b,x)$ |
//! | [`hyp1f1`] | Confluent hypergeometric function | $\hyp 1 1 a b z$ |
//! | [`hyp2f1`] | Gauss' hypergeometric function | $\hyp 2 1 {a_1\enspace a_2} b z$ |
//!
//! # Parabolic cylinder functions
//!
Expand Down Expand Up @@ -363,22 +363,22 @@
//! | ---------- | ---------------- | ----------------------------------- |
//! | [`kelvin`] | [`kelvin_zeros`] | Kelvin functions as complex numbers |
//! | [`ber`] | [`ber_zeros`] | Kelvin function $\ber(x)$ |
//! | [`berp`] | [`berp_zeros`] | Derivative of [`ber`], $\berp(x)$ |
//! | [`berp`] | [`berp_zeros`] | Derivative of [`ber`], $\ber\'(x)$ |
//! | [`bei`] | [`bei_zeros`] | Kelvin function $\bei(x)$ |
//! | [`beip`] | [`beip_zeros`] | Derivative of [`bei`], $\beip(x)$ |
//! | [`beip`] | [`beip_zeros`] | Derivative of [`bei`], $\bei\'(x)$ |
//! | [`ker`] | [`ker_zeros`] | Kelvin function $\ker(x)$ |
//! | [`kerp`] | [`kerp_zeros`] | Derivative of [`ker`], $\kerp(x)$ |
//! | [`kerp`] | [`kerp_zeros`] | Derivative of [`ker`], $\ker\'(x)$ |
//! | [`kei`] | [`kei_zeros`] | Kelvin function $\kei(x)$ |
//! | [`keip`] | [`keip_zeros`] | Derivative of [`kei`], $\keip(x)$ |
//! | [`keip`] | [`keip_zeros`] | Derivative of [`kei`], $\kei\'(x)$ |
//!
//! # Combinatorics
//!
//! | Function | Description |
//! | -------------- | ----------------------------------------------------------------------- |
//! | [`comb`] | $k$-combinations of $n$ things, ${}_n C_k = \binom{n}{k}$ |
//! | [`comb_rep`] | $k$-combinations with replacement, $\big(\\!\\!\binom{n}{k}\\!\\!\big)$ |
//! | [`perm`] | $k$-permutations of $n$ things, ${}_n P_k = \frac{n!}{(n-k)!}$ |
//! | [`stirling2`] | Stirling number of the second kind $S(n,k)$ |
//! | Function | Description |
//! | -------------- | ------------------------------------------------------------------------ |
//! | [`comb`] | $k$-combinations of $n$ things, $_nC_k = {n \choose k}$ |
//! | [`comb_rep`] | $k$-combinations with replacement, $\big(\\!\\!{n \choose k}\\!\\!\big)$ |
//! | [`perm`] | $k$-permutations of $n$ things, $_nP_k = {n! \over (n-k)!}$ |
//! | [`stirling2`] | Stirling number of the second kind $S(n,k)$ |
//!
//! # Factorials
//!
Expand Down Expand Up @@ -410,10 +410,10 @@
//!
//! | Function | Description |
//! | ------------- | ------------------------------------------------------------ |
//! | [`bernoulli`] | Bernoulli numbers $B_0, \ldots, B_{N-1}$ |
//! | [`bernoulli`] | Bernoulli numbers $B_0,\dotsc,B_{N-1}$ |
//! | [`binom`] | Binomial coefficient $\binom{n}{k}$ for real input |
//! | [`diric`] | Periodic sinc function, also called the Dirichlet kernel |
//! | [`euler`] | Euler numbers $E_0, \ldots, E_{N-1}$ |
//! | [`euler`] | Euler numbers $E_0,\dotsc,E_{N-1}$ |
//! | [`lambertw`] | Lambert W function, $W(z)$ |
//! | [`sici`] | Sine and cosine integrals $\Si(z)$ and $\Ci(z)$ |
//! | [`shichi`] | Hyperbolic sine and cosine integrals $\Shi(z)$ and $\Chi(z)$ |
Expand All @@ -440,8 +440,8 @@
//! | [`xlog1py`] | $x \ln(1+y)$ or $0$ if $x = 0$ |
//! | [`logaddexp`] | $\ln(e^x + e^y)$ |
//! | [`logaddexp2`] | $\log_2(2^x + 2^y)$ |
//! | [`exprel`] | Relative error exponential, $\frac{e^x - 1}{x}$ |
//! | [`sinc`] | Normalized sinc function, $\frac{\sin(\pi x)}{\pi x}$ |
//! | [`exprel`] | Relative error exponential, $e^x - 1 \over x$ |
//! | [`sinc`] | Normalized sinc function, $\sin(\pi x) \over \pi x$ |
//!
#![warn(
Expand Down
6 changes: 3 additions & 3 deletions src/scipy_special/convex_analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/// This function is concave.
///
/// The origin of this function is in convex programming [^1]. Given a discrete probability
/// distribution $p_1,\\, \ldots,\\, p_n$, the definition of entropy in the context of
/// distribution $p_1,\dotsc,p_n$, the definition of entropy in the context of
/// *information theory* is
///
/// $$
Expand Down Expand Up @@ -64,8 +64,8 @@ pub fn entr(x_i: f64) -> f64 {
/// This function is jointly convex in $x$ and $y$.
///
/// The origin of this function is in convex programming [^1]. Given two discrete probability
/// distributions $p_1,\\, \ldots,\\, p_n$ and $q_1,\\, \ldots,\\, q_n$, the definition of relative
/// entropy in the context of *information theory* is [^2]
/// distributions $p_1,\dotsc,p_n$ and $q_1,\dotsc,q_n$, the definition of relative entropy in the
/// context of *information theory* is [^2]
///
/// $$
/// H\left[ \\{ p_i \\} \\, \rvert \\, \\{ q_i \\} \right]
Expand Down
48 changes: 20 additions & 28 deletions src/scipy_special/hypergeometric.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ impl HypergeometricArg for num_complex::Complex<f64> {
}
}

/// Hypergeometric function $_0F_0\[\rvert\\,z\]$ for real or complex $z$
/// Hypergeometric function $_0F_0\left[\middle\| z\right]$ for real or complex $z$
///
/// This function is currently not implemented in SciPy, but is straightforward to evaluate.
/// Both [`f64`] and [`num_complex::Complex<f64>`](num_complex::Complex) are accepted for `z`.
Expand All @@ -181,24 +181,22 @@ impl HypergeometricArg for num_complex::Complex<f64> {
/// This function is defined as
///
/// $$
/// _0F_0\[\rvert\\,z\] = \sum\_{n=0}^\infty \frac{z^n}{n!} ,
/// _0F_0\left[ \middle\| z\right] = \sum\_{n=0}^\infty {z^n \over n!},
/// $$
///
/// which is just the exponential function, $e^z$.
///
/// # See also
/// - [`hyp1f0`]: Hypergeometric function $_1F_0\[a\\,\rvert\\,z\]$
/// - [`hyp0f1`]: Confluent hypergeometric limit function, $_0F_1\[b\\,\rvert\\,z\]$
/// - [`hyp1f1`](crate::hyp1f1): Kummer's confluent hypergeometric function,
/// $\hyp{1}{1}{a}{b}{\big\|\\,z}$
/// - [`hyp2f1`](crate::hyp2f1): Gauss' hypergeometric function,
/// $\hyp{2}{1}{a_1,\\ a_2}{b}{\big\|\\,z}$
/// - [`hyp1f0`]: Hypergeometric function $_1F_0\left[a\middle\| z\right]$
/// - [`hyp0f1`]: Confluent hypergeometric limit function, $_0F_1\left[b\middle\| z\right]$
/// - [`hyp1f1`](crate::hyp1f1): Kummer's confluent hypergeometric function, $\hyp 1 1 a b z$
/// - [`hyp2f1`](crate::hyp2f1): Gauss' hypergeometric function, $\hyp 2 1 {a_1\enspace a_2} b z$
///
pub fn hyp0f0<T: HypergeometricArg>(z: T) -> T {
z.hyp0f0()
}

/// Hypergeometric function $_1F_0\[a\\,\rvert\\,z\]$ for real or complex $z$
/// Hypergeometric function $_1F_0\left[a\middle\| z\right]$ for real or complex $z$
///
/// This function is currently not implemented in SciPy, but is straightforward to evaluate.
/// Both [`f64`] and [`num_complex::Complex<f64>`](num_complex::Complex) are accepted for `z`.
Expand All @@ -208,25 +206,23 @@ pub fn hyp0f0<T: HypergeometricArg>(z: T) -> T {
/// This function is defined as
///
/// $$
/// _1F_0\[a\\,\rvert\\,z\] = \sum\_{n=0}^\infty \rpow{a}{n} \frac{z^n}{n!}
/// _1F_0\left[a\middle\| z\right] = \sum\_{n=0}^\infty \rpow a n {z^n \over n!}
/// $$
///
/// Here $\rpow{\square}{n}$ is the rising factorial; see [`pow_rising`](crate::pow_rising).
/// Here $\rpow \square n$ is the rising factorial; see [`pow_rising`](crate::pow_rising).
/// It's also equal to $(1 - z)^{-a}$.
///
/// # See also
/// - [`hyp0f0`]: Hypergeometric function $_0F_0\[\rvert\\,z\]$
/// - [`hyp0f1`]: Confluent hypergeometric limit function, $_0F_1\[b\\,\rvert\\,z\]$
/// - [`hyp1f1`](crate::hyp1f1): Kummer's confluent hypergeometric function,
/// $\hyp{1}{1}{a}{b}{\big\|\\,z}$
/// - [`hyp2f1`](crate::hyp2f1): Gauss' hypergeometric function,
/// $\hyp{2}{1}{a_1,\\ a_2}{b}{\big\|\\,z}$
/// - [`hyp0f0`]: Hypergeometric function $_0F_0\left[\middle\| z\right]$
/// - [`hyp0f1`]: Confluent hypergeometric limit function, $_0F_1\left[b\middle\| z\right]$
/// - [`hyp1f1`](crate::hyp1f1): Kummer's confluent hypergeometric function, $\hyp 1 1 a b z$
/// - [`hyp2f1`](crate::hyp2f1): Gauss' hypergeometric function, $\hyp 2 1 {a_1\enspace a_2} b z$
///
pub fn hyp1f0<T: HypergeometricArg>(a: f64, z: T) -> T {
z.hyp1f0(a)
}

/// Confluent hypergeometric limit function $_0F_1\[b\\,\rvert\\,z\]$ for real or complex $z$
/// Confluent hypergeometric limit function $_0F_1\left[b\middle\| z\right]$ for real or complex $z$
///
/// This is a translation of the [`scipy.special.hyp0f1`][hyp0f1] Cython implementation into Rust,
/// using the same Cephes-based [scipy/xsf][xsf] FFI functions as SciPy.
Expand All @@ -239,22 +235,18 @@ pub fn hyp1f0<T: HypergeometricArg>(a: f64, z: T) -> T {
/// This function is defined as
///
/// $$
/// _0F_1\[b\\,\rvert\\,z\] = \sum\_{n=0}^\infty \frac{1}{\rpow{b}{n}} \frac{z^n}{n!}.
/// _0F_1\left[b\middle\| z\right] = \sum\_{n=0}^\infty {1\over \rpow b n} {z^n \over n!}.
/// $$
///
/// Here $\rpow{\square}{n}$ is the rising factorial; see [`pow_rising`](crate::pow_rising).
/// Here $\rpow \square n$ is the rising factorial; see [`pow_rising`](crate::pow_rising).
///
/// It's also the limit as $a \to \infty$ of $\hyp{1}{1}{a}{b}{\big\|\\,z}$, and satisfies the
/// It's also the limit as $a \to \infty$ of $\hyp 1 1 a b z$, and satisfies the
/// differential equation $f\'\'(z) + b f\'(z) = f(z)$. See [^1] for more information.
///
/// # See also
/// - [`hyp1f0`]: Hypergeometric function, $_1F_0\[a\\,\rvert\\,z\]$
/// - [`hyp1f1`](crate::hyp1f1): Kummer's confluent hypergeometric function,
/// $\hyp{1}{1}{a}{b}{\big\|\\,z}$
/// - [`hyp2f1`](crate::hyp2f1): Gauss' hypergeometric function,
/// $\hyp{2}{1}{a_1,\\ a_2}{b}{\big\|\\,z}$
/// - [`bessel_j`](crate::bessel_j): Bessel function of the first kind, $J_v(x)$
/// - [`bessel_i`](crate::bessel_i): Modified Bessel function of the first kind, $I_v(x)$
/// - [`hyp1f0`]: Hypergeometric function, $_1F_0\left[a\middle\| z\right]$
/// - [`hyp1f1`](crate::hyp1f1): Kummer's confluent hypergeometric function, $\hyp 1 1 a b z$
/// - [`hyp2f1`](crate::hyp2f1): Gauss' hypergeometric function, $\hyp 2 1 {a_1\enspace a_2} b z$
///
/// [^1]: Weisstein, Eric W. "Confluent Hypergeometric Limit Function." From MathWorld -- A Wolfram
/// Resource. <https://mathworld.wolfram.com/ConfluentHypergeometricLimitFunction.html>
Expand Down
Loading