Topic

The Fourier transform

A Fourier series describes a function on an interval by a list of coefficients. The Fourier transform does the same for a function on the whole line, and the list becomes a function of a continuous frequency. fourierTransform(f) gives its values as certified enclosures, and, when f is one of the standard pairs, the formula as well.

const T = fourierTransform("exp(-x^2)");
T.at(2);                 // { re, im }: two certified integrals
T.formula.text;          // "sqrt(pi)*exp(-1/4*w^2)"
T.check("1/3").agrees;   // formula and integral side by side
T.parseval();            // { time, frequency, agrees }
T.inversion("1/2");      // the inverse transform beside f(1/2)
F(ω)=∫−∞∞f(x) e−iωx dx,f(x)=12π∫−∞∞F(ω) eiωx dω. F(\omega) = \int_{-\infty}^{\infty} f(x)\,e^{-i\omega x}\,dx, \qquad f(x) = \frac{1}{2\pi}\int_{-\infty}^{\infty} F(\omega)\,e^{i\omega x}\,d\omega .

That is the default convention, "angular". convention: "unitary" puts 1/2π1/\sqrt{2\pi} on both integrals, and "frequency" uses e−2πiξxe^{-2\pi i \xi x} with no factor on either. Whichever is chosen is used consistently by the inverse, by Parseval and by the checks.

Values

Since e−iωx=cos⁡ωx−isin⁡ωxe^{-i\omega x} = \cos\omega x - i\sin\omega x, the real part of F(ω) is the integral of f(x) cos ωx and the imaginary part is minus the integral of f(x) sin ωx. Each is an improper integral, and at(ω) returns the two enclosures. They are proven: the part of the line far out is bounded from the leading behaviour of f, which is the reason the function must be absolutely integrable. For 1/(1 + |x|) the integral of |f| diverges and at refuses. A function that is zero outside an interval is given with support: [a, b]; an end may be "inf".

When f decays only like a power of x, the far part is known only by a bound and the enclosure is correspondingly wider (a few digits for 1/(1 + x²)). It is still an enclosure.

The standard pairs

f(x)F(ω)name
e−ax2e^{-ax^2}π/a  e−ω2/4a\sqrt{\pi/a}\;e^{-\omega^2/4a}Gaussian
e−a∣x∣e^{-a|x|}2aa2+ω2\dfrac{2a}{a^2 + \omega^2}two-sided exponential
1x2+s2\dfrac{1}{x^2 + s^2}πs e−s∣ω∣\dfrac{\pi}{s}\,e^{-s|\omega|}Lorentzian
e−axe^{-ax} for x > 0, else 01a+iω\dfrac{1}{a + i\omega}one-sided exponential
1 on [a, b], else 0e−iaω−e−ibωiω\dfrac{e^{-ia\omega} - e^{-ib\omega}}{i\omega}box

Three rules extend the table. A shift f(x − c) multiplies the transform by e−icωe^{-ic\omega}. Multiplying f by x differentiates the transform: xf(x)↦i F′(ω)x f(x) \mapsto i\,F'(\omega). And the transform is linear, so sums go term by term. With these, fourierTransform recognises any sum of terms of the form polynomial times e−ax2+bx+ce^{-ax^2 + bx + c} or polynomial times e−a∣x−m∣e^{-a|x - m|}, the Lorentzian with any centre, polynomial times e−axe^{-ax} on [0, ∞), and constants on a finite interval.

A formula found this way is compared with the certified integrals at two frequencies before it is returned, so its trust is "checked": a wrong formula cannot come back. When f is not in the table, formula is null and the values are still available.

Parseval and inversion

∫−∞∞∣f(x)∣2 dx=12π∫−∞∞∣F(ω)∣2 dω. \int_{-\infty}^{\infty} |f(x)|^2\,dx = \frac{1}{2\pi}\int_{-\infty}^{\infty} |F(\omega)|^2\,d\omega .

parseval() encloses both sides, the right one from the formula, and reports whether the enclosures meet. inversion(x) does the same for the inversion theorem: the inverse transform of the formula at x beside f(x). inverseFourier(F) is the inverse on its own, for a formula F you supply (a string for a real F, or { re, im }).

Convolution

(f∗g)(x)=∫−∞∞f(t) g(x−t) dt,f∗g^=f^ g^. (f * g)(x) = \int_{-\infty}^{\infty} f(t)\,g(x - t)\,dt, \qquad \widehat{f * g} = \hat f\,\hat g .

convolution(f, g).at(x) is the integral, enclosed. .theorem(x) computes the same number a second way, as the inverse transform of the product of the two formulas, and checks that the two enclosures meet.

The heat equation on the whole line

Transforming ut=k uxxu_t = k\,u_{xx} in x turns it into u^t=−kω2u^\hat u_t = -k\omega^2 \hat u, so each frequency simply decays: u^(ω,t)=F(ω) e−kω2t\hat u(\omega, t) = F(\omega)\,e^{-k\omega^2 t}. Multiplying by a Gaussian in ω is convolving with a Gaussian in x:

u(x,t)=∫−∞∞f(y) e−(x−y)2/4kt4πkt dy. u(x, t) = \int_{-\infty}^{\infty} f(y)\,\frac{e^{-(x - y)^2/4kt}}{\sqrt{4\pi k t}}\,dy .

heatLine({ k, initial }) gives at(x, t) from that integral, viaTransform(x, t) from the decaying frequencies, and check(x, t) for both together. heat() is the total ∫u dx\int u\,dx, which does not change with time. On an interval the same equation is solved by Fourier series, and the wave equation on the whole line is wave({ c, position, velocity }) with no length, by d'Alembert's formula.

callreturns
fourierTransform(f, { variable = "x", frequency = "w", convention, support, digits = 15 })FourierTransform
T.at(ω), T.formulaAt(ω){ re, im } of RationalInterval
T.formula, T.pairs{ re, im, text, trust } or null; the names of the pairs used
T.check(ω), T.parseval(), T.inversion(x)both sides and agrees
inverseFourier(F, { variable = "w", convention }).at(x){ re, im }
convolution(f, g).at(x), .theorem(x)RationalInterval; { convolution, viaTransforms, transform, agrees }
heatLine({ k = 1, initial, support }).at(x, t), .viaTransform(x, t), .check(x, t), .heat()RationalInterval
Try itEdit the code and run it with @ratmath/analytic and Core's R, Rational, RationalInterval in scope. The last line's value is shown; PRINT(…) adds lines, TEX(…) typesets math.
Ctrl/⌘ + Enter runs