8.3 Fourier Series ended on a cliff-hanger. A heat or flow problem hands you only on the physical interval , but the Fourier series of the last lesson wants a function on a full period . Whatever we invent on the missing half is a choice, and the lesson showed the choice has consequences: for the odd extension (a sawtooth) converged with a rms error of at 39 terms, while the even extension (a triangle) reached . A factor of 150 from a decision that costs nothing to make.
This lesson turns that decision into a rule. The rule has two halves, and they agree. The boundary conditions of the physical problem say which functions are allowed (8.2 Eigenvalue Problems & Sturm–Liouville Theory: Dirichlet ends give sines, Neumann ends give cosines), and the smoothness of the extension says how fast the series converges. For a simulation the first half is not optional: a solver that represents a wall velocity with the wrong basis violates the wall condition at every time step.
Transcript
- A heat or flow problem hands you f on the physical interval from zero to pi, and nothing else. A Fourier series wants a full period, so we must invent the left half. There are two natural ways. Rotate the graph half a turn about the origin: the odd extension. Or mirror it across the vertical axis: the even extension. It is a choice, and last time it made a factor of 150 difference.
- The odd extension first. Cosine times an odd function is odd, so it integrates to zero: every a k vanishes. Sine times an odd function is even, so the integral over minus pi to pi is twice the integral over zero to pi. That gives the sine series: b k is 2 over pi times the integral of f sine k x. The 2 over pi is one over the squared length of sine k x on the half interval, since sine squared integrates to pi over 2.
- The even extension is f of the absolute value of x. Now sine times f is odd, so every b k vanishes, and the cosine series has a k equal to 2 over pi times the integral of f cosine k x. Set k to 0 and a 0 over 2 is the average of f. The constant mode is always there: it is the lambda equals 0 eigenfunction of the insulated rod, which keeps its heat.
- Take f equal x. The sine series has b k equal to 2 times minus 1 to the k plus 1, over k: 2, minus 1, two thirds, minus a half. The cosine series has a 0 equal pi, and a k equal minus 4 over pi k squared for odd k. These are the sawtooth and the triangle of the last lesson. The sim finds a 1, a 3 and a 5 by quadrature alone: minus 1.273240, minus 0.141471 and minus 0.050930. Notice the tails: one over k against one over k squared.
- Why the gap? The series is the Fourier series of the extension, so its decay is the extension's smoothness. The odd extension is continuous only if f vanishes at both walls. Otherwise it jumps, and you pay a 1 over k tail and a Gibbs overshoot. The even extension is always continuous, but has a corner unless the slope is zero at the walls, so it pays 1 over k squared. The winner depends on f: cosine for x, sine for x times pi minus x, and for the constant 1 the cosine series is exact.
- But smoothness only says what is cheap. The boundary conditions say what is allowed. Dirichlet ends give sines, with lambda equal k squared. Neumann ends give cosines. One Dirichlet end and one Neumann end give sine of k minus a half times x, with lambda equal k minus a half, squared. That extension is odd about 0 and even about pi, with period 4 pi. Every partial sum inherits the boundary condition of its modes.
- That last point has a price. Take f equal x with 7 terms. The sine sum is exactly 0 at the wall x equals pi, although f is pi there, and its slope is minus 14, which is minus 2 N and grows without bound. The cosine sum has slope exactly zero at both walls although f has slope 1, and its values creep toward the truth: 0.0792 at the left wall, 3.0624 at the right. The series converges inside, but its derivative does not converge at the wall. Read fluxes from the equation.
- Here are the error curves for f equal x. At 39 terms the sine series has root mean square error 0.2250, the cosine series 0.00145, and the mixed series 0.00107: its extension has one corner per period of 4 pi, instead of two per 2 pi. For x times pi minus x the roles reverse. The sine series reaches 0.00006 and the cosine series only 0.00474. The odd extension there has no jump and no corner.
- Fluid solvers face this choice at every time step. At a solid wall the normal velocity must vanish, so it is expanded in sines. The pressure in the projection step has zero normal gradient, so it uses cosines. Fast sine and cosine transforms, computed with the F F T, do the work. Even on a grid, the discrete sine vectors are exact eigenvectors of the second difference matrix with fixed ends.
- To recap. Reflect f oddly for sines, evenly for cosines. The boundary conditions choose which, and the smoothness of the extension sets the speed. Partial sums obey the wall condition, but their derivatives do not converge there. Next, we put these series to work on the heat equation by separation of variables: each mode decays at its own rate, and the 1 over k tail disappears the instant time starts.
The problem: data on half an interval
Take a rod, a channel or a string on (8.1 Two-Point Boundary Value Problems explains how to rescale any interval to this one). The initial profile lives on only. We want to write with the eigenfunctions of for the physical boundary conditions. By the orthogonality of the last two lessons the coefficients are projections, so the only real question is which .
A full-period Fourier series needs on . We have it on the right half. So reflect the graph across the vertical axis in one of the two natural ways, apply the formulas of 8.3 Fourier Series, and read off the answer on , where the extension equals .
The odd extension gives the sine series
Define for and for , repeated with period . The graph on the left is the right-hand graph rotated by half a turn about the origin. For the product is odd and integrates to zero over a symmetric interval, so every . The product is even, so the integral over is twice the integral over :
The factor is on the half interval, since . It is the projection formula of 1.1 Vectors, Linear Combinations & Span: dot product over squared length.
The even extension gives the cosine series
Define : the graph is mirrored across the vertical axis. Now is odd, so all , and
With the formula says , the average of . The cosine series always contains the constant mode, which is the eigenfunction for of the Neumann problem (the insulated rod keeps its total heat).
On an interval substitute : the modes are and , and the prefactor becomes .
Worked example 1: both ways
For the sine series, integrate by parts, :
For the cosine series , and for , using ,
These are exactly the sawtooth and triangle series of the last lesson, now read as two different expansions of the same function on . The sim computes every coefficient by quadrature and never looks at a closed form. It returns and, for the cosine series, and with .
What to try. (1) with : compare the three error curves. (2) Switch the middle panel between the odd, even and mixed extensions and see the sawtooth, the triangle and a third shape. (3) : the cosine series is exact in one term. (4) : now the sine series is the winner. (5) Read the table of end values and end slopes: the sine sum is stuck at at both walls and the cosine sum at slope , whatever is.
Why the choice changes convergence: smoothness of the extension
The series for on is the Fourier series of the extension, so its coefficients decay at the rate the extension’s smoothness allows (8.3 Fourier Series: a jump gives , a corner , a jump in gives ). So ask what each extension does at the walls and .
Odd extension. Continuity at needs , so , and by periodicity the same at : the odd extension is continuous only if . Otherwise it jumps, by at , and the series pays a tail and a Gibbs overshoot. The slope, in contrast, is automatically continuous: reflecting through the origin gives . What can break is the second derivative.
Even extension. The extension is always continuous, because meets itself at . The slope is another matter: the right slope is and the left slope is , so there is a corner unless , and likewise at . So the cosine series never jumps but pays a tail for any with nonzero slope at a wall.
The sim confirms these rules (three of its four functions shown). Root-mean-square errors on , measured directly on a 4000-point grid:
| on | sine | cosine | |
|---|---|---|---|
| (exact) | |||
| (exact) | |||
For the jump at in the odd extension costs the sine series a factor of about 150 at . For the even extension is just the constant, so one mode captures everything while the sine series is a square wave with and the familiar overshoot: its maximum is at and still at . For , which vanishes at both walls, the roles reverse: the odd extension is continuous with a continuous slope, only jumps from to , the coefficients are for odd (, , ), and 39 terms leave an error of . The even extension has corners of slope at and the coefficients for even (, , ), giving , about 85 times worse.
Boundary conditions pick the series
The smoothness rule says what is cheap. The boundary conditions say what is allowed, and in a PDE they win. Look at the eigenfunctions of on from 8.2 Eigenvalue Problems & Sturm–Liouville Theory:
| ends | eigenfunctions | series | |
|---|---|---|---|
| Dirichlet, | , | sine | |
| Neumann, | , | cosine | |
| , | , | mixed |
Every partial sum inherits the boundary condition of its modes. Each vanishes at both walls, so every of the sine series vanishes there, no matter what does; each has zero slope at both walls, so every of the cosine series has zero slope there. That is not a flaw but the point: if the heat problem says the rod is held at , the solution built from sines obeys that at every step.
The third row is a genuine mixed problem. Orthogonality holds: for half-integers , , because and are integers; and again. So . Geometrically this is an extension that is odd about and even about , with period . For the integral is with ; since and it equals , and the sim returns . This series converges at the rate with the best constant of the three here: at its error is , against for the cosine series, because its extension has one corner per period of instead of two per .
What the wall values say. Take , . The sine sum has although : at the jump of the odd extension the series sits at the midpoint of the two sides (last lesson, from memory). Its slope at the wall is , growing without bound as increases while . The cosine sum has although , and its values are and , creeping toward the true and . In both cases the series converges to in the interior and in the mean-square sense, but the derivative of the series does not converge to at the wall. For heat flow the flux is , so a method that reads the wall flux off a Fourier sum with the wrong basis gets nonsense even when the temperature looks good. Hence the rule: choose the basis whose modes satisfy the boundary condition you actually have, and read fluxes from the equation, not by differentiating the sum.
Worked example 2: the constant and the parabola, step by step
. Sine: , so for odd : in the sim. Cosine: and for , so the series is and the sim’s coefficients are to six digits. A constant satisfies the Neumann condition, so Neumann’s basis represents it exactly.
. Odd extension: , , . Integrate by parts twice; the boundary terms vanish because , leaving , hence for odd . At , with for odd , the series says , which sums the alternating series to (the next lesson, 8.5 Convergence & the Gibbs Phenomenon, makes the pointwise claim honest; the continuity of the extension is what justifies it, from memory).
Computing it
Now build the half-range machinery yourself. The three bases are supplied through a single function mode; you write the projection, the partial sum and the error.
What comes next
We can now do the first half of every classical PDE problem on a bounded interval: pick the basis the walls dictate, and project the initial data onto it. Two things are still unproved. One is the convergence claim: we have seen in the sim that the series converges in the mean-square sense and that jumps leave a stubborn overshoot, but not where the series converges pointwise, which is the business of 8.5 Convergence & the Gibbs Phenomenon. The other is what the series are for. The next lesson in the build order, 9.3 Solving the Heat Equation: Separation of Variables, puts them to work: with the solution of the heat equation is , each sine mode decaying at its own rate (9.2 The Heat (Diffusion) Equation derived the equation). Because high dies fastest, the tail we complained about above vanishes the instant .
Concept checks
Problems
Find the sine series and the cosine series of on . Which extension is the square wave, and why does the other series need only one term?
Show worked solution
Sine: , so ; this is the odd extension, a square wave of height . Cosine: and for , so the series is just . The even extension of a constant is the same constant, so it has no jump and no corner; a numerical quadrature gives and .
Show that , , are the eigenfunctions of with and , and find the coefficients for on .
Show worked solution
For the solution vanishing at is , and requires , i.e. . (The cases give only .) Orthogonality and were shown above. With , , since . And . So : , , in agreement with the sim.
Using and its sine series ( odd), evaluate the series at to find . Then compute the first four partial sums to see how fast it converges.
Show worked solution
At , , and for . So , i.e. the sum equals . Partial sums: . They oscillate around the limit with an error shrinking like , the same decay as the coefficients.
A rod of length is insulated at both ends and starts with temperature . (a) Find the cosine series . (b) What temperature does the rod approach as ? (c) The series has zero slope at but . Explain why this is not a contradiction.
Show worked solution
(a) With the scaled formulas, , so for odd and for even , and . Thus , with . (b) The nonconstant modes decay (their eigenvalues are ), the constant mode does not, so the rod tends to the average temperature : an insulated rod keeps its heat. (c) Every finite sum of cosines has zero slope at the ends, while the series equals in the limit. The convergence is not uniform for the derivative: the terms of the differentiated series, , form a square wave, which equals inside and is at the endpoints (midpoint of the jump). The true boundary condition is satisfied by every partial sum, and the interior slope appears as the limit of a series that is not uniformly convergent near the wall.
Key Takeaways
- A function given on has two natural expansions: reflect it oddly () to get the sine series , or evenly () to get the cosine series , with the average of . On replace by and by .
- Boundary conditions choose the basis: Dirichlet ends give sines, Neumann ends cosines, and with gives with . Every partial sum inherits the boundary condition of its modes.
- Coefficient decay is the smoothness of the extension. The odd extension is continuous only if ; the even extension is always continuous but has a corner unless vanishes at the walls.
- For at the rms errors are (sine), (cosine) and (mixed); for they are (sine) and (cosine); for the cosine series is exact and the sine series has and a Gibbs maximum of .
- A partial sum of a sine series is at the walls and one of a cosine series has zero slope there, for every . The series converges to in the interior but its derivative does not converge to at the wall (for , : slope at for the sine sum).
- Spectral flow solvers use sine transforms for wall-normal velocity and cosine transforms for pressure-like quantities with zero normal gradient (from memory).
- The next row in the build order, 9.3 Solving the Heat Equation: Separation of Variables, turns this into the solution of the heat equation, one decaying mode at a time; pointwise convergence and the Gibbs phenomenon proper wait for 8.5 Convergence & the Gibbs Phenomenon.