Re: tol, atol and rtol behavior of scipy.sparse.linalg solvers

Robert Kern <[email protected]> Mon, 1 May 2023 20:17:26 -0400
Newsgroups gmane.comp.python.scientific.devel
Message-ID <CAF6FJivdbVFv4WkeCxSD05A+R7viEohB4GuKP9=u_HBgi=M5Gg@mail.gmail.com>
On Mon, May 1, 2023 at 7:22 PM Stefan van der Walt <[email protected]>
wrote:

> On Mon, May 1, 2023, at 11:49, Ilhan Polat wrote:
>
> If atol is actually set to something, then we return max(atol,
> tol*norm(b)). Why max is used I don't understand.
>
> Typically, atol, rtol pair is used as tol = atol + rtol*<some metric>.
> This is more or less what everybody expects from this pair and their naming
> is chosen to reflect this. But I'm a bit lost in all the issues I could
> read.
>
>
> The first formulation — max(atol, rtol*norm(b)) — is what I'd expect.
> I.e., you use atol when answers are small, or rtol for larger answers.  I'm
> a bit surprised to see them summed; is this standard?
>

I concur. `max()` is the appropriate way to combine the two that I'd expect
to see in almost all circumstances. `+` does have a history in our
ecosystem as we do use `+` in `np.isclose()`, though, but I think that is a
bit of a special case of comparing two numbers rather than the size of one
number, and I've never been really convinced by the arguments for it.
`math.isclose()` works like `max()` (though it is implemented with explicit
`||` operations).

Julia's iterative solvers use `max()`.


https://github.com/JuliaLinearAlgebra/IterativeSolvers.jl/blob/master/src/cg.jl#L141

MATLAB's numerical integration routines use `max()`.

  https://www.mathworks.com/help/matlab/ref/integral.html#btc_m8o-4

-- 
Robert Kern

_______________________________________________
SciPy-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/scipy-dev.python.org/
Member address: [email protected]