对数log ln lg 的java实现和mysql实现

一、基本概念

log: 表示对数,与指数相反。例如:
在这里插入图片描述我们读作log以3为底,9的对数。具体计算方式是3的2次方为9,及以3为底9的对数就是2。
lg: 10为底的对数,叫作常用对数。
ln: 以无理数e(e=2.71828…)为底的对数,叫作自然对数

对数是对求幂的逆运算,正如除法是乘法的倒数,反之亦然。 这意味着一个数字的对数是必须产生另一个固定数字(基数)的指数。 在简单的情况下,乘数中的对数计数因子。更一般来说,乘幂允许将任何正实数提高到任何实际功率,总是产生正的结果,因此可以对于b不等于1的任何两个正实数b和x计算对数。

如果a的x次方等于N(a>0,且a不等于1),那么数x叫做以a为底N的对数(logarithm),记作x=logₐN。其中,a叫做对数的底数,N叫做真数。

二、javaAPI

1.求lg

java.lang.Math @Contract(pure = true) 
public static double log10(double a)

Returns the base 10 logarithm of a double value. 
返回以10为底的对数
Special cases:
If the argument is NaN or less than zero, then the result is NaN.
如果参数是NaN或者小于0的数据,则返回NaN
If the argument is positive infinity, then the result is positive infinity.
如果参数是正无群大,返回正无群大
If the argument is positive zero or negative zero, then the result is negative infinity.
如果参数为正零或负零,则结果为负无穷大。
If the argument is equal to 10n for integer n, then the result is n.
如果整数n的参数等于10n,则结果为n。
The computed result must be within 1 ulp of the exact result. Results must be semi-monotonic.
计算结果必须在精确结果的1ulp范围内。结果必须是半单调的。

2.求ln

java.lang.Math @Contract(pure = true) 
public static double log(double a)

Returns the natural logarithm (base e) of a double value. 
返回double类型的自然对数(以e为底)。
Special cases:
If the argument is NaN or less than zero, then the result is NaN.
If the argument is positive infinity, then the result is positive infinity.
If the argument is positive zero or negative zero, then the result is negative infinity.
The computed result must be within 1 ulp of the exact result. Results must be semi-monotonic.

Params:
a – a value
Returns:
the value ln a, the natural logarithm of a.
值ln a,a的自然对数。
External annotations:
@org.jetbrains.annotations.Contract(pure = true)

3.求ln(x+1)

java.lang.Math @Contract(pure = true) 
public static double log1p(double x)

Returns the natural logarithm of the sum of the argument and 1. Note that for small values x,<
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值