Categories
1. Matlab Advanced

MATLAB exponent

MATLAB offers us different types of exponent functions that can compute the exponential of an array or matrix. These functions can be used to compute basic exponential, matrix exponential, or exponential integral as per our requirement. In this article, we will learn about 3 exponent functions offered by MATLAB: exp, expint, and expm. With the help of these functions, we can compute the solution when our input is an array, matrix, or a complex number and ‘e’ is raised to this power.

Syntax of exponent function:

  1. E = exp (I)
  2. E = expint (I)
  3. E = expm (I)

Description of the syntax:

  1. E = exp (I) is used to return the exponential ‘e’ raised to the power (I). For an array, it will compute the exponential of every element
  2. E = expint (I) is used to return the exponential integral of every element in the input ‘I’
  3. E = expm (I) is used to compute the matrix exponential for our input matrix ‘I’. Please note that matrix exponential is given by the formula:
expm(I) = EVec * diag (exp (diag (EVal))) / EVec,

where EVec represents Eigen Vectors and Eval represents Eigen Values

Examples of Matlab exponent

Let us now understand the code for these exponent functions in MATLAB

Example 1 (exp (I))

In this example, we will find the exponent of an array in MATLAB by using the exp (I) function. Below are the steps to be followed:

  1. Initialize the array whose exponent we need to compute
  2. Pass the input array as an argument to the exp function

Code:

I = [2 4 6 2 6] [Initializing the array whose exponent we need to compute] E = exp (I)
[Passing the input array as an argument to the exp function]

This is how our input and output will look like in MATLAB:

Input:

Matlab exponent input 1

Output:

Matlab exponent output 1

As we can see in the output, the exp function has computed the exponential of every element in our input array ‘I’.

 Next, we will learn the use of the expint function

Example 2 (expint (I))

In this example, we will find the integral exponent of an array in MATLAB by using the expint (I) function. Below are the steps to be followed:

  1. Initialize the array whose integral exponent we need to compute
  2. Pass the input array as an argument to the expint function

Code:

I = [2 3 5 1 6] [Initializing the array whose integral exponent we need to compute] E = expint (I)
[Passing the input array as an argument to the expm function]

This is how our input and output will look like in MATLAB:

Input:

Matlab exponent input 2

Output:

Matlab exponent output 2

As we can see in the output, the expint function has computed the integral exponential of every element in our input array ‘I’.

Next, we will learn the use of the expm function

Example 3 (expm (I))

In this example, we will find the matrix exponent of a matrix in MATLAB by using the expm (I) function. Below are the steps to be followed:

  1. Initialize the matrix whose matrix exponent we need to compute
  2. Pass the input matrix as an argument to the expm function

Code:

I = [2 3 5; 1 0 3; 2 5 7] [Initializing the 3 x 3 matrix whose matrix exponent we need to compute] 
E = expint (I)
[Passing the input matrix as an argument to the expm function]

This is how our input and output will look like in MATLAB:

Input:

input 3

Output:

output 3

As we can see in the output, the expm function has computed the matrix exponential of our input matrix ‘I’.

The exponent functions discussed above can also be used to compute the exponential of complex numbers. Let us understand this with an example.

Example 4 (exp (I))

In this example, we will find the exponent of an array of complex numbers in MATLAB by using the exp (I) function. Below are the steps to be followed:

  1. Initialize the array of complex numbers whose exponent we need to compute
  2. Pass the input array as an argument to the exp function

Code:

I = [2 + 3i   5 - 1i   4 + 5i] [Initializing the array of complex numbers whose exponent we need to compute] E = exp (I)
[Passing the input array as an argument to the exp function]

This is how our input and output will look like in MATLAB:

Input:

input 4

Output:

output 4

As we can see in the output, the exp function has computed the exponential of every complex element in our input array ‘I’.

Leave a Reply

Your email address will not be published. Required fields are marked *