如何在去噪器中生成平方根的同分式?

2024-04-20 01:11:33 发布

您现在位置:Python中文网/ 问答频道 /正文

# From jupyter notebook
import sympy
sympy.init_printing()

x1 = sympy.Rational(1, 2)
x2 = sympy.sqrt(2)

# ERROR: can't do this..
x3 = sympy.Rational(1, sympy.sqrt(2))

# ERROR: can't do this either
x4 = sympy.Rational(1, x2)

如何在不使用浮点数的情况下将sqrt符号化地放入方程的分母中?你知道吗


Tags: fromimportinitjupytererrorsqrtthisdo
1条回答
网友
1楼 · 发布于 2024-04-20 01:11:33

当您需要1/sqrt(2)时,请执行以下操作:

x1 = 1 / sympy.sqrt(2)

当您需要1/2时,请执行以下操作:

x1 = sympy.Rational(1,2)

不要这样做:

x1 = sympy.Rational(1, sympy.sqrt(2))

错误。你知道吗

相关问题 更多 >