We want to fit a+bt^2
to the data given below
import numpy as np
A = np.transpose(np.matrix([[1,1,1,1,1], [(-2)**2, (-1)**2, 0, 1, 2**2]]))
A
b = np.transpose(np.matrix([[1,1,2,3,-2]]))
b
# First, we find A^T A
C = np.transpose(A)*A
Cinv = np.linalg.inv(C)
Cinv
Now we solve the system by multiplying both sides by the inverse of (A^T)(A)
x = Cinv * np.transpose(A)* b
x
# a coefficient
x[0,:]
# b coefficient
x[1,:]