math — mathematische Funktionen

Das math-Modul stellt einige grundlegende mathematische Funktionen für die Arbeit mit Gleitkommazahlen bereit.

Hinweis: Auf der OpenMV Cam haben Gleitkommazahlen eine Präzision von 32 Bit.

Funktionen

math.acos(x: float) float

Gibt den Arkuskosinus von x zurück.

math.acosh(x: float) float

Gibt den Areakosinus hyperbolicus von x zurück.

math.asin(x: float) float

Gibt den Arkussinus von x zurück.

math.asinh(x: float) float

Gibt den Areasinus hyperbolicus von x zurück.

math.atan(x: float) float

Gibt den Arkustangens von x zurück.

math.atan2(y: float, x: float) float

Gibt den Hauptwert des Arkustangens von y/x zurück.

math.atanh(x: float) float

Gibt den Areatangens hyperbolicus von x zurück.

math.ceil(x: float) int

Gibt eine ganze Zahl zurück, nämlich x aufgerundet in Richtung positiver Unendlichkeit.

math.copysign(x: float, y: float) float

Gibt x mit dem Vorzeichen von y zurück.

math.cos(x: float) float

Gibt den Kosinus von x zurück.

math.cosh(x: float) float

Gibt den Kosinus hyperbolicus von x zurück.

math.degrees(x: float) float

Wandelt das Bogenmaß x in Grad um und gibt das Ergebnis zurück.

math.erf(x: float) float

Gibt die Fehlerfunktion von x zurück.

math.erfc(x: float) float

Gibt die komplementäre Fehlerfunktion von x zurück.

math.exp(x: float) float

Gibt die Exponentialfunktion von x zurück.

math.expm1(x: float) float

Gibt exp(x) - 1 zurück.

math.fabs(x: float) float

Gibt den Absolutwert von x zurück.

math.floor(x: float) int

Gibt eine ganze Zahl zurück, nämlich x abgerundet in Richtung negativer Unendlichkeit.

math.fmod(x: float, y: float) float

Gibt den Rest von x/y zurück.

math.frexp(x: float) Tuple[float, int]

Zerlegt eine Gleitkommazahl in ihre Mantisse und ihren Exponenten. Der zurückgegebene Wert ist das Tupel (m, e), sodass x == m * 2**e exakt gilt. Wenn x == 0 ist, gibt die Funktion (0.0, 0) zurück, andernfalls gilt die Beziehung 0.5 <= abs(m) < 1.

math.gamma(x: float) float

Gibt die Gammafunktion von x zurück.

math.isfinite(x: float) bool

Gibt True zurück, wenn x endlich ist.

math.isinf(x: float) bool

Gibt True zurück, wenn x unendlich ist.

math.isnan(x: float) bool

Gibt True zurück, wenn x keine Zahl ist (not-a-number)

math.ldexp(x: float, exp: int) float

Gibt x * (2**exp) zurück.

math.lgamma(x: float) float

Gibt den natürlichen Logarithmus der Gammafunktion von x zurück.

math.log(x: float, base: float = e) float

Mit einem Argument wird der natürliche Logarithmus von x zurückgegeben.

Mit zwei Argumenten wird der Logarithmus von x zur angegebenen Basis base zurückgegeben.

math.log10(x: float) float

Gibt den Logarithmus von x zur Basis 10 zurück.

math.log2(x: float) float

Gibt den Logarithmus von x zur Basis 2 zurück.

math.modf(x: float) Tuple[float, float]

Gibt ein Tupel aus zwei Gleitkommazahlen zurück, nämlich den Nachkomma- und den Ganzzahlanteil von x. Beide Rückgabewerte haben dasselbe Vorzeichen wie x.

math.pow(x: float, y: float) float

Gibt x hoch y zurück.

math.radians(x: float) float

Wandelt Grad x in Bogenmaß um und gibt das Ergebnis zurück.

math.sin(x: float) float

Gibt den Sinus von x zurück.

math.sinh(x: float) float

Gibt den Sinus hyperbolicus von x zurück.

math.sqrt(x: float) float

Gibt die Quadratwurzel von x zurück.

math.tan(x: float) float

Gibt den Tangens von x zurück.

math.tanh(x: float) float

Gibt den Tangens hyperbolicus von x zurück.

math.trunc(x: float) int

Gibt eine ganze Zahl zurück, nämlich x gerundet in Richtung 0.

Konstanten

math.e: float

Basis des natürlichen Logarithmus.

math.pi: float

Das Verhältnis des Umfangs eines Kreises zu seinem Durchmesser.