Skip to main content
19-Tanzanite
March 14, 2024
Solved

Matrix exponential function via Taylor's series

  • March 14, 2024
  • 1 reply
  • 3136 views

Hi,

I found this file Mathcad - expm.xmcd where it calculates:

Cornel_0-1710424822428.png

It seems that the calculation of exponential with exponent a matrix it is more rapidly done in this way than using e^([matrix]) in Mathcad Prime.

I put this in a Mathcad file (see MCP9 attached file), but I am not sure if I did things correctly (like I do not see a influence of that if 0<n) and I do not fully understand the procedure/calculation (I see that there is 2 methods. What are the difference between them? What is better to use?)

Can someone check and explain the procedure/calculation if understand it?

Cornel_2-1710424864799.png

Cornel_1-1710424853105.png

 

Best answer by Werner_E

@Cornel wrote:

I also see that it cannot be evaluated symbolically. This method will work only for numeric values, right? Or is it possible to make also to work with symbolic variable?

 

 


The function uses an approximation (just 21 summands of the Taylor series expansion). So it would not make much sense to evaluate it symbolically.

Furthermore, because of this 21 summands, the result would be rather large!

 

The reason for the while-loop and the continuous division of the matrix A by 2 is to make A small enough so that 21 summand of the series expansion provide enough precision (faster convergence).

You could as well do without but you will have to use much more summands to get a decent precision if the values of the matrix elements are larger.

Werner_E_0-1710431169183.png

Werner_E_1-1710431421625.png

If you feel like doing so you may evaluate expm2 symbolically with symbolic variables 😉

 

You could also rewrite the original function an can determine the value of n and the divided matrix using logarithms. That way the function could be evaluated symbolically. But it does not make sense to write an approximation for exp() and using ln() to do so.

 

 

 

1 reply

Cornel19-TanzaniteAuthor
19-Tanzanite
March 14, 2024

I also see that it cannot be evaluated symbolically. This method will work only for numeric values, right? Or is it possible to make also to work with symbolic variable?

Cornel_0-1710426482001.png

 

Werner_E25-Diamond IAnswer
25-Diamond I
March 14, 2024

@Cornel wrote:

I also see that it cannot be evaluated symbolically. This method will work only for numeric values, right? Or is it possible to make also to work with symbolic variable?

 

 


The function uses an approximation (just 21 summands of the Taylor series expansion). So it would not make much sense to evaluate it symbolically.

Furthermore, because of this 21 summands, the result would be rather large!

 

The reason for the while-loop and the continuous division of the matrix A by 2 is to make A small enough so that 21 summand of the series expansion provide enough precision (faster convergence).

You could as well do without but you will have to use much more summands to get a decent precision if the values of the matrix elements are larger.

Werner_E_0-1710431169183.png

Werner_E_1-1710431421625.png

If you feel like doing so you may evaluate expm2 symbolically with symbolic variables 😉

 

You could also rewrite the original function an can determine the value of n and the divided matrix using logarithms. That way the function could be evaluated symbolically. But it does not make sense to write an approximation for exp() and using ln() to do so.

 

 

 

25-Diamond I
March 14, 2024

So floating point limits are yet another reason for not using expm2() and rather staying with the original expm().

 

BTW, here is a version which also can be evaluated using a symbolical matrix.

I didn't wait for the calculation to finish, though, as it does not make any sense at all to evaluate a numerical approximation with symbols.

Werner_E_0-1710451877449.png

You may use a lower number like 2 or 3 instead of the 20 to see what expression you can expect from a symbolic eval.

 

Here I used just 1 instead of 20:

Werner_E_1-1710452494337.png