Finding quadratic function from two points and known max value - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: Not HP Calculators (/forum-7.html) +--- Forum: Not remotely HP Calculators (/forum-9.html) +--- Thread: Finding quadratic function from two points and known max value (/thread-8945.html) Finding quadratic function from two points and known max value - Dave Britten - 08-31-2017 12:57 PM I need to work this into a C# program for generating points along an arc, and the math is making me cross-eyed. Essentially, I know two points on the parabola, I know the y value of the maximum (but not x), and I know that the second derivative is negative, i.e. the coefficient of x^2 is negative. All the typical approaches of treating it as a system of 3 linear equations seem to rely on having three known points, but I've got two, plus an additional equation 2*a*x_3+b=0 where x_3 is unknown. Is there a straight-forward way of tackling this without pulling a bunch of numeric and matrix libraries into the program? RE: Finding quadratic function from two points and known max value - grsbanks - 08-31-2017 01:03 PM Short answer: nope. Just like a linear function can be defined with 2 points, a quadratic function needs 3 points to be defined. The best you can get is a family of functions that pass through the two points you know and have the known maximum. In the more general case, a polynomial of order n (ax^n+bx^(n-1)+cx^(n-2)...) requires n+1 points and you end up solving a system of n+1 simultaneous equations to get your coefficients. RE: Finding quadratic function from two points and known max value - Dave Britten - 08-31-2017 01:09 PM Well, I've got two points, plus a known maximum value. Intuitively, I think that uniquely defines a parabola, though I could be wrong. RE: Finding quadratic function from two points and known max value - Nigel (UK) - 08-31-2017 02:46 PM I think that there are two possible solutions, but I could be wrong too! Let the maximum y-value be $$c$$ and let this occur at $$x=b$$, where $$b$$ is as yet unknown. Then the parabola's equation can be written as $$y=c-a(x-b)^2,$$ where $$a$$ is another unknown. We know two points $$(x_1, y_1)$$ and $$(x_2, y_2)$$ on the curve. Substituting these into the equation above gives \eqalign{y_1=c-a(x_1-b)^2\cr y_2=c-a(x_2-b)^2\cr}. Rearranging gives $${x_1-b\over x_2-b}=\pm\sqrt{c-y_1\over c-y_2}.$$ The value of $$b$$ is between $$x_1$$ and $$x_2$$ if the right-hand side is negative and outside this range otherwise; this is where the ambiguity comes in. Since $$c$$, $$y_1$$, and $$y_2$$ are known the right hand side can be computed and a sign chosen; this means that $$b$$ can be found, and then either of the previous equations can be used to give $$a$$. Is this what you are looking for? Nigel (UK) RE: Finding quadratic function from two points and known max value - Dave Britten - 08-31-2017 05:02 PM Oh yes, I see what you mean. In the cases I'm dealing with, the x value of the vertex will always lie between the two known points, so that narrows it down to a single possible function. RE: Finding quadratic function from two points and known max value - Dave Britten - 08-31-2017 05:31 PM Yup, right on the money. Just find b with "b = (x2 * sqrt((c - y1)/(c - y2)) + x1) / (sqrt((c - y1)/(c - y2)) + 1)", then find a with "a = (c - y1)/(x1 - b)^2". Then you've got your a, b, and c for the vertex form, and you can calculate y values. Thanks Nigel.