Accuracy of Madhava Series for Pi

The following code computes a list of partial sums of the Madhava series for π.

(* initialize values *)
numTerms=40;
piValues=Table[0,numTerms];
sum=0;

(* run the loop *)
Do[
sum = sum+(((-1))^(i+1))/(2i-1);
piValues[[i]]=4*sum,
{i,1,numTerms}
]

N[piValues]

accuracy=N[-Log[10,Abs[Pi-piValues]]]

ListPlot[accuracy,AxesLabel->{"iteration","accuracy"}]

ListPlot[10^accuracy,AxesLabel->{"iteration","accuracy"}]

Linear regression

Range[numTerms]

10^accuracy

Transpose[{Range[numTerms],10^accuracy}]

model=LinearModelFit[Transpose[{Range[numTerms],10^accuracy}],x,x]

model["BestFit"]

model["BestFit"][[1]]

model["BestFit"][[2]]

Plot[model["BestFit"],{x,0,numTerms}]

Show[
Plot[model["BestFit"],{x,0,numTerms},PlotStyle->Orange,AxesLabel->{"iteration","10^accuracy"}],
ListPlot[10^accuracy]
]

Log[10,model["BestFit"]]

Show[
Plot[Log[10,model["BestFit"]],{x,0,numTerms},PlotStyle->Orange,AxesLabel->{"iteration","accuracy"}],
ListPlot[accuracy]
]