New issue 216 by warren.w...@enthought.com: taylor returns wrong number of
coefficients when method='quad' is used.
http://code.google.com/p/mpmath/issues/detail?id=216
What steps will reproduce the problem?
Here's a ipython session that demonstrates the problem:
In [1]: import mpmath as mp
In [2]: mp.mp.dps = 20
In [3]: mp.taylor(mp.sin, 0, 2)
Out[3]: [mpf('0.0'), mpf('1.0'), mpf('0.0')]
In [4]: mp.taylor(mp.sin, 0, 2, method='quad')
Out[4]: [mpf('0.0'), mpf('1.0')]
In [5]: mp.taylor(mp.sin, 0, 3)
Out[5]: [mpf('0.0'), mpf('1.0'), mpf('0.0'),
mpf('-0.16666666666666666666674')]
In [6]: mp.taylor(mp.sin, 0, 3, method='quad')
Out[6]: [mpf('0.0'), mpf('1.0'), mpf('0.0')]
In [7]: mp.__version__
Out[7]: '0.17'
What is the expected output? What do you see instead?
When the option method='quad' is used, the number of coefficients returned
by taylor is one less than it should be.
What version of the product are you using? On what operating system?
Version 0.17, Mac OSX.
It turns out there is an off-by-one bug in diffs(). When the method is
not 'step', the 'while' statement should be 'while k < n + 1:' (rather
than 'while k < n:').
Patch attached.
Attachments:
issue216patch.diff 1.1 KB
Comment #2 on issue 216 by fredrik....@gmail.com: taylor returns wrong
number of coefficients when method='quad' is used.
http://code.google.com/p/mpmath/issues/detail?id=216
Patched in r1242. Thank you very much!