Méthode Python math.log1p()

Python math 模块Module math de Python

Python math.log1p(x)La méthode renvoie le logarithme népérien de 1+x (base e).

Syntaxe

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

math.log1p(x)

Description des paramètres :

  • x-- Requis, un nombre. Si x n'est pas un nombre, TypeError est renvoyé. Si la valeur est 0 ou négative, ValueError est renvoyé.

Valeur de retour

Renvoie un float, représentant le logarithme népérien de 1+x en base e.

Exemple

L'exemple suivant renvoie le logarithme népérien de 1+x en base e :

Exemple

# Importer le package math
import math

# Afficher le logarithme népérien de 1+x en base e
print(math.log1p(2.7183))
print(math.log1p(2))
print(math.log1p(1))

Résultat de sortie :

1.313266574586334
1.0986122886681098
0.6931471805599453

Python math 模块Module math de Python

Autres extensions