Modelica.Math

Library of mathematical functions (e.g., sin, cos) and of functions operating on vectors and matrices

Information

This package contains basic mathematical functions (such as sin(..)), as well as functions operating on vectors, matrices, nonlinear functions, and Boolean vectors.

Main Authors

Martin Otter and Marcus Baur
Deutsches Zentrum für Luft- und Raumfahrt e.V. (DLR)
Institut für Systemdynamik und Regelungstechnik (DLR-SR)
Forschungszentrum Oberpfaffenhofen
D-82234 Wessling
Germany
email: Martin.Otter@dlr.de

Copyright © 1998-2020, Modelica Association and contributors

Extends from Modelica.Icons.Package (Icon for standard packages).

Package Content

Name Description
Modelica.Math.Vectors Vectors Library of functions operating on vectors
Modelica.Math.BooleanVectors BooleanVectors Library of functions operating on Boolean vectors
Modelica.Math.Matrices Matrices Library of functions operating on matrices
Modelica.Math.Nonlinear Nonlinear Library of functions operating on nonlinear equations
Modelica.Math.Polynomials Polynomials Library of functions operating on polynomials (including polynomial fitting)
Modelica.Math.Random Random Library of functions for generating random numbers
Modelica.Math.Distributions Distributions Library of distribution functions
Modelica.Math.Special Special Library of special mathematical functions
Modelica.Math.FastFourierTransform FastFourierTransform Library of functions for the Fast Fourier Transform (FFT)
Modelica.Math.Icons Icons Icons for Math
Modelica.Math.isEqual isEqual Determine if two Real scalars are numerically identical
Modelica.Math.isPowerOf2 isPowerOf2 Determine if the integer input is a power of 2
Modelica.Math.sin sin Sine
Modelica.Math.cos cos Cosine
Modelica.Math.tan tan Tangent (u shall not be -pi/2, pi/2, 3*pi/2, ...)
Modelica.Math.asin asin Inverse sine (-1 <= u <= 1)
Modelica.Math.acos acos Inverse cosine (-1 <= u <= 1)
Modelica.Math.atan atan Inverse tangent
Modelica.Math.atan2 atan2 Four quadrant inverse tangent
Modelica.Math.atan3 atan3 Four quadrant inverse tangent (select solution that is closest to given angle y0)
Modelica.Math.sinh sinh Hyperbolic sine
Modelica.Math.cosh cosh Hyperbolic cosine
Modelica.Math.tanh tanh Hyperbolic tangent
Modelica.Math.asinh asinh Inverse of sinh (area hyperbolic sine)
Modelica.Math.acosh acosh Inverse of cosh (area hyperbolic cosine)
Modelica.Math.exp exp Exponential, base e
Modelica.Math.log log Natural (base e) logarithm (u shall be > 0)
Modelica.Math.log10 log10 Base 10 logarithm (u shall be > 0)
Modelica.Math.wrapAngle wrapAngle Wrap angle to interval ]-pi,pi] or [0,2*pi[

Modelica.Math.isEqual Modelica.Math.isEqual

Determine if two Real scalars are numerically identical

Information

Syntax

Math.isEqual(s1, s2);
Math.isEqual(s1, s2, eps=0);

Description

The function call "Math.isEqual(s1, s2)" returns true, if the two Real scalars s1 and s2 are identical. Otherwise the function returns false. The equality check is performed by "abs(s1-s2) ≤ eps", where "eps" can be provided as third argument of the function. Default is "eps = 0".

Example

  Real s1 = 2.0;
  Real s2 = 2.0;
  Real s3 = 2.000001;
  Boolean result;
algorithm
  result := Math.isEqual(s1,s2);     // = true
  result := Math.isEqual(s1,s3);     // = false
  result := Math.isEqual(s1,s3,0.1); // = true

See also

Vectors.isEqual, Matrices.isEqual, Strings.isEqual

Extends from Modelica.Icons.Function (Icon for functions).

Inputs

NameDescription
s1First scalar
s2Second scalar
epsThe two scalars are identical if abs(s1-s2) <= eps

Outputs

NameDescription
result= true, if scalars are identical

Modelica.Math.isPowerOf2 Modelica.Math.isPowerOf2

Determine if the integer input is a power of 2

Information

Syntax

Math.isPowerOf2(i);

Description

The function call "Math.isPowerOf2(i)" returns true, if the Integer input i is a power of 2. Otherwise the function returns false. The Integer input has to be >=1.

Example

  Integer i1 = 1;
  Integer i2 = 4;
  Integer i3 = 9;
  Boolean result;
algorithm
  result := Math.isPowerOf2(i1);     // = true 2^0
  result := Math.isPowerOf2(i2);     // = true 2^2
  result := Math.isPowerOf2(i3);     // = false

Extends from Modelica.Icons.Function (Icon for functions).

Inputs

NameDescription
iInteger scalar

Outputs

NameDescription
result= true, if integer scalar is a power of 2

Modelica.Math.sin Modelica.Math.sin

Sine

Information

This function returns y = sin(u), with -∞ < u < ∞:

Extends from Modelica.Math.Icons.AxisLeft (Basic icon for mathematical function with y-axis on left side).

Inputs

NameDescription
uIndependent variable [rad]

Outputs

NameDescription
yDependent variable y=sin(u)

Modelica.Math.cos Modelica.Math.cos

Cosine

Information

This function returns y = cos(u), with -∞ < u < ∞:

Extends from Modelica.Math.Icons.AxisLeft (Basic icon for mathematical function with y-axis on left side).

Inputs

NameDescription
uIndependent variable [rad]

Outputs

NameDescription
yDependent variable y=cos(u)

Modelica.Math.tan Modelica.Math.tan

Tangent (u shall not be -pi/2, pi/2, 3*pi/2, ...)

Information

This function returns y = tan(u), with -∞ < u < ∞ (if u is a multiple of (2n-1)*pi/2, y = tan(u) is +/- infinity).

Extends from Modelica.Math.Icons.AxisCenter (Basic icon for mathematical function with y-axis in the center).

Inputs

NameDescription
uIndependent variable [rad]

Outputs

NameDescription
yDependent variable y=tan(u)

Modelica.Math.asin Modelica.Math.asin

Inverse sine (-1 <= u <= 1)

Information

This function returns y = asin(u), with -1 ≤ u ≤ +1:

Extends from Modelica.Math.Icons.AxisCenter (Basic icon for mathematical function with y-axis in the center).

Inputs

NameDescription
uIndependent variable

Outputs

NameDescription
yDependent variable y=asin(u) [rad]

Modelica.Math.acos Modelica.Math.acos

Inverse cosine (-1 <= u <= 1)

Information

This function returns y = acos(u), with -1 ≤ u ≤ +1:

Extends from Modelica.Math.Icons.AxisCenter (Basic icon for mathematical function with y-axis in the center).

Inputs

NameDescription
uIndependent variable

Outputs

NameDescription
yDependent variable y=acos(u) [rad]

Modelica.Math.atan Modelica.Math.atan

Inverse tangent

Information

This function returns y = atan(u), with -∞ < u < ∞:

Extends from Modelica.Math.Icons.AxisCenter (Basic icon for mathematical function with y-axis in the center).

Inputs

NameDescription
uIndependent variable

Outputs

NameDescription
yDependent variable y=atan(u) [rad]

Modelica.Math.atan2 Modelica.Math.atan2

Four quadrant inverse tangent

Information

This function returns y = atan2(u1,u2) such that tan(y) = u1/u2 and y is in the range -pi < y ≤ pi. u2 may be zero, provided u1 is not zero. Usually u1, u2 is provided in such a form that u1 = sin(y) and u2 = cos(y):

Extends from Modelica.Math.Icons.AxisCenter (Basic icon for mathematical function with y-axis in the center).

Inputs

NameDescription
u1First independent variable
u2Second independent variable

Outputs

NameDescription
yDependent variable y=atan2(u1, u2)=atan(u1/u2) [rad]

Modelica.Math.atan3 Modelica.Math.atan3

Four quadrant inverse tangent (select solution that is closest to given angle y0)

Information

This function returns y = atan3(u1,u2,y0) such that tan(y) = u1/u2 and y is in the range: -pi < y-y0 ≤ pi.
u2 may be zero, provided u1 is not zero. The difference to Modelica.Math.atan2(..) is the optional third argument y0 that allows to specify which of the infinite many solutions shall be returned:

Note, for the default case (y0=0), exactly the same result as with atan2(..) is returned.

Extends from Modelica.Math.Icons.AxisCenter (Basic icon for mathematical function with y-axis in the center).

Inputs

NameDescription
u1First independent variable
u2Second independent variable
y0y shall be in the range: -pi < y-y0 <= pi [rad]

Outputs

NameDescription
yDependent variable y=atan3(u1, u2, y0)=atan(u1/u2) [rad]

Modelica.Math.sinh Modelica.Math.sinh

Hyperbolic sine

Information

This function returns y = sinh(u), with -∞ < u < ∞:

Extends from Modelica.Math.Icons.AxisCenter (Basic icon for mathematical function with y-axis in the center).

Inputs

NameDescription
uIndependent variable

Outputs

NameDescription
yDependent variable y=sinh(u)

Modelica.Math.cosh Modelica.Math.cosh

Hyperbolic cosine

Information

This function returns y = cosh(u), with -∞ < u < ∞:

Extends from Modelica.Math.Icons.AxisCenter (Basic icon for mathematical function with y-axis in the center).

Inputs

NameDescription
uIndependent variable

Outputs

NameDescription
yDependent variable y=cosh(u)

Modelica.Math.tanh Modelica.Math.tanh

Hyperbolic tangent

Information

This function returns y = tanh(u), with -∞ < u < ∞:

Extends from Modelica.Math.Icons.AxisCenter (Basic icon for mathematical function with y-axis in the center).

Inputs

NameDescription
uIndependent variable

Outputs

NameDescription
yDependent variable y=tanh(u)

Modelica.Math.asinh Modelica.Math.asinh

Inverse of sinh (area hyperbolic sine)

Information

The function returns the area hyperbolic sine of its input argument u. This inverse of sinh(..) is unique and there is no restriction on the input argument u of asinh(u) (-∞ < u < ∞):

Extends from Modelica.Math.Icons.AxisCenter (Basic icon for mathematical function with y-axis in the center).

Inputs

NameDescription
uIndependent variable

Outputs

NameDescription
yDependent variable y=asinh(u)

Modelica.Math.acosh Modelica.Math.acosh

Inverse of cosh (area hyperbolic cosine)

Information

This function returns the area hyperbolic cosine of its input argument u. The valid range of u is

+1 ≤ u < +∞

If the function is called with u < 1, an error occurs. The function cosh(u) has two inverse functions (the curve looks similar to a sqrt(..) function). acosh(..) returns the inverse that is positive. At u=1, the derivative dy/du is infinite. Therefore, this function should not be used in a model, if u can become close to 1:

Extends from Modelica.Math.Icons.AxisLeft (Basic icon for mathematical function with y-axis on left side).

Inputs

NameDescription
uIndependent variable

Outputs

NameDescription
yDependent variable y=acosh(u)

Modelica.Math.exp Modelica.Math.exp

Exponential, base e

Information

This function returns y = exp(u), with -∞ < u < ∞:

Extends from Modelica.Math.Icons.AxisCenter (Basic icon for mathematical function with y-axis in the center).

Inputs

NameDescription
uIndependent variable

Outputs

NameDescription
yDependent variable y=exp(u)

Modelica.Math.log Modelica.Math.log

Natural (base e) logarithm (u shall be > 0)

Information

This function returns y = log(10) (the natural logarithm of u), with u > 0:

Extends from Modelica.Math.Icons.AxisLeft (Basic icon for mathematical function with y-axis on left side).

Inputs

NameDescription
uIndependent variable

Outputs

NameDescription
yDependent variable y=ln(u)

Modelica.Math.log10 Modelica.Math.log10

Base 10 logarithm (u shall be > 0)

Information

This function returns y = log10(u), with u > 0:

Extends from Modelica.Math.Icons.AxisLeft (Basic icon for mathematical function with y-axis on left side).

Inputs

NameDescription
uIndependent variable

Outputs

NameDescription
yDependent variable y=lg(u)

Modelica.Math.wrapAngle Modelica.Math.wrapAngle

Wrap angle to interval ]-pi,pi] or [0,2*pi[

Information

This function wraps the input angle u to the interval ]-pi,pi], if positiveRange == false. Otherwise the input angle u is wrapped to the interval [0,2*pi[.

Extends from Modelica.Math.Icons.AxisCenter (Basic icon for mathematical function with y-axis in the center).

Inputs

NameDescription
uInput angle [rad]
positiveRangeUse only positive output range, if true

Outputs

NameDescription
yWrapped output angle [rad]
Automatically generated Thu Oct 1 16:08:15 2020.