Mathematical Functions

Important Notes

The entries in the table below are the mathematical functions provided in the library. Each of them is a ready-made instance of a libcalculus.Function, which are callable for evaluation but can also be used with methods such as libcalculus.integrate, libcalculus.residue etc., as is documented in Analysis Methods.

Evaluating such a function is very simple - \(\text{sinh}(3)\) can be evaluated using libcalculus.sinh(3). Please note that the variable name in the following table is mostly \(z\) - this is not to imply that those functions can only accept complex inputs; real inputs are accepted as well. Read the Caveats section for more information.

Builtin Functions

Name

Mathematical Notation

Notes

abs

\(z\mapsto\left|z\right|\)

Absolute value

arccos

\(z\mapsto\text{arccos}\left(z\right)\)

Inverse cosine

arccot

\(z\mapsto\text{arccot}\left(z\right)\)

Inverse cotangent

arccsc

\(z\mapsto\text{arccsc}\left(z\right)\)

Inverse cosecant

arcosh

\(z\mapsto\text{arcosh}\left(z\right)\)

Inverse hyperbolic cosine

arcoth

\(z\mapsto\text{arcoth}\left(z\right)\)

Inverse hyperbolic cotangent

arcsch

\(z\mapsto\text{arcsch}\left(z\right)\)

Inverse hyperbolic cosecant

arcsec

\(z\mapsto\text{arcsec}\left(z\right)\)

Inverse secant

arcsin

\(z\mapsto\text{arcsin}\left(z\right)\)

Inverse sine

arctan

\(z\mapsto\text{arctan}\left(z\right)\)

Inverse tangent

arg

\(z\mapsto\text{arg}\left(z\right)\)

Complex argument

arsech

\(z\mapsto\text{arsech}\left(z\right)\)

Inverse hyperbolic secant

arsinh

\(z\mapsto\text{arsinh}\left(z\right)\)

Inverse hyperbolic sine

artanh

\(z\mapsto\text{artanh}\left(z\right)\)

Inverse hyperbolic tangent

conj

\(z\mapsto\bar{z}\)

Complex conjugate

constant(c)

\(z\mapsto c\)

Constant function

cos

\(z\mapsto\text{cos}\left(z\right)\)

Cosine

cosh

\(z\mapsto\text{cosh}\left(z\right)\)

Hyperbolic cosine

cot

\(z\mapsto\text{cot}\left(z\right)\)

Cotangent

coth

\(z\mapsto\text{coth}\left(z\right)\)

Hyperbolic cotangent

csc

\(z\mapsto\text{csc}\left(z\right)\)

Cosecant

csch

\(z\mapsto\text{csch}\left(z\right)\)

Hyperbolic cosecant

e

\(z\mapsto e\)

Euler’s number

exp

\(z\mapsto e^z\)

Exponential function

identity

\(z\mapsto z\)

Identity function

imag

\(z\mapsto\text{Im}\left(z\right)\)

Imaginary part

line(z1, z2)

\(t\mapsto\left(1-t\right)z_1+tz_2\)

Contour representing a line with \(t\in\left[0,1\right]\)

ln

\(z\mapsto\text{ln}\left(z\right)\)

Natural logarithm (principal branch)

pi

\(z\mapsto \pi\)

Constant π

piecewise(comp_, then_, else_)

\(z\mapsto \begin{cases} \text{then_}\left(z \right ) & ; \;\text{comp_}\left(z \right )=\mathbb{T} \\ \text{else_}\left(z \right ) & ; \;\text{comp_}\left(z \right )=\mathbb{F} \end{cases}\)

If comp_ returns True at z return then_(z), otherwise return else_(z).

real

\(z\mapsto\text{Re}\left(z\right)\)

Real part

sec

\(z\mapsto\text{sec}\left(z\right)\)

Secant

sech

\(z\mapsto\text{sech}\left(z\right)\)

Hyperbolic secant

sin

\(z\mapsto\text{sin}\left(z\right)\)

Sine

sinh

\(z\mapsto\text{sinh}\left(z\right)\)

Hyperbolic sine

sphere(center=0, radius=1)

\(t\mapsto \text{center}+\text{radius}\cdot e^{2\pi it}\)

Contour representing a circle with \(t\in\left[0,1\right]\)

tan

\(z\mapsto\text{tan}\left(z\right)\)

Tangent

tanh

\(z\mapsto\text{tanh}\left(z\right)\)

Hyperbolic tangent

Operations

Any standard mathematical operation can be applied to a libcalculus.Function object. Given two libcalculus.Function objects f and g:

Syntax

Mathematical Notation

Notes

-f

\(z\mapsto -f\left(z\right)\)

Function additive inverse

f + g

\(z\mapsto f\left(z\right)+g\left(z\right)\)

Function addition

f - g

\(z\mapsto f\left(z\right)-g\left(z\right)\)

Function subtraction

f * g

\(z\mapsto f\left(z\right)\cdot g\left(z\right)\)

Function multiplication

f / g

\(z\mapsto \frac{f\left(z\right)}{g\left(z\right)}\)

Function division

f ** g

\(z\mapsto \left(f\left(z\right)\right)^{g\left(z\right)}\)

Function exponentiation

f @ g

\(z\mapsto f\left(g\left(z\right)\right)\)

Function composition

The corresponding in-place operations are supported; operations with constants are supported where applicable as well:

>>> (2 * libcalculus.sin)(3)
0.2822400161197344
>>> (4 ** libcalculus.sin)(3)
(1.2160815815872013+0j)

Other Remarks

Try to use library builtins as much as possible - this comes in handy with mathematical constants for example:

f = libcalculus.pi * libcalculus.sin
g = np.pi * libcalculus.sin

In this instance, f.latex() will return "\\pi \\sin\\left(x\\right)" (corresponding to \(\pi \sin\left(x\right)\)), while g.latex() will return "3.14159 \\sin\\left(x\\right)" (corresponding to \(3.14159 \sin\left(x\right)\)).

Caveats

The library employs a fundamental distinction between “purely complex-valued” functions and ones that might occasionally return a complex value: (1j * libcalculus.sin)(3) will call an underlying C++ function accepting a real input and returning a complex output; however, libcalculus.arcsin(3) will actually return np.nan. To avoid this, cast to complex - libcalculus.arcsin(complex(3)) will correctly return (1.5707963267948966+1.762747174039086j).