Il modulo cmath fornisce l’accesso alle funzioni con i numeri complessi.
Gli argomenti possono essere anche interi e reali… ma il risultato è sempre un numero complesso.
Costanti
cmath.e | 2.718281828459045 |
cmath.inf | infinity |
cmath.infj | Numero complesso con parte immaginaria infinity |
cmath.nan | not a number |
cmath.nanj | Numero complesso con parte immaginaria not a number |
cmath.pi | 3.141592653589793 |
cmath.tau | 2π: 6.283185307179586 |
Funzioni specifiche
Nome funzione | Tipo | Funzionalità |
---|---|---|
cmath.phase(c) | float | Restituisce l’argomento di c. Equivale a math.atan2(c.imag, c.real) |
cmath.polar(c) | tuple | Restituisce la rappresentazione di c in coordinate polari. Equivale a (abs(c), phase(c)) |
cmath.rect(r, phi) | complex | Restituisce il numero complesso con coordinate polari r e phi. Equivale a r*(math.cos(phi)+math.sin(phi)*1j) |
Continua con le funzioni matematiche per i numeri complessi
- cmath.acos(x), Return the arc cosine (measured in radians) of x.
- cmath.acosh(x), Return the inverse hyperbolic cosine of x.
- cmath.asin(x), Return the arc sine (measured in radians) of x.
- cmath.asinh(x), Return the inverse hyperbolic sine of x.
- cmath.atan(x), Return the arc tangent (measured in radians) of x.
- cmath.atanh(x), Return the inverse hyperbolic tangent of x.
- cmath.cos(x), Restituisce il coseno dell’angolo x espresso in radianti.
- cmath.cosh(x), Return the hyperbolic cosine of x.
- cmath.exp(x), Restituisce e elevato a x.
- cmath.log(x), Restituisce il logaritmo naturale (base e) di x.
- cmath.log(x, base), Restituisce il logaritmo con base data di x.
- cmath.log10(x), Restituisce il logaritmo con base 10 di x.
- cmath.sin(x), Restituisce il seno dell’angolo x espresso in radianti.
- cmath.sinh(x), Return the hyperbolic sine of x.
- cmath.sqrt(x), Restituisce la radice quadrata di x.
- cmath.tan(x), Restituisce la tangente dell’angolo x espresso in radianti.
- cmath.tanh(x), Return the hyperbolic tangent of x.
Valore logico
- cmath.isfinite(x), Return True if x is neither an infinity nor a NaN, and False otherwise.
- cmath.isinf(x), Return True if x is a positive or negative infinity, and False otherwise.
- cmath.isnan(x), Return True if x is a NaN (not a number), and False otherwise.