Mathematica uses the floating-point model for number representation. This inherently gets Integrate and NIntegrate specially the fame of not generating much provable decimals at all.
Division is not the place for Mathematicas fame overall. Maple for example compares open their product to Mathematica on a focus among others for recursion. Wolfram Inc. did react and upgraded with some functions dedicated to recursion.
The named problem still remains in Mathematica:
s[i_] := s[i] = 2*s[i - 1] - 3*s[i - 1]^2;
s[0] = SetAccuracy[3/10, 20]
0.3000000000000000000
{s[1], s[2], s[10], s[25], s[40]}
{0.3300000000000000000, 0.333300000000000000, 0.33333333333333, \
0.3333, 0.*10^62}
Enhancement for Mathematica from Wolfram Incs is:
RecurrenceTable[{a[n + 1] == 2 a[n] - 3*a[n]^2, a[0] == 3/10}, a, {n,
1, 10}]
{33/100, 3333/10000, 33333333/100000000, \
3333333333333333/10000000000000000, \
33333333333333333333333333333333/100000000000000000000000000000000, \
3333333333333333333333333333333333333333333333333333333333333333/\
10000000000000000000000000000000000000000000000000000000000000000,
333333333333333333333333333333333333333333333333333333333333333333333\
33333333333333333333333333333333333333333333333333333333333/
10000000000000000000000000000000000000000000000000000000000000000000\
0000000000000000000000000000000000000000000000000000000000000,
333333333333333333333333333333333333333333333333333333333333333333333\
3333333333333333333333333333333333333333333333333333333333333333333333\
3333333333333333333333333333333333333333333333333333333333333333333333\
33333333333333333333333333333333333333333333333/
10000000000000000000000000000000000000000000000000000000000000000000\
0000000000000000000000000000000000000000000000000000000000000000000000\
0000000000000000000000000000000000000000000000000000000000000000000000\
0000000000000000000000000000000000000000000000000,
333333333333333333333333333333333333333333333333333333333333333333333\
3333333333333333333333333333333333333333333333333333333333333333333333\
3333333333333333333333333333333333333333333333333333333333333333333333\
3333333333333333333333333333333333333333333333333333333333333333333333\
3333333333333333333333333333333333333333333333333333333333333333333333\
3333333333333333333333333333333333333333333333333333333333333333333333\
3333333333333333333333333333333333333333333333333333333333333333333333\
33333333333333333333333/
10000000000000000000000000000000000000000000000000000000000000000000\
0000000000000000000000000000000000000000000000000000000000000000000000\
0000000000000000000000000000000000000000000000000000000000000000000000\
0000000000000000000000000000000000000000000000000000000000000000000000\
0000000000000000000000000000000000000000000000000000000000000000000000\
0000000000000000000000000000000000000000000000000000000000000000000000\
0000000000000000000000000000000000000000000000000000000000000000000000\
0000000000000000000000000,
333333333333333333333333333333333333333333333333333333333333333333333\
3333333333333333333333333333333333333333333333333333333333333333333333\
3333333333333333333333333333333333333333333333333333333333333333333333\
3333333333333333333333333333333333333333333333333333333333333333333333\
3333333333333333333333333333333333333333333333333333333333333333333333\
3333333333333333333333333333333333333333333333333333333333333333333333\
3333333333333333333333333333333333333333333333333333333333333333333333\
3333333333333333333333333333333333333333333333333333333333333333333333\
3333333333333333333333333333333333333333333333333333333333333333333333\
3333333333333333333333333333333333333333333333333333333333333333333333\
3333333333333333333333333333333333333333333333333333333333333333333333\
3333333333333333333333333333333333333333333333333333333333333333333333\
3333333333333333333333333333333333333333333333333333333333333333333333\
3333333333333333333333333333333333333333333333333333333333333333333333\
333333333333333333333333333333333333333333333/
10000000000000000000000000000000000000000000000000000000000000000000\
0000000000000000000000000000000000000000000000000000000000000000000000\
0000000000000000000000000000000000000000000000000000000000000000000000\
0000000000000000000000000000000000000000000000000000000000000000000000\
0000000000000000000000000000000000000000000000000000000000000000000000\
0000000000000000000000000000000000000000000000000000000000000000000000\
0000000000000000000000000000000000000000000000000000000000000000000000\
0000000000000000000000000000000000000000000000000000000000000000000000\
0000000000000000000000000000000000000000000000000000000000000000000000\
0000000000000000000000000000000000000000000000000000000000000000000000\
0000000000000000000000000000000000000000000000000000000000000000000000\
0000000000000000000000000000000000000000000000000000000000000000000000\
0000000000000000000000000000000000000000000000000000000000000000000000\
0000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000000000000000000000000000000000000}
This rather short excursion sheets some light on the kernel of the given question.
New in version 12 is the built-in Typed
. It introduces a representation of
expressions that should be assumed to be of a specified type for compilation and other purposes.
An example from FunctionCompile
is:
cfun = FunctionCompile[
Function[{Typed[arg, "MachineInteger"]},
Module[{factFun},
factFun =
Function[{arg1}, If[arg1 === 1, 1, arg1*factFun[arg1 - 1]]];
factFun[arg]]]];
First[RepeatedTiming[cfun[10]]/RepeatedTiming[10!]]
5.86162269785962781826373415267759306657260113508390167035153045127714\
38976022830
This throws warning concerning General::precsm and gives more precision comparable to Maple or Matlab or C/C++.
So for more precision put all the functions into the FunctionCompile
built-in and invest the time.
I agree with the suggestion from the other answer so far it advances the precision of the result.
Some enhancement can be taken from failed to use setprecision
The example is:
ER2[α_, K_, q_] :=
1 + Sum[Binomial[α + K, m] Sum[
Binomial[m, r]*(-1)^r/((1/q)^(α + K + r - m) - 1), {r, 0,
m}], {m, 0, K - 1}];
ER2[0, 268, 1/10] // N
ER2[0, 268, SetPrecision[0.1, 50]]
SetPrecision[Unevaluated@ER2[0, 268, 0.1], 50]
3.19697
3.196969869247707935345524749
3.1969698692477079353455247
But that is built-in Mathematica precision enhancement.
Another chance is the use of NSum
.
{sum1, {points1}} =
Reap[NSum[Log[i^2]/(2^i i!), {i, ∞},
Method -> "WynnEpsilon", EvaluationMonitor :> Sow[i]]];
{sum2, {points2}} =
Reap[NSum[Log[i^2]/(2^i i!), {i, ∞},
Method -> "EulerMaclaurin", EvaluationMonitor :> Sow[i]]];
{sum1 - sum2, points1 // Length, points2 // Length}
{ListPlot[Transpose@{points1, Range[Length[points1]]},
ImageSize -> 200],
ListPlot[Transpose@{points2, Range[Length[points2]]},
ImageSize -> 200]}


This is an example out of the book Mathematica Navigator, page 669.
It gives more insight into the convergence of the series and adds some theory about solving methodology for such kind of series.
.
Both methods offer precision control with PrecisionGoal
and AccuracyGoal
. The Mathematica documentation lists the WynnEpsilon under the section "Possible Issues".
Wynn's extrapolation algorithm loses precision for series that are not alternating:
NSum[1/n^3, {n, 1, ∞}, Method -> "WynnEpsilon",
WorkingPrecision -> 30] // Precision
7.27779
The series in this question appear not to be alternating.
The The Mathematica GuideBook for Numericsgives an exmaple for this question on page 281:
Timing[NSum[1/(i^2 + 2), {i, Infinity}, Method -> #]] & /@ {Integrate,
NIntegrate, SequenceLimit, Fit} // InputForm
{{0.296279, 0.8610281004917035}, {0.004104, 0.8610281004917042},
{0.001149, 0.8598255911884887}, {0.001189, 0.8598255911884887}}
The terms are similar to the ones of this question. Mr. Michael Trott recommends therefore the default method as already chosen and find an optimum with the EvaluationMonitor
method already presented.
Mr. Trott presents in that book examples in which VerifyConvergence->False and Off[SequenceLimit::seqlim] work. Have a try for advances in more precision. All can be ready in the Google books online version of the book freely available. I was not able to find SequenceLimit in the Mathematica documentation but there is a built-in named NLimit
with the option SequenceLimit
. But the examples work in 12.0 for me.
That is it from the Mathematica inside for this type of numerical calculations. Always keep in mind that from the university standpoint a remainder calculation is necessary that leads to the O-notation calculus.
The preliminaries thoughs are needed to the active for reading the article:
NIntegrate Integration Strategies.
Since the strategies are:
"The "LocalAdaptive" strategy has an initialization routine and a Recursive Routine (RR). RR produces the leaves of a tree, the nodes of which are regions. The children of a node/region are subregions obtained by its partition. RR takes a region as an argument and returns an integral estimate for it."
as stated in the article from Wolfram Inc. in the section "Local Adaptive Strategy".
In this article, there is a section dealing with the integration of
Plot[1/(10 (1/2 - x)^2 + 1), {x, 0, 1}]

It is than demonstrated that:
"Multidimensional example of using the "Partitioning" option. To make the plot, the sampling points of the first region to be integrated, {0,1}x{0,1}, are removed:"
sampledPoints =
Reap[NIntegrate[(1 + (x + y)^2)^-1, {x, 0, 1}, {y, 0, 1},
Method -> {"LocalAdaptive", "Partitioning" -> {3, 4}},
EvaluationMonitor :> Sow[{x, y}]]][[2, 1]];
sampledPoints =
Partition[sampledPoints, 17(*Length[sampledPoints]/(3*4+1)*)];
sampledPoints = Flatten[Rest[sampledPoints], 1];
ListPlot[sampledPoints, AspectRatio -> 1,
GridLines -> {Range[3]/3, Range[4]/4}]

It follows that for functions of the type 1/(a+(x+y)^2) or alike are well integrated with the "Example Implementation of a Local Adaptive Strategy" from the referred Wolfram Inc. article. Nice precision goals are easily and fast and with high reproducibility achieved.
This table extends the answer:

I recommend for the numerical part to evaluate the article in full perhaps some nice ideas to get more precision will be gained in the special case, but the article focusses on singularities more than 2-dimensional integration precision. It shows up many test on convergence and precision that are fun to apply. The article has 85 pages in length.
Here are calculation for reference with the Mathematica example for WorkingPrecision:
AG = 15;
PG = 15;
WP = 50;
Table[NIntegrate[SetPrecision[1/Sqrt[Sin[x]], wp + 2], {x, 0, 1},
Method -> {"GlobalAdaptive", "SymbolicProcessing" -> 0,
"SingularityHandler" -> None, MinRecursion -> 9},
PrecisionGoal -> AG, AccuracyGoal -> PG, WorkingPrecision -> WP,
IntegrationMonitor :> ((errors = Through[#1@"Error"]) &)] -
integexact, {wp, 20, 40, 2}]
Total@errors
{-0.0000403805375729249773658836249940223892505415071 + (
1176456130984411 I)/
10141204801825835211973625643008, \
-0.0000403805375729249773658836249940223892505415071 + (
1176456130984411 I)/
10141204801825835211973625643008, \
-0.0000403805375729249773658836249940223892505415071 + (
1176456130984411 I)/
10141204801825835211973625643008, \
-0.0000403805375729249773658836249940223892505415071 + (
1176456130984411 I)/
10141204801825835211973625643008, \
-0.0000403805375729249773658836249940223892505415071 + (
1176456130984411 I)/
10141204801825835211973625643008, \
-0.0000403805375729249773658836249940223892505415071 + (
1176456130984411 I)/
10141204801825835211973625643008, \
-0.0000403805375729249773658836249940223892505415071 + (
1176456130984411 I)/
10141204801825835211973625643008, \
-0.0000403805375729249773658836249940223892505415071 + (
1176456130984411 I)/
10141204801825835211973625643008, \
-0.0000403805375729249773658836249940223892505415071 + (
1176456130984411 I)/
10141204801825835211973625643008, \
-0.0000403805375729249773658836249940223892505415071 + (
1176456130984411 I)/
10141204801825835211973625643008, \
-0.0000403805375729249773658836249940223892505415071 + (
1176456130984411 I)/10141204801825835211973625643008}
0.000062690729178774772783412492441137149675804414387926

Table[NIntegrate[SetPrecision[1/Sqrt[Sin[x]], wp + 2], {x, 0, 1},
PrecisionGoal -> AG, AccuracyGoal -> PG, WorkingPrecision -> wp,
IntegrationMonitor :> ((errors = Through[#1@"Error"]) &)] -
integexact, {wp, 20, 40, 2}]
Total@errors
{4.972*10^-16 + (1176456130984411 I)/10141204801825835211973625643008,
4.97155*10^-16 + (1176456130984411 I)/
10141204801825835211973625643008,
4.9715456*10^-16 + (1176456130984411 I)/
10141204801825835211973625643008,
4.971545601*10^-16 + (1176456130984411 I)/
10141204801825835211973625643008,
4.97154560077*10^-16 + (1176456130984411 I)/
10141204801825835211973625643008,
4.9715456007147*10^-16 + (1176456130984411 I)/
10141204801825835211973625643008,
4.971545600714668*10^-16 + (1176456130984411 I)/
10141204801825835211973625643008,
4.97154560070974729*10^-16 + (1176456130984411 I)/
10141204801825835211973625643008,
4.9715456007097409096*10^-16 + (1176456130984411 I)/
10141204801825835211973625643008,
4.971545600709740909560*10^-16 + (1176456130984411 I)/
10141204801825835211973625643008,
4.97154560070974083528010*10^-16 + (1176456130984411 I)/
10141204801825835211973625643008}
4.93444152315623988446577100475728722424000980*10^-16
Happy use of Mathematica!
Integrate
, which you need to set up theintegrand
. Since your problem seems to be with the numerical integration, providing the pre-calculated results of the symbolic step would go a long way towards not wasting your bounty prize. Dump itsInputForm
into a pastebin or some such; do NOT provide a nb file though; those contain executable code, and most people don't open executable files from unknown sources. $\endgroup$