bos/statistics — Issue #14: Comparison to zero in ridders
Author: Shimuuar
Created: 2011-10-19 06:39:53+00:00
State: open

There are still several issues with ridder. First documentation doesn't say whether error tolerance is absolute or relative. Line 89 suggest that it's absolute error but in the definition of ~= it's treated as relative error.

Lines 83 and 84 are especially troublesome. AFAIU it's meant to be approximate comparison to zero. But in my experience it's ill defined unless scale of the problem is known. For different problems 1 could be very big number or approximately zero. Here is illustration:

x ~= 0 ≡ abs (x - 0) <= abs (tol * x) ≡ abs x <= abs (tol * x)

If tol < 1 it just a comparison to zero. But since tol is absolute error it could be greater than 1 in which case condition always evaluates to True:

> ridders 1.1 (15e3,16e3) (cos . (* 0.0001))
Root 15000.0
> ridders 0.9 (15e3,16e3) (cos . (* 0.0001))
Root 15707.584948424925