# Is this behaviour of the Hypergeometric function $\,_3F_2$ correct and how can I tell?

I have the following function:

L[n_, t_] := Abs[2/Pi*(2 n - 1)!!^2/((2 n)! (2 n - 1)^2)  *
HypergeometricPFQ[{3/2, 1/2 - n, 1/2 - n}, {3/2 - n, 3/2 - n}, Exp[-2 I*t]]]^2


If I now plot this function, let's say:

Plot[L[n, t], {t, 0, Pi/2}, PerformanceGoal -> "Speed"]


Then, very "smooth" results are yielded until n=16. For n>16, the plot becomes really oscillatory, which seems weird to me.

I wonder whether this is a numeric problem and how to find out whether it is? I evaluated some values with high precision and they seem to agree with the plot... This is what I tested, for example:

 Lo[N[17, 200], N[0.273, 100]]=0.

• You're observing numerical instabilities in fixed-precision arithmetic. Take advantage of Mathematica's arbitrary precision capabilities by adding the option WorkingPrecision->20 to the Plot. Raise the setting as needed to address any observed instabilities. – QuantumDot Jul 20 '17 at 13:35

Apperantely the machine precision can be limiting, see the help function for HypergeometricPFQ.

Machine-precision input may be insufficient to get a correct answer:

In:= HypergeometricPFQ[{10, 10}, {50}, 2.]

Out= -12642.7 + 12642.7 I


With exact input, the answer is correct:

In:= N[HypergeometricPFQ[{10, 10}, {50}, 2], 20]

Out= -1705.7573316355444417 - 356.7499860560238175 I


If we plot it with exact inputs, i.e.

ListPlot[Table[{t, L[17, t]}, {t, 0, π/2, π/100}]]


we get the right result: We can also increase WorkingPrecision like QuantumDot suggests:

Plot[L[17, t], {t, 0, π/2}, WorkingPrecision -> 30] • The diagnosis is essentially right. See my comment to the OP to effect a cure to Plot. – QuantumDot Jul 20 '17 at 13:37

One approach is to use the adaptive precision control built into N. Three digits is usually enough for plotting. Start by setting the precision of the input to Infinity, which converts it to the exact fraction represented by the binary floating-point number:

Block[{f},
f[t_?NumericQ] := With[{tt = SetPrecision[t, Infinity]}, N[L[17, tt], 3]];
Plot[f[t], {t, 0, Pi/2}]
] // AbsoluteTiming It's faster than a set arbitrary precision:

Plot[L[17, t], {t, 0, Pi/2},
WorkingPrecision -> 20] // AbsoluteTiming 