Skip to content

FourierCoefficient ​

The nn-th complex Fourier coefficient of ff on [−π,π][-\pi, \pi], cn=12π∫−ππf(x) e−inx dxc_n = \frac{1}{2\pi}\int_{-\pi}^{\pi} f(x)\, e^{-inx}\,dx, for a concrete integer nn — a curated set of closed forms, not compute-engine's Integrate.

✓ checked against that system · ! checked, with disagreements (hover a chip)Wolfram LanguageFourierCoefficient!
FourierCoefficient(f, x, n)cnc_n, for a concrete integer nn.
Typed signatures
TypePackageApplies
(expression, expression, integer) -> expressionanalyticalways

Domain: Transforms

Details
  • Covered, combined by linearity (a sum, a negation, a constant factor free of xx):
  • - a trig monomial cos⁡(x)psin⁡(x)q\cos(x)^p \sin(x)^q (nonnegative integer p,qp, q — a plain cos⁡(x)\cos(x) or sin⁡(x)\sin(x) is p=1,q=0p=1,q=0 or p=0,q=1p=0,q=1), via the exponential binomial expansion cos⁡(x)=(E+E−1)/2\cos(x) = (E+E^{-1})/2, sin⁡(x)=(E−E−1)/(2i)\sin(x) = (E-E^{-1})/(2i), E=eixE = e^{ix} -- exact, and what covers a "sin/cos polynomial" like cos⁡2(x)\cos^2(x) (checked against Wolfram directly).
  • - cos⁡(mx)\cos(mx) / sin⁡(mx)\sin(mx) for a nonzero integer mm -- one resonant pair of terms.
  • - xx, x2x^2, ∣x∣|x|: the standard sawtooth, parabola, and triangle-wave coefficients.
  • - xm\sqrt[m]{x} for odd mm (the real root, an odd function): ckc_k in Γ\Gamma and the exponential integral E−1/m(±ikπ)E_{-1/m}(\pm ik\pi), checked against Wolfram and numerical quadrature.
  • - eaxe^{ax} for a nonzero real constant aa: cn=(−1)nsinh⁡(aπ)/(π(a−in))c_n = (-1)^n \sinh(a\pi)/(\pi(a - in)).
  • Declined, on purpose: a symbolic order nn (Wolfram answers with a Piecewise closed form there, which is a materially bigger derivation than any single one of the atoms above and not attempted here); xkx^k for k>2k > 2; a mixed polynomial-times-trig product like xcos⁡(x)x\cos(x); and anything else outside the list -- correctness over coverage.
  • Deliberately NOT built on compute-engine's own Integrate, which probing found both too weak to reach most of these forms (it declines x^2 * Cos(2x) outright) and, on one it does answer, silently wrong -- Integrate(Abs(x) * Exp(-ix), {x, -pi, pi}) comes back exactly half of what an independent numeric quadrature gives.

Examples

Basic #

c2c_2 of the sawtooth xx is i(−1)2/2=i/2i(-1)^2/2 = i/2

live ↗
InFourierCoefficient(x,x,2)\mathrm{FourierCoefficient}(x, x, 2)Out12i\frac{1}{2}i

Coefficient 5 of t2+tt^2+t is complex, −225−i5-\frac{2}{25} - \frac{i}{5}

live ↗
InFourierCoefficient(t2+t,t,5)\mathrm{FourierCoefficient}(t^2+t, t, 5)Out−225−15i-\frac{2}{25}-\frac{1}{5}i
Scope #

c2c_2 of cos⁡2(x)=12+12cos⁡(2x)\cos^2(x) = \tfrac12+\tfrac12\cos(2x) is 1/41/4 -- a sin/cos polynomial, via the binomial expansion

live ↗
InFourierCoefficient(cos⁡(x)2,x,2)\mathrm{FourierCoefficient}(\cos(x)^2, x, 2)Out14\frac{1}{4}

c0c_0 of x2x^2 is its average value, π2/3\pi^2/3

live ↗
InFourierCoefficient(x2,x,0)\mathrm{FourierCoefficient}(x^2, x, 0)Outπ23\frac{π^2}{3}

c0c_0 of the triangle wave ∣x∣|x| is π/2\pi/2

live ↗
InFourierCoefficient(∣x∣,x,0)\mathrm{FourierCoefficient}(\vert x\vert, x, 0)Outπ2\frac{π}{2}

c1c_1 of ∣x∣|x| is −2/π-2/\pi -- checked against an independent numeric quadrature, since Wolfram's own Integrate gets this one wrong by a factor of 2

live ↗
InFourierCoefficient(∣x∣,x,1)\mathrm{FourierCoefficient}(\vert x\vert, x, 1)Out−2π-\frac{2}{π}

c1c_1 of exe^x, algebraically equal to Wolfram's own i(−1)1sinh⁡(π)/((i+1)π)i(-1)^1\sinh(\pi)/((i+1)\pi)

live ↗
InFourierCoefficient(ex,x,1)\mathrm{FourierCoefficient}(e^{x}, x, 1)Out1π((−12−12i)sinh⁡(π))\frac{1}{π}((-\frac{1}{2}-\frac{1}{2}i)\sinh(π))
live ↗
InFourierCoefficient(exp⁡(−t),t,3)\mathrm{FourierCoefficient}(\exp(-t), t, 3)Out1π((−110+310i)sinh⁡(π))\frac{1}{π}((-\frac{1}{10}+\frac{3}{10}i)\sinh(π))
Properties #

Coefficient 3 follows the same −2n2−in-\frac{2}{n^2} - \frac{i}{n} pattern

live ↗
InFourierCoefficient(t2+t,t,3)\mathrm{FourierCoefficient}(t^2+t, t, 3)Out−29−13i-\frac{2}{9}-\frac{1}{3}i
live ↗
In∑n=−22FourierCoefficient(t2+t,t,n)exp⁡(int)\sum_{n=-2}^2\mathrm{FourierCoefficient}(t^2+t, t, n)\exp(i nt)Out(−2−i)exp⁡(it)+(12−12i)exp⁡(−2it)+(12+12i)exp⁡(2it)+(−2+i)exp⁡(−it)+π23(-2-i)\exp(i t)+(\frac{1}{2}-\frac{1}{2}i)\exp(-2i t)+(\frac{1}{2}+\frac{1}{2}i)\exp(2i t)+(-2+i)\exp(-i t)+\frac{π^2}{3}
Possible issues #

Declines a symbolic order nn -- not cheap the way a concrete integer is

live ↗
InFourierCoefficient(x,x,n)\mathrm{FourierCoefficient}(x, x, n)OutFourierCoefficient(x,x,n)\mathrm{FourierCoefficient}(x, x, n)

Declines tan⁡(x)\tan(x) -- it has poles inside [−π,π][-\pi, \pi], so the defining integral doesn't actually converge, even though Wolfram formally returns 0 by symmetry

live ↗
InFourierCoefficient(tan⁡(x),x,1)\mathrm{FourierCoefficient}(\tan(x), x, 1)OutFourierCoefficient(tan⁡(x),x,1)\mathrm{FourierCoefficient}(\tan(x), x, 1)
About
Examples12
Checked againstWolfram Language 10 agree2 differ
CrosswalkWolfram Language

Implementation

primitive · kernela kernel — an algorithm over mutable state that would not be readable as a tree

nativeenginetypescriptpackages/symbols/analysis/analytic/src/fourier-series.ts

See also: FourierSeries, Fourier