possible bug in test_exp_pade and a fix

5 views
Skip to first unread message

Ondřej Čertík

unread,
Oct 10, 2011, 7:18:17 PM10/10/11
to mpm...@googlegroups.com
Hi Fredrik,

In this pull request:

https://github.com/sympy/sympy/pull/635

we have found a possible bug in mpmath, that Mario fixed with this patch:

https://github.com/pernici/sympy/commit/5745821120f01ff4638b5d87472649c307648800

Just see the pull request for background information. Do you think
that this patch should
be applied to mpmath upstream? It seems to fix the problem.

Ondrej

Fredrik Johansson

unread,
Oct 10, 2011, 10:04:51 PM10/10/11
to mpm...@googlegroups.com
2011/10/11 Ondřej Čertík <ondrej...@gmail.com>:

Yes, it probably should.

Mario, can you commit this to the mpmath svn repository?

Fredrik

mario

unread,
Oct 30, 2011, 8:07:58 AM10/30/11
to mpmath
Hi Fredrik,
I committed the same fix to mpmath which I put in sympy, but it does
not work.
I wanted to increase the precision in computing exp_pade; to do this I
wrote in calculus.py

```
if method == 'pade':
prec = ctx.prec
ctx.prec += 2*A.rows
A = ctx.matrix(A)
res = ctx._exp_pade(A)
```

and it works in sympy, but not in mpmath.
In fact putting e.g. `ctx.prec += 2*A.rows + 10` in mpmath nothing
changes, putting it in sympy it increases the
precision of norm(d,inf) in the test by 3 digits.
If in mpmath in the test I increase `mp.dps` by `3` before calling
`expm(a1, method='pade')` the precision of norm(d,inf) in the test
increases by 3 digits.
What am I doing wrong?

Mario

Fredrik Johansson

unread,
Oct 30, 2011, 8:23:01 AM10/30/11
to mpm...@googlegroups.com
Hi Mario,

On Sun, Oct 30, 2011 at 1:07 PM, mario <mario....@gmail.com> wrote:
> Hi Fredrik,
> I committed the same fix to mpmath which I  put in sympy, but it does
> not work.

Thanks!

> I wanted to increase the precision in computing exp_pade; to do this I
> wrote in calculus.py
>
> ```
>        if method == 'pade':
>            prec = ctx.prec
>            ctx.prec += 2*A.rows
>            A = ctx.matrix(A)
>            res = ctx._exp_pade(A)
> ```
>
> and it works in sympy, but not in mpmath.
> In fact  putting e.g. `ctx.prec += 2*A.rows + 10`  in mpmath nothing
> changes, putting it in sympy it increases the
> precision of norm(d,inf) in the test by 3 digits.
> If in mpmath in the test I increase `mp.dps` by `3` before calling
> `expm(a1, method='pade')` the precision of norm(d,inf) in the test
> increases by 3 digits.
> What am I doing wrong?

I don't know. I tried adding " + 10" as above and it decreased
norm(d,inf) in the test. All tests currently pass for me.

Fredrik

Reply all
Reply to author
Forward
0 new messages