Accurate Curve Fitting - A Proposed New Problem

Back to General discussions forum

CSFPython     2026-03-03 09:01:49

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.

Rodion (admin)     2026-03-03 10:48:29
User avatar

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.

gardengnome     2026-03-14 16:49:52
User avatar

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).

CSFPython     2026-03-14 20:20:24

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.

Please login and solve 5 problems to be able to post at forum