jonathf / numpoly

Numpy compatible polynomial representation
https://numpoly.readthedocs.io
BSD 2-Clause "Simplified" License
12 stars 5 forks source link

Make truncation formula less sensitive to rounding #81

Closed jonathf closed 3 years ago

jonathf commented 3 years ago

The multivariate generalization of truncation formula |x|_p <= b is done as: (sum((x/b)^p))^(1/p) <= 1 to allow for non-scalar b. However, for intuitive setups like b=9, p=1, x=[5,1,1,1,1] will evaluate as False because of rounding errors.

To fix this, we add a nudge factor to the bound: (sum((x/b)^p))^(1/p) <= 1+nudge Small enough that the user will never notice, but big enough to catch all rounding errors. As this problem is likely to scale with the dimensionality, the nudge factor should scale the same way.

Solves #80.