Bugs in arithmetic-geometric mean
Closed this issue · 0 comments
mtommila commented
There are several problems with the real and complex agm() functions, at least:
- E.g. complex agm(-1.2, -1.2) does not converge and hangs forever
- Does not check if a = -b (or if a = b)
- For complex values in general, does not choose the "correct" branch of the square root (always chooses the positive square root)
- Real agm unnecessarily rejects arguments that are both negative
- Calculation of the target precision and working precision are buggy
For choosing the "correct" branch of the complex square root, google for "complex arithmetic geometric mean" or see e.g. https://homepage.univie.ac.at/tomack.gilmore/papers/Agm.pdf for an algorithm.