本文整理汇总了Python中sympy.holonomic.HolonomicFunction.diff方法的典型用法代码示例。如果您正苦于以下问题:Python HolonomicFunction.diff方法的具体用法?Python HolonomicFunction.diff怎么用?Python HolonomicFunction.diff使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sympy.holonomic.HolonomicFunction
的用法示例。
在下文中一共展示了HolonomicFunction.diff方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_HolonomicFunction_addition
# 需要导入模块: from sympy.holonomic import HolonomicFunction [as 别名]
# 或者: from sympy.holonomic.HolonomicFunction import diff [as 别名]
def test_HolonomicFunction_addition():
x = symbols('x')
R, Dx = DifferentialOperators(ZZ.old_poly_ring(x), 'Dx')
p = HolonomicFunction(Dx**2 * x, x)
q = HolonomicFunction((2) * Dx + (x) * Dx**2, x)
assert p == q
p = HolonomicFunction(x * Dx + 1, x)
q = HolonomicFunction(Dx + 1, x)
r = HolonomicFunction((x - 2) + (x**2 - 2) * Dx + (x**2 - x) * Dx**2, x)
assert p + q == r
p = HolonomicFunction(x * Dx + Dx**2 * (x**2 + 2), x)
q = HolonomicFunction(Dx - 3, x)
r = HolonomicFunction((-54 * x**2 - 126 * x - 150) + (-135 * x**3 - 252 * x**2 - 270 * x + 140) * Dx +\
(-27 * x**4 - 24 * x**2 + 14 * x - 150) * Dx**2 + \
(9 * x**4 + 15 * x**3 + 38 * x**2 + 30 * x +40) * Dx**3, x)
assert p + q == r
p = HolonomicFunction(Dx**5 - 1, x)
q = HolonomicFunction(x**3 + Dx, x)
r = HolonomicFunction((-x**18 + 45*x**14 - 525*x**10 + 1575*x**6 - x**3 - 630*x**2) + \
(-x**15 + 30*x**11 - 195*x**7 + 210*x**3 - 1)*Dx + (x**18 - 45*x**14 + 525*x**10 - \
1575*x**6 + x**3 + 630*x**2)*Dx**5 + (x**15 - 30*x**11 + 195*x**7 - 210*x**3 + \
1)*Dx**6, x)
assert p+q == r
p = x**2 + 3*x + 8
q = x**3 - 7*x + 5
p = p*Dx - p.diff()
q = q*Dx - q.diff()
r = HolonomicFunction(p, x) + HolonomicFunction(q, x)
s = HolonomicFunction((6*x**2 + 18*x + 14) + (-4*x**3 - 18*x**2 - 62*x + 10)*Dx +\
(x**4 + 6*x**3 + 31*x**2 - 10*x - 71)*Dx**2, x)
assert r == s
示例2: test_to_Sequence_Initial_Coniditons
# 需要导入模块: from sympy.holonomic import HolonomicFunction [as 别名]
# 或者: from sympy.holonomic.HolonomicFunction import diff [as 别名]
def test_to_Sequence_Initial_Coniditons():
x = symbols('x')
R, Dx = DifferentialOperators(QQ.old_poly_ring(x), 'Dx')
n = symbols('n', integer=True)
_, Sn = RecurrenceOperators(QQ.old_poly_ring(n), 'Sn')
p = HolonomicFunction(Dx - 1, x, 0, [1]).to_sequence()
q = [(HolonomicSequence(-1 + (n + 1)*Sn, 1), 0)]
assert p == q
p = HolonomicFunction(Dx**2 + 1, x, 0, [0, 1]).to_sequence()
q = [(HolonomicSequence(1 + (n**2 + 3*n + 2)*Sn**2, [0, 1]), 0)]
assert p == q
p = HolonomicFunction(Dx**2 + 1 + x**3*Dx, x, 0, [2, 3]).to_sequence()
q = [(HolonomicSequence(n + Sn**2 + (n**2 + 7*n + 12)*Sn**4, [2, 3, -1, -1/2, 1/12]), 1)]
assert p == q
p = HolonomicFunction(x**3*Dx**5 + 1 + Dx, x).to_sequence()
q = [(HolonomicSequence(1 + (n + 1)*Sn + (n**5 - 5*n**3 + 4*n)*Sn**2), 0, 3)]
assert p == q
C_0, C_1, C_2, C_3 = symbols('C_0, C_1, C_2, C_3')
p = expr_to_holonomic(log(1+x**2))
q = [(HolonomicSequence(n**2 + (n**2 + 2*n)*Sn**2, [0, 0, C_2]), 0, 1)]
assert p.to_sequence() == q
p = p.diff()
q = [(HolonomicSequence((n + 2) + (n + 2)*Sn**2, [C_0, 0]), 1, 0)]
assert p.to_sequence() == q
p = expr_to_holonomic(erf(x) + x).to_sequence()
q = [(HolonomicSequence((2*n**2 - 2*n) + (n**3 + 2*n**2 - n - 2)*Sn**2, [0, 1 + 2/sqrt(pi), 0, C_3]), 0, 2)]
assert p == q
示例3: test_diff
# 需要导入模块: from sympy.holonomic import HolonomicFunction [as 别名]
# 或者: from sympy.holonomic.HolonomicFunction import diff [as 别名]
def test_diff():
x, y = symbols('x, y')
R, Dx = DifferentialOperators(ZZ.old_poly_ring(x), 'Dx')
p = HolonomicFunction(x*Dx**2 + 1, x, 0, [0, 1])
assert p.diff().to_expr() == p.to_expr().diff().simplify()
p = HolonomicFunction(Dx**2 - 1, x, 0, [1, 0])
assert p.diff(x, 2).to_expr() == p.to_expr()
p = expr_to_holonomic(Si(x))
assert p.diff().to_expr() == sin(x)/x
assert p.diff(y) == 0
C_0, C_1, C_2, C_3 = symbols('C_0, C_1, C_2, C_3')
q = Si(x)
assert p.diff(x).to_expr() == q.diff()
assert p.diff(x, 2).to_expr().subs(C_0, -S(1)/3) == q.diff(x, 2).simplify()
assert p.diff(x, 3).series().subs({C_3:-S(1)/3, C_0:0}) == q.diff(x, 3).series()