#A helpful script for Exercise 3.4.1.

#Here is the data for Exercise 3.4.1
data = [[0.1, 0.11], [0.6, 0.5], [1.1, 0.6], [1.4, 0.5]];
N = len(data);

#A plot:
plt1 = scatter_plot(data);
show(plt1)

#aTo fit a function u(a,t) = a*t to this data by adjusting "a", define
var('t a');
u(t,a) = a*t; #The model function to fit
SS = function('SS')(a);
SS(a) = add((u(data[i][0],a)-data[i][1])^2 for i in range(N));

#Now minimize SS(a) with respect to a. Repeat for parts (b)-(d).