FourierCosCoefficient is way more powerful than I expected. For example,
In[1] := Table[FourierCosCoefficient[1/(2 - 2 Cos[x]), x, i], {i, -5, 5, 1}]
Out[1] = {-5, -4, -3, -2, -1, 0, -1, -2, -3, -4, -5}
In[2] := FourierCosCoefficient[1/(4 - 2 Cos[x] - 2 Cos[y]), {x, y}, {2, 3}]
Out[2] = -((8/3 + \[Pi] - Log[2])/\[Pi])
These are indeed the correct results.
However, the functions above have singularities, so we can't obtain the results by just integration.
How does FourierCosCoefficient find the results? What algorithm does FourierCosCoefficient take for the above examples?
1/(2 - 2 Cos[x])is a usual function, not a generalised function. Its Fourier series does not exist since the function is not integrable on $[-\pi,\pi]$. Just to compare, the code of Maplewith(OrthogonalExpansions):FourierSeries(1/(2-2*cos(x)), x = -Pi .. Pi, n, 'Coefficients');results in $${\frac {\infty }{\pi}}+\sum {i=1}^{n} \left( {\frac {\cos \left( ix \right) }{\pi}\int{-\pi}^{\pi}!{\frac {\cos \left( ix \right) }{2-2 ,\cos \left( x \right) }},{\rm d}x} \right) $$ and , for example,int(cos(3*x)/(2-2*cos(x)), x = -Pi .. Pi);performs $\infty$. – user64494 Mar 03 '24 at 06:59Integrate[ 1/(4 - 2 Cos[x] - 2 Cos[y])*Cos[2 x]*Cos[3 y], {x, -Pi, Pi}, {y, -Pi, Pi}]crashes my comp. – user64494 Mar 03 '24 at 08:46Sum[RealAbs[n]*Exp[I*n*x], {n, -k, k}]results in(1/((-1 + E^( I x))^2))E^(-I k x) (-E^(I x) + E^(I (1 + k) x) + E^(I x + I k x) - E^(I k x + I (1 + k) x) + k - E^(I x) k - E^(I k x + I (1 + k) x) k + E^(I k x + I (2 + k) x) k)BothLimitandDiscreteLimitof it ask->Infinityreturn the inputs. Substitution{k -> 100, x -> 1.}results in-6.75723 + 1.64313*10^-14 I, substitution{k -> 1000, x -> 1.produces2075.02 + 0. I. – user64494 Mar 03 '24 at 09:12Table[FourierSinCoefficient[1/(2 - 2 Sin[x]), x, i], {i, -5, 5, 1}]returns{5 + 46/(3 \[Pi]), 0, -3 - 10/\[Pi], 0, ( 2 + \[Pi])/\[Pi], 0, -((2 + \[Pi])/\[Pi]), 0, 3 + 10/\[Pi], 0, -5 - 46/(3 \[Pi])}though the function is not odd. – user64494 Mar 03 '24 at 09:42