如何计算pi power 2?

时间:2022-06-19 20:21:07
equations = [
    Eq(N_bRd, X_c * f_y * A * gamma_M1),
    Eq(L_c, L * beta),
    Eq(N_cr, (pi) ** 2 * E_E * i / (beta * L) ** 2),
    Eq(lamda, sqrt(N_bRd / N_cr)),
]
results = solve(equations)
# results = solve(equations, [m_A,m_D,theta_c,theta_b,delta])
results

I am getting the following error with sympy NotAlgebraic:

我通过sympy NotAlgebraic得到以下错误:

pi doesn't seem to be an algebraic element

pi似乎不是一个代数元素

When I change pi to 3.14 it work just fine.

当我将pi改为3.14时它工作得很好。

1 个解决方案

#1


2  

Common mathematical constants are defined in the mpmath module (a sympy dependency):

常见的数学常量在mpmath模块中定义(一个sympy依赖):

>>> from mpmath import mp
>>> mp.pi
<pi: 3.14159~>

>>> mp.pi**2
mpf('9.869604401089358')

From the sympy docs:

来自sympy docs:

These constants are implemented as lazy objects that can evaluate to any precision. Whenever the objects are used as function arguments or as operands in arithmetic operations, they automagically evaluate to the current working precision.

这些常量实现为可以评估任何精度的惰性对象。只要对象在算术运算中用作函数参数或操作数,它们就会自动计算当前的工作精度。

#1


2  

Common mathematical constants are defined in the mpmath module (a sympy dependency):

常见的数学常量在mpmath模块中定义(一个sympy依赖):

>>> from mpmath import mp
>>> mp.pi
<pi: 3.14159~>

>>> mp.pi**2
mpf('9.869604401089358')

From the sympy docs:

来自sympy docs:

These constants are implemented as lazy objects that can evaluate to any precision. Whenever the objects are used as function arguments or as operands in arithmetic operations, they automagically evaluate to the current working precision.

这些常量实现为可以评估任何精度的惰性对象。只要对象在算术运算中用作函数参数或操作数,它们就会自动计算当前的工作精度。