Skip to main content
replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/
Source Link

Here's an extrapolatory approach based on Richardson extrapolation of the integrals over each "period." (Richardson[] code from Anton Antonov's answer hereAnton Antonov's answer here):

Clear[Richardson]
Richardson[A_, n_, N_] := 
 Total@Table[(A[n + k]*(n + k)^N*If[OddQ[k + N], -1, 1])/(k! (N - k)!), {k, 0, N}]

(* the integral from 2 n Pi to 2 (n+1) Pi *)
Clear[aa];
aa[n_Integer /; n >= 0] := 
  aa[n] = NIntegrate[ArcCot[x]*Sin[x]/(5/4 + Cos[x]), {x, 2 n Pi, 2 (n + 1) Pi}, 
    WorkingPrecision -> 50];

We get around machine precision with 100 terms plus 6 extrapolation terms:

sf[n_] := Sum[aa[i], {i, 0, n}]; (* partial sum = integral over {0, 2 (n+1) Pi} *)
Richardson[sf, 100, 6]
% - Pi*Log[3/2/(1 + 1/2*Exp[-1])]
(*
  0.743355751361227474780881457479018423835    
  -2.97535713733265290609713*10^-16
*)

Without extrapolation:

sf[100]
% - Pi*Log[3/2/(1 + 1/2*Exp[-1])]
(*
  0.74207790286093203962531860751097243182349263171074
  -0.00127784850029573269127658323333660172377741318898
*)

Update

More extrapolatory terms yields an approximation accurate to machine precision with many fewer terms overall:

Richardson[sf, 1, 16]
% - Pi*Log[3/2/(1 + 1/2*Exp[-1])]
(*
  0.74335575136122767678505611095516483469029
  -9.553153907978914419885698*10^-17
*)

Here's an extrapolatory approach based on Richardson extrapolation of the integrals over each "period." (Richardson[] code from Anton Antonov's answer here):

Clear[Richardson]
Richardson[A_, n_, N_] := 
 Total@Table[(A[n + k]*(n + k)^N*If[OddQ[k + N], -1, 1])/(k! (N - k)!), {k, 0, N}]

(* the integral from 2 n Pi to 2 (n+1) Pi *)
Clear[aa];
aa[n_Integer /; n >= 0] := 
  aa[n] = NIntegrate[ArcCot[x]*Sin[x]/(5/4 + Cos[x]), {x, 2 n Pi, 2 (n + 1) Pi}, 
    WorkingPrecision -> 50];

We get around machine precision with 100 terms plus 6 extrapolation terms:

sf[n_] := Sum[aa[i], {i, 0, n}]; (* partial sum = integral over {0, 2 (n+1) Pi} *)
Richardson[sf, 100, 6]
% - Pi*Log[3/2/(1 + 1/2*Exp[-1])]
(*
  0.743355751361227474780881457479018423835    
  -2.97535713733265290609713*10^-16
*)

Without extrapolation:

sf[100]
% - Pi*Log[3/2/(1 + 1/2*Exp[-1])]
(*
  0.74207790286093203962531860751097243182349263171074
  -0.00127784850029573269127658323333660172377741318898
*)

Update

More extrapolatory terms yields an approximation accurate to machine precision with many fewer terms overall:

Richardson[sf, 1, 16]
% - Pi*Log[3/2/(1 + 1/2*Exp[-1])]
(*
  0.74335575136122767678505611095516483469029
  -9.553153907978914419885698*10^-17
*)

Here's an extrapolatory approach based on Richardson extrapolation of the integrals over each "period." (Richardson[] code from Anton Antonov's answer here):

Clear[Richardson]
Richardson[A_, n_, N_] := 
 Total@Table[(A[n + k]*(n + k)^N*If[OddQ[k + N], -1, 1])/(k! (N - k)!), {k, 0, N}]

(* the integral from 2 n Pi to 2 (n+1) Pi *)
Clear[aa];
aa[n_Integer /; n >= 0] := 
  aa[n] = NIntegrate[ArcCot[x]*Sin[x]/(5/4 + Cos[x]), {x, 2 n Pi, 2 (n + 1) Pi}, 
    WorkingPrecision -> 50];

We get around machine precision with 100 terms plus 6 extrapolation terms:

sf[n_] := Sum[aa[i], {i, 0, n}]; (* partial sum = integral over {0, 2 (n+1) Pi} *)
Richardson[sf, 100, 6]
% - Pi*Log[3/2/(1 + 1/2*Exp[-1])]
(*
  0.743355751361227474780881457479018423835    
  -2.97535713733265290609713*10^-16
*)

Without extrapolation:

sf[100]
% - Pi*Log[3/2/(1 + 1/2*Exp[-1])]
(*
  0.74207790286093203962531860751097243182349263171074
  -0.00127784850029573269127658323333660172377741318898
*)

Update

More extrapolatory terms yields an approximation accurate to machine precision with many fewer terms overall:

Richardson[sf, 1, 16]
% - Pi*Log[3/2/(1 + 1/2*Exp[-1])]
(*
  0.74335575136122767678505611095516483469029
  -9.553153907978914419885698*10^-17
*)
Added example
Source Link
Michael E2
  • 244.7k
  • 18
  • 351
  • 774

Here's an extrapolatory approach based on Richardson extrapolation of the integrals over each "period." (Richardson[] code from Anton Antonov's answer here):

Clear[Richardson]
Richardson[A_, n_, N_] := 
 Total@Table[(A[n + k]*(n + k)^N*If[OddQ[k + N], -1, 1])/(k! (N - k)!), {k, 0, N}]

(* the integral from 2 n Pi to 2 (n+1) Pi *)
Clear[aa];
aa[n_Integer /; n >= 0] := 
  aa[n] = NIntegrate[ArcCot[x]*Sin[x]/(5/4 + Cos[x]), {x, 2 n Pi, 2 (n + 1) Pi}, 
    WorkingPrecision -> 50];

We get around machine precision with 100 terms plus 6 extrapolation terms:

sf[n_] := Sum[aa[i], {i, 0, n}]; (* partial sum = integral over {0, 2 (n+1) Pi} *)
Richardson[sf, 100, 6]
% - Pi*Log[3/2/(1 + 1/2*Exp[-1])]
(*
  0.743355751361227474780881457479018423835    
  -2.97535713733265290609713*10^-16
*)

Without extrapolation:

sf[100]
% - Pi*Log[3/2/(1 + 1/2*Exp[-1])]
(*
  0.74207790286093203962531860751097243182349263171074
  -0.00127784850029573269127658323333660172377741318898
*)

Update

More extrapolatory terms yields an approximation accurate to machine precision with many fewer terms overall:

Richardson[sf, 1, 16]
% - Pi*Log[3/2/(1 + 1/2*Exp[-1])]
(*
  0.74335575136122767678505611095516483469029
  -9.553153907978914419885698*10^-17
*)

Here's an extrapolatory approach based on Richardson extrapolation of the integrals over each "period." (Richardson[] code from Anton Antonov's answer here):

Clear[Richardson]
Richardson[A_, n_, N_] := 
 Total@Table[(A[n + k]*(n + k)^N*If[OddQ[k + N], -1, 1])/(k! (N - k)!), {k, 0, N}]

(* the integral from 2 n Pi to 2 (n+1) Pi *)
Clear[aa];
aa[n_Integer /; n >= 0] := 
  aa[n] = NIntegrate[ArcCot[x]*Sin[x]/(5/4 + Cos[x]), {x, 2 n Pi, 2 (n + 1) Pi}, 
    WorkingPrecision -> 50];

We get around machine precision with 100 terms plus extrapolation:

sf[n_] := Sum[aa[i], {i, 0, n}]; (* partial sum = integral over {0, 2 (n+1) Pi} *)
Richardson[sf, 100, 6]
% - Pi*Log[3/2/(1 + 1/2*Exp[-1])]
(*
  0.743355751361227474780881457479018423835    
  -2.97535713733265290609713*10^-16
*)

Without extrapolation:

sf[100]
% - Pi*Log[3/2/(1 + 1/2*Exp[-1])]
(*
  0.74207790286093203962531860751097243182349263171074
  -0.00127784850029573269127658323333660172377741318898
*)

Here's an extrapolatory approach based on Richardson extrapolation of the integrals over each "period." (Richardson[] code from Anton Antonov's answer here):

Clear[Richardson]
Richardson[A_, n_, N_] := 
 Total@Table[(A[n + k]*(n + k)^N*If[OddQ[k + N], -1, 1])/(k! (N - k)!), {k, 0, N}]

(* the integral from 2 n Pi to 2 (n+1) Pi *)
Clear[aa];
aa[n_Integer /; n >= 0] := 
  aa[n] = NIntegrate[ArcCot[x]*Sin[x]/(5/4 + Cos[x]), {x, 2 n Pi, 2 (n + 1) Pi}, 
    WorkingPrecision -> 50];

We get around machine precision with 100 terms plus 6 extrapolation terms:

sf[n_] := Sum[aa[i], {i, 0, n}]; (* partial sum = integral over {0, 2 (n+1) Pi} *)
Richardson[sf, 100, 6]
% - Pi*Log[3/2/(1 + 1/2*Exp[-1])]
(*
  0.743355751361227474780881457479018423835    
  -2.97535713733265290609713*10^-16
*)

Without extrapolation:

sf[100]
% - Pi*Log[3/2/(1 + 1/2*Exp[-1])]
(*
  0.74207790286093203962531860751097243182349263171074
  -0.00127784850029573269127658323333660172377741318898
*)

Update

More extrapolatory terms yields an approximation accurate to machine precision with many fewer terms overall:

Richardson[sf, 1, 16]
% - Pi*Log[3/2/(1 + 1/2*Exp[-1])]
(*
  0.74335575136122767678505611095516483469029
  -9.553153907978914419885698*10^-17
*)
Source Link
Michael E2
  • 244.7k
  • 18
  • 351
  • 774

Here's an extrapolatory approach based on Richardson extrapolation of the integrals over each "period." (Richardson[] code from Anton Antonov's answer here):

Clear[Richardson]
Richardson[A_, n_, N_] := 
 Total@Table[(A[n + k]*(n + k)^N*If[OddQ[k + N], -1, 1])/(k! (N - k)!), {k, 0, N}]

(* the integral from 2 n Pi to 2 (n+1) Pi *)
Clear[aa];
aa[n_Integer /; n >= 0] := 
  aa[n] = NIntegrate[ArcCot[x]*Sin[x]/(5/4 + Cos[x]), {x, 2 n Pi, 2 (n + 1) Pi}, 
    WorkingPrecision -> 50];

We get around machine precision with 100 terms plus extrapolation:

sf[n_] := Sum[aa[i], {i, 0, n}]; (* partial sum = integral over {0, 2 (n+1) Pi} *)
Richardson[sf, 100, 6]
% - Pi*Log[3/2/(1 + 1/2*Exp[-1])]
(*
  0.743355751361227474780881457479018423835    
  -2.97535713733265290609713*10^-16
*)

Without extrapolation:

sf[100]
% - Pi*Log[3/2/(1 + 1/2*Exp[-1])]
(*
  0.74207790286093203962531860751097243182349263171074
  -0.00127784850029573269127658323333660172377741318898
*)