Modelica.Math

Mathematical functions

Modelica.Math.baseIcon1 Modelica.Math.baseIcon2 Modelica.Math.sin Modelica.Math.cos Modelica.Math.tan Modelica.Math.asin Modelica.Math.acos Modelica.Math.atan Modelica.Math.atan2 Modelica.Math.sinh Modelica.Math.cosh Modelica.Math.tanh Modelica.Math.exp Modelica.Math.log Modelica.Math.log10 Modelica.Math.tempInterpol1

Information


This package contains the following basic mathematical functions:

   sin(u)        sine
   cos(u)        cosine
   tan(u)        tangent     (u shall not be -pi/2, pi/2, 3*pi/2, ...)
   asin(u)       inverse sine    (-1 <= u <= 1)
   acos(u)       inverse cosine  (-1 <= u <= 1)
   atan(u)       inverse tangent 
   atan2(u1,u2)  four quadrant inverse tangent
   sinh(u)       hyperbolic sine
   cosh(u)       hyperbolic cosine
   tanh(u)       hyperbolic tangent
   exp(u)        exponential, base e
   log(u)        natural (base e) logarithm (u > 0)
   log10(u)      base 10 logarithm (u > 0)

These functions are used by calling them directly with a full name (e.g. y = Modelica.Math.asin(0.5)).

Main Author:
Martin Otter
Deutsches Zentrum für Luft und Raumfahrt e.V. (DLR)
Institut für Robotik und Mechatronik
Postfach 1116
D-82230 Wessling
Germany
email: Martin.Otter@dlr.de

Release Notes:


Copyright (C) 1999-2000, Modelica Association and DLR.

The Modelica package is free software; it can be redistributed and/or modified under the terms of the Modelica license, see the license conditions and the accompanying disclaimer in the documentation of package Modelica in file "Modelica/package.mo".

Types and constants

type Angle = Modelica.SIunits.Angle ;


Modelica.Math.baseIcon1 Modelica.Math.baseIcon1

Basic icon for mathematical function with y-axis on left side

Modelica.Math.baseIcon1

Modelica definition

partial function baseIcon1 
  "Basic icon for mathematical function with y-axis on left side" 
  end baseIcon1;

Modelica.Math.baseIcon2 Modelica.Math.baseIcon2

Basic icon for mathematical function with y-axis in middle

Modelica.Math.baseIcon2

Modelica definition

partial function baseIcon2 
  "Basic icon for mathematical function with y-axis in middle" end 
  baseIcon2;

Modelica.Math.sin Modelica.Math.sin

sine

Modelica.Math.sin

Modelica definition

function sin "sine" 
  extends baseIcon1;
  input Angle u;
  output Real y;
external "C" y = sin(u);
end sin;

Modelica.Math.cos Modelica.Math.cos

cosine

Modelica.Math.cos

Modelica definition

function cos "cosine" 
  extends baseIcon1;
  input Angle u;
  output Real y;
external "C" y = cos(u);
end cos;

Modelica.Math.tan Modelica.Math.tan

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

Modelica.Math.tan

Modelica definition

function tan "tangent (u shall not be -pi/2, pi/2, 3*pi/2, ...)" 
  extends baseIcon2;
  input Angle u;
  output Real y;
external "C" y = tan(u);
end tan;

Modelica.Math.asin Modelica.Math.asin

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

Modelica.Math.asin

Modelica definition

function asin "inverse sine (-1 <= u <= 1)" 
  extends baseIcon2;
  input Real u;
  output Angle y;
external "C" y = asin(u);
end asin;

Modelica.Math.acos Modelica.Math.acos

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

Modelica.Math.acos

Modelica definition

function acos "inverse cosine (-1 <= u <= 1)" 
  extends baseIcon2;
  input Real u;
  output Angle y;
external "C" y = acos(u);
end acos;

Modelica.Math.atan Modelica.Math.atan

inverse tangent

Modelica.Math.atan

Modelica definition

function atan "inverse tangent" 
  extends baseIcon2;
  input Real u;
  output Angle y;
external "C" y = atan(u);
end atan;

Modelica.Math.atan2 Modelica.Math.atan2

four quadrant inverse tangent

Modelica.Math.atan2

Information


y = atan2(u1,u2) computes y such that tan(y) = u1/u2 and
y is in the range -pi < y < pi. u2 may be zero, provided
u1 is not zero.

Modelica definition

function atan2 "four quadrant inverse tangent" 
  extends baseIcon2;
  input Real u1;
  input Real u2;
  output Angle y;
external "C" y = atan2(u1, u2);
end atan2;

Modelica.Math.sinh Modelica.Math.sinh

hyperbolic sine

Modelica.Math.sinh

Modelica definition

function sinh "hyperbolic sine" 
  extends baseIcon2;
  input Real u;
  output Real y;
external "C" y = sinh(u);
end sinh;

Modelica.Math.cosh Modelica.Math.cosh

hyperbolic cosine

Modelica.Math.cosh

Modelica definition

function cosh "hyperbolic cosine" 
  extends baseIcon2;
  input Real u;
  output Real y;
external "C" y = cosh(u);
end cosh;

Modelica.Math.tanh Modelica.Math.tanh

hyperbolic tangent

Modelica.Math.tanh

Modelica definition

function tanh "hyperbolic tangent" 
  extends baseIcon2;
  input Real u;
  output Real y;
external "C" y = tanh(u);
end tanh;

Modelica.Math.exp Modelica.Math.exp

exponential, base e

Modelica.Math.exp

Modelica definition

function exp "exponential, base e" 
  extends baseIcon2;
  input Real u;
  output Real y;
external "C" y = exp(u);
end exp;

Modelica.Math.log Modelica.Math.log

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

Modelica.Math.log

Modelica definition

function log "natural (base e) logarithm (u shall be > 0)" 
  extends baseIcon1;
  input Real u;
  output Real y;
external "C" y = log(u);
end log;

Modelica.Math.log10 Modelica.Math.log10

base 10 logarithm (u shall be > 0)

Modelica.Math.log10

Modelica definition

function log10 "base 10 logarithm (u shall be > 0)" 
  extends baseIcon1;
  input Real u;
  output Real y;
external "C" y = log10(u);
end log10;

Modelica.Math.tempInterpol1 Modelica.Math.tempInterpol1

temporary routine for linear interpolation (will be removed)

Modelica.Math.tempInterpol1

Modelica definition

function tempInterpol1 
  "temporary routine for linear interpolation (will be removed)" 
  input Real u "in1;put value (first column of table)";
  input Real table[:, :] "table to be interpolated";
  input Integer icol "column of table to be interpolated";
  output Real y "interpolated input value (icol column of table)";
protected 
  Integer i;
  Integer n "number of rows of table";
  Real u1;
  Real u2;
  Real y1;
  Real y2;
algorithm 
  n := size(table, 1);
  if n <= 1 then
    y := table[1, icol];
  else
    // Search interval
    if u <= table[1, 1] then
      i := 1;
    else
      i := 2;
      while i < n and u > table[i, 1] loop
        i := i + 1;
      end while;
      i := i - 1;
    end if;
    
    // Get interpolation data
    u1 := table[i, 1];
    u2 := table[i + 1, 1];
    y1 := table[i, icol];
    y2 := table[i + 1, icol];
    
    // Interpolate
    if u1 >= u2 then
      y := y1;
      // since not possible to throw error
    else
      y := y1 + (y2 - y1)*(u - u1)/(u2 - u1);
    end if;
  end if;
end tempInterpol1;

HTML-documentation generated by Dymola Tue Jun 20 21:40:18 2000 .