({{, (RefLink[Log, paclet:ref/Log])[z]
gives the natural logarithm of z (logarithm to base e). }, {, (RefLink[Log, paclet:ref/Log])[b,z]
gives the logarithm to base b. }})

OpenersNotesSection(Spacer1)Details

(RefLink[Log, paclet:ref/Log]) is a mathematical function, suitable for both symbolic and numerical manipulation.

(RefLink[Log, paclet:ref/Log]) gives exact rational number results when possible.

For certain special arguments, (RefLink[Log, paclet:ref/Log]) automatically evaluates to exact values.

(RefLink[Log, paclet:ref/Log]) can be evaluated to arbitrary numerical precision.

(RefLink[Log, paclet:ref/Log]) automatically threads over lists.

(RefLink[Log, paclet:ref/Log])[z] has a branch cut discontinuity in the complex z plane running from -∞ to 0.

OpenersPrimaryExamplesSection(Spacer1)Examples  (79)

OpenersExampleSection0(Spacer1)Basic Examples  (3)

(RefLink[Log, paclet:ref/Log]) gives the natural logarithm (to base e):

Log[1000.]

(RefLink[Log, paclet:ref/Log])[b,z] gives the logarithm to base b:

Log[10,1000]

Series expansion:

Series[Log[1+x],{x,0,10}]

OpenersExampleSection1(Spacer1)Scope  (40)

OpenersExampleSubsection0(Spacer1)Numerical Evaluation  (5)

Evaluate numerically to high precision:

N[Log[5/2],50]

The precision of the output tracks the precision of the input:

Log[2.50000000000000000000000000000000000000000000]

Complex arguments:

Log[2.5+I]

Evaluate (RefLink[Log, paclet:ref/Log]) efficiently at high precision:

Log[2.5`500]//Timing

Log[2.5`100000];//Timing

(RefLink[Log, paclet:ref/Log]) can deal with real-valued intervals from [0,∞):

Log[Interval[{1/3,2}]]

(RefLink[Log, paclet:ref/Log]) threads elementwise over lists and matrices:

Log[{1,2.1,3.1,4.1}]

Log[(({{1, u}, {v, 0}}))]//MatrixForm

OpenersExampleSubsection1(Spacer1)Specific Values  (5)

Simple exact values are generated automatically:

Log[E]

Log[2,1024]

Log[3,3^-12]

Log[Pi,Sqrt[Pi]]

Zero argument gives a symbolic result:

Log[0]

Values at infinity:

Log[Infinity]

Log[ComplexInfinity]

Find limits at branch cuts:

Limit[Log[-2+ϵ I],ϵ->0,Direction->1]

Limit[Log[-2+ϵ I],ϵ->0,Direction->-1]

Find the real zero of log(x):

xzero=Solve[Log[x]== 0&&0<x<2,x][[1,1,2]]

Plot[Log[x],{x,0,2},Epilog->{PointSize[Large],Red,Point[{xzero,Log[xzero]}]}]

OpenersExampleSubsection2(Spacer1)Visualization  (3)

Plot the (RefLink[Log, paclet:ref/Log]) function:

Plot[Log[x],{x,0,4}]

Plot the real part of log(x+i y):

ContourPlot[Re[Log[x+I y]],{x,-3,3},{y,-3,3},Contours->24]

Plot the imaginary part of log(x+i y):

ContourPlot[Im[Log[x+I y]],{x,-3,3},{y,-3,3},Contours->24]

Polar plot with r=log(ϕ):

PolarPlot[Log[ϕ],{ϕ,0,12π},Frame->True]

OpenersExampleSubsection3(Spacer1)Function Properties  (2)

(RefLink[Log, paclet:ref/Log]) is defined for all real positive values:

FunctionDomain[Log[x],x]

Complex domain:

FunctionDomain[Log[z],z,Complexes]

(RefLink[Log, paclet:ref/Log]) takes all real values:

FunctionRange[Log[x],x,y]

The range for complex values:

FunctionRange[Log[z],z,y,Complexes]

OpenersExampleSubsection4(Spacer1)Differentiation  (4)

First derivative:

D[Log[x],x]

Higher derivatives:

Table[D[Log[x],{x,n}],{n,1,4}]

Plot[Evaluate[%],{x,0,3},PlotLegends->{"First Derivative","Second Derivative","Third Derivative","Fourth Derivative"}]

Formula for the n(^th) derivative:

D[Log[x],{x,n}]

Derivative of a nested logarithmic function:

D[Log[Log[x]],x]

OpenersExampleSubsection5(Spacer1)Integration  (3)

Indefinite integrals of (RefLink[Log, paclet:ref/Log]):

Integrate[Log[x],x]

Integrate[Log[b,x],x]

Definite integral of (RefLink[Log, paclet:ref/Log]):

Integrate[Log[x],{x,0,1}]

More integrals:

Integrate[((Log[z])^a),z]

Integrate[Exp[-t]Log[t],{t,0,1}]

Integrate[(((Log[a+b z])^2)/(e+f z)),z]

Integrate[(a^(α-1))Log[a,z],a]

OpenersExampleSubsection6(Spacer1)Series Expansions  (4)

Taylor expansion for (RefLink[Log, paclet:ref/Log]):

Series[Log[x],{x,1,4}]

Plot the first three approximations for (RefLink[Log, paclet:ref/Log]) around x=1:

terms=Normal@Table[Series[Log[x],{x,1,m}],{m,1,3}];
Plot[{Log[x],terms},{x,0,2},PlotLegends->"Expressions"]

General term in the series expansion of (RefLink[Log, paclet:ref/Log]) around x=1:

SeriesCoefficient[Log[x],{x,1,n}]

The first term in the Fourier series of (RefLink[Log, paclet:ref/Log]):

FourierSeries[Log[z],z,1]

(RefLink[Log, paclet:ref/Log]) can be applied to power series:

Log[x+((x^2)/2)+((x^3)/3)+((O[x])^4)]

Log[a+((a^2)/2)+((a^3)/3)+((O[a])^4),x]//Simplify

OpenersExampleSubsection7(Spacer1)Function Identities and Simplifications  (6)

Basic identity for (RefLink[Log, paclet:ref/Log]):

b^Log[b,x]

Logarithm of a power function simplification:

FunctionExpand[Log[(x^a)],x>0 &&a∈Reals]

Simplify logarithms with assumptions:

Log[E^n]

Simplify[%,n>0]

Refine[%%, n > 0]

Logarithm of a product:

FunctionExpand[Log[x y],x>0&&x+y≥0]

Change of base:

FullSimplify[Log[b,x]==((Log[a,x])/(Log[a,b]))]

Expand assuming real variables x and y:

ComplexExpand[Log[x+I y]]

OpenersExampleSubsection8(Spacer1)Function Representations  (8)

Integral representation:

Integrate[1/t,{t,1,x},Assumptions->Re[x]>0||x∉Reals]

Series representation:

Sum[(((-1))^(k-1))((((z-1))^k)/k),{k,1,Infinity}]

(RefLink[Log, paclet:ref/Log]) arises from the power function in a limit:

Limit[(((z^ϵ)-1)/ϵ),ϵ->0]

Natural (RefLink[Log, paclet:ref/Log]):

Log[E,z]

(RefLink[Log, paclet:ref/Log]) is the inverse of (RefLink[Exp, paclet:ref/Exp]):

Solve[Exp[y]==x,y,Reals]

(RefLink[Log, paclet:ref/Log]) can be represented in terms of (RefLink[MeijerG, paclet:ref/MeijerG]):

Log[x]==MeijerG[{{1,1},{}},{{1},{0}},x-1]//FullSimplify

(RefLink[Log, paclet:ref/Log]) can be represented as a (RefLink[DifferentialRoot, paclet:ref/DifferentialRoot]):

DifferentialRootReduce[Log[x],x]

(RefLink[TraditionalForm, paclet:ref/TraditionalForm]) formatting:

Log[x]//TraditionalForm

OpenersExampleSection2(Spacer1)Generalizations & Extensions  (2)

(RefLink[Log, paclet:ref/Log]) can deal with real-valued intervals from [0,∞):

Log[Interval[{1/3,2}]]

(RefLink[Log, paclet:ref/Log]) is a numerical function:

Attributes[Log]

NumericQ[Log[1+E]]

OpenersExampleSection3(Spacer1)Applications  (8)

Plot (RefLink[Log, paclet:ref/Log]) for various bases:

Plot[{Log[2,x],Log[E,x],Log[10,x]},{x,0.5,10}]

Plot the real and imaginary parts of (RefLink[Log, paclet:ref/Log]):

Plot[{Re[Log[x]],Im[Log[x]]},{x,-2,2},PlotStyle->Thick]

Plot the real and imaginary parts over the complex plane:

{Plot3D[Re[Log[x+I y]],{x,-2,2},{y,-2,2}],Plot3D[Im[Log[x+I y]],{x,-2,2},{y,-2,2}]}

Plot data logarithmically and doubly logarithmically:

data=Table[{x/100,(x/100)^5},{x,100}];

{ListPlot[data],ListLogPlot[data],ListLogLogPlot[data]}//Row

Benford's law predicts that the probability of the first digit is (Subscript[log, 10])(1+1/n) in many sequences:

Table[{n,Log[10,1+1./n]}, {n,1,9}]

Analyze the first digits of the following sequence:

seq=NestList[3/2(#+Mod[#,2])&,1,10000];
Take[seq, 15]

Use (RefLink[Tally, paclet:ref/Tally]) to count occurrences of each digit:

Sort[Tally[IntegerDigits[seq][[All,1]]]]

Shannon entropy for a set of probabilities:

h[p_List]:=-p.Log[p]

Equi-entropy surfaces for four symbols:

h[{p1,p2,p3,1-p1-p2-p3}]

ContourPlot3D[Re[%],{p1,0,1},{p2,0,1},{p3,0,1},RegionFunction->(1-#1-#2-#3>0&),Contours->5]

Approximate the n(^th) prime number:

ListPlot[{Table[Prime[n],{n,2, 100}],Table[Round[ n(Log[n]+Log[Log[n]]-1)],{n,2,100}]}]

Exponential divergence of two nearby trajectories for a quadratic map:

ListPlot[Log[Abs[NestList[38/10 #(1-#)&,N[1/4,1000],200]-NestList[38/10 #(1-#)&,N[1/4+10^-20,1000],200]]]]

OpenersExampleSection4(Spacer1)Properties & Relations  (13)

Compositions with the inverse function might need (RefLink[PowerExpand, paclet:ref/PowerExpand]):

Exp[Log[z]]

Log[Exp[z]]

PowerExpand[%]

Get expansion that is correct for all complex arguments:

PowerExpand[Log[Exp[z]],Assumptions->{}]

PowerExpand[Log[(1/z)],Assumptions->{}]

PowerExpand[Log[z w],Assumptions->{}]

PowerExpand[Log[z^2],Assumptions->{}]

PowerExpand[Log[z^a],Assumptions->{}]

Simplify logarithms with assumptions:

Log[E^n]

Simplify[%,n>0]

Refine[%%, n > 0]

Convert inverse trigonometric and hyperbolic functions into logarithms:

TrigToExp[{ArcSin[z],ArcCosh[z]}]

(RefLink[Log, paclet:ref/Log]) arises from the power function in a limit:

Limit[(((z^ϵ)-1)/ϵ),ϵ->0]

Solve a logarithmic equation:

Reduce[((Log[z])^3)-5 Log[z]==2,z]

Reduce a logarithmic equation:

Reduce[Log[Exp[z]]==w,z]

Numerically find a root of a transcendental equation:

FindRoot[((Log[z])^2)-5 Log[z+3]+z==6,{z, 10}]

The natural logarithms of integers are transcendental:

Refine[Log[n]∈Algebraics,n∈Integers&&n>1]

Integral transforms:

LaplaceTransform[Log[t],t,s]

FourierTransform[Log[t],t,s]

Solve differential equations:

DSolve[a w[a] w''[a]-2 a ((w'[a])^2)+w[a] w'[a]==0,w,a]

DSolve[w'[a]+Log[a]w[a]==0,w,a]

Limits:

Limit[(x^(1-Log[Log[Log[(1/x)]]])),x->0]

(RefLink[Log, paclet:ref/Log]) is automatically returned as a special case for various special functions:

{HypergeometricPFQ[{1,1},{2},z],MeijerG[{{1,1},{}},{{1},{0}},z]}

OpenersExampleSection5(Spacer1)Possible Issues  (7)

For a symbolic base, the base b log evaluates to a quotient of logarithms:

Log[b,z]

Generically, (f^(-1))(f(z))≠z:

Log[Exp[-100. I]]

Exp[Log[-100. I]]

Because intermediate results can be complex, approximate zeros can appear:

Exp[Log[-SetPrecision[100,50] I]]

Machine-precision inputs can give numerically wrong answers on branch cuts:

Log[- 2+I ((Pi+1)^2-Pi^2-2Pi-1 -Exp[-Pi^4])]//N

Use arbitrary-precision arithmetic to obtain correct results:

Log[- 2+I ((Pi+1)^2-Pi^2-2Pi-1 -Exp[-Pi^4])]//N[#,100]&//N

Compositions of logarithms can give functions that are zero almost everywhere:

f[z_]:=Log[z]+Log[1/z]

ListPlot3D[Flatten[Table[{x,y,Im[f[x+I y]]},{x,-3,3,6/25},{y,-3,3,6/24}],1],PlotRange->All]

This function is a differential-algebraic constant:

D[f[z],z]

Logarithmic branch cuts can occur without their corresponding branch point:

f[z_]=Log[z+(Sqrt[-1+z]) (Sqrt[1+z])];

The argument of the logarithm never vanishes:

Reduce[z+(Sqrt[-1+z]) (Sqrt[1+z])==0,z,Complexes]

But it can take negative values, so the logarithm has a branch cut:

(z+(Sqrt[-1+z]) (Sqrt[1+z]))/.z->-7

The kink at z=-1 marks the appearance of the second sheet:

Plot3D[Im[f[x+I y]],{x,-3,3},{y,-1,1},Exclusions->{{y==0,x<1}}]

Logarithmic terms in Puiseux series are considered coefficients inside (RefLink[SeriesData, paclet:ref/SeriesData]):

Series[x^x+Log[Log[1/x]],{x,0,3}]

InputForm[%]

In traditional form, parentheses are needed around the argument:

log x

log(x)

ln(x)

(Subscript[log, b])(x)

OpenersExampleSection6(Spacer1)Neat Examples  (6)

Successive integrals of the log function:

NestList[Integrate[#,x]&,Log[x],4]

Amoeba of a cubic:

p[z_]= (z^3)-2 (z^2)+I z+3;
ParametricPlot[{Log[Abs[r (E^(I φ))]],Log[Abs[p[r (E^(I φ))]]]},{r,0.01,4},{φ,0,2 π}]

Plot the Riemann surface of (RefLink[Log, paclet:ref/Log]):

ParametricPlot3D[{Re[Exp[x+I y]],Im[Exp[x+I y]],y},{x,-2,2},{y,-2Pi,2Pi}]

Plot (RefLink[Log, paclet:ref/Log]) at integer points:

ArrayPlot[Table[FractionalPart[Abs[Log[x  y]]],{x,-20,20},{y,-20,20}]]

Calculate (RefLink[Log, paclet:ref/Log]) through an analytically continued summed Taylor series:

log[n_, z_]=(z-1)(∑_(k=0)^n)(((((-1))^k)(((z-1))^k))/(1+k))

Visualize how the value is approached as n->∞:

Log[0.1+0.2I]

Plot[{Re@log[n,0.1+0.2I],Im@log[n,0.1+0.2I]},{n,0,20}]

Plot the Riemann surface of (RefLink[Log, paclet:ref/Log])[Log[z]]:

ParametricPlot3D[Evaluate[{Re[Exp[Exp[x+I y]]],Im[Exp[Exp[x+I y]]],y}],{x,-2,2},{y,-2Pi,2Pi},BoxRatios->{1,1,3/2}]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Log10, paclet:ref/Log10])  ▪  (RefLink[Log2, paclet:ref/Log2])  ▪  (RefLink[Exp, paclet:ref/Exp])  ▪  (RefLink[Power, paclet:ref/Power])  ▪  (RefLink[Arg, paclet:ref/Arg])  ▪  (RefLink[RealExponent, paclet:ref/RealExponent])  ▪  (RefLink[MantissaExponent, paclet:ref/MantissaExponent])  ▪  (RefLink[ProductLog, paclet:ref/ProductLog])  ▪  (RefLink[HarmonicNumber, paclet:ref/HarmonicNumber])  ▪  (RefLink[MultiplicativeOrder, paclet:ref/MultiplicativeOrder])  ▪  (RefLink[BitLength, paclet:ref/BitLength])  ▪  (RefLink[IntegerLength, paclet:ref/IntegerLength])  ▪  (RefLink[LogPlot, paclet:ref/LogPlot])  ▪  (RefLink[PowerRange, paclet:ref/PowerRange])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Some Mathematical Functions, paclet:tutorial/SomeMathematicalFunctions])}, {▪(RefLinkPlain[Elementary Transcendental Functions, paclet:tutorial/ElementaryTranscendentalFunctions])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Elementary Functions, paclet:guide/ElementaryFunctions])}, {▪(RefLinkPlain[Mathematical Functions, paclet:guide/MathematicalFunctions])}, {▪(RefLinkPlain[Image Processing & Analysis, paclet:guide/ImageProcessing])}, {▪(RefLinkPlain[Functions Used in Statistics, paclet:guide/FunctionsUsedInStatistics])}, {▪(RefLinkPlain[Analytic Number Theory, paclet:guide/AnalyticNumberTheory])}, {▪(RefLinkPlain[Audio Processing, paclet:guide/AudioProcessing])}, {▪(RefLinkPlain[Neural Networks, paclet:guide/NeuralNetworks])}})}})

({{(Spacer1), ({{(Spacer1)Related Links}, {(WebLink[DocumentationFooterIconsRelatedLinks-MathWorld.png(Spacer1)MathWorld, http://mathworld.wolfram.com/NaturalLogarithm.html])}, {(WebLink[DocumentationFooterIconsRelatedLinks-Functions.png(Spacer1)The Wolfram Functions Site, http://functions.wolfram.com/ElementaryFunctions/Log/])}, {(WebLink[DocumentationFooterIconsRelatedLinks-EIWL.png(Spacer1)An Elementary Introduction to the Wolfram Language, https://www.wolfram.com/language/elementary-introduction/23-more-about-numbers.html])(WebLink[: More about Numbers, https://www.wolfram.com/language/elementary-introduction/23-more-about-numbers.html])}, {(WebLink[DocumentationFooterIconsRelatedLinks-NKS.png(Spacer1)NKS|Online, http://www.wolframscience.com/nksonline/index/search.cgi?SearchIndex=Log]) ((WebLink[A New Kind of Science, http://www.wolframscience.com/nksonline/]))}})}})