Skip to Main Content Skip to Search
Product Documentation

log - Natural logarithm

Syntax

Y = log(X)

Description

The log function operates element-wise on arrays. Its domain includes complex and negative numbers, which may lead to unexpected results if used unintentionally.

Y = log(X) returns the natural logarithm of the elements of X. For complex or negative z where z = x + y*i, the complex logarithm is returned.

log(z) = log(abs(z)) + i*atan2(y,x)

Examples

The statement abs(log(-1)) is a clever way to generate π.

ans =

    3.1416

See Also

exp | log10 | log2 | logm | reallog

  


Free MATLAB Interactive Kit

Explore how to use MATLAB to make advancements in engineering and science.


Download free kit

Trials Available

Try the latest version of MATLAB and other MathWorks products.


Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS