iconEuler Reference

Mathematical Functions

Content

Special Functions.

Core Functions

Many basic mathematical functions (operators, trigonometric functions, exponential functions etc.) are listed in the documentation of the core.

This file contains special functions like hyperbolic functions, elliptic functions, beta functions etc. It does also contain some polynomial functions.

Hyperbolic Functions

function sinh (x:numerical)
  Computes (exp(x)-exp(-x))/2
function cosh (x:numerical)
  Computes (exp(x)+exp(-x))/2
function asinh (z:numerical)
  Computes log(z+sqrt(z^2+1))
function acosh (z:numerical)
  Computes log(z+(z^2-1))
function map sinc (z:numerical)
  Computes sin(x)/x
  
  Takes care of x~=0, returning 1 in this case.
  For intervals containing 0, the function fails.
function sec (x:numerical)
  Computes 1/cos(x)
function cosec (x:numerical)
  Computes 1/sin(x)
function cot (x:numerical)
  Computes 1/tan(x)

Polar Coordinates

function args polar 
  polar(x,y), polar(x,y,z) compute polar coordinates.
  
  This function computes the polar coordinates in two or three
  dimensions.
  
  Returns {phi,r} or {phi,psi,r}
  
  >{phi,r}=polar(1,2); degprint(phi), r,
  63�26'5.82''
  2.2360679775
  
  See: 
rect (Mathematical Functions)
function args rect 
  rect(phi,r), rect(phi,psi,r) compute rectangle coordinates.
  
  Computes rectangle coordinates in two or three dimensions.
  
  >{x,y}=rect(45�,sqrt(2)); [x,y]
  [ 1  1 ]
  
  Returns {x,y} or {x,y,z}
  
  See: 
polar (Mathematical Functions),
polar (Maxima Documentation)

Logarithms

function logbase (x:numerical, a:numerical)
  Computes the logarithm to base a
function log10 (x:numerical)
  Computes the logarithm to base 10

Polynomials

There are many built-in functions for polynomials, like polyval, polyadd etc.

function overwrite polysolve (p:vector,
    usematrix=0, check=1)
  All roots of the polynomial p.
  
  Uses the Baurhuber method to find all zeros using the built-in
  function polysolve(o) by default.
  
  If usematrix=1 and p is not complex, the companion matrix is used
  and the algorithm from AlgLib and LAPACK. This is slower, but more
  accurate for huge degrees.
function polydif (p:vector)
  Returns the polynomial p'.
  
  Polynomials are stored in Euler starting with the constant
  coefficient.
  
  >polydif([0,0,1])
  [ 0  2 ]

Chebychev Polynomials

function map cheb (x:complex, n:nonnegative integer)
  Computes the Chebyshev polynomial T_n(x).
  
  The functions used T(x,n) = cos(n*acos(x)), if possible. For x<-1
  and x>1, it uses T(x,n) = (w+1/w)/2, where w is the n-th power of
  the inverse Joukowski transform.
  
  >x=-1.1:0.01:1.1; y=x'; z=x+I*y;
  >plot2d(abs(cheb(z,5)),niveau=exp(0:10))
  
  See: 
chebpoly (Mathematical Functions),
chebrek (Mathematical Functions)
function chebrek (x:vector, n:nonnegative integer)
  Computes the Chebyshev polynomial via the recursion formula.
  
  >chebrek(-1:0.1:1,10)
  [ 1  -0.2007474688  0.9884965888  -0.0998400512  -0.9884965888  -0.5
  0.5623462912  0.9955225088  0.4284556288  -0.5388927488  -1
  -0.5388927488  0.4284556288  0.9955225088  0.5623462912  -0.5
  -0.9884965888  -0.0998400512  0.9884965888  -0.2007474688  1 ]
  
  Works for vector x and scalar n.
function chebpoly (n:nonnegative integer)
  Computes the coefficients of the n-th Chebyshev polynomial.
  
  >p=chebpoly(10)
  [ -1  0  50  0  -400  0  1120  0  -1280  0  512 ]
  >plot2d("polyval(p,x)",-1,1);
  
  >x=-1.1:0.01:1.1; y=x'; z=x+I*y;
  >p=chebpoly(10); w=abs(polyval(p,z));
  >plot2d(log(w+0.2),niveau=0:10,>hue,>spectral)
  
  The function uses a loop.
function chebfit (xp:vector, yp:vector, n:nonnegative integer, ..
    a:real scalar=-1, b:real scalar=1)
  Fits Chebyshev polynomials on [a,b] to (xp,yp).
  
  Returns the vector of coefficients p(x) = sum a_[i] T(x,i)
  
  See: 
chebval (Mathematical Functions)
function map chebval (x:number; alpha:vector, ..
    a:real scalar=-1, b:real scalar=1)
  Evaluates sum a[i]*T(x,i).
  
  See: 
chebfit (Mathematical Functions)

Beta, Gamma and Elliptical Functions

Note that all these functions have the main argument x as first argument, and the order arguments as second arguments. In general, each of these functions has many different versions depending on the software or the web site.

function comment gamma (x)
  Gamma function at real or complex x
  
  See: 
gammai (Mathematical Functions),
gammaln (Mathematical Functions)
function comment gammaln (x)
  Logarithm of the Gamma function for real x
function comment gammai (x,a)
  Incomplete normalized Gamma function of order a.
  
  The result is normalized, so that the total integral over x is 1.
  It is also the lower integral, so that it is a distribution (see
  gammaic() for the upper integral). To get the ordinary incomplete
  gamma function multiply by gamma(a). To get the upper gamma
  function compute (1-gamma(x,a))*gamma(a).
  
  Note that the order is the second argument in Euler.
  
  Maxima has incomplete gamma functions with reversed arguments, and
  it is using the upper integral.
  
  >gammai(3,4)
  0.352768111218
  >&float(1-gamma_incomplete_regularized(4,3))
  0.35276811121777
  
  See: 
gamma (Maxima Documentation),
gammaic (Mathematical Functions)
function comment gammaic (x,a)
  Upper incomplete, regularized gamma function of order a
  
function comment beta (a,b)
  Beta function B(a,b).
function comment betai (x:real, a:real, b:real)
  Computes the normalized incomplete beta function.
function comment invbetai (x:real, a:real, b:real)
  Computes the inverse of the normalized incomplete beta function.
function map ellrf (x:real nonnegative scalar, ..
    y:real nonnegative scalar, z:real nonnegative scalar, eps=none)
  Carlson's elliptic integral of the first kind RF (x; y; z).
  
  The iteration is implemented in the Euler language.
  
  x, y, and z must be non-negative, and at most one can be zero.
  Computes
  
  1/2 integrate(1/sqrt((t+x)*(t+y)*(t+z)),t=0..inf)
  
  See: 
ellrd (Mathematical Functions),
ellf (Mathematical Functions)
function map ellf (phi: real scalar, k: real scalar)
  Elliptic integral of the first kind F(phi,k)
function map ellrd (x:real nonnegative scalar,
    y:real nonnegative scalar, z:real nonnegative scalar,
    eps=none)
  Carlson's elliptic integral of the second kind RD(x; y; z).
  
  x and y must be non-negative, and at most one can be zero. z must
  be positive. Computes
  
  3/2 integrate(1/(t+z)*sqrt((t+x)*(t+y)*(t+z))),t=0..inf)
  
  
  See: 
ellrf (Mathematical Functions),
elle (Mathematical Functions)
function map elle (phi: real scalar, k: real scalar)
  Elliptic integral of the second kind E(phi,k).
  
  See: 
ellrd (Mathematical Functions)

Bessel Functions

Note that the following functions have the order as the second argument, and the x-value as the first argument.

Bessel functions are canonical solutions of the cylinder function. They are used to compute many other useful functions.

function comment besselj (x,a)
  BesselJ function of the first kind at x with order a
  
  See: 
bessely (Mathematical Functions),
besseli (Mathematical Functions),
besselk (Mathematical Functions)
function comment bessely (x,a)
  Bessel function of the second kind at x with order a
  
  See: 
besselj (Mathematical Functions),
besseli (Mathematical Functions),
besselk (Mathematical Functions)
function comment besseli (x,a)
  Modified Bessel function of the first kind at x with order a
  
  See: 
besselj (Mathematical Functions),
bessely (Mathematical Functions),
besselk (Mathematical Functions)
function comment besselk (x,a)
  BesselJ function of the second kind at x with order a
  
  See: 
besselj (Mathematical Functions),
bessely (Mathematical Functions),
besseli (Mathematical Functions)
function comment besselallr (x,a)
  BesselJ and BesselY and their derivatives
  
  See: 
besselj (Mathematical Functions),
besselmodallr (Mathematical Functions)
function comment besselmodallr (x,a)
  Modified BesselJ and BesselY and their derivatives
  
  See: 
besselj (Mathematical Functions),
besselallr (Mathematical Functions)

Integer Arithmetic with Euler

Euler uses double arithmetic for this. If you need infinite integer arithmetic, use symbolic expressions or Python.

function map gcd (a:integer, b:integer)
  Computes the greatest common divisor of a and b.
  
  >factor(gcd(11^4*123*1237,11^2*123^2))
  [3,  11,  11,  41]
  
  See: 
lcm (Mathematical Functions),
lcm (Maxima Documentation),
gcdext (Mathematical Functions)
function lcm (a,b)
  Returns least common multiple of a and b.
  
  See: 
gcd (Mathematical Functions),
gcd (Maxima Documentation)
function gcdext (x:integer, y:integer)
  Return {g,a,b} such that ax+by=g.
  
  >p=23423429; isprime(p)
  1
  >x=3423; {g,a,b}=gcdext(x,p); g, a*x+b*p,
  4831125
  >mod(a*x,p)
  1
  
  See: 
gcd (Maxima Documentation)
function map invmod (x:integer, m:integer)
  Return y such that x*y is 1 modulo m.
  
  >p=23423429; invmod(3423,p)
function primes (n:integer)
  Return all primes up to n using the Sieve of Eratosthenes.
  
  >length(primes(1000000))
  78498
  
function map isprime (n:integer)
  Returns true if n is a prime number, false otherwise.
  
  >nonzeros(isprime(1:100))
  [2,  3,  5,  7,  11,  13,  17,  19,  23,  29,  31,  37,  41,  43,  47,
  53,  59,  61,  67,  71,  73,  79,  83,  89,  97]
  >primes(100)
  [2,  3,  5,  7,  11,  13,  17,  19,  23,  29,  31,  37,  41,  43,  47,
  53,  59,  61,  67,  71,  73,  79,  83,  89,  97]
  >sum(isprime(1000000:1100000))
  7216
  
  See: 
factor (Mathematical Functions),
factor (Maxima Documentation)
function factor (n:integer, p=none)
  Returns prime factorization of n.
  
  >fraction factor(344234237)
  [41,  8395957]
  
  See: 
isprime (Mathematical Functions)

Documentation Homepage