简体   繁体   中英

How to calculate pi power 2 in sympy?

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:

pi doesn't seem to be an algebraic element

When I change pi to 3.14 it work just fine.

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

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

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

From the 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM