4 ms·
Why do you consider that naive? Also, I wouldn't use epsilon, because that is a very small number and is related to representation of numbers. I would instead
by gotaquestion 5y ago
Why do you consider that naive?
Also, I wouldn't use epsilon, because that is a very small number and is related to representation of numbers. I would instead use a larger "tolerance" value, in `if |a-b| < tol ...` because that indicates the expected accuracy of your algorithm (unless you're really working with 1e-80 tolerance?). But TFA explains that.
But back to point (a) is that not reasonable? (If not, I've got some code to change... :)
- PennRobotics 5y agoNaive because it's just the easiest way. (Also, right, I forgot abs.) I imagine the downside with a chosen "epsilon" (which I used as an alias for any tolerance) is that it can be truncated on some machines, plus this equation on its own doesn't do relative accuracy. On an LEGO EV3, Python's float is 1e38 max with 7 significant digits. I've never run into problems, which is why I keep using it, too.