cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X

Matrix exponential function via Taylor's series

Cornel
18-Opal

Matrix exponential function via Taylor's series

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
Werner_E
24-Ruby V
(To:Cornel)


@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.

 

 

 

View solution in original post

8 REPLIES 8

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_E
24-Ruby V
(To:Cornel)


@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.

 

 

 

Cornel_2-1710438984170.png

 

Cornel_1-1710438905272.png

 

Werner_E
24-Ruby V
(To:Cornel)

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

 

 

 

 

I am thinking to use this:

Cornel_3-1710496045861.png
What do you think @Werner_E ?


It works for symbolics:

Cornel_1-1710495941066.png

And also for numerics:

Cornel_2-1710495965276.png

EDIT:...yeah, but it suffers for same problem:

Cornel_5-1710496170114.png

 

 

And also your function:

Cornel_0-1710496314913.png

Cornel_1-1710496322655.png

 

 

But I see that this is ok:

Cornel_2-1710496395075.png

Cornel_3-1710496416657.png
But this implementation of expm function does not work for symbolics...

 

 

Werner_E
24-Ruby V
(To:Cornel)

You have to decide what you use depending on your needs!!

And its completely unclear to me, what your needs are, why you would need a function like this with results going up to the IEEE limit of 10^307 or why you would like to symbolically evaluate of an appoiximation!!??

So its your choice ...

Top Tags