autodiff.reverse.log¶
- autodiff.reverse.log(x, base=2.718281828459045)¶
Return the logarithm of x of any base, default to natural log.
- Parameters
- xint, float, Dual
- baseint, float
- Returns
- outfloat or Dual
Notes
The log of x is undefined when x is less than or equal to 0.
Examples
>>> ad.log(2) 0.6931471805599453
>>> x = ad.Node(2) >>> ad.log(x) Node(0.6931471805599453)
>>> x = ad.Node(2) >>> ad.log(x, base=10) Node(0.30102999566398114)
>>> x = ad.Node(2) >>> ad.log(x, base=2) Node(1.0)
Derivative undefined:
>>> x = ad.Node(0) >>> ad.log(x) Traceback (most recent call last): ... ValueError: Log of x is undefined for x = 0
Error when base is non-positive:
>>> x = ad.Node(2) >>> ad.log(x, base=0) Traceback (most recent call last): ... ValueError: Cannot have non-positive base