​
Least Squares Method

We want to find a parabola with a vertical axis that passes through the origin and is closest to the given data points in the least squares sense . The equation of a parabola with a vertical axis can be written as follows :
ya
2
x
+bx+c
Given that the parabola passes through the origin, we have :
0a
2
(0)
+b(0)+c
Which simplifies to :
c0
Now, our equation becomes :
ya
2
x
+bx
We are given three points :
(-1,3)
,
(1,1)
, and
(2,5)
.
Substituting these into the equation, we have three linear equations :
For
(-1,3)
:
3a
2
(-1)
+b(-1)
For
(1,1)
:
1a
2
(1)
+b(1)
For
(2,5)
:
5a
2
(2)
+b(2)
To minimize the least squares error, we can set up a matrix equation
Axb
, where
A
is the matrix of independent variables,
x
is the vector of coefficients, and
b
is the matrix of the dependent variable .
Let
A
1
-1
1
1
4
2
, x
a
b
, andb
3
1
5
.
The matrix equation becomes :

1
-1
1
1
4
2

a
b

3
1
5


You can solve this system of equations using Wolfram Mathematica’s LinearSolve function.

In[]:=
(*Definethematrixofindependentvariablesandthevectorofdependentvariables*)A={{1,-1},{1,1},{4,2}};​​b={3,1,5};​​​​(*UsetheLinearSolvefunctiontosolvethesystemofequations*)​​x=LinearSolve[Transpose[A].A,Transpose[A].b]​​​​(*Theresultisalistofcoefficients[a,b]*)​​
Out[]=

20
11
,-
12
11


Solving the problem using alternative Fredholm theorem

The alternative Fredholm theorem states that a linear system
Axb
has a solution if and only if
b
is orthogonal to the null space of
T
A
. In other words, if
T
A
b0
, then there is a solution to the system . Let' s check this condition :
T
A

1
1
4
-1
1
2

T
A
b
1
1
4
-1
1
2

3
1
5

24
8
≠0
Since
T
A
b≠0
,thesystem
Axb
doesnothaveasolution.However,wecanfindthebestapproximatesolution(theleastsquaressolution)usingthenormalequations:
T
A
A
1
1
4
-1
1
2

1
-1
1
1
4
2

18
8
8
6
Now we solve the normal equation
T
A
Ax
T
A
b
:
18
8
8
6

a
b

24
8

Thus, we get a system of the form :
18a+8b24​​8a+6b8
Now, solving the above system by the method of substitution, we find that
a
20
11
and
b-
12
11
and the equation of the parabola is :
y
20
11
2
x
-
12
11

Here is how you can solve this using Mathematica:

In[]:=
(*Definethematrixofindependentvariablesandthevectorofdependentvariables*)A={{1,-1},{1,1},{4,2}};​​b={3,1,5};​​​​(*Computethenormalequations*)​​normalA=Transpose[A].A;​​normalb=Transpose[A].b;​​​​(*Solvethenormalequations*)​​solution=LinearSolve[normalA,normalb]​​​​(*Theresultisalistofcoefficients[a,b]*)​​
Out[]=

20
11
,-
12
11
