Modified:
/trunk/mpmath/calculus/differentiation.py
/trunk/mpmath/tests/test_diff.py
=======================================
--- /trunk/mpmath/calculus/differentiation.py Sun Jan 9 09:47:36 2011
+++ /trunk/mpmath/calculus/differentiation.py Wed Nov 16 13:33:02 2011
@@ -264,7 +264,7 @@
n = int(n)
if options.get('method', 'step') != 'step':
k = 0
- while k < n:
+ while k < n + 1:
yield ctx.diff(f, x, k, **options)
k += 1
return
=======================================
--- /trunk/mpmath/tests/test_diff.py Wed Jul 28 13:09:06 2010
+++ /trunk/mpmath/tests/test_diff.py Wed Nov 16 13:33:02 2011
@@ -16,6 +16,13 @@
assert diffun(sin)(2).ae(cos(2))
assert diffun(sin, n=2)(2).ae(-sin(2))
+def test_diffs():
+ mp.dps = 15
+ assert [chop(d) for d in diffs(sin, 0, 1)] == [0, 1]
+ assert [chop(d) for d in diffs(sin, 0, 1, method='quad')] == [0, 1]
+ assert [chop(d) for d in diffs(sin, 0, 2)] == [0, 1, 0]
+ assert [chop(d) for d in diffs(sin, 0, 2, method='quad')] == [0, 1, 0]
+
def test_taylor():
mp.dps = 15
# Easy to test since the coefficients are exact in floating-point