1. mrmath mathematische-funktionen

Mathematische funktionen.

Module author: Michael Rippstein <info@anatas.ch>

1.1. Konstanten

Die Konstanten werden von dem Modul mrmath bereitgestellt.

RAD: float = 0.017453292519943295

Konstante zum umrechnen von Grad ins Bogenmass.

\(\text{RAD} = \frac{\pi}{180}\)

DEG: float = 57.29577951308232

Konstante zum umrechnen vom Bogenmass in Grad.

\(\text{DEG} = \frac{180}{\pi}\)

ARCS: float = 206264.80624709636

Bogensekunden pro Radian.

\(\text{ARCS} = \frac{3600 \cdot 180}{\pi}\)

1.2. Hyperbelfunktionen

coth(x)[source]

Kotangens hyperbolicus.

Parameters

x (float) – eingabe ist \(x = -\infty \dots + \infty \qquad x \neq 0\)

Returns

\(coth(x)\)

Return type

float

Raises

ArithmeticError – wird ausgelöst wenn \(x = 0\)

Examples

>>> coth(0)
Traceback (most recent call last):
    ...
ArithmeticError

>>> print( round( coth(1), 5 ) )
1.31304

1.3. Zahlenteoretische und “darstellende” Funktionen

frac(x)[source]

Liefert den Nachkommateil einer Zahl.

Return type

Nachkommanteil

Parameters

x (float) –

Notes

Der Nachkommanteil ist immer positive.

Examples

>>> frac(1.123)
0.123

>>> frac(-1.123)
0.123

>>> frac(0.123)
0.123

>>> frac(-0.123)
0.123

>>> round(frac(7654321.123456789),9)
0.123456789
modulo(x, y)[source]

Berechnet x mod y.

Parameters
Returns

x mod y

Return type

float

Examples

>>> round(modulo(370, 360), 1)
10.0

>>> round(modulo(-370, 360), 1)
350.0

>>> round(modulo(-30, 360), 1)
330.0

>>> round(modulo(-0, 360), 1)
0.0

>>> round(modulo(360, 360), 1)
0.0

>>> round(modulo(370, -360), 1)
-10.0

>>> round(modulo(-370, -360), 1)
-350.0

>>> round(modulo(-30, -360), 1)
-330.0

>>> round(modulo(-0, -360), 1)
0.0

>>> round(modulo(360, -360), 1)
0.0
iseven(number)[source]

Prüft ob eine ganzzahl gerade ist.

Parameters

number (int) – ganze zahl

Returns

ist n gerade

Return type

bool

Examples

>>> iseven(0)
True

>>> iseven(1)
False

>>> iseven(2)
True

>>> iseven(-1)
False

>>> iseven(-2)
True
isodd(number)[source]

Prüft ob eine ganzzahl ungerade ist.

Parameters
  • n – ganze zahl

  • number (int) –

Returns

ist n ungerade

Return type

boolean

Examples

>>> isodd(0)
False

>>> isodd(1)
True

>>> isodd(2)
False

>>> isodd(-1)
True

>>> isodd(-2)
False

1.4. Winkelumrechnungen

ddd(deg, min_, sec)[source]

Umrechnung eines in Grad, bogenminuten und bogensekunden gegebenen winkels in dezimale darstellung.

Parameters
  • deg (int) – winkelgrad

  • min – bogenminuten

  • sec (float) – bogensekunden

  • min_ (int) –

Returns

winkel in dezimaler darstellung

Return type

float

Examples

>>> round(ddd(15, 30, 0.0), 1)
15.5

>>> round(ddd(-8, 9, 10.0), 5)
-8.15278

>>> round(ddd(0, 1, 0.0), 5)
0.01667

>>> round(ddd(0, -5, 0.0), 5)
-0.08333
dms(angle)[source]

Ermittelt Grad, Bogenminuten und Bogensekunden zu gegebenem Winkel.

Parameters
  • dd – Winkel in Grad in dezimaler Darstellung

  • angle (float) –

Returns

  • D (int) – Winkelgrade

  • M (int) – Bogenminuten

  • S (float) – Bogensekunden

Return type

Tuple[int, int, float]

Examples

>>> dms(0.5)
(0, 30, 0.0)

>>> dms(-0.5)
(0, -30, 0.0)