%mathpiper,def="Ln"

2 # Ln(0)                    <-- -Infinity;
2 # Ln(1)                    <-- 0;
2 # Ln(Infinity)                    <-- Infinity;
2 # Ln(Undefined)                   <-- Undefined;

/* 2 # Ln(-Infinity)                    <-- 0; */
2 # Ln(x_IsNegativeNumber)_InNumericMode() <-- Complex(Ln(-x), Pi);
3 # Ln(x_IsNumber)_(InNumericMode() And x>=1) <-- Internal'LnNum(x);
4 # Ln(Exp(_x))              <-- x;

3 # Ln(Complex(_r,_i)) <-- Complex(Ln(Abs(Complex(r,i))), Arg(Complex(r,i)));
4 # Ln(x_IsNegativeNumber) <-- Complex(Ln(-x), Pi);
5 # Ln(x_IsNumber)_(InNumericMode() And x<1) <-- - Internal'LnNum(DivideN(1, x));

Ln(xlist_IsList) <-- MapSingle("Ln",xlist);

%/mathpiper



%mathpiper_docs,name="Ln",categories="User Functions;Calculus Related (Symbolic)"
*CMD Ln --- natural logarithm
*STD
*CALL
	Ln(x)

*PARMS

{x} -- argument to the function

*DESC

This function calculates the natural logarithm of "x". This is the
inverse function of the exponential function, {Exp}, i.e. $Ln(x) = y$ implies that $Exp(y) = x$. For complex
arguments, the imaginary part of the logarithm is in the interval
(-$Pi$,$Pi$]. This is compatible with the branch cut of {Arg}.

This function is threaded, meaning that if the argument {x} is a
list, the function is applied to all entries in the list.

*E.G.

In> Ln(1)
Result: 0;
In> Ln(Exp(x))
Result: x;
In> Differentiate(x) Ln(x)
Result: 1/x;

*SEE Exp, Arg
%/mathpiper_docs