- #1

fluidistic

Gold Member

- 3,649

- 99

## Homework Statement

I must find the best fitting function of the form ax²+bx+c using least squares.

The points are (-1,6.1), (0,2.8), (1,2.2), (3,6) and (6,26.9).

**2. Homework Equations + attempt at a solution**

[tex]A\vec x= \vec b[/tex], I'm looking for [tex]\vec x =\begin {pmatrix} a \\ b \\ c \end {pmatrix}[/tex]. I know that [tex]\vec b = \begin {pmatrix} 6.1 \\ 2.8 \\ 2.2 \\ 6 \\ 26.9 \end {pmatrix}[/tex].

With the use of some theory, the system I want to solve is equivalent to [tex]A^{T}A \vec x = A^{T} \vec b[/tex].

My matrix A is [tex]\begin {bmatrix} 1 & -1 & 1 \\ 0 & 0 & 1 \\ 1 & 1 & 1 \\ 9 & 3 & 1 \\ 36 & 6 & 1 \end {bmatrix}[/tex].

[tex]A^{T}A=\begin {bmatrix} 1379 & 243 & 47 \\ 243 & 47 & 9 \\ 47 & 9 & 5 \end {bmatrix}[/tex].

And [tex]A^{T}\vec b = \begin {bmatrix} 1030.7 \\ 175.5 \\ 44 \end {bmatrix}[/tex].

This gave me [tex]\vec x = \begin {bmatrix} 2.669598408 \\ -9.505782817 \\ 0.6247662773 \end {bmatrix}[/tex]. Thus [tex]f(x) \approx 2.67 x^2-9.51 x +0.62[/tex].

I've plotted it in my calculator and it doesn't seem to fit well at all. My friend put these points in a program and he got a much better fitting ([tex]a \approx 3[/tex], [tex]b \approx -2[/tex], [tex]c \approx 1[/tex]).

I've redone the algebra and I don't see my error(s).

I've followed the method of this page: http://tutorial.math.lamar.edu/Classes/LinAlg/LeastSquares.aspx.

I got right all problems involving a linear fit, but failed all other fits (exponentials, quadratic, etc.). What am I doing wrong?!!

Another question that really matters to me is...

**why don't we solve Ax=b directly since we know both A and b, we would get 3 equations with 3 unknowns... why bother with the transpose of A?**

Thank you very much for any help.