special

package module
v0.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 16, 2020 License: BSD-3-Clause Imports: 1 Imported by: 2

README


layout: default title: special

GoDoc Go Report Card Coverage Build Status

special

Package special provides special mathematical functions for Go. Please consult the GoDoc page for specific details and visit ScientificGo to see more scientific packages for Go.

Installation

go get scientificgo.org/special

Usage

import "scientificgo.org/special"

Documentation

Overview

Package special provides common special functions to extend the Go standard package math.

Index

Constants

View Source
const (
	Cahen      = 6434105462883380261822543077575647632865878602682395059870309203 // https://oeis.org/A118227
	Catalan    = 0.91596559417721901505460351493238411077414937428167213426649811 // https://oeis.org/A006752
	EulerGamma = 0.57721566490153286060651209008240243104215933593992359880576723 // https://oeis.org/A001620
	Glaisher   = 1.28242712910062263687534256886979172776768892732500119206374002 // https://oeis.org/A074962
	Omega      = 0.56714329040978387299996866221035554975381578718651250813513107 // https://oeis.org/A030178
	Plastic    = 1.32471795724474602596090885447809734073440405690173336453401505 // https://oeis.org/A060006
)

Mathematical constants.

Variables

This section is empty.

Functions

func Beta

func Beta(x, y float64) float64

Beta returns the complete beta function, defined by

Beta(x, y) = Gamma(x) Gamma(y) / Gamma(x+y)

where Gamma is the gamma function.

See http://mathworld.wolfram.com/BetaFunction.html for more information.

func ChebyshevT

func ChebyshevT(n int, x float64) float64

ChebyshevT returns the nth Chebyshev polynomial of the first kind at x.

See http://mathworld.wolfram.com/ChebyshevPolynomialoftheFirstKind.html for more information.

func ChebyshevU

func ChebyshevU(n int, x float64) float64

ChebyshevU returns the nth Chebyshev polynomial of the second kind at x.

See http://mathworld.wolfram.com/ChebyshevPolynomialoftheSecondKind.html for more information.

func Chi

func Chi(x float64) float64

Chi returns the hyperbolic cosine integral evaluated at x.

func Ci

func Ci(x float64) float64

Ci returns the cosine integral, defined by

          ∞                              x
Ci(x) = - ∫ dt Cos(t) / t = γ + Log(x) + ∫ dt (Cos(t) - 1) / t
         t=x                            t=0

where γ is the Euler-Mascheroni constant.

See http://mathworld.wolfram.com/CosineIntegral.html for more information.

func Cin

func Cin(x float64) float64

Cin returns the secondary cosine integral, defined by

         x
Cin(x) = ∫ dt (1 - Cos(t)) / t = γ + Log(x) - Ci(x)
        t=0

where γ is the Euler-Mascheroni constant and Ci is the primary cosine integral.

See http://mathworld.wolfram.com/CosineIntegral.html for more information.

func Digamma

func Digamma(x float64) float64

Digamma returns the first logarithmic derivative of the Gamma function, defined by

Digamma(x) = d/dx Lgamma(x)

See http://mathworld.wolfram.com/DigammaFunction.html for more information.

func Ei

func Ei(x float64) float64

Ei returns the exponential integral of x, defined by

        x
Ei(x) = ∫ dt Exp(t) / t
       t=-∞

See http://mathworld.wolfram.com/ExponentialIntegral.html for more information.

func En

func En(n int, x float64) float64

En returns the En function, defined by

           ∞
En(n, x) = ∫ dt Exp(-x*t) / t**n
          t=1

See http://mathworld.wolfram.com/En-Function.html for more information.

func Eta

func Eta(x float64) float64

Eta returns the Dirichlet eta function, defined by

         ∞
Eta(x) = ∑ (-1)**(n+1) / n**x = (1 - 2**(1-x)) Zeta(x)
        n=1

where Zeta is the Riemann zeta function.

See http://mathworld.wolfram.com/DirichletEtaFunction.html for more information.

func Fibonacci

func Fibonacci(n float64) float64

Fibonacci returns the nth Fibonacci. The Fibonacci numbers are defined, for integer n, by

F(n) = F(n-1) + F(n-2)
F(0) = F(1) = 1

and can extended to non-integer n by

Fibonacci(n) = (φ**n - Cos(nπ)/φ**n) / √5

where φ = (1 + √5) / 2 is the golden ratio.

See http://mathworld.wolfram.com/FibonacciNumber.html for more information.

func GammaIncL

func GammaIncL(a, x float64) float64

GammaIncL returns the lower incomplete gamma function, defined by

                  x
GammaIncL(a, x) = ∫ dt Exp(-t) * t**(a-1)
                 t=0

GammaIncL also satisfies the identity

GammaIncL(a, x) + GammaIncU(a, x) = Gamma(a)

where GammaIncU is the upper incomplete gamma function.

See http://mathworld.wolfram.com/IncompleteGammaFunction.html for more information.

func GammaIncU

func GammaIncU(a, x float64) float64

GammaIncU returns the lower incomplete gamma function, defined by

                  ∞
GammaIncU(a, x) = ∫ dt Exp(-t) * t**(a-1)
                 t=x

GammaIncU also satisfies the identity

GammaIncL(a, x) + GammaIncU(a, x) = Gamma(a)

where GammaIncL is the lower incomplete gamma function.

See http://mathworld.wolfram.com/IncompleteGammaFunction.html for more information.

func GammaRatio

func GammaRatio(x, y []float64) float64

GammaRatio returns the ratio of products of Gamma functions, i.e.

                  n-1             m-1
GammaRatio(x, y) = ∏ Gamma(x[i]) / ∏ Gamma(y[j])
                  i=0             j=0

where x = {x[0], ..., x[n-1]} and y = {y[0], ..., y[m-1]} are slices of length n and m respectively. The result is NaN if x and y contain a different number of infinite or NaN values.

See http://mathworld.wolfram.com/GammaFunction.html for more information.

func GammaRegP

func GammaRegP(a, x float64) float64

GammaRegP returns the regularised lower incomplete gamma function, defined by

                                 x
GammaRegP(a, x) = [1 / Gamma(a)] ∫ dt Exp(-t) * t**(a-1)
                                t=0

The regularised lower incomplete gamma function has a series representation

                               ∞
GammaRegP(a, x) = Exp(-x) a**x ∑ x**k / Gamma(a+k+1)
                              k=0

and also satisfies the identity

GammaRegP(a, x) + GammaRegQ(a, x) = 1

where GammaRegQ is the regularised upper incomplete gamma function.

See http://mathworld.wolfram.com/RegularizedGammaFunction.html for more information.

func GammaRegQ

func GammaRegQ(a, x float64) float64

GammaRegQ returns the regularised upper incomplete gamma function, defined by

                                 ∞
GammaRegQ(a, x) = [1 / Gamma(a)] ∫ dt Exp(-t) * t**(a-1)
                                t=x

GammaRegQ also satisfies the identity

GammaRegP(a, x) + GammaRegQ(a, x) = 1

where GammaRegP is the regularised lower incomplete gamma function.

See http://mathworld.wolfram.com/RegularizedGammaFunction.html for more information.

func GammaSign

func GammaSign(x float64) int

GammaSign returns the sign of the Gamma function at x. For non-positive integer x, the sign is given by the sign of the residue, i.e. (-1)**|x|.

func GegenbauerC

func GegenbauerC(n int, a, x float64) float64

GegenbauerC returns the nth Gegenbauer polynomial with paramater a at x.

See http://mathworld.wolfram.com/GegenbauerPolynomial.html for more information.

func Harmonic

func Harmonic(x float64) float64

Harmonic returns the harmonic numbers, defined for integer n by

              n
Harmonic(n) = ∑ 1/k
             k=1

and extended to non-integer x by

Harmonic(x) = EulerGamma + Digamma(x+1)

where Digamma is the logarithmic derivative of the Gamma function.

See http://mathworld.wolfram.com/HarmonicNumber.html for more information.

func HermiteH

func HermiteH(n int, x float64) float64

HermiteH returns the nth unnormalised, or physics, Hermite polynomial, which is related to the normalised Hermite polynomial by

H(n, x) = √2**n He(n, x√2)

where He is the normalised Hermite polynomial.

See http://mathworld.wolfram.com/HermitePolynomial.html for more information.

func HermiteHe

func HermiteHe(n int, x float64) float64

HermiteHe returns the nth normalised Hermite polynomial, which is related to the "physics" Hermite polynomial by

H(n, x) = √2**n He(n, x√2)

where H is the unnormalised, or physics, Hermite polynomial.

See http://mathworld.wolfram.com/HermitePolynomial.html for more information.

func HypPFQ

func HypPFQ(a, b []float64, x float64) float64

HypPFQ returns the type-(p,q) generalised hypergeometric function, defined by

               ∞            p-1         q-1
pFq(a; b; x) = ∑ x**k / k! * ∏ (a[i])_k / ∏ (b[j])_k
              k=0           i=0         j=0

where a and b are length p and q respectively and (x)_k is the k-th Pochhammer symbol of x. The function pFq is commonly denoted

   | a[0], a[1], ..., a[p-1]    |
pFq|                        ; x |
   | b[0], b[1], ..., b[q-1]    |

for p, q ≥ 2.

See http://mathworld.wolfram.com/HypergeometricFunction.html for more information.

func JacobiP

func JacobiP(n int, a, b, x float64) float64

JacobiP returns the nth Jacobi polynomial with parameters a, b at x.

See http://mathworld.wolfram.com/JacobiPolynomial.html for more information.

func LaguerreAL

func LaguerreAL(n int, a, x float64) float64

LaguerreAL returns the nth associated Laguerre polynomial with parameter a at x.

See http://mathworld.wolfram.com/AssociatedLaguerrePolynomial.html for more information.

func LaguerreL

func LaguerreL(n int, x float64) float64

LaguerreL returns the nth Laguerre polynomial at x.

See http://mathworld.wolfram.com/LaguerrePolynomial.html for more information.

func LambertW

func LambertW(k int, x float64) float64

LambertW returns the real branches of the Lambert W function, implicitly defined by

W(x) Exp(W(x)) = x

or, equivalently, as the inverse of the function

f(x) = x Exp(x)

where Exp is the exponential function. The principal branch (k=0) is defined on x ≥ -1/e and the secondary branch (k=-1) is defined over -1/e ≤ x < 0.

See http://mathworld.wolfram.com/LambertW-Function.html for more information.

func LegendreAP

func LegendreAP(n, m int, x float64) float64

LegendreAP returns the nth associated Legendre polynomial of the first kind with parameter m at x.

See http://mathworld.wolfram.com/AssociatedLegendrePolynomial.html for more information.

func LegendreP

func LegendreP(n int, x float64) float64

LegendreP returns the nth Legendre polynomial of the first kind at x.

See http://mathworld.wolfram.com/LegendrePolynomial.html for more information.

func LegendreQ

func LegendreQ(n int, x float64) float64

LegendreQ returns the nth Legendre polynomial of the second kind at x.

See http://mathworld.wolfram.com/LegendreFunctionoftheSecondKind.html for more information.

func LgammaRatio

func LgammaRatio(x, y []float64) (float64, int)

LgammaRatio returns the natural logarithm and sign of the ratio of products of Gamma functions, i.e.

                        n-1             m-1
LgammaRatio(x, y) = Log| ∏ Gamma(x[i]) / ∏ Gamma(y[j]) |
                        i=0             j=0

where x = {x[0], ..., x[n-1]} and y = {y[0], ..., y[m-1]} are slices of length n and m respectively. The result is NaN if x and y contain a different number of infinite or NaN values.

See http://mathworld.wolfram.com/GammaFunction.html for more information.

func Li

func Li(x float64) float64

Li returns the logarithmic integral of x, defined for x ≥ 0 by

        x
Li(x) = ∫ dt / Log(t) = Ei(Log(x))
       t=0

where Ei(x) is the exponential integral.

See http://mathworld.wolfram.com/LogarithmicIntegral.html for more information.

func Li2

func Li2(x float64) float64

Li2 returns the secondary logarithmic integral of x, defined for x ≥ 0 by

         x
Li2(x) = ∫ dt / Log(t) = Li(x) - Li(2)
        t=2

such that Li2(2) = 0, where Li(x) is the primary logarithmic integral.

See http://mathworld.wolfram.com/LogarithmicIntegral.html for more information.

func Poch

func Poch(x, k float64) float64

Poch returns the kth Pochhammer symbol of x, defined by

Poch(x, k) = Gamma(x+k) / Gamma(x)

See http://mathworld.wolfram.com/PochhammerSymbol.html for more information.

func Polygamma

func Polygamma(n int, x float64) float64

Polygamma returns the nth derivative of the Digamma function.

Polygamma(n, x) = (d/dx)**n Digamma(x)

See http://mathworld.wolfram.com/PolygammaFunction.html for more information.

func Shi

func Shi(x float64) float64

Shi returns the hyperbolic sine integral evaluated at x.

func Si

func Si(x float64) float64

Si returns the sine integral, defined by

         x                       ∞
 Si(x) = ∫ dt Sin(t) / t = π/2 - ∫ dt Sin(t) / t
	       t=0                     t=x

See http://mathworld.wolfram.com/SineIntegral.html for more information.

func SphericalHarmonicY

func SphericalHarmonicY(l, m int, theta, phi float64) (float64, float64)

SphericalHarmonicY returns the angular portion of the solutions to Laplace's equation in spherical coordinates, where theta is in [0, π], phi is in [0, 2π] and |l| ≤ m.

See http://mathworld.wolfram.com/SphericalHarmonic.html for more information.

func Trigamma

func Trigamma(x float64) float64

Trigamma returns the logarithmic second derivative of Gamma(x), or, equivalently, the first derivative of the Digamma function.

Trigamma(x) = d/dx Digamma(x)

See http://mathworld.wolfram.com/TrigammaFunction.html for more information.

func ZernikeR

func ZernikeR(n, m int, x float64) float64

ZernikeR returns the nth Zernike polynomial with parameter m at x.

See http://mathworld.wolfram.com/ZernikePolynomial.html for more information.

func Zeta

func Zeta(x float64) float64

Zeta returns the Riemann zeta function, defined by

          ∞
Zeta(x) = ∑ 1 / n**x
         n=1

although it has many other equivalent definitions. This definition is valud for x > 1, however the Zeta function can be analytically continued to the entire complex-plane; this implementation is valid for all real numbers.

See http://mathworld.wolfram.com/RiemannZetaFunction.html for more information.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL