Issue 216 in mpmath: taylor returns wrong number of coefficients when method='quad' is used.

1 view
Skip to first unread message

mpm...@googlecode.com

unread,
Nov 16, 2011, 12:27:14 AM11/16/11
to mpmath...@googlegroups.com
Status: New
Owner: ----

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.


mpm...@googlecode.com

unread,
Nov 16, 2011, 1:37:37 AM11/16/11
to mpmath...@googlegroups.com

Comment #1 on 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

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

mpm...@googlecode.com

unread,
Nov 16, 2011, 4:34:05 PM11/16/11
to mpmath...@googlegroups.com
Updates:
Status: Fixed

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!

Reply all
Reply to author
Forward
0 new messages