[mpmath] r1242 committed - correct number of coefficients returned by diffs with method='quad' (p...

6 views
Skip to first unread message

mpm...@googlecode.com

unread,
Nov 16, 2011, 4:34:04 PM11/16/11
to mpmath-...@googlegroups.com
Revision: 1242
Author: fredrik.johansson
Date: Wed Nov 16 13:33:02 2011
Log: correct number of coefficients returned by diffs with
method='quad' (patch contributed by Warren Weckesser)
http://code.google.com/p/mpmath/source/detail?r=1242

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

Reply all
Reply to author
Forward
0 new messages