计算 $I_n=e^{-1}\int_0^1 x^n e^x\mathrm{d}x$ ($n=0,1,2,\ldots$)
容易证明
\[
I_n=\begin{cases}
1-nI_{n-1}, & n\geqslant 1,\\
1-e^{-1}, & n=0.
\end{cases}
\]
将递推公式改写为 $I_{n+1}=1-(n+1)*I_n$, 则使用 Sowya 可以计算如下:
首先计算 $I_0$:
>> setprecision(100)
Now the precision is: 100
------------------------
>> exp(1)
out> 2.7182818284590452353602874713526624977572470936999595749669676277240766303535475945713821785251664274
令 e 等于上面的 exp(1)
>> e=2.7182818284590452353602874713526624977572470936999595749669676277240766303535475945713821785251664274
>> 1-1/e
in> 1-1/2.7182818284590452353602874713526624977572470936999595749669676277240766303535475945713821785251664274
out> 0.6321205588285576784044762298385391325541888689682321654921631983025385042551001966428527256540803562
------------------------
然后再计算 $I_1=1-I_0$:
>> 1-0.6321205588285576784044762298385391325541888689682321654921631983025385042551001966428527256540803562
in> 1-0.6321205588285576784044762298385391325541888689682321654921631983025385042551001966428527256540803562
out> 0.3678794411714423215955237701614608674458111310317678345078368016974614957448998033571472743459196438
------------------------
利用 printRecursiveSeries() 函数(Pro版本中提供)计算 $I_n$, $n=1,2,3,\ldots,20$.
>> printRecursiveSeries(1-(n+1)*I_n,I_n,0.3678794411714423215955237701614608674458111310317678345078368016974614957448998033571472743459196438,20,\n,linenumber)
[1] 0.3678794411714423215955237701614608674458111310317678345078368016974614957448998033571472743459196438
[2] 0.2642411176571153568089524596770782651083777379364643309843263966050770085102003932857054513081607124
[3] 0.2072766470286539295731426209687652046748667861906070070470208101847689744693988201428836460755178628
[4] 0.1708934118853842817074295161249391813005328552375719718119167592609241021224047194284654156979285488
[5] 0.1455329405730785914628524193753040934973357238121401409404162036953794893879764028576729215103572560
[6] 0.1268023565615284512228854837481754390159856571271591543575027778277230636721415828539624709378564640
[7] 0.1123835040693008414398016137627719268881004001098859194974805552059385542950089200222627034350047520
[8] 0.1009319674455932684815870898978245848951967991209126440201555583524915656399286398218983725199619840
[9] 0.0916122929896605836657161909195787359432288079117862038185999748275759092406422416029146473203421440
[10] 0.0838770701033941633428380908042126405677119208821379618140002517242409075935775839708535267965785600
[11] 0.0773522288626642032287810011536609537551688702964824200459972310333500164706465763206112052376358400
[12] 0.0717732536480295612546279861560685549379735564422109594480332275997998023522410841526655371483699200
[13] 0.0669477025756157036898361799711087858063437662512575271755680412026025694208659060153480170711910400
[14] 0.0627321639413801483422934804044769987111872724823946195420474231635640281078773157851277610033254400
[15] 0.0590175408792977748655977939328450193321909127640807068692886525465395783818402632230835849501184000
[16] 0.0557193459312356021504352970744796906849453957747086900913815592553667458905557884306626407981056000
[17] 0.0527711191689947634425999497338452583559282718299522684465134926587653198605515966787351064322048000
[18] 0.0501198549580942580332009047907853495932911070608591679627571321422242425100712597827680842203136000
[19] 0.0477227557962090973691828089750783577274689658436758087076144892977393923086460641274063998140416000
[20] 0.0455448840758180526163438204984328454506206831264838258477102140452121538270787174518720037191680000
------------------------