Main Content

Exponents and Logarithms

Exponential, logarithm, power, and root functions

In addition to common functions like exp and log, MATLAB® has several other related functions to allow flexible numerical calculations. The expm1 and log1p functions compensate for numerical round-off errors in small arguments, while the reallog, realpow, and realsqrt functions restrict the range of these functions to real numbers. nthroot calculates roots of any order, while the specialized functions pow2 and nextpow2 calculate powers of two.


expm1Compute exp(x)-1 accurately for small values of x
logNatural logarithm
log10Common logarithm (base 10)
log1pCompute log(1+x) accurately for small values of x
log2Base 2 logarithm and floating-point number dissection
nextpow2Exponent of next higher power of 2
nthrootReal nth root of real numbers
pow2Base 2 exponentiation and scaling of floating-point numbers
reallogNatural logarithm for nonnegative real arrays
realpowArray power for real-only output
realsqrtSquare root for nonnegative real arrays
sqrtSquare root