scipy/scipy — pull request #2909 by gertingold (2013-09-21 20:28:47+00:00)
Title: increase precision of hyperu

In gh-2287 it was pointed out that the precision of `hyperu` can be as low as 6 significant digits. The reason is that the code defines 6 significant digits as sufficient for a valid result. In this pull request, I propose to increase the precision to 9 significant digits which means that iterations are run a bit more often than before. The final check for valid results can stay at 6 significant digits.

For the example from gh-2287 one obtains:
```
hyperu(1, 1.5, 20.2)
old code: 0.048360865288403269
new code: 0.04836091865669917
mpmath: 0.048360918656699191
```
which is a significant improvement without changing the basic algorithm.

An interesting effect happens for a set of parameters taken from `test_mpmath.py`:
```
hyperu(-0.1, 1, 10)
old code: 1.2577123535311705
new code: 1.2577123420521401
mpmath: 1.2577123420521652
```
In the old code the result from `CHGUL` was accepted as sufficiently accurate. In the new code, this is no longer the case and finally the better result coming from `CHGUBI` is used. Strangely enough, the estimate of accuracy is `ID=-3` (which is not caused by the changes proposed here) and does not reflect at all the 14 significant digits. As a consequence, an accuracy warning is now generated by the code, although the result is much better than with the old code. To remedy the situation, one probably would need to improve the error estimation in ``CHGUBI`` which is, however, not intended in this pull request.

A side remark: Many parameter sets which lead to errors in ``test_mpmath.py`` are actually cases where the result is complex. However, ``CHGU`` is not designed to treat such cases. A typical situation are negative non-integer values for `a` and negative values for `x`. I wonder whether one should aim for an improved code or rather document the restrictions on the parameters and possibly restrict the tests to the valid parameter sets. The latter might be useful to identify the cases where problems exist with the present code.