Home:ALL Converter>How to get `A^(-1/2)` in Python?

How to get `A^(-1/2)` in Python?

Ask Time:2021-09-22T05:53:03         Author:Hermi

Json Formatter

If I have a matrix

A=array([[ 0.59484625,  0.        ,  0.        ,  0.        ],
       [ 0.        ,  0.58563893,  0.        ,  0.        ],
       [ 0.        ,  0.        ,  0.58280472,  0.        ],
       [ 0.        ,  0.        ,  0.        ,  0.58216725]])

How to get A^(-1/2)?

It seems that linalg.matrix_power(D,-1/2) does not work in Python.

In my opinion, A^(-1/2) is just

A=array([[ 0.59484625**(-1/2),  0.        ,  0.        ,  0.        ],
       [ 0.        ,  0.58563893**(-1/2),  0.        ,  0.        ],
       [ 0.        ,  0.        ,  0.58280472**(-1/2),  0.        ],
       [ 0.        ,  0.        ,  0.        ,  0.58216725**(-1/2)]])

But how to do that for a larger matrix?

Author:Hermi,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/69275937/how-to-get-a-1-2-in-python
yy