# 5 points exactly on y = 2x_1 - x_2 + 3
p1 <- c(0,1,2)
p2 <- c(1,0,5)
p3 <- c(1,1,4)
p4 <- c(0,2,1)
p5 <- c(2,0,7)
# Assemble points in a single matrix for input
x <- matrix(c(p1,p2,p3,p4,p5),ncol=3,byrow=TRUE)
# Find the least squares estimate of a_1,a_2,a_3
a <- solveLS(x)
print(a)
Run the code above in your browser using DataLab