![]() |
Equation of the parabola given three points - Printable Version +- HP Forums (https://archived.hpcalc.org/museumforum) +-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html) +--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html) +--- Thread: Equation of the parabola given three points (/thread-250405.html) |
Equation of the parabola given three points - Gerson W. Barbosa - 09-15-2013 That's essentially what was requested in the first part of a problem my daughter asked me some explanation about the other day. Incidentally I had worked on a similar problem involving four points that morning and had used my HP-50g to solve the corresponding system of linear equations. But calculators are not allowed in her class, so I had to find another method. Her teacher's solution used Gauss elimination which doesn't involve many calculations in a 3x3 system, but a mistake done in the beginning leads to completely wrong answers (like mine, when doing it by hand that way). I don't like this kind of problem being posed to students, I mean problems involving number crunching when a calculator is not available. On the other hand, according to her math textbook, this problem had been asked on the admittance exam of an important university here (UNICAMP), so her teacher is not wrong by occasionally asking a bit of hand calculations from his students. However, I decided to find a faster method, perhaps an easier-to-remember formula, considering the time per question is usually short during this kind of exams. Here is my approach:
Given three points P1 = (x1, y2)For instance, using the data points from the textbook, P1 = (1, 2)find the equation of the corresponding parabola, y = ax2 + bx + cThe solution consists basically in solving a system of linear equations: y1 = ax12 + bx1 + cOr, in matrix form, / \ / \ / \Rather than solving it numerically, it should be better to solve it symbolically. Thus the resulting formula may be used again to solve similar problems, avoiding unnecessary and heavy matrix calculations. The determinant of the square matrix above, a Vandermonde Matrix, is very easy to compute, requiring only three subtractions and three multiplications. Also not difficult to calculate are the other matrices associated to the Cramer's Rule for this system. So, that method appears to be more adequate to be used here:
or, more mnemonically,
y1 y2 y3Now, solving for the original numerical example: x1 = 1 y1 = 2 Here is a QBASIC program that handles the cases from n = 2 through 4, that is, linear, quadratic, cubic and biquadratic equations, where n is the number of data points:
DEFDBL A-H, O-Z: DEFINT I-N
Re: Equation of the parabola given three points - Paul Dale - 09-15-2013 Interesting approach. My initial thought was to use Lagrane interpolation and simplify. The formulas in that link look complicated but are simple in use.
Re: Equation of the parabola given three points - Gerson W. Barbosa - 09-15-2013 Yes, I read about Lagrange interpolation later, when I was almost done and was not able to generalize for higher orders. The algorithm as currently implemented returns only the first two and the last two coefficients of the polynomial correctly. I did the order 3 calculations above by hand and used its model to guess order 4. I didn't try to go up to the next order. My formula to a term looks like
In the first example above I used about 12 multiplications, 12 additions and subtractions and 3 divisions (considering the ones that have been reused and not considering the operations needed to calculate the indexes), which is somewhat comparable to the 6 divisions, 6 multiplications, 12 subtractions and 2 additions used in examples 2 and 3 of the Lagrange interpolation link above. But for higher order polynomials (4 and above) the Lagrange interpolation method should outperform this approach significantly (if it can be expanded to higher orders).
Gerson. Edited: 15 Sept 2013, 8:59 p.m.
Re: Equation of the parabola given three points - Paul Dale - 09-15-2013 Lagrange interpolation works for any order and gives the minimum degree polynomial that goes through the specified points.
Re: Equation of the parabola given three points - Gerson W. Barbosa - 09-15-2013 Are there native (or non-native) calculator implementations? Thanks!
Gerson.
Re: Equation of the parabola given three points - Paul Dale - 09-15-2013 Yes, although this program doesn't output the polynomial. Instead, it evaluates it for a specific argument. - Pauli
Edited: 15 Sept 2013, 9:19 p.m.
Re: Equation of the parabola given three points - Thomas Klemm - 09-15-2013 Since these are elements of a sequence you can as well just calculate differences and use binomial coefficents to reconstruct it: 2 0.7 -0.2Here we take into account that we start the sequence with 1 (thus n-1): p(n) = 2*C(n-1, 0) + 0.7*C(n-1, 1) - 0.2*C(n-1, 2)
Cheers
PS: I'm leaving the other example as an exercise.
Re: Equation of the parabola given three points - Thomas Klemm - 09-15-2013 Here we go: 5 36 50 6
Cheers Re: Equation of the parabola given three points - Eddie W. Shore - 09-15-2013 Quote:
Interesting. I have tried it for example 2. This is an easier approach for sequential data.
Re: Equation of the parabola given three points - Gerson W. Barbosa - 09-15-2013 Thanks! I'll try to remember this if I ever take an admittance examination again :-)
5 36 50 6 Cheers, Gerson.
P.S. Looks like I would've failed by taking to long... Edited: 15 Sept 2013, 10:16 p.m.
Re: Equation of the parabola given three points - Gerson W. Barbosa - 09-15-2013 Quote: Also by having used the 50g to compute C(n-1,k) and submitting the second line to W|A :-) Re: Equation of the parabola given three points - Thomas Klemm - 09-15-2013 Quote:But then they are allowed to use WolframAlpha during the exams? That reminds me of my godchild which was allowed to use her mobile during an exam because she "forgot" her calculator. I received an SMS while in the shower that morning: "was gibt (x-y) hoch 4?". I delivered the answer with a smile ...
Cheers Re: Equation of the parabola given three points - John Ioannidis - 09-15-2013 Why are you complicating this more than you should? In such exams, what matters is getting it right from first principles.
@1: a*1*1 + b*1 + c = 2.0, => a + b + c = 2.0 (1)Where in this do you need a calculator?
Re: Equation of the parabola given three points - Gerson W. Barbosa - 09-15-2013 Quote: No calculators, no cell phones, no digital watches, no table pencils or anything that could be used as a calculation aide is allowed during admittance exams. Problems are usually written in such a way these are not necessary. Perhaps that was the intention of the examiners in example number one. Applicants not aware of the method your method would be in disadvantage trying to solve the problem using Gauss elimination, for instance. Cheers,
Gerson.
Re: Equation of the parabola given three points - Thomas Klemm - 09-16-2013 Quote: Mathematically my solution is simpler as only a matrix multiplication is involved. The coefficients of this matrix are constant given that we always start with the same x. Or then they can be calculated easily by recursion (Horner scheme). Your solution still needs the inversion of an upper triangular matrix. Of course the inverse of this matrix could be calculated beforehand as well. But who wants to learn that by heart? Binominal coefficients on the other hand are fairly easy to remember. I sugest to calculate the 2nd example with your method as well and compare both. What happens when we don't start the sequence with x=1 but with x=7?
Quote: I didn't.
Cheers Re: Equation of the parabola given three points - Gerson W. Barbosa - 09-16-2013 Quote: I think that question had been addressed to me, since it's I who mentioned calculators not being allowed in class in the first place (I've noticed some replies posted in the wrong place in the thread lately) and the example John solved using the substitution method was #1, not #2. If such is the case, I've actually complained about the teacher using Gauss elimination, which I think it's excellent for automated solutions but not for hand calculations. By the way, I'd seen this teacher's explanation and liked it. I liked her use of the whiteboard as well, but I'd love to see her solution for a cubic using the same method. I guess she'd run out of board space soon :-)
Gerson.
Re: Equation of the parabola given three points - John Ioannidis - 09-16-2013 In an exam you don't solve the general problem. If you don't understand this, there's nothing I can say that will convince you.
Re: Equation of the parabola given three points - Thomas Klemm - 09-16-2013 How is Gauss elimination different from the substitution method? | 1 1 1 | | c | | 2 | What you have noted is that Cramer's rule appears to be more adequate to be used here. I just tried to point out that the reason for this is that we have a sequence. And this is something we can take advantage of to solve the problem.
In fact we can just write down the inverse of the last matrix from above. The columns correspond to the binomial coefficients: | 1 -1 1 | | 2 | | c | As a teacher I wouldn't start with this peculiar solution. Instead I'd let the students explore what happens with sequences when calculating differences between elements. And then again and again. What happens with quadratic or cubic progression? What's happening in Pascal's triangle? And then ask them how we could take advantage of that. Hopefully that would lead to the solution. And it might as well prepare them for what's happening later in calculus.
Cheers Re: Equation of the parabola given three points - Thomas Klemm - 09-16-2013 It's funny, because my solution doesn't solve the general problem. Especially in an exam it can be an advantage to know different ways to solve a problem.
Re: Equation of the parabola given three points - Bunuel66 - 09-16-2013 There is an intermediate approach taking benefit of the coefficient of 'c' which is always 1 in all the equations. By experience, the Pivot of Gauss or the general inversion method based on the transposition of the cofactors matrix can be very confusing and error prone for students. If I had to teach that problem I would show how to reduce it to a 2x2 matrix formulation for 'a' and 'b' and then getting the third data: 'c'.
My two cents....
Re: Equation of the parabola given three points - Gerson W. Barbosa - 09-16-2013 On the HP-49G, 49g+ and 50g all these years:
[[1 2 3 4][5 41 127 269]]
Gerson.
Re: Equation of the parabola given three points - Gjermund Skailand - 09-17-2013
Re: Equation of the parabola given three points - deachp - 09-18-2013 « Edited: 18 Sept 2013, 12:22 a.m.
Re: Equation of the parabola given three points - Gerson W. Barbosa - 09-18-2013 Since we're using a 50g (or a 49G,49G+), we could also try «
Just for comparison, « We should expect drastic running time differences as orders get higher. Time x n plots for both programs might be interesting. Best regards, Gerson.
Edited: 18 Sept 2013, 2:03 a.m.
Re: Equation of the parabola given three points - Gerson W. Barbosa - 09-18-2013 The point is this solution takes up more time and memory. Instead of n2 + 2, Lagrange interpolation requires only 2n matrix elements.
LGPI:Gerson. Re: Equation of the parabola given three points - Csaba Tizedes (Hungary) - 09-18-2013 My first idea was my quadratic-fit program without linear algebra: It's maybe interesting not useful :D
:)
Re: Equation of the parabola given three points - Csaba Tizedes (Hungary) - 09-18-2013 ... but with this program you will get the right answer... :)
y = -0.1000 * x^2 + 1.0000 * x + 1.1000 Re: Equation of the parabola given three points - Gerson W. Barbosa - 09-18-2013 Quote:Useful, albeit not for my purpose, but surely interesting!
Quote:Very nice! Congratulations! I too like to use Sigma+ (and Sigma-) when I can :-) Cheers,
Gerson.
|