function [E]=cos_res(par,xd,yd)

a=par(1);
b=par(2);

yf=a*cos(b*xd); % y-values on the fitted curve

E=sum((yd - yf).^2); % quantity to be minimized is the 2-norm squared

end

