我尝试使用“if/else”工具修改数学函数g=x³的图像
我需要的是,当我的函数图像大于0时,结果保持不变,但如果图像是其他内容,我希望图像成为1/g的结果
目前我试着这样做:
from sympy import *
from sympy.abc import x
g = x**3
if g > 0:
g = g
else:
g = 1/g
plot(g)
但它回答了我这个问题:
File "c:/Users/Anticrate/Desktop/PYTHON Sauvegardes/tes7.py", line 8, in <module>
if g > 0:
File "C:\Users\Anticrate\anaconda3\lib\site-packages\sympy\core\relational.py", line 398, in __bool__
raise TypeError("cannot determine truth value of Relational")
TypeError: cannot determine truth value of Relational
可以使用
Piecewise
创建基于符号条件定义的函数:相关问题 更多 >
编程相关推荐