% A helpful scriptt for Exercise 3.4.2.
% Here is the data for Exercise 3.4.2:

tvals = [0 300 1200 3000];
yvals = [1.0 0.78 0.37 0.08];

% However, we will work with the log of the concentration, so

ylogs = log(yvals)

% A quick plot of (time, distance) pairs:

scatter(tvals,ylogs)

% To fit a function u(k,t) = k*t to this data by adjusting "k", define

syms u(k,t);
u(k,t) = k*t;
syms SS(k)
SS(k) = sum((u(tvals,k)-ylogs).^2);

% Then minimize the resulting expression SS as a function of k.
%