sympy 符号矩阵平方根 [英] sympy symbolic matrix square root

查看:49
本文介绍了sympy 符号矩阵平方根的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用 sympy sqrtm 函数来计算符号矩阵的平方根?例如,如果我有矩阵 [[1, a], [a, 1]] 且 a > 0,我可以使用 sympy 来计算平方根吗?

Is it possible to use the sympy sqrtm function to compute the square root of a symbolic matrix? For example, if I have the matrix [[1, a], [a, 1]] with a > 0, can I use sympy to compute the square root?

推荐答案

from sympy import *
a=symbols('a')
m=Matrix( [[1, a], [a, 1]])
m**(1/2)

给予

Matrix([
[ (-a + 1)**0.5/2 + (a + 1)**0.5/2, -(-a + 1)**0.5/2 + (a + 1)**0.5/2],
[-(-a + 1)**0.5/2 + (a + 1)**0.5/2,  (-a + 1)**0.5/2 + (a + 1)**0.5/2]])

在 Mathematica 中比较结果

To compare result, in Mathematica

这篇关于sympy 符号矩阵平方根的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆