Ad
  • Custom User Avatar

    Thanks for your feedback! I thought my idea was a bit more innovative. So, I think I will unpublish this kata.

  • Custom User Avatar

    The kata and the description is just a thinly disguised polynomial root finder, which has been done since a long time ago: e.g this

  • Custom User Avatar

    IMPORTANT: We are looking for truncated roots, as they will be irrational.

    Rounding/truncating a root makes no sense, as it hits all kinds of floating point errors while also disregarding which value is closer to the real value. What if two nearest values around a root quantized by the same decimal places have the same absolute different between 0? (say, bolzanos_theorem('4*(x+0.5)**2', [-1, 2], 0), which has f(0) = 1 and f(1) = 1)? What if f(0) = 100000 but f(1) = 0.000001?

    What if the root is exactly one of the quantized values (such as f(0) = 0)? Then the value will either be a strict underestimate or overestimate (or (semi-)randomly) based on how the root is searched, and being at the truncation boundary means sometimes the code will just gives you the wrong result because it didn't find the exact value, and truncated -0.0000000000001 down to -1.

    tl;dr Please use proper floating point testing and just use test.assert_approx_equals for this.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution