7.3 Exponential Functions

This page introduces exponential functions and arbitrary base logarithms in each CAS.

Octave / MATLAB

Mathematica

Sage


Octave / MATLAB

The natural exponential function

In MATLAB (and Octave) the natural exponential function $x\mapsto e^x$ is exp(). The constant $e$ may be computed (approximately) with exp(1).

>> syms x positive % Have symbolic toolbox treat x as a positive real. >> exp( log(x) ) ans = x >> log( exp(x) ) ans = x >> diff( exp(x) ) ans = exp(x) >> exp(1) ans = 2.7183

Incidentally exp() accepts non-real complex inputs.

>> exp( i*pi ) ans = -1.0000 + 0.0000i

The general exponential function

As we've already seen, general exponential expressions may be computed with the operator ^ using the syntax base^exponent.

>> 2^3 ans = 8 >> 0.5432^-0.1837 ans = 1.1186 >> exp(1)^log(10) ans = 10.0000 >> syms a x >> diff(a^x, x) ans = a^x*log(a)

Alternatively you can exploit the identity ${\displaystyle a^x = e^{x\ln{a}}}$ (for $a>0$) and replace a^x with exp(x*log(a)).

Logarithms with base $a$

The formula $\log_a{x}=\frac{\ln{x}}{\ln{a}}$ facilitates computation of logs with arbitrary base.

octave:1> % Base 3 log of 9 octave:1> log(9)/log(3) ans = 2


Mathematica

The natural exponential function

The natural exponential function in Mathematica is Exp[].

The general exponential function

General exponential expressions may be computed using the ^ operator, or by putting the exponent in superscript position over the base. (You can move the cursor to superscript position in a Mathematica notebook using Ctrl- 6, and leave the superscript position with the right arrow key.) In particular you can replace Exp[x] with $\mathbb{e}^x$. (The exponential value ${\bf \mathbb{e}}$ may be entered in a Mathematica notebook as Escee Esc or \[ExponentialE]. Using a regular lowercase "e" is not equivalent... but capital "E" is... if you can stand the unsightlyness of it.)

Logarithms with base $a$

You can override the default base of $\mathbb{e}$ in a call to Log[] by supplying an alternative base as an additional input. Note, though, that this "additional" argument must be placed first.


Sage

The natural exponential function

In Sage, $e^x$ can be entered as exp(x) or e^x.

The general exponential function

Use the ^ operator to form general exponential expresssion.

Logarithms with base $a$

You can override the default base of $e$ in log() by specifying an alternative base as a second parameter.