The numerics of FresnelS[]

I think this is worth reporting to Support.

For instance, using formula 7.5.8 from the DLMF:

With[{x = N[8 + 1*^-28, 32]}, 
     With[{ζ = Sqrt[π] (1 - I) x/2}, Im[(1 + I)/2 Erf[ζ]]]]
   0.46021421439301448386198863207105

and the result is comparable to evaluating N[FresnelS[8 + 1*^-28], 32].


In theory, one is supposed to use the auxiliary functions $f(z)$ and $g(z)$ for computing Fresnel integrals of moderate or large arguments. However,

With[{x = N[8 + 1*^-28, 32]}, {FresnelG[x], FresnelF[x]}]
   {0.00019781962280286444301613974000765, 0.0392}

and assembling FresnelS[] from that yields

With[{x = N[8 + 1*^-28, 32]},
     {gg, ff} = {FresnelG[x], FresnelF[x]};
     1/2 - ff Cos[π x^2/2] - gg Sin[π x^2/2]]
   0.4608

Contrast this with (cf. formula 7.5.10):

With[{x = N[8 + 1*^-28, 32]}, 
     With[{ζ = Sqrt[π] (1 - I) x/2}, 
          ReIm[(1 + I)/2 Exp[ζ^2] Erfc[ζ]]]]
   {0.000197819622802864443016139740, 0.039785785606985516138011367928}

which works much better:

With[{x = N[8 + 1*^-28, 32]},
     With[{ζ = Sqrt[π] (1 - I) x/2},
          {gg, ff} = ReIm[(1 + I)/2 Exp[ζ^2] Erfc[ζ]]];
     1/2 - ff Cos[Pi x^2/2] - gg Sin[Pi x^2/2]]
   0.460214214393014483861988632071

The incorrect result is:

FresnelS[N[8+1*^-28, 32]] //InputForm

0.4607524835944079246`3.970167826243401

Note that the precision of the output is 3.97, indicating that the 4th digit may not be accurate, which is exactly what you observe. If you increase the precision:

FresnelS[N[8+1*^-28, 43]] //InputForm

0.4607524835944079246`3.970167826243401

You still only get approximately 4 digits of precision. A further increase to 44 does produce a better answer:

FresnelS[N[8+1*^-28, 44]] //InputForm

0.4602142143930144838619886320710524339132605359776113605072`40.31143196057397

I think having the same result for 32 and 43 digits of precision looks suspicious, and the fact that approximately an additional 16 digits of precision (beyond the 28) are needed to get a correct result suggests that there may be some incorrect machine number approximation being used under the hood. I would also suggest reporting this issue to support.