Back to General discussions forum
This is an exercise in representing a curve by a given number of straight line segments, such that the area between the curve and the straight line segments is minimised.
Dear Clive, thanks a lot for this problem of somewhat new kind! Image you provided is quite helpful.
I'm a bit unsure if there should or should not be minor issues with fractional answer (e.g. rounding / trailing zero trimming) if there'll be may be any inconvenience, please report and we'll make small amend to enable floating point number comparison in this problem.
Given the issues I had with floating point precision, I would be interested to know whether the expected answers are provably the best answers. I only got this to work once I switched to numpy (otherwise exactly the same algorithm).
Mathias,
My program is in normal Python with no use of any libraries. When setting the problem I made sure that my answers were between 100 and 1000 times more accurate than the precision that I asked for in the problem. I am very confident of the accuracy of the values used by the checker.