NIntegrate[1/Sqrt[x],{x,0,1},Method->{"GlobalAdaptive",Method->"ClenshawCurtisRule"}]//InputForm

NIntegrate[1/Sqrt[x],{x,0,1},Method->{"LocalAdaptive",Method->"ClenshawCurtisRule"}]//InputForm

NIntegrate[1/Sqrt[x],{x,0,1},Method->"LobattoKronrodRule"]//InputForm

NIntegrate[1/Sqrt[x],{x,0,1},Method->{"GlobalAdaptive",Method->"LobattoKronrodRule"}]//InputForm

NIntegrate[1/Sqrt[x],{x,0,1},Method->"MonteCarloRule"]//InputForm

NIntegrate[1/Sqrt[x],{x,0,1},Method->{"AdaptiveMonteCarlo", Method->"MonteCarloRule"}]//InputForm

(b-a) ((f(a)+f(b))/2)≈(∫_a^b)f(x)dx.

T(f,n)==(1/2) h f(a)+h (∑_(i=1)^(n-2))f(a+h i)+(1/2) h f(b)≈(∫_a^b)f(x)dx,

NIntegrate[x+5,{x,0,7},Method->"TrapezoidalRule"]

"TrapezoidalRule" options.

k=4;
Reap@NIntegrate[x+5,{x,1,7},Method->{"TrapezoidalRule","Points"->k,"RombergQuadrature"->False},EvaluationMonitor:>Sow[x]]

NIntegrate[x^2+y,{x,0,1},{y,0,1},Method->"TrapezoidalRule"]

NIntegrate[Sqrt[x],{x,0,1},Method->{"GlobalAdaptive",Method->{"TrapezoidalRule","Points"->5,"RombergQuadrature"->True},"SingularityDepth"->∞},MaxRecursion->100,PrecisionGoal->8]//InputForm//Timing

NIntegrate[Sqrt[x],{x,0,1},Method->{"GlobalAdaptive",Method->{"TrapezoidalRule","Points"->5,"RombergQuadrature"->False},"SingularityDepth"->∞},MaxRecursion->100,PrecisionGoal->8]//InputForm//Timing

n=5;precision=MachinePrecision;
{absc,weights,errweights}=NIntegrate`TrapezoidalRuleData[n,precision]

rombergAbsc=absc;
lowOrderWeights=-(errweights-weights);
rombergWeights=((4weights-lowOrderWeights)/3);
rombergErrorWeights=rombergWeights-weights;
{rombergAbsc,rombergWeights,rombergErrorWeights}

NIntegrate[1/Sqrt[x],{x,0,1},Method->"NewtonCotesRule"]

"NewtonCotesRule" options.

NIntegrate`NewtonCotesRuleData[25,MachinePrecision][[2]]

n=5;precision=MachinePrecision;
{absc,weights,errweights}=NIntegrate`NewtonCotesRuleData[n,precision]

NIntegrate[1/Sqrt[x],{x,0,1},Method->"GaussBerntsenEspelidRule"]

"GaussBerntsenEspelidRule" options.

Table[(k=0;NIntegrate[x^(1/2),{x,0,1},Method->{"GaussBerntsenEspelidRule","Points"->i},EvaluationMonitor:>k++];k),{i,2,20}]

n=5;precision=20;
{absc,weights,errweights}=NIntegrate`GaussBerntsenEspelidRuleData[n,precision]

polyd[vec_List, nu_] := (Times@@(vec[[nu]]-Drop[vec,{nu}]))^(-1);
dvdWeights[vec_List] := dvdWeights[vec] = Table[polyd[vec, nu],{nu, 1, Length[vec]}];

{absc,weights,errweights}=NIntegrate`GaussRuleData[2n+1,precision];

((((((-1))^n) (Sqrt[π]) ((Gamma[1+n])^2)))/(Gamma[(3/2)+2 n] (2^(2 n)))) dvdWeights[absc]

NIntegrate[1/Sqrt[x],{x,0,1},Method->"GaussKronrodRule"]

"GaussKronrodRule" options.

Table[(k=0;NIntegrate[x^10,{x,0,1},Method->{"GaussKronrodRule","Points"->i},EvaluationMonitor:>k++];k),{i,2,20}]

n=5;precision=20;
{absc,weights,errweights}=NIntegrate`GaussKronrodRuleData[n,precision]

p=If[OddQ[n],3*n+2,3*n+1]

f[x_]:=(x^p)

Total@MapThread[{f[#1]#2,f[#1]#3}&,{absc,weights,errweights}]

N[Integrate[f[x],{x,0,1}],precision]

f[x_]:=(x^(2n-1))

Total@MapThread[{f[#1]#2,f[#1]#3}&,{absc,weights,errweights}]

N[Integrate[f[x],{x,0,1}],precision]

NIntegrate[1/Sqrt[x],{x,0,1},Method->"LobattoKronrodRule"]

"LobattoKronrodRule" options.

Table[(k=0;NIntegrate[x^10,{x,0,1},Method->{"LobattoKronrodRule","Points"->i},EvaluationMonitor:>k++];k),{i,3,20}]

n=5;precision=20;
{absc,weights,errweights}=NIntegrate`LobattoKronrodRuleData[n,precision]

p=If[OddQ[n],3*n-3,3*n-2]

f[x_]:=(x^p)

Total@MapThread[{f[#1]#2,f[#1]#3}&,{absc,weights,errweights}]

N[Integrate[f[x],{x,0,1}],precision]

f[x_]:=(x^(2n-3))

Total@MapThread[{f[#1]#2,f[#1]#3}&,{absc,weights,errweights}]

N[Integrate[f[x],{x,0,1}],precision]

NIntegrate[1/Sqrt[x],{x,0,1},Method->"ClenshawCurtisRule"]

"ClenshawCurtisRule" options.

NIntegrate[Sqrt[x],{x,0,1},Method->{"ClenshawCurtisRule","Points"->10}]

Table[(k=0;NIntegrate[x^10,{x,0,1},Method->{"ClenshawCurtisRule","Points"->i},EvaluationMonitor:>k++];k),{i,3,20}]

n=5;precision=20;
{absc,weights,errweights}=NIntegrate`ClenshawCurtisRuleData[n,precision]

nn=2n-1;
N[(1/2)Table[Cos[(π/(nn-1))i],{i,nn-1,0,-1}]+(1/2),precision]

f[x_]:=(x^(2n-1))

Total@MapThread[{f[#1]#2,f[#1]#3}&,{absc,weights,errweights}]

Integrate[f[x],{x,0,1}]

NIntegrate[1/Sqrt[x],{x,0,1},Method->{"MultipanelRule",Method->"GaussKronrodRule","Panels"->3}]

"MultipanelRule" options.

npanels=3;
NIntegrate`MultiPanelRuleData[{"GaussKronrodRule","Points"->2},npanels,MachinePrecision]

{absc,weights,errweights}=NIntegrate`GaussKronrodRuleData[2,MachinePrecision]

Join@@Map[Rescale[absc,{0,1},#]&,Partition[Range[0,npanels](1/npanels),2,1]]

(1/npanels)Join@@Table[weights,{npanels}]

NIntegrate[1/Sqrt[x+y+z],{x,0,1},{y,0,1},{z,0,1},Method->"CartesianRule"]

"CartesianRule" options.

(∫_V)f((Subscript[x, 1]),…,(Subscript[x, d]))d(Subscript[x, 1])…d(Subscript[x, D]) ≈(∑_((Subscript[i, 1])=1)^(Subscript[n, 1]))(…(∑_((Subscript[i, D])=1)^(Subscript[n, D]))((∏_(k=1)^D)(Subscript[w, (Subscript[i, k])]^k)) f((Subscript[α, (Subscript[i, 1])]^1),…,(Subscript[α, (Subscript[i, D])]^D))).

(∫_V)f(x)dx≈(∑_((Subscript[i, D])=1)^n)(Subscript[w, i]) f((Subscript[α, i])),

pnts=Reap[NIntegrate[x+y^9,{x,0,1},{y,0,1},Method->{{"TrapezoidalRule","Points"->4},{"GaussKronrodRule","Points"->5}},EvaluationMonitor:>Sow[{x,y}]]][[2,1]];
Graphics[Point/@pnts,AspectRatio->1,Axes->True,AxesOrigin->{-0.02,-0.02}]

NIntegrate[x+y,{x,0,1},{y,0,1},Method->"GaussKronrodRule"]

NIntegrate[x+y,{x,0,1},{y,0,1},Method->{"LobattoKronrodRule","GaussKronrodRule"}]

NIntegrate[x+y^3,{x,0,1},{y,0,1},Method->{{"TrapezoidalRule","Points"->8},{"GaussKronrodRule","GaussPoints"->12}}]

crule=NIntegrate`CartesianRuleData[{{"GaussKronrodRule","GaussPoints"->2},{"TrapezoidalRule","Points"->2}},MachinePrecision]

productFunc=MapAt[Flatten[Outer[Times,Sequence@@#]]&,#,{1,3}]&@MapAt[Flatten[Outer[Times,Sequence@@#]]&,#,{1,2}]&@MapAt[Flatten[Outer[List,Sequence@@#],Length[#]-1]&,#,{1,1}]&;

productFunc[crule]

NIntegrate[1/Sqrt[x+y],{x,0,1},{y,0,1},Method->"MultidimensionalRule"]

"MultidimensionalRule" options.

tbl=Table[Prepend[Table[
(k=0;NIntegrate[x^m+y^m,{x,0,1},{y,0,1},Method->{"MultidimensionalRule","Generators"->gen},EvaluationMonitor:>k++];k),{gen,{5,6,9}}],m],{m,1,20}];
Grid[Join[{{"Monomial","Number of generators",SpanFromLeft,SpanFromLeft},{"degree","5","6","9"}},tbl],Dividers->{{False,True,False},{False,False,True,False}},Alignment->{Center}]

numberOfGenerators=9;

MakeOrbit[generator_]:=
Module[{perms,signs,gperms,len=Length[generator]},
perms=Permutations[Range[len]];
signs=Flatten[Outer[List,Sequence@@Table[{1,-1},{len}]],len-1];
gperms=Map[Part[generator,#1]&,perms];
Union[Flatten[Outer[Times,gperms,signs,1],1]]
];

dimension=2;
precision=MachinePrecision;
rdata=NIntegrate`MultiDimensionalRuleData[numberOfGenerators,precision,dimension];
generators=rdata[[1,1]];
weights=rdata[[1,2]];

orbits=MakeOrbit/@generators;

Clear[f]
f[x_,y_]:=x^3*y^3

Total@MapThread[Total[Map[f@@(#1+1/2)&,#1]*#2]&,{orbits,weights}]//InputForm

Integrate[f[x,y],{x,0,1},{y,0,1}]//N//InputForm

graphs=Graphics[{Red,AbsolutePointSize[4],Point/@#1},Axes->False,AspectRatio->1,Frame->True,FrameTicks->None,PlotRange->{{-1,1},{-1,1}}/2,ImageSize->{75,75}]&/@orbits;

Row[graphs]

Graphics[First/@graphs,Frame->True,FrameTicks->None]

NIntegrate[BesselJ[0,x+(x^2)],{x,0,∞},Method->"LevinRule"]

"LevinRule" options.

Scope

Collocation Method

NIntegrate[Sin[x+x^3],{x,3,1000},Method->{"LevinRule","Points"->11}]

NIntegrate[Sin[x]Sin[1000x],{x,0,5},Method->{"LevinRule","Kernel"->Sin[1000x]}]

NIntegrate[Sin[x]Sin[1000x],{x,0,5},Method->{"LevinRule",ExcludedForms->Sin[x]}]

NIntegrate[Sin[x]Exp[I x]BesselJ[0,x/100],{x,5,500},Method->{"LevinRule","LevinFunctions"->{Exp,Sin}}]

NIntegrate[Sin[x]Exp[I x]BesselJ[0,x/100],{x,5,500},Method->{"LevinRule","LevinFunctions"->{"ExpRelated","TrigRelated"}}]

Named groups recognized by the "LevinFunctions" method option.

NIntegrate`LevinIntegrand Object

li=NIntegrate`LevinIntegrandReduce[x Exp[I x]BesselJ[0,100x]+(Sqrt[x]),x]

li["Kernel"]

First[li["DifferentialMatrices"]]//MatrixForm

D[li["Kernel"],x]==First[li["DifferentialMatrices"]].li["Kernel"]

FullSimplify[%]

li["Properties"]

li["Rules"]

NIntegrate`LevinIntegrandReduce[Sin[x]+Cos[x],x]["Rules"]

NIntegrate`LevinIntegrandReduce[Sin[x]+Cos[x],x,"AdditiveTerm"->Sin[x]]["Rules"]

NIntegrate`LevinIntegrandReduce[Sin[x]Log[x],x,"LevinFunctions"->Automatic]["Rules"]

NIntegrate`LevinIntegrandReduce[Sin[x]Log[x],x,"LevinFunctions"->All]["Rules"]

NIntegrate[Sin[x]+Cos[x],{x,5,10},Method->{"LevinRule","AdditiveTerm"->Sin[x],"Amplitude"->{1,0},"Kernel"->{Cos[x],-Sin[x]},"DifferentialMatrix"->{{0,1},{-1,0}}}]

NIntegrate[ignored,{x,5,10},Method->{"LevinRule","AdditiveTerm"->Sin[x],"Amplitude"->{1,0},"Kernel"->{Cos[x],-Sin[x]},"DifferentialMatrix"->{{0,1},{-1,0}}}]

NIntegrate[(((E^x)-1)/(E-1)),{x,0,1},Method->{"MonteCarloRule","Points"->1000}]

"MonteCarloRule" options.

(∫_V)f(x)dx==vol(V)(∫_(R^d))(1/(vol(V)))Boole(x∈V)f(x)dx==vol(V) E(f),

MC(f,n)==(1/n)(∑_(i=1)^n)f((Subscript[x, i])).

SD(f,n)==(s/(Sqrt[n]))==(1/(Sqrt[n (n-1)]))(Sqrt[(∑_(i=1)^n)(((f((Subscript[x, i]))-MC(f,n)))^2)]).

"AxisSelector" options.

MinVariance options.

t=NIntegrate[Exp[-((((x-1/2))^2)+(((y-1/2))^2))],{x,0,1},{y,0,1},Method->{"MonteCarloRule","AxisSelector"->Random}]

f[x_?NumberQ,y_?NumberQ]:=Boole[Abs[(((x-(1/2)))^2)+(((y-(1/2)))^2)]<(1/6)] ((E^(-3 ((x^2)+(y^2))))+(1/2));
Plot3D[f[x,y],{x,0,1},{y,0,1},PlotRange->All,PlotPoints->20]

t=Reap[NIntegrate[f[x,y],{x,0,1},{y,0,1},Method->{"AdaptiveMonteCarlo",Method->{"MonteCarloRule","AxisSelector"->Random}},MinRecursion->1,PrecisionGoal->2.8,EvaluationMonitor:>Sow[{x,y}]]][[2,1]];
Graphics[{PointSize[0.006],Point[t]},AspectRatio->1,Frame->True,PlotLabel->"Number of sampling points = "<>ToString[Length[t]]]

t=Reap[NIntegrate[f[x,y],{x,0,1},{y,0,1},Method->{"AdaptiveMonteCarlo",Method->{"MonteCarloRule","AxisSelector"->{"MinVariance","SubsampleFraction"->1/3}}},MinRecursion->1,PrecisionGoal->2.8,EvaluationMonitor:>Sow[{x,y}]]][[2,1]];Graphics[{PointSize[0.006],Point[t]},AspectRatio->1,Frame->True,PlotLabel->"Number of sampling points = "<>ToString[Length[t]]]

Do[NIntegrate[(1/(Sqrt[(x^2)+(y^2)])),{x,-1,2},{y,-1,2},Method->{"AdaptiveMonteCarlo",Method->{"MonteCarloRule","Points"->500,"AxisSelector"->Random}}],{100}]//Timing

Do[NIntegrate[(1/(Sqrt[(x^2)+(y^2)])),{x,-1,2},{y,-1,2},Method->{"AdaptiveMonteCarlo",Method->{"MonteCarloRule","Points"->500,"AxisSelector"->{"MinVariance","SubsampleFraction"->0.3}}}],{100}]//Timing

Do[NIntegrate[(1/(Sqrt[(x^2)+(y^2)])),{x,-1,2},{y,-1,2},Method->{"AdaptiveMonteCarlo",Method->{"MonteCarloRule","Points"->500,"AxisSelector"->{"MinVariance","SubsampleFraction"->0.6}}}],{100}]//Timing

Is there a type of rule that is better than other types for any integral or for integrals of a certain type?

Given an integration strategy, what rules perform better with it? For what integrals?

Given an integral, an integration strategy, and an integration rule, what number of points in the rule will minimize the total number of sampling points used to reach an integral estimate that satisfies the precision goal?

In general the higher the degree of the rule the faster the integration will be for smooth integrands and for higher-precision goals. On the other hand, the rule degree might be too high for the integrand and hence too many sampling points might be used when the adaptive strategies work around, for example, the integrand's discontinuities.

The error estimation functional of a rule influences significantly the total amount of work by the integration strategy. Rules with a smaller number of points might lead (1) to a wrong result because of underestimation of the integral, or (2) to applying too many sampling points because of overestimation of the integrand. (See "Examples of Pathological Behavior".) Further, the error estimation functional might be computed with one or several embedded null rules. In general, the larger the number of the null rules the better the error estimation—fewer phase errors are expected. The number of the null rules and the weights assigned to them in the sum that computes the error estimate determine the sets of pathological integrals and integrals hard to compute for that rule. (Some of the multidimensional rules of (RefLink[NIntegrate, paclet:ref/NIntegrate]) use several embedded null rules to compute the error estimate. All of the one-dimensional integration rules of (RefLink[NIntegrate, paclet:ref/NIntegrate]) use only one null rule.)

Local adaptive strategies are more effective with closed rules that have their sampling points more uniformly distributed (for example, "ClenshawCurtisRule") than with open rules (for example, GaussKronrodRule) and closed rules that have sampling points distributed in a non-uniform way (for example, "LobattoKronrodRule").

The percent of points reused by the strategy might greatly determine what is the best rule. For one-dimensional integrals, "LocalAdaptive" reuses all points of the closed rules. "GlobalAdaptive" throws away almost all points of the regions that need improvement of their error estimate.

RuleError[f_,rule_String,prec_,pnts_?NumberQ]:=
Block[{absc,weights,errweights},
{absc,weights,errweights}=ToExpression["NIntegrate`"<>rule<>"Data"][pnts,prec];
Abs[Total[MapThread[f[#1]#2&,{absc,weights}]]-Integrate[f[x],{x,0,1}]]
];

funcs={(Sqrt[x]),Abs[x-(1/E)],(Piecewise[{{2, x≤(1/E)}, {3, x>(1/E)}}]),(1/((10^4) ((((1/π)-x))^2)+1))};

Row[Plot[#,{x,0,1},PlotRange->All,Frame->True,FrameTicks->{None,Automatic},ImageSize->{120,120}]&/@funcs,"  "]

errors=Table[{pnts,RuleError[#,"GaussBerntsenEspelidRule",30,pnts]},{pnts,4,100,1}]&/@Function/@(Function[{f},f/.x->#]/@funcs);

gr=ListLinePlot[MapThread[Tooltip[{#[[1]],Log[10,#[[2]]]}&/@#1,#2]&,{errors,funcs}],PlotRange->{{0,100},{0,-9}},AxesOrigin->{0,0},ImageSize->{300}];
xc=110;
xcSq=106;
legend={Text[funcs[[1]],{xc,-2},{-1,0}],Text[funcs[[2]],{xc,-4},{-1,0}],Text[funcs[[3]],{xc,-6},{-1,0}],Text[funcs[[4]],{xc,-8},{-1,0}]};
legendSq={Text["  ",{xcSq,-2},{-1,0}],Text["  ",{xcSq,-4},{-1,0}],Text["  ",{xcSq,-6},{-1,0}],Text["  ",{xcSq,-8},{-1,0}]};
legendSq=MapThread[Append[#1,Background->#2]&,{legendSq,Cases[gr,Hue[s__],∞]}];
Row[{gr," ",Graphics[{ legend,legendSq},ImageSize->{200,200},AspectRatio->5]}]

Minimal Number of Sampling Points

Attributes[SamplingPoints]={HoldFirst};
SamplingPoints[expr_]:=
Module[{k=0,res},
res=Hold[expr]/.HoldPattern[NIntegrate[s___]]:>NIntegrate[s,EvaluationMonitor:>k++];ReleaseHold[res];k]

tblga=Table[{pg,pnts,SamplingPoints[NIntegrate[#,{x,0,1},Method->{"GlobalAdaptive","SymbolicProcessing"->0,Method->{"GaussBerntsenEspelidRule","Points"->pnts}},MaxRecursion->100,WorkingPrecision->35,PrecisionGoal->pg]]},{pg,4,30},{pnts,4,25}]&/@funcs;

minPnts=(#[[Position[#,Min[#[[3]]&/@#]][[1,1]]]]&[#]&/@#)&/@tblga;

gr=ListLinePlot[(Drop[#,-1]&/@#)&/@minPnts,PlotRange->{{0,30},{0,26}},PlotStyle->Thickness[0.003],AxesOrigin->{3,0},ImageSize->{300,200}];
xc=110;
xcSq=106;
legend={Text[funcs[[1]],{xc,-2},{-1,0}],Text[funcs[[2]],{xc,-4},{-1,0}],Text[funcs[[3]],{xc,-6},{-1,0}],Text[funcs[[4]],{xc,-8},{-1,0}]};
legendSq={Text["  ",{xcSq,-2},{-1,0}],Text["  ",{xcSq,-4},{-1,0}],Text["  ",{xcSq,-6},{-1,0}],Text["  ",{xcSq,-8},{-1,0}]};
legendSq=MapThread[Append[#1,Background->#2]&,{legendSq,Cases[gr,Hue[s__],∞]}];
Row[{gr," ",Graphics[{ legend,legendSq},ImageSize->{200,200},AspectRatio->5]}]

RuleErrors[f_,rule_String,prec_,pnts_?NumberQ]:=
Block[{absc,weights,errweights,exact},
{absc,weights,errweights}=ToExpression["NIntegrate`"<>rule<>"Data"][pnts,prec];
{Abs[Total[MapThread[f[#1]#2&,{absc,weights}]]-Integrate[f[x],{x,0,1}]],Abs[Total[MapThread[f[#1]#2&,{absc,errweights}]]]}
];

funcs={(Sqrt[x]),Abs[x-(1/E)],(Piecewise[{{2, x≤(1/E)}, {3, x>(1/E)}}]),(1/((10^4) ((((1/π)-x))^2)+1))};

Row[Plot[#,{x,0,1},PlotRange->All,Frame->True,FrameTicks->{None,Automatic},ImageSize->{120,120}]&/@funcs,"  "]

rules={"GaussKronrodRule","LobattoKronrodRule","TrapezoidalRule","ClenshawCurtisRule"};
errors=Outer[Table[{pnts,RuleErrors[#2,#1,30,pnts]},{pnts,4,100,1}]&,rules,Function/@(Function[{f},f/.x->#]/@funcs)];
exactErrors=Map[#[[1]]&,errors,{-2}];
ruleErrors=Map[#[[2]]&,errors,{-2}];

Row[{Grid[Join[{{"exact errors","error estimates"}},Flatten[Transpose[{{#,SpanFromLeft}&/@rules,Transpose[Map[
Function[{d},
(gr=ListLinePlot[Map[{#[[1]],Log[10,#[[2]]]}&/@#&,d],ImageSize->{200,100},PlotRange->{{0,100},{0,-9}},AxesOrigin->{0,0}];
xc=110;
xcSq=106;
legend={Text[funcs[[1]],{xc,-1.5},{-1,0}],Text[funcs[[2]],{xc,-3.5},{-1,0}],Text[funcs[[3]],{xc,-5.5},{-1,0}],Text[funcs[[4]],{xc,-7.5},{-1,0}]};
legendSq={Text["  ",{xcSq,-1.5},{-1,0}],Text["  ",{xcSq,-3.5},{-1,0}],Text["  ",{xcSq,-5.5},{-1,0}],Text["  ",{xcSq,-7.5},{-1,0}]};
legendSq=MapThread[Append[#1,Background->#2]&,{legendSq,Cases[gr,Hue[s__],∞]}];
gr)],{exactErrors,ruleErrors},{2}]]}],1]],Dividers->All],Graphics[{legend,legendSq},ImageSize->{200,200},AspectRatio->5]}]

The Wrong Estimation

f[x_]:=Sech[10*(x-0.2)]^2+Sech[100*(x-0.4)]^4+Sech[1000*(x-0.6)]^6

exact=Integrate[f[x],{x,0,1}]

est=NIntegrate[f[x],{x,0,1}]

Abs[exact-est]

Plot[f[x],{x,0,1}]

Better Results

NIntegrate[f[x],{x,0,1},Method->"GlobalAdaptive",MaxRecursion->20,PrecisionGoal->12]

Table[{pg,NIntegrate[f[x],{x,0,1},Method->"GlobalAdaptive",MaxRecursion->20,PrecisionGoal->pg]},{pg,6,12}]

Plot[f[x],{x,0,1},PlotPoints->100]

eps=0.0015;Plot[f[x],{x,0.6-eps,0.6+eps}]

NIntegrate[f[x],{x,0.6-eps,0.6+eps}]

Abs[exact-est]

Why the Estimator Is Misled

{absc,weights,errweights}=NIntegrate`GaussKronrodRuleData[5,MachinePrecision];

IRuleEstimate[f_,{a_,b_}]:=
Module[{integral,error},
{integral,error}=(b-a)Total@MapThread[{f[#1]#2,f[#1]#3}&,{Rescale[absc,{0,1},{a,b}],weights,errweights}];
{integral,Abs[error]}
]

cTbl=Reap[NIntegrate[f[x],{x,0,1},
EvaluationMonitor:>Sow[x]]][[2]]//Flatten;

ListPlot[Transpose[{cTbl,Range[1,Length[cTbl]]}],AspectRatio->0.5,PlotRange->{{0,1},{0,Length[cTbl]}},PlotStyle->{Hue[0.7]}]

gk= Sort[Take[cTbl,-11]]
g=Take[gk,{2,-2,2}]

fgk=f/@gk;
fg=f/@g;

gkf[x_]:=Evaluate[InterpolatingPolynomial[Transpose[{gk,fgk}],x]]
gf[x_]:=Evaluate[InterpolatingPolynomial[Transpose[{g,fg}],x]]

Plot[{gkf[x],gf[x]},{x,Min[gk],Max[gk]}]
eps=0.01;
Plot[{gkf[x],gf[x]},{x,0.6-eps,0.6+eps}]

Integrate[gkf[x],{x,0.5,0.75}]
Integrate[gf[x],{x,0.5,0.75}]
%-%%//FullForm

f[x_,λ_,μ_]:=((10^(-μ))/((((x-λ))^2)+(10^(-2μ))))

num=NIntegrate[f[x,0.415,1.25],{x,-1,1},PrecisionGoal->2]

exact=Integrate[f[x,0.415,1.25],{x,-1,1}]

Abs[num-exact]/Abs[exact]

{absc,weights,errweights}=NIntegrate`GaussKronrodRuleData[5,MachinePrecision];

IRuleEstimate[f_,{a_,b_}]:=
Module[{integral,error},
{integral,error}=(b-a)Total@MapThread[{f[#1]#2,f[#1]#3}&,{Rescale[absc,{0,1},{a,b}],weights,errweights}];
{integral,Abs[error]}
]

exact=-ArcTan[(10^μ) (-1+λ)]+ArcTan[(10^μ) (1+λ)];

Block[{λ, μ=1.15,pnts=1000,rres,errres,exactres,lambdas},
(* the plot uses 1000 values λ *)
lambdas=Table[λ,{λ,-1,1,(2/(pnts-1))}];
(* this computes the integral and error esitmates over the λ's *)
{rres,errres}=Transpose@Map[Function[{λ},IRuleEstimate[f[#1,λ,Evaluate[μ]]&,{-1,1}]],lambdas];

(* this computes the exact integrals over the λ's *)
exactres =Map[exact/.λ->#1&,lambdas];

(* this finds the number underestimating error estimates *)
Print["Percent of underestimation: ",100*Length[Select[errres-Abs[exactres-rres],#1<0&]]/Length[lambdas]//N,"%", " "];

(* the plots, blue is for |GK[f,5]-GK[f,5]|, red is for |GK[f,5]-(∫_(-1)^1)f[x,λ,μ]| *)
ListLinePlot[{Transpose[{lambdas,errres}],Transpose[{lambdas,Abs[exactres-rres]}]},PlotRange->All,PlotStyle->{{Hue[0.7]},{Hue[0]}},AxesLabel->{λ,"error"}]
]

Clear[FitPlots];
FitPlots[f_,{a_,b_},abscArg_]:=
Module[{absc=Rescale[abscArg,{0,1},{a,b}]},
(* this finds the interpolating polynomial through the Gauss abscissas and the values of f over them *)
polyGauss[x_]:=Evaluate[InterpolatingPolynomial[Transpose[{Take[absc,{2,-2,2}],f[#1]&/@(Take[absc,{2,-2,2}])}],x]];

(* this finds the interpolating polynomial through the Gauss-Kronrod abscissas and the values of f over them *)
polyGaussKronrod[x_]:=Evaluate[InterpolatingPolynomial[Transpose[{absc,f[#1]&/@absc}],x]];

(* plot of the Gauss interpolating points *)
samplPointsGauss=Graphics[{GrayLevel[0],PointSize[0.02],Point/@Transpose[{Take[absc,{2,-2,2}],f[#1]&/@Take[absc,{2,-2,2}]}]}];

(* plot of the Gauss-Kronrod interpolating points *)
samplPointsGaussKronrod=Graphics[{Red,PointSize[0.012],Point/@Transpose[{absc,f[#1]&/@absc}]}];

(* interpolating polynomials and f plots *)
Block[{$DisplayFunction=Identity},
funcPlots=Plot[{polyGauss[x],polyGaussKronrod[x],f[x]},{x,a,b},PlotRange->All,PlotStyle->{{Hue[0.7]},{Hue[0.8]},{Hue[0]}}];
];

exact=Integrate[f[x],{x,a,b}];
r1=Integrate[polyGauss[x],{x,a,b}];
r2=Integrate[polyGaussKronrod[x],{x,a,b}];
Print["estimated integral:"<>ToString@r2,"  exact integral:"<>ToString@Re@exact];
Print["estimated error:"<>ToString@Abs[r1-r2],"  actual error:"<>ToString@Abs[r2-exact]];
Show[{funcPlots,samplPointsGauss,samplPointsGaussKronrod}]
];

FitPlots[f[#1,0.415,1.25]&,{-1,1},absc]

FitPlots[f[#1,0.53,1.25]&,{-1,1},absc]