Celeb Glow
general | April 05, 2026

Find best-fit parabola to the given data

$\begingroup$

Find the parabola $At^2+Bt+C$ that best approximates the data set $t= -1,0,1,2,3$ and $b(t) = 5,2,1,2,5$.

Would I be using least squares such that $x = (A^TA)^{-1}A^Tb$? Thank you in advance.

$\endgroup$ 3

5 Answers

$\begingroup$

The normal equations will solve the general case. In your specific case, the values of $b(t)$ are symmetric around $t=1$, so the parabola must be $A(t-1)^2+(C-1)$. Using the point at $t=1$ we can see that $C=2$, then a quick check shows $A=1$ and we have $b(t)=(t-1)^2+1$, which fits the points perfectly.

$\endgroup$ $\begingroup$

Elaborating on what @callculus said we can do

enter image description here

Which in your case looks like this

enter image description here

then just solve for A, B, and C.

You can check you answer by looking at your final equation.

$\endgroup$ 1 $\begingroup$

Hint: In your case

$A=\begin{pmatrix}{} n&\sum_{i=1}^5 t_i & \sum_{i=1}^5 t_i^2 \\ \sum_{i=1}^5 t_i & \sum_{i=1}^5 t_i^2 & \sum_{i=1}^5 t_i^3 \\ \sum_{i=1}^5 t_i^2 & \sum_{i=1}^5 t_i^3 & \sum_{i=1}^5 t_i^4\end{pmatrix}=\begin{pmatrix}{} 5 & 5 & 15 \\ 5 & 15 & 35 \\ 15 & 35 & 99 \end{pmatrix}$

$\endgroup$ $\begingroup$

Problem statement

Given a sequence of $m=5$ data points $\left\{ x_{k}, y_{k} \right\}_{k=1}^{m}$, and the trial function $$ y(x) = a_{0} + a_{1} x + a_{2} x^{2}. $$ The linear system is $$ \begin{align} \mathbf{A} a &= y\\ % \left[ \begin{array}{rrr} 1 & -1 & 1 \\ 1 & 0 & 0 \\ 1 & 1 & 1 \\ 1 & 2 & 4 \\ 1 & 3 & 9 \\ \end{array} \right] % \left[ \begin{array}{rrr} a_{0} \\ a_{1} \\ a_{2} \end{array} \right] % & = % \left[ \begin{array}{rrr} 5 \\ 2 \\ 1 \\ 2 \\ 5 \end{array} \right] % \end{align} $$

Solution via normal equations

The normal equations are $$ \begin{align} \mathbf{A}^{*} \mathbf{A} a & = \mathbf{A}^{*} y \\ % \left[ \begin{array}{rrr} 5 & 5 & 15 \\ 5 & 15 & 35 \\ 15 & 35 & 99 \\ \end{array} \right] % \left[ \begin{array}{rrr} a_{0} \\ a_{1} \\ a_{2} \end{array} \right] % &= % \left[ \begin{array}{rrr} 15 \\ 15 \\ 59 \end{array} \right] % \end{align} $$ The solution is $$ \begin{align} a_{LS} & = \left( \mathbf{A}^{*} \mathbf{A} \right)^{-1} \mathbf{A}^{*} y \\ % &= \frac{1}{70} \left[ \begin{array}{rrr} 26 & 3 & -5 \\ 3 & 27 & -10 \\ -5 & -10 & 5 \\ \end{array} \right] % \left[ \begin{array}{rrr} 15 \\ 15 \\ 59 \end{array} \right] \\ % &= % \left[ \begin{array}{rrr} 2 \\ -2 \\ 1 \end{array} \right], % \end{align} $$ $$ y(x) = 2 -2x + x^{2}. $$ This is an exact fit because $$ r^{2} = \left( \mathbf{A} a_{LS} - b \right)^{*} \left( \mathbf{A} a_{LS} - b \right) = 0. $$

The plot shows the solution against the data points.

Data and solution

$\endgroup$ $\begingroup$

I would like to show here how to solve the generalized problem of parabolic data fitting explicitly without specialized matrix math terminology; and so that each multiplication, division, subtraction and addition can be seen at once. This is written in the language of the free program "PARI" but all the commands are simple to translate to any language.

Step 1: assign a label to the y-axis data:

? V=[5,2,1,2,5]

"PARI" confirms that entry:

%280 = [5, 2, 1, 2, 5]

Then type in the following processing algorithm which calculates a best fit parabola through any y-axis data set with constant x-axis separation:

? g=#V;h=(g-1)g(g+1)/3;i=h*(3gg-7)/5;
a=sum(i=1,g,V[i]);b=sum(i=1,g,(2i-1-g)V[i]);c=sum(i=1,g,(2i-1-g)(2i-1-g)V[i]);
A=matdet([a,c;h,i])/matdet([g,h;h,i]);B=b/h
2;C=matdet([g,h;a,c])/matdet([g,h;h,i])4;
xextreme=-B/(2
C);yextreme=-B
B/(4*C)+A;fit=Polrev([A,B,C]);
print("\n","y of extreme is ",yextreme,"\n","which occurs this many data points from center of data: ",xextreme)

Those commands then produce the following screen output:

y of extreme is 1 which occurs this many data points from center of data: 0

The algorithm stores the polynomial of the fit in the variable "fit":

? fit %282 = x^2 + 1 ?

(Note that to make that algorithm short the x-axis labels are assigned as X=[-(N-1)/2..(N-1)/2], thus they are X=[-2,-1,0,1,2] To correct that for the same polynomial as parameterized by an x-axis coordinate data set of say X=[−1,0,1,2,3]: just apply a simple linear transform, in this case: "x^2 + 1" --> "(t - 1)^2 + 1".)

$\endgroup$

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy