2

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?

user64494
  • 26,149
  • 4
  • 27
  • 56
Leo
  • 131
  • 2
  • I remembered now from class, that at point of discontinuity of the function, the series converges to the average of the function at that point. But not sure this helps with your function, since at zero it blows up. But see Fouriercoscoefficient-for-generalized-function-with-singularity for related discuassion – Nasser Mar 01 '24 at 23:45
  • 1
    I'm currently teaching EE261, The Fourier transform and its applications at Stanford (using Mathematica) and can confirm that such series converge to the average of limits on either side of a discontinuity. The square wave function is the clearest case. – David G. Stork Mar 02 '24 at 00:24
  • @Nasser Hi, the "Fourier series coefficient" of $f(x)=(2-2\cos{x})^{-1}$ is $\tilde{f}n = -|n|/2$. This is not a conventional Fourier series because $\sum{n=-\infty}^{\infty} |n|\exp{\mathrm{i}nx}$ is nowhere convergent. The proper way is to understand it as the Fourier transformation between a distribution on $\mathbb{R}/2\pi\mathbb{Z}$ and a distribution on $\mathbb{Z}$. I'm surprised that Mathematica can give results in this vastly generalized sense. – Leo Mar 02 '24 at 00:28
  • @Nasser: The link refers to this actual page. What was your intention? – azerbajdzan Mar 02 '24 at 09:45
  • @Leo: Fourier series are meant for functions without a pole. So I am not sure that in such a case the result is always correct and coincides with some extensions/generalizations of Fourier series. – azerbajdzan Mar 02 '24 at 09:50
  • Opps, no I pasted wrong link. Here it is again integrate-does-not-converge-while-fourier-transform-does there few more like this as well. – Nasser Mar 02 '24 at 12:57
  • The function defined by 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 Maple with(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:59
  • [CASE:5119482] has been submitted by me. – user64494 Mar 03 '24 at 07:04
  • Concerning you second example, Integrate[ 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:46
  • 1
    @user64494: Can you stop editing OP question if you do not understand the topic? Leave the title as it was typed by OP. – azerbajdzan Mar 03 '24 at 08:50
  • @azerbajdzan: Please indicate the distribution (generalized function) in the question. – user64494 Mar 03 '24 at 08:53
  • @Leo: Concerning your comment, Sum[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) Both Limit and DiscreteLimit of it as k->Infinity return the inputs. Substitution {k -> 100, x -> 1.} results in -6.75723 + 1.64313*10^-14 I, substitution {k -> 1000, x -> 1. produces 2075.02 + 0. I. – user64494 Mar 03 '24 at 09:12
  • Table[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

1 Answers1

1

I think FourierCosCoefficient is simply ignoring pole of the function at x=0. We can see it by computing indefinite integral and then substituting upper and lower bounds of integration - we get the same result as FourierCosCoefficient.

I am not sure whether it is a feature or simply a bug.

Table[1/π Integrate[1/(2 - 2 Cos[x]) Cos[k x], x], {k, -5, 5}];
(# /. x -> π) - (# /. x -> -π) & /@ %

{-5, -4, -3, -2, -1, 0, -1, -2, -3, -4, -5}
azerbajdzan
  • 15,863
  • 1
  • 16
  • 48
  • Would this not be wrong math if this is what Mathematica did? Since Fundamental Theorem of Calculus which you used can't be applied if the integrand is not Continuous between the limits of integration? Can FTC really be used if there are countable number of poles between the limits? I did not think so. – Nasser Mar 02 '24 at 23:30
  • This is definitely a bug in FourierCoefficient: Integrate[1/(2 - 2 Cos[x])*Cos[3*x], {x, -Pi, Pi}] performs "Integrate::idiv: Integral of Cos[3 x]/(2-2 Cos[x]) does not converge on {-[Pi],[Pi]}.". – user64494 Mar 03 '24 at 07:02
  • [CASE:5119482] has been submitted by me. – user64494 Mar 03 '24 at 07:04
  • 1
    @Nasser: As OP said in his comments it can have some sense not as a function but as a distribution. – azerbajdzan Mar 03 '24 at 08:07
  • @azerbajdzan: Are you serious? Can you indicate this distribution (generalized function)? – user64494 Mar 03 '24 at 08:18
  • 1
    @user64494: Have you read OP comment under the question? His explanation is more concrete. – three777 Mar 03 '24 at 08:35
  • @three777: Can you indicate this distribution (generalized function)? OP does not do it. – user64494 Mar 03 '24 at 08:48
  • @azerbajdzan: There is no distribution (generalized function) in the question. There are functions with singularities which have no Fourier series in the question. – user64494 Mar 03 '24 at 08:51