[sympy] Cannot do mpmath.sqrtm() in sympy

2014-11-24 Thread Yuxiang Wang
Dear all, I have the following code to extract the square root of a symmetric second-order tensor. from sympy import symbols, Matrix, mpmathimport numpy as np F11, F12, F13, F21, F22, F23, F31, F32, F33 = symbols('F11, F12, F13, F21, F22, F23, F31, F32, F33', real=True) F = np.array([[F11, F

Re: [sympy] Cannot do mpmath.sqrtm() in sympy

2014-11-24 Thread Tim Lahey
Hi, mpmath is for multi-precision math, not symbolic math. It's expecting numbers, not symbols. I don't think there's a square root routine for symbolic matrices implemented. Cheers, Tim. On 24 Nov 2014, at 14:05, Yuxiang Wang wrote: Dear all, I have the following code to extract the squ

Re: [sympy] Cannot do mpmath.sqrtm() in sympy

2014-11-24 Thread Yuxiang Wang
Hi Tim, Thank you for your response! And thanks for letting me know that symbolic square root matrix routine was not implemented. I will try to do the following: 1) Get eigenvectors first; 2) Take square root of the eigenvalues; 3) Re-construct the square root matrix from the original eigenve

Re: [sympy] Cannot do mpmath.sqrtm() in sympy

2014-11-24 Thread Aaron Meurer
It seems sqrt(Matrix) (where sqrt is sympy.sqrt) is unevaluated, but if you do Matrix(B)**(S(1)/2) it tries to evaluate it (but it hangs). You shouldn't use NumPy if you are dealing with symbolic matrices. There is no advantage to using NumPy at that point, vs. sympy.Matrix. Aaron Meurer On Mon,

Re: [sympy] Cannot do mpmath.sqrtm() in sympy

2014-11-24 Thread Yuxiang Wang
Hi Aaron, Thank you for the response! I tried to use numpy.ndarray because I got other orders of tensors, so I wanted to be consistent. But it seems that Matrix object can be higher-order too, so I'll try to use them. Thanks for the tip! Shawn On Monday, November 24, 2014 3:22:34 PM UTC-5, Aa

Re: [sympy] Cannot do mpmath.sqrtm() in sympy

2014-11-25 Thread Chris Smith
To take the sqrt of each element in B, use B.applyfunc(sqrt). On Monday, November 24, 2014 5:30:48 PM UTC-6, Yuxiang Wang wrote: > > Hi Aaron, > > Thank you for the response! > > I tried to use numpy.ndarray because I got other orders of tensors, so I > wanted to be consistent. But it seems that

Re: [sympy] Cannot do mpmath.sqrtm() in sympy

2014-11-25 Thread Yuxiang Wang
Chris, Thanks for responding! I was actually doing the square-root of the matrix, rather than the element-wise. But thanks still! -Shawn On Tuesday, November 25, 2014 3:33:43 PM UTC-5, Chris Smith wrote: > > To take the sqrt of each element in B, use B.applyfunc(sqrt). > > On Monday, November 2