#A helpful script for Exercise 3.4.9, modeling a cooling potato. #The data, in time/temperature pairs: data = [[0, 204], [2, 193], [4, 184], [8, 169], [10, 162], [13, 156], [17, 149], [20, 143], [24, 138], [30, 130]] N = len(data); #A plot: plt1 = scatter_plot(data); show(plt1) #The temperature might be modeled by the function var('t k'); u(t,k) = 72 + 132*exp(-k*t); #The model function to fit SS = function('SS')(k); SS(k) = add((u(data[i][0],k)-data[i][1])^2 for i in range(N)); #Now minimize SS(k) with respect to k.