-2
$\begingroup$

$e^A$ is just the $A$ matrix with all of its elements exponentiated, called a matrix exponential.

It follows that the inverse $(e^{A})^{-1} = e^{-A}$ for square matrices, although I could find nothing on whether this is supposed to still hold for symmetric matrices. In my case $A$ is a symmetric matrix.

In Python, I try to test the previous equality, but found that it doesn't hold for a symmetric matrix. not sure why or if I've done something wrong

import numpy as np

A = np.array([[1.4,0.02,0.01],
             [0.02,1.5,0.03],
             [0.01,0.03,1.6]])
print(A)

print(np.linalg.inv(np.exp(A)))
print(np.exp(-A))

which outputs

[[1.4  0.02 0.01]
 [0.02 1.5  0.03]
 [0.01 0.03 1.6 ]]

[[ 0.27060306 -0.05136872 -0.04449588]
 [-0.05136872  0.24409113 -0.04030659]
 [-0.04449588 -0.04030659  0.21935596]]

[[0.24659696 0.98019867 0.99004983]
 [0.98019867 0.22313016 0.97044553]
 [0.99004983 0.97044553 0.20189652]]

The last two matrices should be equal to each other, but they're not

$\endgroup$
5
  • 4
    $\begingroup$ I think your reasoning ultimately implies that the inverse of a matrix should equal the original matrix with each element inverted, and this is not the case even for symmetric matrices. $\endgroup$ – Richard Hardy Dec 11 '20 at 19:07
  • $\begingroup$ no i wasn't going to take it that far. i will have to look for a way to disambiguate the matrix whose elements are exponentiated from the matrix exponential though. there doesn't seem to be a symbol for it since $e^A$ only can be used for the second $\endgroup$ – develarist Dec 11 '20 at 19:18
  • $\begingroup$ I guessed you were not going to take it that far, but if you follow through your argumentation, I think you will end up at what I indicated. At least I ended up there following the post. (Possibly by mistake.) $\endgroup$ – Richard Hardy Dec 11 '20 at 19:21
  • $\begingroup$ worth watching out that I don't do that nevertheless. thanks for pointing it out $\endgroup$ – develarist Dec 11 '20 at 19:23
  • 1
    $\begingroup$ It would answer your question, because this is where the argument leads us to, and we know this cannot be correct. I was going to write this up, but you have already accepted another answer, so I will spare the effort. $\endgroup$ – Richard Hardy Dec 11 '20 at 19:25
11
$\begingroup$

This is a case of reasoning from a false premise.

  1. The matrix exponential is not defined as the exponentiation of each element of a matrix. Instead, the definition of a matrix exponential is $$ \exp(X) = \sum_{k=0}^\infty \frac{1}{k!} X^k $$ for a square matrix $X$.

    If you want to exponentiate a matrix, you'll need to use a function like scipy.linalg.expm. However, note that matrix exponentials are not easily done in general. See: Cleve Moler, Charles Van Loan. "Nineteen Dubious Ways to Compute the Exponential of a Matrix, Twenty-Five Years Later". Society for Industrial and Applied Mathematics, Vol. 45, No. 1

  2. The function np.exp doesn't compute a matrix exponential. Instead, it's a function that exponentiates the elements of A. The documentation tells you as much.

$\endgroup$
10
  • $\begingroup$ but the function np.exp(A) does exponentiate the elements of $A$ $\endgroup$ – develarist Dec 11 '20 at 19:04
  • 5
    $\begingroup$ Yes, it does exponentiate the elements of A. That's because np.exp is not a matrix exponential. Instead, it's a function that exponentiates the elements of A. The documentation tells you as much. $\endgroup$ – Sycorax Dec 11 '20 at 19:05
  • 7
    $\begingroup$ (+1) Matrix exponent is scipy.linalg.expm $\endgroup$ – gunes Dec 11 '20 at 19:05
  • 6
    $\begingroup$ @develarist It seems you have an outstanding question about the difference between a matrix exponential and exponentiating the elements of a matrix. This is perfectly fine, but it's a question of mathematics, not statistics. You'd best ask a question in math.SE, and be sure to explain what, specifically, is giving you trouble. $\endgroup$ – Sycorax Dec 11 '20 at 19:08
  • 4
    $\begingroup$ I'm not going to troubleshoot your python problems, but the function has a documentation page. docs.scipy.org/doc/scipy/reference/generated/… so I don't think the problem lies with scipy. $\endgroup$ – Sycorax Dec 11 '20 at 19:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.