本文整理汇总了Python中sympy.Symbol.diff方法的典型用法代码示例。如果您正苦于以下问题:Python Symbol.diff方法的具体用法?Python Symbol.diff怎么用?Python Symbol.diff使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sympy.Symbol
的用法示例。
在下文中一共展示了Symbol.diff方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_diff
# 需要导入模块: from sympy import Symbol [as 别名]
# 或者: from sympy.Symbol import diff [as 别名]
def test_diff():
x = Symbol('x')
assert Rational(1, 3).diff(x) is S.Zero
assert I.diff(x) is S.Zero
assert pi.diff(x) is S.Zero
assert x.diff(x, 0) == x
assert (x**2).diff(x, 2, x) == 0
raises(ValueError, lambda: x.diff(1, x))
a = Symbol("a")
b = Symbol("b")
c = Symbol("c")
p = Rational(5)
e = a*b + b**p
assert e.diff(a) == b
assert e.diff(b) == a + 5*b**4
assert e.diff(b).diff(a) == Rational(1)
e = a*(b + c)
assert e.diff(a) == b + c
assert e.diff(b) == a
assert e.diff(b).diff(a) == Rational(1)
e = c**p
assert e.diff(c, 6) == Rational(0)
assert e.diff(c, 5) == Rational(120)
e = c**Rational(2)
assert e.diff(c) == 2*c
e = a*b*c
assert e.diff(c) == a*b
示例2: test_speed
# 需要导入模块: from sympy import Symbol [as 别名]
# 或者: from sympy.Symbol import diff [as 别名]
def test_speed():
# this should return in 0.0s. If it takes forever, it's wrong.
x = Symbol("x")
assert x.diff(x, 10**8) == 0