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.

Functions

 exp Exponential expm1 Compute exp(x)-1 accurately for small values of x log Natural logarithm log10 Common logarithm (base 10) log1p Compute log(1+x) accurately for small values of x log2 Base 2 logarithm and floating-point number dissection nextpow2 Exponent of next higher power of 2 nthroot Real nth root of real numbers pow2 Base 2 exponentiation and scaling of floating-point numbers reallog Natural logarithm for nonnegative real arrays realpow Array power for real-only output realsqrt Square root for nonnegative real arrays sqrt Square root

Topics

Powers and Exponentials

This topic shows how to compute matrix powers and exponentials using a variety of methods.

Graphical Comparison of Exponential Functions

This example shows an interesting graphical approach for discovering whether e^pi is greater than pi^e.