在Python SymPy中设置函数的域

2024-06-30 16:19:48 发布

您现在位置:Python中文网/ 问答频道 /正文

我想知道是否有可能设置一个数学领域。功能。例如,当我定义以下表达式时

>>> import sympy as syp
>>> x = syp.Symbol('x')
>>> miles_to_km = x * 1.609344
>>> miles_to_km.evalf()
1.609344*x

是否可以限制域,使x在[0,inf]范围内?所以目标是我可以使用sympy.plot函数来生成一个从0开始的图,并且只包含正的x值,而不是

enter image description here


Tags: toimport功能定义表达式as数学symbol
1条回答
网友
1楼 · 发布于 2024-06-30 16:19:48

如果我们通过以下方式检查手册:

help(syp.plot)

您将获得:

...

expr : Expression representing the function of single variable

range: (x, 0, 5), A 3-tuple denoting the range of the free variable.

...

所以,你可以:

^{pr2}$

将得到以下输出:

enter image description here

相关问题 更多 >