python独立log示例_带有Python示例的math.log1p()方法

python独立log示例

Python math.log1p()方法 (Python math.log1p() method)

math.log1p() method is a library method of math module, it is used to get the natural logarithm of 1+x (base e), it accepts a number and returns the natural logarithm of 1+number on base e.

math.log1p()方法数学模块的库方法,用于获取1 + x(以e为底)的自然对数,它接受一个数字并以e基础返回1+数字的自然对数。

Note: If we provide anything else except a number, the method returns a TypeError – "TypeError: a float is required".

注意:如果我们提供除数字以外的任何其他内容,该方法将返回TypeError – “ TypeError:需要浮点数”

Syntax of math.log1p() method:

math.log1p()方法的语法:

    math.log1p(x)

Parameter(s):x – is the number whose logarithm to be calculated.

参数: x –是要计算其对数的数字。

Return value: float – it returns a float value that is the natural logarithm of 1 + x.

返回值: float-返回一个浮点值,它是1 + x的自然对数。

Example:

例:

    Input:
    x = 21

    # function call
    print(math.log1p(x))

    Output:
    3.091042453358316

Python代码演示math.log1p()方法的示例 (Python code to demonstrate example of math.log1p() method)

# python code to demonstrate example of 
# math.log1p() method

# importing math module
import math

# log1p()
x = 21
print("Natural logarithm of 1 +", x, " is = ", math.log1p(x))

x = 10.23
print("Natural logarithm of 1 +", x, " is = ", math.log1p(x))

Output

输出量

Natural logarithm of 1 + 21  is =  3.091042453358316
Natural logarithm of 1 + 10.23  is =  2.418588768750352


翻译自: https://www.includehelp.com/python/math-log1p-method-with-example.aspx

python独立log示例

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值