JuliaPy / SymPy.jl

Julia interface to SymPy via PyCall
http://juliapy.github.io/SymPy.jl/
MIT License
268 stars 62 forks source link

How to use `SymPy` to solve equations? #488

Closed zdlspace0528 closed 1 year ago

zdlspace0528 commented 1 year ago
using SymPy
@syms x y z e₁ e₂  c₁ c₂ c₃  c₅ s₁ s₂ s₃ g₁ g₂
fx = x*(x - 1)*(c₁ + c₂*y*z - c₂*y - c₂*z - e₁ - e₂*y*z + e₂*y + 
e₂*z - g₁*y - g₂*z - s₁*y)
fy = y*(y - 1)*(c₃ + g₁*x - g₁ + s₁*x)
fz = -z*(z - 1)*(-c₅ + s₂ + s₃)
solve([fx, fy, fz], [x, y, z])

It runs long long time, but no results.

jverzani commented 1 year ago

Yeah, you are doing everything correctly, but sometimes SymPy doesn't get a conclusion in a reasonable amount of time. I think on Discourse you have had some very useful guidance. One thing I'd try would be pursuing if narrowing the domain of the variables is helpful (e.g., @syms x::real y::real ...). But in my experience, solving with a large number of symbolic variables isn't always as successful as it could be.