exponential - matlab exp
TRANSCRIPT
4/9/2014 Exponential - MATLAB exp
http://www.mathworks.com/help/matlab/ref/exp.html 1/5
Exponential
Y = exp(X) example
example
collapse all
exp
Syntax
Description
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
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, w hich 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 iπ.
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 =
4/9/2014 Exponential - MATLAB exp
http://www.mathworks.com/help/matlab/ref/exp.html 2/5
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');
4/9/2014 Exponential - MATLAB exp
http://www.mathworks.com/help/matlab/ref/exp.html 3/5
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)
4/9/2014 Exponential - MATLAB exp
http://www.mathworks.com/help/matlab/ref/exp.html 4/5
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)
4/9/2014 Exponential - MATLAB exp
http://www.mathworks.com/help/matlab/ref/exp.html 5/5
expand all
collapse all
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, w hereas the complex portion depends on sin.
Input Arguments
X — Input array
scalar | vector | matrix | multidimensional array
More About
Algorithms
For complex inputs z = x + 1i*y, the exp function calculates the complex exponential exp(x).*(cos(y) +
1i*sin(y)).
See Also
expint | expm | expm1 | log | log10 | mpower | power