Written and maintained by CASRAI Editorial Board
Last updated
In MATLAB the exponential function is exp: Y = exp(X) returns ex for each element of X. There is no e^x operator and no built-in variable named e; the number e is exp(1), which displays as 2.7183. This guide is for researchers and analysts who need to write exponentials correctly, tell exp from the matrix exponential expm, and read the output.
What exp is used for in research
The exponential function appears wherever growth, decay or likelihood models do: exponential growth and decay curves, rate laws, survival and hazard models, softmax and log-likelihood calculations, and transformations that reverse a natural logarithm. In MATLAB, exp is the single function behind all of these, and it works on a whole array at once. To go the other way (from a value back to its exponent), see natural logarithm in MATLAB and ln in MATLAB; to fit an exponential model to data, see fit in MATLAB.
Install or access
exp is part of base MATLAB, so no toolbox is needed. Documentation for the function is published by MathWorks at mathworks.com/help/matlab/ref/double.exp.html. Licensing and access options are on the MathWorks website; this page does not cover pricing.
How do you write exponential in MATLAB?
Use exp(x). The documented syntax is Y = exp(X), which returns ex for each element of X. The input can be a scalar, vector, matrix, N-d array, table or timetable, of type single or double, and complex values are supported.
Exponential function in MATLAB: step by step
- Put your values in a variable:
X = -2:0.5:10; - Apply the function:
Y = exp(X/2);This is the documentation’s own plotting example and computes ex/2 for every element. - Plot it:
plot(X,Y). For labels and axes, see MATLAB plot label and MATLAB graphing.
The scaling in step 2 answers “how to add” a coefficient to the exponent: divide or multiply the argument inside exp, as in exp(X/2). The exponent is whatever expression you pass in.
What is exponential e in MATLAB?
The constant e is obtained as exp(1). MATLAB’s documentation shows it returning 2.7183, which is the default short display of the stored double-precision value, not the full stored precision. Use exp(1) wherever a formula says e; for e2, write exp(2).
What is exp() in math?
exp(x) is the exponential function, e raised to the power x. For a complex number z = x + iy, MATLAB’s documentation gives ez = ex(cos y + i sin y). Setting x = 0 and y = π gives Euler’s identity result, which MATLAB shows for Y = exp(1i*pi) as -1.0000 + 0.0000i.
exp versus expm: element-wise or matrix exponential
For a matrix, exp and expm are different operations. MathWorks states: “Use expm to compute a matrix exponential,” and, on the expm page, “Use exp for the element-by-element exponential.” The expm input must be square.
| Function | What it computes | Input | Documented example, A = [1 1 0; 0 0 2; 0 0 -1] |
|---|---|---|---|
exp(X) |
ex of each element separately | Scalar, vector, matrix, N-d array, table, timetable | First row of exp(A): 2.7183 2.7183 1.0000 |
expm(X) |
The matrix exponential | Square matrix | First row of expm(A): 2.7183 1.7183 1.0862 |
In that example the diagonals agree because the matrix is triangular, but the off-diagonal entries differ. MathWorks also notes that expm(X) equals V*diag(exp(diag(D)))/V when X has a full set of eigenvectors (from [V,D] = eig(X)), though expm is not computed that way. For eigenvalues, see eigenvalue in MATLAB.
Output and how to read it
- The output
Yhas the same data type asX. - For real input, the result is positive.
- For complex input, the result is complex.
- Displayed digits (such as 2.7183) reflect the display format, not the stored value; use
format longto see more digits, or see fprintf in MATLAB to control printed output.
Troubleshooting
- Error or wrong result from e^x. MATLAB has no
e^xoperator for the constant; writeexp(x). - Matrix result looks wrong. If you wanted the matrix exponential,
exp(A)gives element-wise values; useexpm(A). expmerrors on your input.expmrequires a square matrix.- Unexpected complex output. Complex input gives complex output; check whether your data contain an imaginary part.
Free alternatives
| Tool | Element-wise exponential | Matrix exponential |
|---|---|---|
| GNU Octave | exp(x) |
expm(A) |
| Python (NumPy, SciPy) | numpy.exp(x) |
scipy.linalg.expm(A) |
| Julia | exp(x) (broadcast with exp.(x)) |
exp(A) on a square matrix |
Note that Julia reverses MATLAB’s convention: exp on a square matrix is the matrix exponential, and the dot form is element-wise.
FAQ
How do you write exponential in MATLAB?
Write exp(x), for example exp(X/2) on a vector X.
What is exp() in math?
It is e raised to the power x, the inverse of the natural logarithm.
What is exponential e in MATLAB?
exp(1), displayed as 2.7183.
How to add exponential e?
Scale or shift the argument inside exp, such as exp(X/2); to include e in a formula, use exp(1) or fold it into the exponent.
Sources
- MathWorks, exp – Exponential, read 2026-11-07.
- MathWorks, expm – Matrix exponential, read 2026-11-07.







