Méthode Python math.expm1()

Python math 模块Module math de Python

Python math.expm1(x)La méthode renvoie e élevé à la puissance x moins 1,Ex - 1, où e = 2.718281... est la base du logarithme népérien.

math.expm1(x)La méthode est plus précise que d'appelermath.exp()en soustrayant 1.

Version de Python : 2.7

Syntaxe

La syntaxe de la méthode math.expm1() est la suivante :

math.expm1(x)

Description des paramètres :

  • xx -- Obligatoire, un nombre, spécifie l'exposant. Si x n'est pas un nombre, renvoie TypeError.

Valeur de retour

Une valeur à virgule flottante, représentant Ex - 1.

Exemple

L'exemple suivant spécifie différents exposants :

Exemple

# Importer le package math
import math

# Spécifier différents exposants
print(math.expm1(32))
print(math.expm1(-10.89))

Résultat de sortie :

78962960182679.69
-0.9999813562576685

Python math 模块Module math de Python

Autres extensions