Roots of a function: Difference between revisions

m
(→‎{{header|Lua}}: Fixed case for exact matches)
Line 1,388:
1.000000000016 1e-06
2.000000999934 1e-06</pre>
Note that the roots found are all near misses because fractional numbers that seem nice and 'round' in decimal (such as 10^-6) often have some rounding error when represented in binary. To increase the chances of anfinding exact integer roots, try using an integer start value with a step value that is a power of two.
<lang Lua>print("Root (to 12DP)\tMax. Error\n")
for _, r in pairs(root(f, -1, 3, 2^-10)) do
Anonymous user