Orbital library

orbital.math.functional
Class Functions

java.lang.Object
  extended by orbital.math.functional.Functions

public final class Functions
extends java.lang.Object

Common function implementations.

Author:
André Platzer
Stereotype:
Module

Field Summary
static Function arccos
          arccos: [-1,1]→[0,π]; x ↦ arccos x = cos-1 x.
static Function arccot
          arccot: R→(0,π); x ↦ arccot x = cot-1 x.
static Function arcosh
          arcosh: [1,∞)→[0,∞); x ↦ arcosh x = (cosh|[0,∞))-1 x = ㏒(x ± √x2-1).
static Function arcoth
          arcoth: R\[-1,1]→R\{0}; x ↦ arcoth x = coth-1 x = ㏒((x+1) / (x-1)) / 2.
static Function arcsin
          arcsin: [-1,1]→[-π/2,π/2]; x ↦ arcsin x = sin-1 x.
static Function arctan
          arctan: R→(-π/2,π/2); x ↦ arctan x = tan-1 x.
static Function arsinh
          arsinh: R→R; x ↦ arsinh x = sinh-1 x = ㏒(x + √x2+1).
static Function artanh
          artanh: (-1,1)→R; x ↦ artanh x = tanh-1 x = ㏒((1+x) / (1-x)) / 2.
static Function cos
          cos: CC; x ↦ cos x = ∑n=0 (-1)n * x2n / (2n)!.
static Function cosh
          cosh: CC; x ↦ cosh x = (ex+e-x) / 2 = ∑n=0 x2n / (2n)!.
static Function cot
          cot: CZC; x ↦ cot x = cos x / sin x = 1 / tan x.
static Function coth
          coth: R\{0}→R; x ↦ coth x = cosh x / sinh x = 1 / tanh x.
static Function csc
          csc: R\{0}→R; x ↦ csc x = 1 / sin(x).
static Function csch
          csch: R\{0}→R; x ↦ csch x = 1 / sinh(x).
static BinaryFunction delta
          delta: R×RR; (x,x) ↦ 1, (x,y) ↦ 0 for x≠y.
static Function diracDelta
          diracDelta δ: M\{0}→{0}; x ↦ 0 if x≠0.
static Function exp
          exp: CC\{0}; x ↦ ex = ∑n=0 xn / n!.
static Functions functions
          Class alias object.
static Function id
          id: R→R; x ↦ x .
static Function log
          ㏒: C\{0}→C; x ↦ ㏒e x.
static Function logistic
          logistic: A→(0,1); x ↦ 1 / (1 + e-x).
static Function nondet
          Represents a nondeterministic function.
static Function norm
          norm: A→[0,∞); x ↦ ||x||.
static Function one
          one: R→R; x ↦ 1 .
static BinaryFunction projectFirst
          Projects to the first argument, ignoring the second.
static BinaryFunction projectSecond
          Projects to the second argument, ignoring the first.
static Function reciprocal
          reciprocal: C\{0}→C; x ↦ x-1 = 1 / x.
static Function sec
          sec: R→R; x ↦ sec x = 1 / cos(x).
static Function sech
          sech: R→R; x ↦ sech x = 1/cosh(x).
static Function sign
          sign: A→{-1,0,1}; x ↦ -1 if x<0, x ↦ 0 if x=0, x ↦ 1 if x>0.
static Function sin
          sin: CC; x ↦ sin x = ∑n=0 (-1)n * x2n+1 / (2n+1)!.
static Function sinh
          sinh: CC; x ↦ sinh x = (ex-e-x) / 2 = ∑n=0 x2n+1 / (2n+1)!.
static Function sqrt
          sqrt √ : CC; x ↦ √x = x1/2.
static Function square
          square: R→R; x ↦ x2 .
static Function tan
          tan: C\(π/2+πZ)→C; x ↦ tan x = sin x / cos x.
static Function tanh
          tanh: C\(πi/2*Z)→C; x ↦ tanh x = sinh x / cosh x.
static Function zero
          zero: R→R; x ↦ 0 .
 
Method Summary
static BinaryFunction binaryConstant(Arithmetic a)
          constant â: R×R→R; (x,y) ↦ a.
static BinaryFunction binarySymbolic(java.lang.String name)
          symbolic f:R×R→R; (x,y) ↦ f(x, y).
static Function constant(java.lang.Object a)
          constant â: R→R; x ↦ a .
static int delta(int i, int j)
           
static Function exp(Arithmetic b)
          expb: CC\{0}; x ↦ bx .
static Function linear(Arithmetic a)
          linear: A→B; x ↦ a*x.
static Function piecewise(Predicate[] cond, Function[] value)
          Get a function defined piecewise.
static UnivariatePolynomial polynom(int degree)
          polynom: R'→R'; X↦i=0d Xi.
static UnivariatePolynomial polynom(Vector coeff)
          polynom: R'→R'; X↦i=0d aiXi.
static Function pow(Arithmetic p)
          powp: R→R; x ↦ xp .
static Function pow(double p)
           
static Function projection(int component)
          projection πc: An→A; (x1,...xn)T ↦ xc.
static Function projection(int i, int j)
          projection πi,j: An×m→A; (xi,j) ↦ xi,j.
static Function step(Real t)
          step ht: A→{0,1}; x ↦ 1 if x≥t, x ↦ 0 if x<t.
static Function symbolic(java.lang.String name)
          symbolic f:R→R; x ↦ f(x).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

functions

public static final Functions functions
Class alias object.

To alias the methods in this class, use an idiom like

 // alias object
 Functions F = Functions.functions;
 Operations op = Operations.operations;
 // use alias
 Function f = (Function) op.times.apply(F.sin, op.plus.apply(F.square, F.cos));
 // instead of the long form
 Function f = (Function) Operations.times.apply(Functions.sin, Operations.plus.apply(Functions.square, Functions.cos));
 


zero

public static final Function zero
zero: R→R; x ↦ 0 .


one

public static final Function one
one: R→R; x ↦ 1 .


id

public static final Function id
id: R→R; x ↦ x .

derive: id' = 1
integrate: ∫id dx = x2/2


reciprocal

public static final Function reciprocal
reciprocal: C\{0}→C; x ↦ x-1 = 1 / x.

derive: reciprocal' = -x-2
integrate: ∫x-1 dx = ㏒ x

It is generally preferred to use Operations.inverse instead!

See Also:
Operations.inverse

square

public static final Function square
square: R→R; x ↦ x2 .

derive: square' = 2*id
integrate: ∫x2 dx = x3/3

Implementation uses faster x*x for Values.


sqrt

public static final Function sqrt
sqrt √ : CC; x ↦ √x = x1/2.

derive: √x' = -1/2/√x
integrate: ∫ √xdx = 2/3*x3/2

Implementation uses faster Math.sqrt(double) for scalars in [0,∞).

For complex numbers z=r*ei≠0 this function returns

|z|*ei*φ/2 = √r * (cos(φ/2) + i*sin(φ/2))
But just like real numbers, the negative of this is a square root as well.


exp

public static final Function exp
exp: CC\{0}; x ↦ ex = ∑n=0 xn / n!.

derive: (ex)' = ex
integrate: ∫ex dx = ex

For complex numbers x = a + i*b∈C; a,b∈R this function returns ea + i*b = eaei*b = ea * (cos(b) + i*sin(b)).

exp-function is exactly 2kπi-periodic. This is due to the relation ∀z∈C ez+ω = ezeω = 1 ⇔ ω = 2kπi; k∈Z.

See Also:
log, ValueFactory.polar(Real,Real)

log

public static final Function log
㏒: C\{0}→C; x ↦ ㏒e x.

derive: ㏒' = 1 / x
integrate: ∫㏒ x dx = x*㏒ |x| - x

For complex numbers x=r*eiφC this function returns the principal logarithm

㏒(z) = ㏒(r) + i*φ = ㏒ |z| + i*arg(z)
But adding 2kπi will lead to all other (complex) logarithms. These multiple logarithms of complex numbers result from exp-function being 2kπi periodic.

See Also:
exp

sin

public static final Function sin
sin: CC; x ↦ sin x = ∑n=0 (-1)n * x2n+1 / (2n+1)!. Sine function.

derive: sin' = cos
integrate: ∫sin x dx = -cos x

For complex numbers z this function returns sin z = sinh(i*z)/i = (ei*z-e-i*z) / (2i).

functional equations: sin(x+y) = sin x * cos y + cos x * sin y, cos(x+y) = cos x * cos y - sin x * sin y.
sin(x)2 + cos(x)2 = 1

This sinus looks like ∿.

See Also:
arcsin, sinh

cos

public static final Function cos
cos: CC; x ↦ cos x = ∑n=0 (-1)n * x2n / (2n)!. Cosine function

derive: cos' = -sin
integrate: ∫cos x dx = sin x

For complex numbers z this function returns cos z = cosh(i*z) = (ei*z+e-i*z) / 2.

reductions: cos x = sin(π/2+x)

See Also:
arccos, cosh

tan

public static final Function tan
tan: C\(π/2+πZ)→C; x ↦ tan x = sin x / cos x. Tangent function.

derive: tan' = sec2 = 1/cos2 = 1 + tan2
integrate: ∫tan x dx = - ㏒(cos x)

For complex numbers z this function is tan z = tanh(i*z)/i.

See Also:
arctan, cot

cot

public static final Function cot
cot: CZC; x ↦ cot x = cos x / sin x = 1 / tan x. Cotangent function.

derive: cot' = -csc2 = -(1 + cot2).

integrate: ∫cot x dx = ㏒(sin x)

For complex numbers z this function is cot z = coth(i*z)*i.

See Also:
tan

csc

public static final Function csc
csc: R\{0}→R; x ↦ csc x = 1 / sin(x). Cosecant function.

derive: csc' = -cot*csc


sec

public static final Function sec
sec: R→R; x ↦ sec x = 1 / cos(x). Secant function.

derive: sec' = sec*tan.


arcsin

public static final Function arcsin
arcsin: [-1,1]→[-π/2,π/2]; x ↦ arcsin x = sin-1 x. Arc sine function.

derive: arcsin' = 1 / √1 - x2
integrate: ∫arcsin x dx = x * arcsin x + √1 - x2

arcsin x = ∑n=0 (-1)n * nCr(-1/2, n) * x2n+1 / (2n+1) on (-1,1).

See Also:
sin

arccos

public static final Function arccos
arccos: [-1,1]→[0,π]; x ↦ arccos x = cos-1 x. Arc cosine function.

derive: arccos' = - 1 / √1 - x2
integrate: ∫arccos x dx = x * arccos x - √1 - x2

arccos x = π/2 - arcsin x.

See Also:
cos

arctan

public static final Function arctan
arctan: R→(-π/2,π/2); x ↦ arctan x = tan-1 x. Arc tangent function.

derive: arctan' = 1 / (1 + x2)
integrate: ∫arctan x dx = x * arctan x - ㏒(x2 + 1)/2

arctan x = ∑n=0 (-1)n * x2n+1 / (2n+1) on [-1,1].

See Also:
tan

arccot

public static final Function arccot
arccot: R→(0,π); x ↦ arccot x = cot-1 x. Arc cotangent function.

derive: arccot' = - 1 / (1 + x2)
integrate: ∫arccot x dx = x * arccot x + ㏒(x2 + 1)/2

arccot x = π/2 - arctan x.

See Also:
cot

sinh

public static final Function sinh
sinh: CC; x ↦ sinh x = (ex-e-x) / 2 = ∑n=0 x2n+1 / (2n+1)!. Hyperbolic sine function.

derive: sinh' = cosh
integrate: ∫sinh x dx = cosh x

functional equations: sinh(x+y) = sinh x * cosh y + cosh x * sinh y, cosh(x+y) = cosh x * cosh y + sinh x * sinh y.
cosh(x)2 - sinh(x)2 = 1
(cosh x+ sinh x)n = cosh(n*x) + sinh(n*x)

See Also:
arsinh

cosh

public static final Function cosh
cosh: CC; x ↦ cosh x = (ex+e-x) / 2 = ∑n=0 x2n / (2n)!. Hyperbolic cosine function.

derive: cosh' = sinh
integrate: ∫cosh x dx = sinh x

See Also:
arcosh

tanh

public static final Function tanh
tanh: C\(πi/2*Z)→C; x ↦ tanh x = sinh x / cosh x. Hyperbolic tangent function.

derive: tanh' = sech2 = 1/cosh(x)2 = (1 + tanh x) * (1 - tanh x) = 1 - (tanh x)2
integrate: ∫tanh x dx = ㏒(cosh x)

The hyperbolic tangent is a sigmoid function.

See Also:
coth

csch

public static final Function csch
csch: R\{0}→R; x ↦ csch x = 1 / sinh(x). Hyperbolic cosecant function.

derive: csch' = -coth*csch.


sech

public static final Function sech
sech: R→R; x ↦ sech x = 1/cosh(x). Hyperbolic secant function.

derive: sech' = -sech*tanh.


coth

public static final Function coth
coth: R\{0}→R; x ↦ coth x = cosh x / sinh x = 1 / tanh x. Hyperbolic cotangent function.

derive: coth' = -csch2.

integrate: ∫coth x dx = ㏒(sinh x)

|coth 0| = ∞ is a singularity.

See Also:
tanh

arsinh

public static final Function arsinh
arsinh: R→R; x ↦ arsinh x = sinh-1 x = ㏒(x + √x2+1). Area hyperbolic sine function.

derive: arsinh' = 1 / √x2+1)
integrate: ∫arsinh x dx = x * arsinh x - √x2+1)

See Also:
sinh

arcosh

public static final Function arcosh
arcosh: [1,∞)→[0,∞); x ↦ arcosh x = (cosh|[0,∞))-1 x = ㏒(x ± √x2-1). Area hyperbolic cosine function.

derive: arcosh' = 1 / √x2-1)
integrate: ∫arcosh x dx = x*arcosh x - √x2-1)

See Also:
sinh

artanh

public static final Function artanh
artanh: (-1,1)→R; x ↦ artanh x = tanh-1 x = ㏒((1+x) / (1-x)) / 2. Area hyperbolic tangent function.

derive: artanh' = 1 / (1 - x2)
integrate: ∫artanh x dx = x*artanh x + ㏒(x2-1) / 2

See Also:
tanh

arcoth

public static final Function arcoth
arcoth: R\[-1,1]→R\{0}; x ↦ arcoth x = coth-1 x = ㏒((x+1) / (x-1)) / 2. Area hyperbolic cotangent function.

derive: arcoth' = 1 / (1 - x2)
integrate: ∫arcoth x dx = x*arcoth x + ㏒(x2-1) / 2

See Also:
coth

norm

public static final Function norm
norm: A→[0,∞); x ↦ ||x||.

derive: norm'|Rn\{0} = x / ||x||. which is true for the euclidian 2-norm ||x||2 =√x·x, only.

derive: abs'|(-∞,0) = -1, abs'|(0,∞) = 1.

See Also:
Vector.multiply(orbital.math.Vector)

nondet

public static final Function nondet
Represents a nondeterministic function.

This nondeterministic function returns results randomly. It is provided for theoretical reasons and cannot be used as a random generator.


logistic

public static final Function logistic
logistic: A→(0,1); x ↦ 1 / (1 + e-x).

derive: logistic' = e-x / (1 + e-x)2 = logistic(x) * (1 - logistic(x)).
integrate: ∫logistic(x)dx =

The logistic function is a sigmoid function, and resembles the continuous logistic distribution.

See Also:
sign

sign

public static final Function sign
sign: A→{-1,0,1}; x ↦ -1 if x<0, x ↦ 0 if x=0, x ↦ 1 if x>0.

derive: sign' = diracDelta = 0 on R\{0}.

See Also:
step(Real), logistic

diracDelta

public static final Function diracDelta
diracDelta δ: M\{0}→{0}; x ↦ 0 if x≠0.

derive: δ' = δ ??.
integrate: ∫δ(x)dx = step0(x)

See Also:
delta, step(Real), piecewise(Predicate[], Function[])

projectFirst

public static final BinaryFunction projectFirst
Projects to the first argument, ignoring the second.

projectFirst: (x,y) ↦ x.

Equals Functionals.onFirst(id)

Evolves: might be renamed.


projectSecond

public static BinaryFunction projectSecond
Projects to the second argument, ignoring the first.

projectSecond: (x,y) ↦ y.

Equals Functionals.onSecond(id)

Evolves: might be renamed.


delta

public static final BinaryFunction delta
delta: R×RR; (x,x) ↦ 1, (x,y) ↦ 0 for x≠y. Kronecker-delta function.

See Also:
diracDelta
Method Detail

constant

public static final Function constant(java.lang.Object a)
constant â: R→R; x ↦ a .

derive: â' = 0
integrate: ∫adx = a*x


symbolic

public static final Function symbolic(java.lang.String name)
symbolic f:R→R; x ↦ f(x).

derive: (f)' = f'
integrate: ∫f(x)dx = ∫f(x)dx

Parameters:
name - the name of the symbolic function.
Returns:
a pure symbolic function with a specified name.

linear

public static final Function linear(Arithmetic a)
linear: A→B; x ↦ a*x.

derive: linear' = a.
integrate: ∫a*x dx = a*x2/2

linear functions are Lipschitz-continuous.

The concrete sets A and B depend on the exact type of a. For instance if a is a Matrix in Km×n this function is the linear homomorphism Kn→Km; x ↦ a*x.


pow

public static final Function pow(Arithmetic p)
powp: R→R; x ↦ xp .

derive: (xp)' = p*xp-1
integrate: ∫xp dx = xp+1/(p+1)


pow

public static final Function pow(double p)

exp

public static final Function exp(Arithmetic b)
expb: CC\{0}; x ↦ bx .

derive: (bx)' = ㏒ b * bx
integrate: ∫bx dx = bx / ㏒ b


projection

public static final Function projection(int component)
projection πc: An→A; (x1,...xn)T ↦ xc.


projection

public static final Function projection(int i,
                                        int j)
projection πi,j: An×m→A; (xi,j) ↦ xi,j.


polynom

public static final UnivariatePolynomial polynom(int degree)
polynom: R'→R'; X↦i=0d Xi.

This method will return the polynom in R[X]d of the given degree that corresponds to the Vandermonde Matrix so all coefficients are 1. dim R[X]d = d+1. The ring R' is "compatible" with R.

See Also:
polynom(Vector), UnivariatePolynomial

polynom

public static final UnivariatePolynomial polynom(Vector coeff)
polynom: R'→R'; X↦i=0d aiXi.

This method will return the polynom in R[X] with the specified coefficients vector in Rd. Although dim R[X] = ∞ this method will return a polynomial in R[X]d of degree ≤d:=coeff.dimension(). The ring R' is "compatible" with R.

See Also:
polynom(int), ValueFactory.asPolynomial(Vector), UnivariatePolynomial

step

public static final Function step(Real t)
step ht: A→{0,1}; x ↦ 1 if x≥t, x ↦ 0 if x<t.

derive: stept' = diracDelta(t-x).
integrate: ∫stept(x)dx = stept(x) * (x - t)

Step function alias Heaviside function.

See Also:
sign, diracDelta

piecewise

public static final Function piecewise(Predicate[] cond,
                                       Function[] value)
Get a function defined piecewise. piecewise: A→B; x↦fmin {i ¦ ci(x) ∧ 1≤i≤m}(x).

deriving this function requires it to be in C1(A, B). Similarly, integrating requires it to be integrable, at all. Unless you make sure that these requirements are met, the implementation will return values that are completely meaningless.

Note that piecewise functions can be defined in terms of appropriate compositions with heaviside functions which in turn can be defined as translations of the unit step function.

Parameters:
cond - the condition predicates ci.
value - the functions of whom the first one is applied whose associated predicate yields true.
Throws:
java.lang.IllegalArgumentException - if no condition predicate matches for an argument x.
See Also:
step(orbital.math.Real)
Preconditions:
cond.length == value.length

binaryConstant

public static final BinaryFunction binaryConstant(Arithmetic a)
constant â: R×R→R; (x,y) ↦ a.

derive: â' = 0.
integrate: ∫adxi = a*xi


binarySymbolic

public static final BinaryFunction binarySymbolic(java.lang.String name)
symbolic f:R×R→R; (x,y) ↦ f(x, y).

derive: (f)' = f'
integrate: ∫f(x,y)dxi = ∫f(x,y)dxi

Parameters:
name - the name of the symbolic function.
Returns:
a pure symbolic function with a specified name.

delta

public static final int delta(int i,
                              int j)

Orbital library
1.3.0: 11 Apr 2009

Copyright © 1996-2009 André Platzer
All Rights Reserved.