I want to fit some data using quadratic fit. However, I need to force the curve to go through the origin point, or any other point. How can I solve it mathematically?
2026-03-26 12:41:22.1774528882
On
Forcing Quadratic Fit to Origin or to a Point
294 Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail At
2
There are 2 best solutions below
0
On
Starting from Ahmed S. Attaalla's answer.
If you do not want to use matrix calculations, just consider that what you want to minimize is $$SSQ=\sum_{i=1}^n (a X_i^2+b X_i-Y_i)^2$$ Compute the derivatives with respect to $a$ and $b$ and set them equal to $0$. The equations will then be $$a\sum_{i=1}^n X_i^4+b\sum_{i=1}^n X_i^3=\sum_{i=1}^n X_i^2Y_i$$ $$a\sum_{i=1}^n X_i^3+b\sum_{i=1}^n X_i^2=\sum_{i=1}^n X_iY_i$$
Let $(\bar x, \bar y)$ be the point you want the curve to go through. You have some points $(x_i,y_i)$ where you want each point, in the least squares sense, to satisfy:
$$a(x_i-\bar x)^2+b(x_i-\bar x)+\bar y=y$$
As best as they can. Then your equation is,
$$y=a(x-\bar x)^2+b(x-\bar x)+\bar y$$
To make the linear algebra simpler, let $X=x-\bar x$ and $Y=y-\bar y$. Then:
$$Y=aX^2+bX$$
And the problem turns into a simple least squares problem.
$$\begin{pmatrix} Y_1 \\ Y_2 \\ Y_3 \\...\\Y_n \end{pmatrix}=\begin{pmatrix} X_1^2 && X_1 \\\ X_2^2 && X_2 \\ X_3^2 && X_3 \\ ... && ...\\ X_n^2 && X_n \end{pmatrix}\begin{pmatrix} a \\ b \end{pmatrix}$$
Where now if the system $Ax=b$ is inconsistent, solve $A^{T}Ax=A^{T}b$.