python直接调用求解一元二次方程,一元三次方程函数
程序员文章站
2022-05-09 13:47:18
...
安装包
pip install zy
安装成功之后引用包
from zy.math import equation as eq
a = eq.f1(1,0,-1) # a=1 , b=0,c = -1
print(a)
'''
输出结果为
['x1=1.000000', 'x2=-1.000000']
'''
求解一元三次方程
from zy.math import equation as eq
b = eq.f2(1,0,-1,2)
print(b)
'''
['X1 = -1.521380', 'X2 = 0.760690 + 0.857874i', 'X3 = 0.760690 - 0.857874i']
'''