Accelerating the pace of engineering and science

• Trials

# exp

## Description

example

Y = exp(X) returns the exponential for each element of array X. The function accepts both real and complex inputs. For real values of X in the interval (-Inf, Inf), exp returns real values in the interval (0,Inf). For complex values of X, exp returns complex values.

## Examples

expand all

### Calculate Scalar Exponential Values

Examine several common values of the exponential function.

Calculate the exponential of 0.

exp(0)
ans =

1

The result is 1, which is the y-intercept of the exp function.

Calculate the exponential of 1.

exp(1)
ans =

2.7183

The result is equal to Euler's number, e.

Calculate the exponential of .

exp(1i*pi)
ans =

-1.0000 + 0.0000i

The result of -1 is due to Euler's famous formula

Calculate the exponential of -Inf.

exp(-Inf)
ans =

0

The result is 0 since exp returns small values for negative inputs.

### Plot Real-Valued Exponential Function

Define the domain.

X = (-1:0.5:5)';


Calculate the exponential of the vector, X.

Y = exp(X)

Y =

0.3679
0.6065
1.0000
1.6487
2.7183
4.4817
7.3891
12.1825
20.0855
33.1155
54.5982
90.0171
148.4132



The result is a vector of exponential values.

Plot the function values.

plot(X,Y,'LineWidth',1.5)
grid on;
title('Real-Valued Exponential Function');
xlabel('X'); ylabel('Y');


The real-valued exponential function maps values in the domain of all real numbers to the range of .

### Plot Complex-Valued Exponential Function

Define a grid of values for the (X,Y) domain.

[X,Y] = meshgrid(0:0.5:10,0:0.5:10);


Calculate the complex exponential on the grid.

Z = exp(X+1i*Y);


Make a surface plot of the imaginary portion of the function.

surf(X,Y,imag(Z))
grid on; hold on;
xlabel('X'); ylabel('Y'); zlabel('Z');
view(44,42)


exp is a continuous function on the complex plane.

Plot the real portion of the function in the same figure.

surf(X,Y,real(Z))
view(63,14)


In this plot, the real and complex portions of the function are 90 degrees out of phase. Analytically, this is because the real portion depends on cos, whereas the complex portion depends on sin.

## Input Arguments

expand all

### X — Input arrayscalar | vector | matrix | multidimensional array

Input array, specified as a scalar, vector, matrix, or multidimensional array.

Data Types: single | double
Complex Number Support: Yes