[Scientific / technical calculation by Python] List of usage of (special) functions used in physics by using scipy

Introduction

You can use (special) functions that appear in the field of physics in the scipy.special package [1].


from scipy.special import *

** Typical (special) function usages (function names, arguments, etc.) are summarized below so that they can be referred to as appropriate when performing scientific / technical calculations using Python. ** ** Please refer to the official page [1] for a detailed explanation of the options. The definition of special functions is described in reference [2] in an easy-to-understand manner and is helpful.

This paper will be revised and revised as necessary.

● August 7, 2017: Added type 1 and type 2 perfect elliptic integrals.


Hermite polynomial

H_n(x)=n!\sum_{m=0}^{\lfloor n / 2 \rfloor}\dfrac{(-1)^m(2x)^{n-2m}}{m!(n-2m)!} ($ \ Lfloor \ rfloor $ is the [Gaussian symbol](https://ja.wikipedia.org/wiki/%E5%BA%8A%E9%96%A2%E6%95%B0%E3%81%A8% E5% A4% A9% E4% BA% 95% E9% 96% A2% E6% 95% B0))

** Application example in physics **: Proprietary solution for linear restoring force potential for steady-state Schrodinger equation in quantum mechanics [3], etc.

#Usage
from scipy.special import *
eval_hermite(n, x)

Legendre polynomials

\begin{align} P_n(x) = 2^n\cdot \sum_{k=0}^n x^k {n \choose k}{\frac{n+k-1}2\choose n}\end{align}

Application example in physics: [Laplace's equation](https://ja.wikipedia.org/wiki/%E3%83%A9%E3%83%97%E3%83%A9%E3%82%B9%E6% 96% B9% E7% A8% 8B% E5% BC% 8F) [4], Schrodinger equation of three-dimensional central force field [4], [multipole expansion] in electromagnetism (https://en.wikipedia.org) / wiki / Multipole_expansion) Appears in [4] etc.

#Usage
eval_legendre(n, x)

Associated Legendre polynomials

P_n{}^m (t) = {1\over 2^n} (1-t^2)^{m \over 2} \sum_{j=1}^{\lfloor (n-m) / 2\rfloor} {(-1)^j (2n-2j)! \over j!(n-j)!(n-2j-m)!}t^{n-2j-m} (n\leq m, \ $|t|\leq 1$)

** Application example in physics **: Solution of Laplace's equation, representation of spherical harmonics

#Usage
lpmv(m, n, t)

Laguerre polynomial

$L_n(x) = \sum_{k=0}^n (-1)^k {n \choose k} \frac{n!}{k!} x^k $

** Application in physics **: Solving the radial Schrodinger equation under the Coulomb potential [4].

#Usage
eval_laguerre(n, x)

Spherical harmonics

{{Y_{l}^{m}(\theta, \phi) =(-1)^{(m+|m|)/2}\sqrt{ \frac{2l+1}{4\pi}\frac{(l-|m|)!}{(l+|m|)!} \,} \,P_l^{|m|}(\cos\theta)\,e^{im\phi}}}

herel\geq |m|, P_l^{|m|}Is the Associated Legendre polynomial.

** Application example in physics **: Appears when the Schrodinger equation of the one-particle steady state for the spherically symmetric potential is separated into variables [3]. Also, since it forms a complete system in the angular direction, it is often used as an expansion basis for functions with angle dependence.

#Usage
sph_harm(m, l, theta, phi)

Gamma function

\Gamma(z)=\int^{\infty}_{0}t^{z-1}e^{-t}\,dt\qquad (Re(z)>0)

** Application in physics **: Often appears in statistical mechanics. Free Fermi electronic system specific heat formula [3,5], [Stirling's formula](https://ja.wikipedia.org/wiki/%E3%82%B9%E3%82%BF%E3%83%BC% Derivation of E3% 83% AA% E3% 83% B3% E3% 82% B0% E3% 81% AE% E8% BF% 91% E4% BC% BC) (asymptotic expansion of Γ function) [5], etc. ..

#Usage
gamma(z)

Polygamma function

Logarithmic derivative of gamma function, $\psi^{(n)}(z) = \frac{d^{n+1}}{dz^{n+1}} \ln{\Gamma(z)} = \frac{d^n}{dz^n} \psi(z) $ Is called the polygamma function. Often used.

#Usage
polygamma(n, x)

Beta function

{\beta(x,y) = \int_0^1t^{x-1}(1-t)^{y-1}\,dt} =\frac{\Gamma(x)\Gamma(y)}{\Gamma(x+y)} (Where x and y are complex numbers that satisfy $ Re \ x> 0, Re \ y> 0 $)

#Usage
beta(x, y)

Bessel function:

** Examples of applications in physics **: Laplace's equation [5], which appears when solving the Helmholtz equation in a column coordinate system or a polar coordinate system [4]. Propagation of electromagnetic waves, heat conduction of cylindrical objects, vibration solution of thin films [6], etc.

Type 1 Bessel function

#Usage
jn(n, z) #Integer-order Bessel function
jv(v, z) #Bessel function of general degree

Type 2 Bessel function

#Usage
yn(n,x) #Integer order
yv(v,z) #General degree

Hankel function:

Special solution to Vessel's differential equation

#Usage
hankel1(v, z) #First-class Hankel function

Modified Bessel function

[Vessel's differential equations] for pure imaginary variables (https://en.wikipedia.org/wiki/%E3%83%99%E3%83%83%E3%82%BB%E3%83%AB%E9% A special solution of 96% A2% E6% 95% B0).

#Usage
kn(n,x) #Integer order
kv(v,z) #General degree

Spherical Bessel function

J_n(z)

** Application examples in physics **: Regular solution of Schrodinger equation of free particles in spherical coordinate system (non-regular solution is sphere Neumann function) [3], etc.

#Usage
spherical_jn(n, z, derivative=False)

Airy function

\begin{align} \operatorname{Ai}(x) & = \frac{1}{\pi}\int_0^\infty\cos(\tfrac{t^3}{3} + xt)\mathit{dt}\\ \equiv \frac{1}{\pi}\lim_{b\to\infty} \int_0^b \cos(\tfrac{t^3}{3} + xt)\mathit{dt}\end{align}

** Application example in physics **: Classical by [WKB method] in quantum mechanics (https://ja.wikipedia.org/wiki/WKB%E8%BF%91%E4%BC%BC) [3] A solution that connects regression points, etc.

#Usage
airy(z)

Mathieu function (elliptical column function)

** Application examples in physics **: Vibration of elliptical membrane [6], Parameter excitation in forced vibration [6], Solution of steady-state Schrodinger equation for triangular function type potential [3], In general relativity [Einstein equations](https://ja.wikipedia.org/wiki/%E3%82%A2%E3%82%A4%E3%83%B3%E3%82%B7%E3%83%A5%E3% 82% BF% E3% 82% A4% E3% 83% B3% E6% 96% B9% E7% A8% 8B% E5% BC% 8F), etc.

#Usage
mathieu_a(m, q) #Matthew cosine function
mathieu_b(m, q) #Matthew sine function


Complete elliptic integral

** Application example in physics **: Appears in large-amplitude pendulum motion [6], exact solution of 2D Ising model in statistical mechanics, etc.

First-class perfect elliptic integral

{K(k)=\int_0^{\pi/2}{\frac{1}{\sqrt{1-k^2\sin^2\theta}}}d\theta} As $ m = k ^ 2 <1 $

#Usage: ellipk(m)

a=ellipk(0.45)
print(a)

Result: 1.81388393682

Type 2 perfect elliptic integral

{E(k)=\int_0^{\pi/2}{\sqrt{1-k^2\sin^2\theta}}d\theta}

As $ m = k ^ 2 \ le 1 $

#Usage: ellipe(m)
a=ellipe(0.9)
print(a)

Result: 1.1047747327


References

[1] Scipy Official: Special functions

[2] Yoshitaka Onodera, [Applied Mathematics for Physics](https://www.amazon.co.jp/%E7%89%A9%E7%90%86%E3%81%AE%E3%81 % 9F% E3% 82% 81% E3% 81% AE% E5% BF% 9C% E7% 94% A8% E6% 95% B0% E5% AD% A6-% E5% B0% 8F% E9% 87% 8E%E5%AF%BA-%E5%98%89%E5%AD%9D/dp/4785320311/ref=sr_1_2?s=books&ie=UTF8&qid=1501826776&sr=1-2&keywords=%E5%B0%8F%E9% 87% 8E% E5% AF% BA +% E5% 98% 89% E5% AD% 9D), Shokabo, (1988); by Hirokazu Terazawa, [Introduction to Mathematics for Natural Scientists](https: // www.amazon.co.jp/%E8%87%AA%E7%84%B6%E7%A7%91%E5%AD%A6%E8%80%85%E3%81%AE%E3%81%9F % E3% 82% 81% E3% 81% AE% E6% 95% B0% E5% AD% A6% E6% A6% 82% E8% AB% 96-% E5% A2% 97% E8% A8% 82% E7% 89% 88-% E5% AF% BA% E6% B2% A2-% E5% AF% 9B% E4% B8% 80 / dp / 4000054805 / ref = sr_1_1? s = books & ie = UTF8 & qid = 1501697831 & sr = 1- 1 & keywords =% E8% 87% AA% E7% 84% B6% E7% A7% 91% E5% AD% A6% E8% 80% 85% E3% 81% AE% E3% 81% 9F% E3% 82% 81 % E3% 81% AE% E6% 95% B0% E5% AD% A6% E6% A6% 82% E8% AB% 96), Iwanami Shoten, (1983); by Tetsuro Inui, [Special Function](https:: //www.amazon.co.jp/%E7%89%B9%E6%AE%8A%E5%87%BD%E6%95%B0-%E5%B2%A9%E6%B3%A2%E5% 85% A8% E6% 9B% B8-252-% E7% 8A % AC% E4% BA% 95-% E9% 89% 84% E9% 83% 8E / dp / 4000214128), Iwanami Shoten, (1962).

[3] by Landau Rifsitz, [Quantum Mechanics](https://www.amazon.co.jp/%E9%87%8F%E5%AD%90%E5%8A%9B%E5%AD%A6% E2% 80% 95% E9% 9D% 9E% E7% 9B% B8% E5% AF% BE% E8% AB% 96% E7% 9A% 84% E7% 90% 86% E8% AB% 96-1- % E3% 83% A9% E3% 83% B3% E3% 83% 80% E3% 82% A6-% E3% 83% AA% E3% 83% 95% E3% 82% B7% E3% 83% 83% E3% 83% 84% E7% 90% 86% E8% AB% 96% E7% 89% A9% E7% 90% 86% E5% AD% A6% E6% 95% 99% E7% A8% 8B-% E3 % 83% AC% E3% 83% 95% E3% 83% BB% E3% 83% 80% E3% 83% 93% E3% 83% 89% E3% 83% B4% E3% 82% A3% E3% 83 % 81% E3% 83% BB% E3% 83% A9% E3% 83% B3% E3% 83% 80% E3% 82% A6 / dp / 4489000588), Tokyo Tosho, (1983); Kenichi Goto et al., [Quantum mechanics exercise](https://www.amazon.co.jp/%E8%A9%B3%E8%A7%A3%E7%90%86%E8%AB%96%E5%BF%9C%E7 % 94% A8% E9% 87% 8F% E5% AD% 90% E5% 8A% 9B% E5% AD% A6% E6% BC% 94% E7% BF% 92-% E5% BE% 8C% E8% 97% A4-% E6% 86% B2% E4% B8% 80 / dp / 4320031717 / ref = sr_1_1? S = books & ie = UTF8 & qid = 15018825682 & sr = 1-1 & keywords =% E9% 87% 8F% E5% AD% 90% E5% 8A% 9B% E5% AD% A6% E6% BC% 94% E7% BF% 92), Kyoritsu Publishing, (1982).

[4] by Shigenobu Sunakawa, [Theoretical Electromagnetism](https://www.amazon.co.jp/%E7%90%86%E8%AB%96%E9%9B%BB%E7%A3%81% E6% B0% 97% E5% AD% A6-% E7% A0% 82% E5% B7% 9D-% E9% 87% 8D% E4% BF% A1 / dp / 4314008547 / ref = sr_1_1? S = books & ie = UTF8 & qid = 15018259222 & sr = 1-1 & keywords =% E7% 90% 86% E8% AB% 96% E9% 9B% BB% E7% A3% 81% E6% B0% 97% E5% AD% A6) Third Edition, Kii Kuniya Bookstore, (1999).

[5] Ryogo Kubo, [University Exercise Thermology / Statistical Dynamics](https://www.amazon.co.jp/%E5%A4%A7%E5%AD%A6%E6%BC%94%E7 % BF% 92-% E7% 86% B1% E5% AD% A6% E3% 83% BB% E7% B5% B1% E8% A8% 88% E5% 8A% 9B% E5% AD% A6-% E4 % B9% 85% E4% BF% 9D-% E4% BA% AE% E4% BA% 94 / dp / 4785380322 / ref = sr_1_1? s = books & ie = UTF8 & qid = 1501826038 & sr = 1-1 & keywords =% E5% A4% A7 % E5% AD% A6% E6% BC% 94% E7% BF% 92% E3% 80% 80% E7% 86% B1% E5% AD% A6% E3% 83% BB% E7% B5% B1% E8 % A8% 88% E5% 8A% 9B% E5% AD% A6), Revised Edition, Shokabo, (1998).

[6] Morikazu Toda, [Vibration Theory](https://www.amazon.co.jp/%E6%8C%AF%E5%8B%95%E8%AB%96-%E6%96%B0 % E7% 89% A9% E7% 90% 86% E5% AD% A6% E3% 82% B7% E3% 83% AA% E3% 83% BC% E3% 82% BA-3-% E6% 88% B8% E7% 94% B0-% E7% 9B% 9B% E5% 92% 8C / dp / 4563024031 / ref = sr_1_2? s = books & ie = UTF8 & qid = 1501826199 & sr = 1-2 & keywords =% E6% 8C% AF% E5% 8B% 95% E8% AB% 96), Baifukan, (1968).

Recommended Posts

[Scientific / technical calculation by Python] List of usage of (special) functions used in physics by using scipy
[Scientific / technical calculation by Python] List of matrices that appear in Hinpan in numerical linear algebra
[Scientific / technical calculation by Python] Fitting by nonlinear function, equation of state, scipy
[Scientific / technical calculation by Python] Solving (generalized) eigenvalue problem using numpy / scipy, using library
[Scientific / technical calculation by Python] 3rd order spline interpolation, scipy
[Scientific / technical calculation by Python] Basic operation of arrays, numpy
[Scientific / technical calculation by Python] Numerical integration, trapezoidal / Simpson law, numerical calculation, scipy
[Scientific / technical calculation by Python] 1D-3D discrete fast Fourier transform, scipy
[Scientific / technical calculation by Python] Sum calculation, numerical calculation
Scientific / technical calculation by Python] Drawing and visualization of 3D isosurface and its cross section using mayavi
[Scientific / technical calculation by Python] Calculation of matrix product by @ operator, python3.5 or later, numpy
[Scientific / technical calculation by Python] Inverse matrix calculation, numpy
[Scientific / technical calculation by Python] Histogram, visualization, matplotlib
[Scientific / technical calculation by Python] Lagrange interpolation, numerical calculation
[Scientific / technical calculation by Python] Drawing animation of parabolic motion with locus, matplotlib
[Scientific / technical calculation by Python] Numerical calculation to find the value of derivative (differential)
[Scientific / technical calculation by Python] Analytical solution to find the solution of equation sympy
[Scientific / technical calculation by Python] Drawing of 3D curved surface, surface, wireframe, visualization, matplotlib
[Scientific / technical calculation by Python] Solving the boundary value problem of ordinary differential equations in matrix format, numerical calculation
[Scientific / technical calculation by Python] Logarithmic graph, visualization, matplotlib
List of Python code used in big data analysis
[Scientific / technical calculation by Python] Polar graph, visualization, matplotlib
Group by consecutive elements of a list in Python
[Scientific / technical calculation by Python] Plot, visualization, matplotlib of 2D data read from file
[Scientific / technical calculation by Python] Numerical solution of second-order ordinary differential equations, initial value problem, numerical calculation
[Scientific / technical calculation by Python] Monte Carlo integration, numerical calculation, numpy
[Scientific and technical calculation by Python] Drawing of fractal figures [Sierpinski triangle, Bernsley fern, fractal tree]
[Scientific / technical calculation by Python] Wave "beat" and group velocity, wave superposition, visualization, high school physics
[Scientific / technical calculation by Python] Numerical solution of one-dimensional harmonic oscillator problem by velocity Verlet method
[Scientific / technical calculation by Python] Numerical solution of eigenvalue problem of matrix by power method, numerical linear algebra
[Scientific / technical calculation by Python] Monte Carlo simulation of thermodynamics of 2D Ising spin system by Metropolis method
[Scientific / technical calculation by Python] Solving simultaneous linear equations, numerical calculation, numpy
[Python] A memo of frequently used phrases (by myself) in Python scripts
[Scientific / technical calculation by Python] Vector field visualization example, electrostatic field, matplotlib
[Scientific / technical calculation by Python] 2D random walk (drunk walk problem), numerical calculation
[python] Manage functions in a list
Using global variables in python functions
[Scientific / technical calculation by Python] Derivation of analytical solutions for quadratic and cubic equations, mathematical formulas, sympy
Modules of frequently used functions in Python (such as reading external files)
[Scientific / technical calculation by Python] Solving ordinary differential equations, mathematical formulas, sympy
[Control engineering] Calculation of transfer functions and state space models by Python
(Bad) practice of using this in Python
Display a list of alphabets in Python 3
Summary of built-in methods in Python list
Non-logical operator usage of or in python
[Scientific / technical calculation by Python] Solving one-dimensional Schrodinger equation in stationary state by shooting method (1), well-type potential, quantum mechanics
Meaning of using DI framework in Python
[Scientific / technical calculation by Python] Solving second-order ordinary differential equations by Numerov method, numerical calculation
List of main probability distributions used in machine learning and statistics and code in python
[Scientific / technical calculation by Python] Plot, visualize, matplotlib 2D data with error bars
[Scientific / technical calculation by Python] Solving one-dimensional Newton equation by the 4th-order Runge-Kutta method
Extract elements (using a list of indexes) in a NumPy style from a Python list / tuple
[Scientific / technical calculation by Python] Generation of non-uniform random numbers giving a given probability density function, Monte Carlo simulation
[Scientific / technical calculation by Python] Solving one-dimensional Schrodinger equation in stationary state by shooting method (2), harmonic oscillator potential, quantum mechanics
[Python] Sort the list of pathlib.Path in natural sort
List of frequently used built-in functions and methods
Make a copy of the list in Python
View drug reviews using a list in Python
Calculation of technical indicators by TA-Lib and pandas
Summary of evaluation functions used in machine learning
Search by the value of the instance in the list