%function f=nmrtitration(H;A)
% A = [A(1),A(2)] = [K,deltac]
delta=[2.21,2.31,2.41,2.4,2.49,2.53,2.62];
H=[0.000,0.007,0.011,0.017,0.034,0.051,0.085];
deltaG=2.21;
G=0.034;
f = @(A) deltaG + (A(2)-deltaG)/(2*G) .* ( G+H+1/A(1)-sqrt((G+H+1/A(1)).^2-4*G*H) );
S = @(A) sum( (f(A)-delta).^2 );
A=[50000,10.53]; % initial guess can be bad
Aopt = fminsearch(S,A)
disp('These are the errors at each data point:')
f(Aopt)-delta
HH = 0:.001:0.085;
gg = deltaG + (Aopt(2)-deltaG)/(2*G) .* ( G+HH+1/Aopt(1)-sqrt((G+HH+1/Aopt(1)).^2-4*G*HH) );
plot(H,delta,'o',HH,gg)