I am writing this post as a way to formally record my solution to a certain problem, and to make some observations on just how does one check if a problem has been solved.

The starting point of this entry is this little challenge posted in the Wolfram Challenges website:

Given four points, write a function

`ParabolasThrough4`

that returns two parabolic expressions whose parabolas pass through the points.

The website gives a hint to use Newton’s original solution. Taking the hint, I thought writing the solution was pretty straightforward and nicely compact:

ParabolasThrough4[pts_] := Module[{d, h, q, r}, {q, r} = {Det[{##, Times[##], 1} & @@@ pts], Det[{##, #2^2, 1} & @@@ pts]}/Det[{##, #^2, 1} & @@@ pts]; h = -q - Sign[q] Sqrt[q^2 - r]; d = {r/h, h}; (#1 x + y)^2 + {1, x, y}.{##2} & @@@ Transpose[Prepend[LinearSolve[PadLeft[pts, {3, 3}, 1], -(Rest[pts].{d, {1, 1}})^2], d]]]

Note the use of a stabilized form of the quadratic formula.

Checking this implementation against randomly generated convex point sets, it seems to fit the bill, both graphically and after evaluating the resulting parabolas at the original four points.

Alas, trying to submit this solution to the Challenges site fails. What gives?

As it turns out, whenever a proposed solution is rejected, the Challenges site tries to give the exact input that caused the proposed solution to fail. However, the site seemed to be testing against machine precision points, which have been (unhelpfully in this case) truncated for display.

But, checking the parabola coefficients that made it to the display of the message reveals that the “accepted solution” and the proposal have their coefficients differ in the last few places, which caused the rejection. One would try to do a manual check, but again, the input points’ display has been truncated.

So, frustrated by an inflexible solution checker, I gave up and decided to move on to other things; nevertheless, one wonders just how to check solutions in the face of inexact arithmetic.