Course Test · University: upper level
Fourier analysis and transforms: RatMath answers
The same twenty exercises, answered with RatMath Core and the Shelf libraries only. The code below was run when this page was built; its output is shown as printed, and compared with the independent answer.
Agrees 20
Libraries used here: core, analytic, symbolic. In this code each library is in scope under its own name (linalg.det, stats.tTest), and Core's names (R, Rational, …) are in scope directly.
- 1.Square waveAgreesFind the Fourier series of the square wave on , on , period 2, up to .Independent answeris odd, so only sines: , i.e. for odd . , with .RatMath code
const F = analytic.fourier("-1 if -1:x:!0; 1 if 0:x:1", [-1, 1], { terms: 3 }).exact(); [F.b[1], F.b[2], F.b[3]]Output[1.273239544735[14738003:25132866], -0.00000000000005197431:0.00000000000005197431, 0.4244131815[6729961113:9764525427]]
Intervals must have rational ends, so the textbook cannot be used (fourier("x", ["-pi", "pi"])is refused); the course's period-2 versions are used instead. - 2.SawtoothAgreesFind the Fourier coefficients of on .Independent answerOdd: : .RatMath code
const F = analytic.fourier("x", [-1, 1], { terms: 3 }).exact(); [F.a[0], F.b[1], F.b[2], F.b[3]]Output[0, 0.6366197723673420749:0.63661977236785727944, -0.318309886183[93513651:66454066], 0.21220659076495164542:0.2122065908071321605]
- 3.ParabolaAgreesFind the Fourier series of on up to .Independent answerEven: , : , .RatMath code
String(analytic.fourier("x^2", [-1, 1], { terms: 2 }).exact())Output0.333333 - 0.405285*cos(pi*x) + 0.101321*cos(2*pi*x)
- 4.Value at a jumpAgreesTo what does the Fourier series of the square wave converge at ?Independent answerTo the average of the one-sided limits, (every ).RatMath code
analytic.fourier("-1 if -1:x:!0; 1 if 0:x:1", [-1, 1], { terms: 9 }).exact().value(0)Output-0.00000000004839537745:0.00000000004839537745
- 5.OrthogonalityAgreesCompute and .Independent answerintegrates to 0. integrates to .RatMath code
[symbolic.integrate("sin(2x)*sin(3x)", "x", { from: "-pi", to: "pi" }).value, symbolic.integrate("sin(2x)^2", "x", { from: "-pi", to: "pi" }).value]Output[0, pi]
- 6.Parseval's identityAgreesUse Parseval's identity for on to find .Independent answer, so .RatMath code
[symbolic.integrate("x^2", "x", { from: -1, to: 1 }).value, symbolic.sum("4/(n^2*pi^2)", "n", 1, "inf").value, symbolic.sum("1/n^2", "n", 1, "inf").value]Output[2/3, 2/3, pi^2/6]
A factor without the index, here , comes outside the sum first, so both sides of Parseval's identity come out as .Fix: ratmath/symbolic#9,completeSquare,compose,sinusoid, inverse trig values,within,RealSetoperations and chained inequalities,implicitDiff,leibniz, constant factors insum - 7.Discrete Fourier transformAgreesCompute the DFT of .Independent answer, , , .RatMath code
analytic.dft([1, 2, 3, 4]).textOutput["10", "-2 + 2ζ", "-2", "-2 - 2ζ"]
Exact answers are written with ; for , . - 8.DFT of an impulseAgreesFind the DFT of .Independent answerOnly contributes: for every , a flat spectrum.RatMath code
analytic.dft([1, 0, 0, 0]).textOutput["1", "1", "1", "1"]
- 9.AliasingAgreesA 7 Hz sine is sampled at 10 Hz. What frequency does it appear to have?Independent answerThe Nyquist frequency is 5 Hz; folds to Hz, and a sine comes back with its sign reversed: .RatMath code
const a = analytic.alias(7, 10); [a.alias, a.sign, a.aliased]Output[3, -1, true]
- 10.Fourier transformAgreesFind for and for .Independent answer. The Gaussian: .RatMath code
[analytic.fourierTransform("exp(-abs(x))").formula.text, analytic.fourierTransform("exp(-x^2)").formula.text]Output["2/(w^2 + 1)", "sqrt(pi)*exp(-1/4*w^2)"]
- 11.ConvolutionAgreesCompute for .Independent answer(or invert ): .RatMath code
analytic.convolution("exp(-abs(x))", "exp(-abs(x))").at(1)Output0.7357588823428846[3133:4755]
- 12.Laplace transformAgreesFind the Laplace transforms of and .Independent answer: . Shifting : .RatMath code
[analytic.laplace("t^2"), analytic.laplace("exp(2t)*sin(3t)")].map(String)Output["2/s^3", "3/((s - 2)^2 + 9)"]
- 13.Inverse Laplace transformAgreesFind .Independent answer, so .RatMath code
String(analytic.inverseLaplace("1/(s*(s+1))").result)Output1 - exp(-t)
- 14.Legendre polynomialsAgreesFind .Independent answerRodrigues: .RatMath code
analytic.legendre(3)Output[0, -3/2, 0, 5/2]
The answer is a coefficient list, constant term first. - 15.Sturm–Liouville eigenvaluesAgreesFind the first three eigenvalues of , .Independent answer, : , , .RatMath code
analytic.sturmLiouville({ interval: [0, 1], count: 3 }).map((e) => e.eigenvalue)Output[9869603901/1000000000:9869604901/1000000000, 2467401069/62500000:4934802263/125000000, 88826439111/1000000000:88826440111/1000000000]
The interval needs rational ends, so the classic (eigenvalues ) is refused. - 16.Heat equationAgreesSolve on with at both ends and . Find .Independent answer; .RatMath code
analytic.heat({ k: 1, length: 1, initial: "sin(pi*x)", terms: 3 }).at("1/2", "1/10").valueOutput0.37270[755611254181306:812159433401409]
- 17.Wave equationAgreesA string of length 1 with starts at rest in the shape . Find the displacement at at and .Independent answer: , .RatMath code
const W = analytic.wave({ length: 1, position: "sin(pi*x)" }); [W.at("1/2", "1/2"), W.at("1/2", "1/3")]Output[-0.00000000000000000001:0.00000000000000000001, 0.[49999999999999999999:50000000000000000001]]
- 18.Laplace's equation on a discAgreesSolve in the unit disc with on the boundary. Find at , .Independent answer(harmonic and right on the circle): .RatMath code
const u = analytic.laplaceDisc({ boundary: "cos(theta)" }); [u.closedForm, u.at("1/2", 0).value]Output["r*cos(theta)", 1/2]
Boundary values with finitely many modes give the exact finite sum: the solution is and the value is the fraction , with no tail.Fix: ratmath/analytic#20,nFor,deltaForandverifyCertificate;supremum,limsup,liminf; limits of ; uniform convergence decided both ways;pde.transport; exact finite-mode Laplace solutions - 19.Convolution theoremAgreesCheck the convolution theorem for at .Independent answer, whose inverse transform at 1 is , the same as the direct convolution.RatMath code
const r = analytic.convolution("exp(-abs(x))", "exp(-abs(x))").theorem(1); [r.agrees, r.viaTransforms]Output[true, 0.7357588[7243462884235:9227470254627]]
- 20.Mean-square convergenceAgreesFor on , find the mean square error of the 3-term Fourier sum .Independent answerBy Bessel's equality, . Half of that is .RatMath code
analytic.fourier("x", [-1, 1], { terms: 3 }).exact().meanSquareError()Output0.05751455563627443977:0.0575145556456395458