本文整理匯總了Python中polynomial.Polynomial.differentiate方法的典型用法代碼示例。如果您正苦於以下問題:Python Polynomial.differentiate方法的具體用法?Python Polynomial.differentiate怎麽用?Python Polynomial.differentiate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類polynomial.Polynomial
的用法示例。
在下文中一共展示了Polynomial.differentiate方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_simple_operations
# 需要導入模塊: from polynomial import Polynomial [as 別名]
# 或者: from polynomial.Polynomial import differentiate [as 別名]
def test_simple_operations(self):
"""tests with some specific polynomials"""
p1 = Polynomial([2.,0,3.,0]) # 2 + 3x^2
self.assertEqual(str(p1), '2.0 + 3.0X^2')
self.assertEqual(repr(p1), 'Polynomial([2.0, 0.0, 3.0])')
p2 = Polynomial([3.,2.]) #3 + 2x
self.assertEqual(str(p2), '3.0 + 2.0X')
self.assertEqual(p1.degree(), 2)
self.assertEqual(p1[4], 0, "Index out of range should return zero")
self.assertEqual(p1[0], 2)
self.assertEqual(p1+p2, Polynomial([5,2,3]))
self.assertEqual(p1.differentiate(), Polynomial([0,6]))
self.assertEqual(p1(2), 14)
self.assertEqual(p1*p2, Polynomial([6., 4., 9., 6.]))