% R_H = [0.001097099798333 1.685516409638056e-008];
% R_D = [0.001097361324731 1.691716517447233e-008];

% accepted Rydberg of hydrogen
R_a = 0.001096776;

% If omitted n_i = 3
R_D = 0.001097389384470;
R_H = 0.001097112233761;
sigD = 2.013169749139432e-008;
sigH = 2.002606431143734e-008;
% Index of refraction correction
n = 1.0003;

m_e = 9.10938188e-31; %in kg, from NIST 1998
m_h = 1.67262158e-27; %in kg, from NIST 1998

inv_md = R_H/R_D*(1/m_e + 1/m_h) - 1/m_e;
m_d = 1/inv_md; % Calculated mass of deuteron

massratio = m_d/m_h;
fprintf(1,'\nAccepted mass ratio is %f\n', 1.999007); % From NIST
fprintf(1,'Computed mass ratio is %f\n', massratio);
fprintf(1,'Accepted R_H is: %.9f\n', R_a);
fprintf(1,'Computed R_H is: %.9f\n', R_H/n);

% Calculation of errors
B = R_H/R_D;
varB = 1/R_D^2*sigH^2 + (-R_H/R_D^2)^2*sigD^2;
dmd_dB = -m_d^2*(1/m_e+1/m_h);
err_massratio = 1/m_h*sqrt(dmd_dB^2*varB);
