log
result = ln(x)
Input: x · Output: result
What it is
Natural logarithm, elementwise (log is an alias for ln — it is not base-10; see log10 for that). x is a scalar, Vec, or Mat/Signal; a non-positive element gives NaN/-inf rather than an error.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = ln(x) | x scalar, Vec, Mat, or Signalnot documented yet | result — | Returns the same shape as x. |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
x = 0.5
print("tan={tan(x)} asin={asin(x)} acos={acos(x)} atan={atan(x)}")
print("sinh={sinh(x)} cosh={cosh(x)} tanh={tanh(x)}")
print("ln(e^2)={ln(exp(2))} log(e^2)={log(exp(2))} log2(8)={log2(8)}")
z = 3 + 4j
print("arg={arg(z)} phase={phase(z)} re={re(z)} imag={imag(z)} im={im(z)} conj={conj(z)}")
print(ceil(2.1)) # 3
output
tan=0.546302 asin=0.523599 acos=1.047198 atan=0.463648 sinh=0.521095 cosh=1.127626 tanh=0.462117 ln(e^2)=2 log(e^2)=2 log2(8)=3 arg=0.927295 phase=0.927295 re=3 imag=4 im=4 conj=3 - 4j 3
from core-math
How it works
log(x) is natural; log(x, base) is to that base. The second form existed in every language people arrive from and was silently discarded here -- log(8, 2) answered 2.08.
From the note above this builtin in the interpreter, where the reasoning was written down as it was built.
See also
ln — documented in the same entry.