Built-in Mathematical Functions

Index

This index gives a list of keywords that are associated with various cells in this Notebook. If you Command-Double-click one of the keywords below,  Mathematica  will find the cell associated with that keyword, select it, and display it in the center of  your window.

Abs  
AiryAi  
AiryAiPrime  
AiryBi  
AiryBiPrime  
ArcCos  
ArcCosh  
ArcCot  
ArcCoth  
ArcCsc  
ArcCsch  
ArcSec  
ArcSech  
ArcSin  
ArcSinh  
ArcTan  
ArcTanh  
Arg  
ArithmeticGeometricMean  
BernoulliB  
BesselI  
BesselJ  
BesselK  
BesselY  
Beta  
Binomial  
Catalan  
Ceiling  
ChebyshevT  
ChebyshevU  
ClebschGordan  
Conjugate  
Cos  
Cosh  
CosIntegral  
Cot  
Coth  
Csc  
Csch  
Degree  
Divisors  
DivisorSigma  
E  
EllipticE  
EllipticExp  
EllipticF  
EllipticK  
EllipticLog  
EllipticPi  
EllipticTheta  
Erf  
Erfc  
EulerE  
EulerGamma  
EulerPhi  
Exp  
ExpIntegralE  
ExpIntegralEi  
ExtendedGCD  
Factorial  
Factorial`double  
FactorInteger  
Floor  
Gamma  
GaussianIntegers  
GCD  
GegenbauerC  
GoldenRatio  
HermiteH  
Hypergeometric0F1  
Hypergeometric1F1  
Hypergeometric2F1  
HypergeometricU  
I  
Im  
Infinity  
IntegerDigits  
InverseJacobiSN  
JacobiAmplitude  
JacobiP  
JacobiSN  
JacobiSymbol  
JacobiZeta  
LaguerreL  
LCM  
LegendreP    
LerchPhi  
Log  
LogIntegral  
Max  
Min  
Mod  
MoebiusMu  
Multinomial  
Numbers`complex  
Partitions  
PartitionsQ  
Pi  
Pochhammer  
PolyGamma  
PolyLog  
PowerMod  
Prime  
PrimePi  
PrimeQ  
Quotient  
Random  
Re  
ReimannSiegelTheta  
ReimannSiegelZ  
Round  
Sec  
Sech  
SeedRandom  
Sign  
Signature  
Sin  
Sinh  
SinIntegral  
SixJSymbol  
SphericalHarmonicY  
StirlingS1  
StirlingS2  
Tan  
Tanh  
ThreeJSymbol  
Zeta

Naming Conventions

Mathematical functions in Mathematica  are given names according to definite rules.  As with most Mathematica  functions, the names are usually complete English words, fully spelled out.  For a few very common functions, Mathematica  uses the traditional abbreviations.  Thus the modulo function, for example, is Mod, not Modulo.

Mathematical functions that are usually referred to by a person's name have names in Mathematica  of the form PersonSymbol .  Thus, for example, the Legendre polynomials are denoted LegendreP[n, x ].  Although this convention does lead to longer function names, it avoids any ambiguity or confusion.

When the standard notation for a mathematical function involves both subscripts and superscripts, the subscripts are given before the superscripts in the Mathematica  form.  Thus, for example, the associated Legendre polynomials are denoted LegendreP[n, m, x ].

Numerical Functions

Syntax (see page 550)

Round

Round[x ] gives the integer closest to x .

Floor

Floor[x ] gives the greatest integer not larger than x. .

Ceiling

Ceiling[x ] gives the least integer not smaller than x..

Sign

Sign[x ] gives 1 for x > 0, -1 for x < 0 and 0 for x = 0.

Abs

Abs[x ] gives the absolute value |x | of x..

Max

Max[x1 , x2 , ... ] or Max[{x1 , x2 , ... }, ... ] gives the maximum of x1 , x2 , ...

Min

Min[x1 , x2 , ... ] or Min[{x1 , x2 ... }, ... ] gives the minimum of  x1 , x2 , ...

Complex Numbers

x  + I y  gives the complex number x  +iy .

Re

Re[z ] gives the real part.

Im

Im[z ] gives the imaginary part.

Conjugate

Conjugate[z ] gives the complex conjugate.

Abs

Abs[z ] gives the absolute value |z |.

Arg

Arg[z ] gives the argument phi  such that 
z = Abs[z ] Exp[phi ].

Round, Floor and Ceiling

Round[2.5]

Floor[2.5]

Ceiling[2.5]

Real and Imaginary Parts

Re[ 3.2 + 2.3 I]

Im[ 3.2 + 2.3 I]

Conjugate

Conjugate[ 3.2 + 2.3 I]

Argument and Absolute Value

Abs[ 3.2 + 2.3 I]

Arg[ 3.2 + 2.3 I]

Pseudorandom Numbers

Syntax (see page 552)

Random

Random[ ] gives a pseudorandom real between 0 and 1.

Random[Real, xmax ] gives a pseudorandom real between 0 and xmax..

Random[Real, {xmin , xmax }] gives a pseudorandom real between xmin  and xmax..

Random[Complex] gives a pseudorandom complex number in the unit square.

Random[Complex, {zmin , zmax }] gives a pseudorandom complex number in the rectangle defined by zmin  and zmax..

Random[type , range , n ] gives a pseudorandom number with n-digit precision.

Random[Integer] gives a 0 or 1 with probability 1/2.

Random[Integer, {imin , imax }] gives a pseudorandom integer between imin  and imax , inclusive.

SeedRandom

SeedRandom[ ] reseeds the pseudorandom generator with the time of day.

SeedRandom[s ] reseeds with the integer s .

List of Pseudorandom Numbers

Table[Random[ ], {3}]

Pseudorandom Number in a Restricted Range

Random[Real, {-1, 1}]

Arbitrary-Precision Pseudorandom Number

Random[Real, {0, 1}, 30]

Note on Pseudorandom Numbers

Random is unlike almost every other Mathematica  function in that every time you call it, you potentially get a different result. If you use Random in a calculation, therefore, you may get different answers on different occasions. The pseudorandom numbers that Mathematica  generates are always uniformly distributed over the range you specify.  (For information on how to generate pseudorandom numbers with specified distributions, see page 588.)

The sequences you get from Random[ ] are not in most senses "truly random", although they should be "random enough" for practical purposes. The sequences are in fact produced by applying a definite mathematical algorithm, starting from a particular "seed". If you give the same seed, then you get the same sequence. This is illustrated in the next example.

Reseeding the Pseudorandom Number Generator

Note that the same seed produces the same sequence.

SeedRandom[ 122 ]

Table[Random[ ], {3}]

SeedRandom[ 100 ]

Table[Random[ ], {3}]

SeedRandom[ 122 ]

Table[Random[ ], {3}]

Integer and Number-Theoretical Functions

Syntax (see page 553)

Mod

Mod[k , n ] gives k  modulo n  (remainder from dividing k  by n).

Quotient

Quotient[m , n ] gives the quotient of m  and n  (integer part of m ^ n ).

GCD

GCD[n1 , n2 , ... ] gives the greatest common divisor of n1, n2, ...

LCM

LCM[n1 , n2 , ... ] gives the least common multiple of n1, n2, ...

IntegerDigits

IntegerDigits[n , b ] gives the digits of n  in base b .

FactorInteger

FactorInteger[n ] gives a list of the prime factors of n , and their exponents.

Divisors

Divisors[n ] gives a list of the integers that divide n .

Prime

Prime[k ] gives the k th  prime number.

PrimePi

PrimePi[x ] gives the number of primes less than x .

PrimeQ

Prime[n ] gives True if n  is a prime, and False otherwise.

Factors of Gaussian Integers

FactorInteger[n , GaussianIntegers->True] gives a list of the Gaussian prime factors of the Gaussian integer n , and their exponents.

PowerMod

PowerMod[a , b , n ] gives the power a^ b  to modulo n..

EulerPhi

EulerPhi[n ] gives the Euler totient function.

MoebiusMu

MoebiusMu[n ] gives the Mobius function.

DivisorSigma

DivisorSigma[k , n ] gives the divisor function.

JacobiSymbol

JacobiSymbol[n , m ] gives the Jacobi symbol.

ExtendedGCD

ExtendedGCD[m , n ] gives the extended greatest common divisor of m  and n..

Using Mod  and Quotient

Mod[17, 3]

Quotient[17, 3]

3 % + %%

Mod  and Quotient with Real Numbers

Mod[5.6, 1.2]

Quotient[5.6, 1.2]

Greatest Common Divisor

GCD[24, 15]

Least Common Multiple

LCM[24, 15, 9]

Factoring Integers

FactorInteger[24]

A Note on Integer Factoring

According to current mathematical thinking, integer factoring is a fundamentally difficult computational problem. As a result, you can easily type in an integer that Mathematica  will not be able to factor in anything short of an astronomical length of time. As long as the integers you give are less than about 20 digits long, FactorInteger should have no trouble.

Although Mathematica  may not be able to factor a large integer, it can often still test whether or not the integer is prime. In addition, Mathematica  has a fast way of finding the k th prime number.

Testing Whether an Integer Is Prime

PrimeQ[234242423]

Millionth Prime

Prime[ 10^6 ]

Number of Primes Less than a Billion

PrimePi[10^9]

Factoring in Terms of Gaussian Integers

FactorInteger[ 111 + 78 I,
            GaussianIntegers -> True]

Using PowerMod

This gives 2^13421 modulo 3.  Note that PowerMod is equivalent to taking a power and then using Mod, but it is much more efficient.

PowerMod[2, 13421, 3]

Modular Inverse

This gives the modular inverse of 3 modulo 7.

PowerMod[3, -1, 7]

Euler Phi Function

This gives the number of integers less than 60 that are relatively prime to 60.

EulerPhi[60]

Divisors

This gives a list of the divisors of 24 and then the number of such divisors.

Divisors[24]

DivisorSigma[0, 24]

Extended Greatest Common Divisor

The second line shows the property that the extended greatest common divisor satisfies.

{g, {r, s}} = ExtendedGCD[105, 196]

r 105 + s 196 == g

Combinatorial Functions

Syntax (see page 558)

Factorial

n ! is the factorial n (n - 1)(n - 2) x ... x 1.

Double Factorial

n !! is the double factorial n (n - 2)(n - 4) x ...

Binomial

Binomial[n , m ] is a binomial coefficient .

Multinomial

Multinomial[n1 , n2 , ... ] gives multinomial coefficient .

BernoulliB

BernoulliB[n ] gives the n th Bernoulli number.

BernoulliB[n , x ] gives the n th Bernoulli polynomial.

EulerE

EulerE[n ] gives the n th Euler number.

EulerE[n , x ] gives the n th Euler polynomial.

StirlingS1

StirlingS1[n , m ] gives a Stirling number of the first kind.

StirlingS2

StirlingS2[n , m ] gives a Stirling number of the second kind.

Partitions

Partitions[n ] gives the number of unrestricted partitions of the integer n..

PartitionsQ

PartitionsQ[n ] gives the number of partitions of n into distinct parts.

Signature

Signature[{i1 , i2 , ... }] gives the signature of a permutation.

ClebschGordan

ClebschGordan[{j1 , m1 }, {j2 , m2 }, {j , m }] gives a Clebsch-Gordan coefficient.

ThreeJSymbol

ThreeJSymbol[{j1 , m1 }, {j2 , m2 }, {j3 , m3 }] gives a Wigner 3-j symbol.

SixJSymbol

SixJSymbol[{j1 , j2 , j3 }, {j4 , j5 , j6 }] gives a Racah 6-j symbol.

Factorial

For non-integers, Mathematica  evaluates factorials using the gamma function.

30!

3.6!

Binomial Coefficient

Binomial[ 11, 6]

Symbolic Binomial Coefficient

Binomial[ n, 2]

Multinomial Coefficient

Multinomial[ 3, 6, 5]

Bernoulli Polynomial

This gives the second Bernoulli polynomial.

BernoulliB[2, x]

Bernoulli Number

This gives the 20th Bernoulli number as an exact rational number and as an approximate real number.

BernoulliB[20]

NBernoulliB[20]

Symbolic 3-j Symbol

ThreeJSymbol[{j, m}, {j + 1/2, -m-1/2}, 
                                {1/2. 1/2}]

Elementary Transcendental Functions

Syntax (see page 562)

Exp

Exp[x ] gives the exponential of x .

Log

Log[x ] gives the natural logarithm of x .

Log[b , x ] gives the logarithm base b  of x .

Trigonometric Functions

Sin[x ], Cos[x ], Tan[x ], Csc[x ], Sec[x ] and Cot[x ] give the value of the trigonometric functions at x  radians.

Inverse Trigonometric Functions

ArcSin[x ], ArcCos[x ], ArcTan[x ], ArcCsc[x ],
ArcSec[x ] and ArcCot[x ] give the value of the inverse trigonometric functions at x .

Hyperbolic Functions

Sinh[x ], Cosh[x ], Tanh[x ], Csch[x ], Sech[x ] and 
Coth[x ] give the value of the  hyperbolic functions at x .

Inverse Hyperbolic Functions

ArcSinh[x ], ArcCosh[x ], ArcTanh[x ], ArcCsch[x ], ArcSech[x ] and ArcCoth[x ] give the value of the  hyperbolic functions at x .

Trigonometric Function with Exact Result

Note that the arguments to trigonometric functions are always in radians.

Sin[Pi/3]

N[%]

Trigonometric Function with Approximate Result

Note the explicit use of the decimal point.

Tan[2.]

A Note on Exact and Approximate Results

Mathematica  tries to give exact values for mathematical functions when you give it exact input. Thus Sin[Pi] gives 1 but Sin[3] is returned unevaluated. To get an approximate numerical result you can use N or else include an explicit decimal point.

Trigonometric Function Using Degrees

Multiplying by the constant Degree converts the argument to radians.

Tan[2 Degree] //N

Inverse Trigonometric Functions

ArcCsc[1]

ArcTan[.12]

A Note on Inverse Functions

An inverse function is the solution to an equation. For
example, the inverse or arc sine function gives a solution to the equation         y==Sin[x]. However, there are many such solutions. Thus in defining an inverse function one must make a choice of a "principle value". For the inverse trigonometric and hyperbolic functions there are standard choices made in mathematics. These same choices are used by Mathematica .  For example, the values of ArcSin are always in the range -Pi/2 to Pi/2.  For information on a specific inverse function, see  its reference guide entry in The Mathematica  Book.

Hyperbolic Functions

Tanh[.12]

ArcCsch[3.2]

Exponential

Exp[2.3]

E^2.3

Natural Logarithm

Recall that the natural log is a logarithm base E.

Log[5.654]

Common Logarithm

Recall that the common log is a logarithm base 10.

Log[10, 100]

Logarithm Base Two

Log[2, 256]

Factorial

10!

Mathematical Constants

Syntax (see page 566)

Pi

Pi is the ratio of the perimeter of a circle to its diameter. It is approximately equal to 3.14159.

E

E is the base of the natuaral logarithm. It is approximately equal to 2.71828.

Degree

Degree is the degrees-to-radians conversion factor. It is equal to Pi/180.

I

I is the square root of minus 1.

Infinity

Infinity represents a positive infinite quantity.

GoldenRatio

GoldenRatio is equal to (1 + Sqrt[5])/2.

EulerGamma

EulerGamma is Euler's constant

Catalan

Catalan is Catalan's constant.

Arbitrary-Precision Value of a Constant

Note that mathematical  constants are exact quantities in Mathematica  so you must use N to get an approximate numerical value.

N[E, 50]

Orthogonal Polynomials

Syntax (see page 566)

LegendreP

LegendreP[n , x ] gives a Legendre polynomial.

LegendreP[n , m , x ] gives an associated Legendre polynomial.

SphericalHarmonicY

SphericalHarmonicY[ l, m , theta , phi ] gives a spherical harmonic.

GegenbauerC

GegenbauerC[n , m , x ] gives a Gegenbauer polynomial.

ChebyshevT and ChebyshevU

ChebyshevT[n , x ], ChebyshevU[n , x ] give Chebyshev polynomials of the first and second kinds.

HermiteH

HermiteH[n , x ] gives a Hermite polynomial.

LaguerreL

LaguerreL[n , x ] gives a Laguerre polynomial.

LaguerreL[n ,a ,x ] gives a generalized Laguerre polynomial.

JacobiP

JacobiP[n , a , b , x ] gives a Jacobi polynomial.

Legendre Polynomial

This gives the sixth Legendre polynomial.

LegendreP[6, x]

Associated Legendre Polynomial

LegendreP[6, 3, x]

Generalized Laguerre Polynomial

LaguerreL[2, a, x]

Special Functions

Syntax (see page 570)

AiryAi and AiryBi

AiryAi[z ] and AiryBi[z ] give Airy functions.

AiryAiPrime and AiryBiPrime

AiryAiPrime[z ] and AiryBiPrime[z ] give derivatives of Airy functions.

Bessel Functions

BesselJ[n , z ] and BesselY[n , z ] give Bessel functions.

BesselI[n , z ] and BesselK[n , z ] give modified Bessel functions.

Beta

Beta[a , b ] gives a Euler beta function.

Beta[z , a , b ] gives an incomplete beta function.

CosIntegral

CosIntegral[z ] gives a cosine integral function

Erf and Erfc

Erf[z ]  and Erfc[z ] give the error function and the complementary error function.

Erf[z0 , z1 ] gives the generalized error function erf(z1 ) - erf(z0 ).

ExpIntegralE

ExpIntegralE[n , z ] gives the exponential integral function.

ExpIntegralEi

ExpIntegralEi[z ] gives the exponential integral function.

Gamma

Gamma[z ] gives the Euler gamma function.

Gamma[a , z ] gives the incomplete gamma function.

Gamma[a , z0 , z1 ] gives the generalized incomplete gamma function.

Hypergeometric0F1

Hypergeometric0F1[a , z ] gives the hypergeometric function.

Hypergeometric1F1

Hypergeometric1F1[a , b , z ] gives the Kummer confluent hypergeometric function.

HypergeometricU

HypergeometricU[a , b , z ] gives the confluent hypergeometric function.

Hypergeometric2F1

Hypergeometric2F1[a , b , c , z ] gives the hypergeometric function.

LegendreP

LegendreP[n , z ], LegendreQ[n , z ] gives the Legendre functions of the first and second kinds.

LegendreP[n , m , z ], LegendreQ[n , m , z ] gives the associated Legendre functions.

LerchPhi

LerchPhi[z , s , z ]]gives the Lerch's transcendent.

LogIntegral

LogIntegral[z ] gives the logarithmic integral.

Pochhammer

Pochhammer[a , n ] gives the Pochhammer symbol.

PolyGamma

PolyGamma[z ] gives the digamma function.

PolyGamma[n , z ] gives the nth derivative of the digamma function.

PolyLog

PolyLog[n , z ] gives the polylogarithm function.

ReimannSiegelTheta

ReimannSiegelTheta[t ] and ReimannSiegelZ[t ] give the Reimann-Siegel functions.

SinIntegral

SinIntegral[z ] gives the sine integral function.

Zeta

Zeta[s ] gives the Riemann zeta function.

Zeta[s , a ] gives the generalized Riemann zeta function.

A Note on Special Functions

Mathematica  includes all the common special functions of mathematical physics. There are often several conflicting definitions of any particular special function in the literature. When you use a special function in Mathematica , you should look at the definition given on page 571 -579 of The Mathematica  Book.

Exact Result

Mathematica  gives exact results for some values of special functions. When the argument is exact and no exact result is known, the input is returned unevaluated.

Gamma[15/2]

Gamma[15/7]

Arbitrary-Precision Result

Even if no exact result is known, you can get a numerical result to arbitrary precision. This example gives a result computed to 40 decimal places.

Gamma[15/7]

N[%, 40]

Complex Argument

Gamma[ 3 + 4I] //N

Analytic Derivative

Mathematica knows some analytical properties of special functions , such as derivatives.

D[Gamma[x], {x, 2}]

Elliptic Integrals and Elliptic Functions

Syntax (see page 580)

EllipticK

EllipticK[m ] gives the complete elliptic integral of the first kind.

EllipticF

EllipticF[phi, m ] gives the elliptic integral of the first kind.

EllipticE

EllipticE[m ] gives the complete elliptic integral of the second kind.

EllipticE[phi, m ] gives the elliptic integral of the second kind.

JacobiZeta

JacobiZeta[phi, m ] gives the Jacobi zeta function.

EllipticPi

EllipticPi[n, phi, m ] gives the elliptic integral of the third kind.

JacobiAmplitude

JacobiAmplitude[u, m ] gives the amplitude functions.

JacobiSN

JacobiSN[u, m ], JacobiCN[u, m ], etc. give the Jacobi elliptic functions.

InverseJacobiSN

InverseJacobiSN[v, m ], InverseJacobiCN[v, m ], etc. give the inverse Jacobi elliptic functions.

EllipticTheta

EllipticTheta[a, u, q ] gives the elliptic theta functions.

EllipticLog

EllipticLog[{x, y },{a, b }] gives the generalized logarithm associated with the elliptic curve y^2 = x^3+a x^2 - bx.

EllipticExp

EllipticExp[u, {a, b }] gives the generalized exponential associated with the elliptic curve y^2 = x^3+a x^2 - bx.

ArithmeticGeometricMean

ArithmeticGeometricMean[a, b ] gives the arithmetic-geometric mean of a  andb.

A Note on Elliptic Integrals and Elliptic Functions

You should be very careful about the arguments you give to elliptic functions in Mathematica .  There are several incompatible conventions in common mathematical use.  You will often have to convert from a particular convention to the one that Mathematica  uses.

In mathematical usage, the different argument conventions are sometimes distinguished by the use of separators other than commas between the arguments.  Often, however, there is no clue about which notation is used, other than perhaps the specific names given to the arguments.  In addition, in many cases, some arguments are not explicitly given.