lambda = [1.9, 1.96838, 1.99, 1.99684, 1.999, 1.99968, 1.9999, 1.999968, 1.99999];
alpha = 2 - lambda;
P = 1/2 * [0.00042333434, 0.000037657484, 0.0000037510429, 0.00000037903849, 0.000000038277711, 0.0000000039359471, 0.00000000038507873, 0.000000000039461, 0.0000000000038547];

coeffs = polyfit(log(alpha), log(P), 1);
slope = coeffs(1);
intercept = coeffs(2);

close all;
loglog(alpha, P, 'o', 'MarkerSize', 4, ...
    'MarkerEdgeColor', 'k', 'MarkerFaceColor', 'k', 'DisplayName', '-P')
xlabel('\alpha = 2 - \lambda')
ylabel('-P', 'Rotation', 0)
grid on;
hold on;
loglog(alpha, pi^2/512 * power(alpha, 2), ...
    'Color', 'b', 'DisplayName', '0.0193 \alpha\^2')
legend;

% lower_error = zeros(1, length(lambda));
% upper_error = zeros(1, length(lambda));
% 
% disp('\lambda = 1.9');
% lower_error(1) = tsum(sym('1.9'), sym('0.00042333434'), 24) - vpa(pi, 24);
% upper_error(1) = tsum(sym('1.9'), sym('0.00042333435'), 24) - vpa(pi, 24);
% 
% disp('lambda = 1.96838');
% lower_error(2) = tsum(sym('1.96838'), sym('0.000037657483'), 24) - vpa(pi, 24);
% upper_error(2) = tsum(sym('1.96838'), sym('0.000037657484'), 24) - vpa(pi, 24);
% 
% disp('\lambda = 1.99');
% lower_error(3) = tsum(sym('1.99'), sym('0.0000037510429'), 24) - vpa(pi, 24);
% upper_error(3) = tsum(sym('1.99'), sym('0.0000037510430'), 24) - vpa(pi, 24);
% 
% disp('\lambda = 1.99684');
% lower_error(4) = tsum(sym('1.99684'), sym('0.00000037903849'), 24) - vpa(pi, 24);
% upper_error(4) = tsum(sym('1.99684'), sym('0.00000037903850'), 24) - vpa(pi, 24);
% 
% disp('\lambda = 1.999');
% lower_error(5) = tsum(sym('1.999'), sym('0.000000038277711'), 24) - vpa(pi, 24);
% upper_error(5) = tsum(sym('1.999'), sym('0.000000038277712'), 24) - vpa(pi, 24);
% 
% disp('\lambda = 1.99968');
% lower_error(6) = tsum(sym('1.99968'), sym('0.0000000039359470'), 24) - vpa(pi, 24);
% upper_error(6) = tsum(sym('1.99968'), sym('0.0000000039359471'), 24) - vpa(pi, 24);
% 
% disp('\lambda = 1.9999');
% lower_error(7) = tsum(sym('1.9999'), sym('0.00000000038507873'), 24) - vpa(pi, 24);
% upper_error(7) = tsum(sym('1.9999'), sym('0.00000000038507874'), 24) - vpa(pi, 24);
% 
% disp('\lambda = 1.999968');
% lower_error(8) = tsum(sym('1.999968'), sym('0.000000000039460'), 24) - vpa(pi, 24);
% upper_error(8) = tsum(sym('1.999968'), sym('0.000000000039461'), 24) - vpa(pi, 24);
% 
% disp('\lambda = 1.99999');
% lower_error(9) = tsum(sym('1.99999'), sym('0.0000000000038546'), 24) - vpa(pi, 24);
% upper_error(9) = tsum(sym('1.99999'), sym('0.0000000000038547'), 24) - vpa(pi, 24);

% \lambda = 1.9
% ans = -0.000000000000470547644462367232227611
% ans =  0.00000000000838236449982688299595511

% \lambda = 1.96838
% ans = -0.000000000000239426291579340536951012
% ans =  0.000000000000114439815117551308292938

% \lambda = 1.99
% ans = -0.00000000000000207854273098943021958966
% ans =  0.0000000000000100272334928387871636409

% \lambda = 1.99684
% ans = -0.000000000000000160312567735781321456609
% ans =  0.00000000000000023209486991561525450996

% \lambda = 1.999
% ans = -0.0000000000000000055304048613666585322926
% ans =  0.00000000000000000698869963367964781885881

% \lambda = 1.99968
% ans = -0.000000000000000000292711503268236633026395
% ans =  0.000000000000000000108927366343012477076035

% \lambda = 1.9999
% ans = -0.0000000000000000000031922013781016991511848
% ans =  0.00000000000000000000936942992783194408238801

% \lambda = 1.999968
% ans = -0.000000000000000000282824419307369595417559
% ans =  0.00000000000000000011924986312654581247393

% \lambda = 1.99999
% ans = -0.000000000000000000010543256291969347805032
% ans =  0.00000000000000000000202258499510897295918139