Python solve equation for one variable

后端 未结 5 1996
逝去的感伤
逝去的感伤 2021-02-06 11:08

I\'m trying to solve an equation in python using SymPy. I have a generated equation (something like function = y(8.0-(y**3.0)) which I use with SymPy to create a ne

5条回答
  •  无人共我
    2021-02-06 11:46

    (I don't know why you mention scipy in your question when you use sympy in your code. I'll assume you are using sympy.)

    Sympy can solve this equation if you specify an integer power for y (ie y**3.0 changed to y**3).

    The following works for me using Sympy 0.6.7.

    from sympy import Eq, Symbol, solve
    
    y = Symbol('y')
    eqn = Eq(y*(8.0 - y**3), 8.0)
    
    print solve(eqn)
    

提交回复
热议问题