Mathematics for Electrical Science and Physical Science 1. Module 4, taylor and maclaurin series, fourier series and half-range expansions.

GYMAT101 · 10 pages · Your place is saved in this browser

Contents · Taylor, Maclaurin, and Fourier Series
Text size18

Taylor, Maclaurin, and Fourier Series

This notebook teaches how to represent smooth functions locally using Taylor and Maclaurin power series, and how to represent periodic and piecewise-smooth functions globally using Fourier trigonometric series. Learners will compute full and half-range Fourier expansions over arbitrary intervals and apply Dirichlet's convergence theorem to evaluate classical infinite numerical series.

Before you start: Higher-order derivatives of elementary functions; Definite integration and integration by parts; Trigonometric identities and values at integer multiples of pi.

Your path through this module

  1. Local Approximation with Taylor and Maclaurin Series: Any infinitely differentiable function can be represented near a chosen center point as an infinite sum of powers whose coefficients are determined by the function's derivatives at that center.
  2. Periodic Functions and Euler's Formulas for Fourier Series: A periodic, piecewise-smooth function on any interval of length 2L can be decomposed into an average value plus an infinite sum of sines and cosines whose coefficients are found by integrating the function against each harmonic.
  3. Integration Shortcuts and Dirichlet's Convergence Theorem: By evaluating Euler integrals with tabular integration by parts and then plugging a specific x-value into Dirichlet's convergence formula, we can find exact closed-form sums for famous infinite numerical series.
  4. Even and Odd Extensions and Half-Range Series: A function defined only on [0, L] can be mirrored evenly across the vertical axis to produce a pure cosine series, or mirrored oddly through the origin to produce a pure sine series.
  5. Practice: Computing Maclaurin and Taylor Series: Find the general k-th derivative formula (or rewrite the expression in terms of a standard geometric series) to generate Taylor and Maclaurin expansions and identify their intervals of convergence.
  6. Practice: Full Fourier Series on 2pi-Length Intervals: Break integrals across piecewise intervals on [-pi, pi] or [0, 2pi] and apply tabular integration by parts to find full Fourier expansions and sum classical series.
  7. Practice: Full Fourier Series on Arbitrary Intervals [-L, L] and [0, 2L]: Replace nx with npix/L in Euler's formulas to handle arbitrary interval lengths, and combine evaluations at continuous and jump points to solve for multiple infinite series at once.
  8. Practice: Half-Range Cosine Series on [0, L]: Extend a function on [0, L] as an even function to represent it purely with cosines, taking care to compute the n = 1 coefficient separately whenever a product-to-sum formula divides by n - 1.
  9. Practice: Half-Range Sine Series on [0, L]: Extend a function on [0, L] as an odd function so that a0 = 0 and an = 0, leaving only a single sine integral bn to compute.

Local Approximation with Taylor and Maclaurin Series

You already know how to compute derivatives of all orders for elementary functions; now we use those derivatives at a single point to build an infinite polynomial that matches the function. This lets us replace complicated curves with simple addition and multiplication.

Imagine driving along a winding mountain road in heavy fog. Even if you only know your exact position, speed, and how fast you are turning the wheel right now, you can predict where the road goes for the next few meters. In mathematics, a smooth function is one you can differentiate infinitely many times without any sharp corners or breaks. An infinite power series is an endless polynomial built from powers of how far you step away from a starting point x0x_0.

To make our polynomial match the function f(x)f(x) near the center point x0x_0, we force both to have the exact same value, slope, curvature, and higher derivatives at x0x_0. This rule produces the Taylor series:

f(x)=∑k=0∞f(k)(x0)k!(x−x0)kf(x) = \sum_{k=0}^{\infty} \frac{f^{(k)}(x_0)}{k!}(x - x_0)^k

In plain words, each term adjusts the polynomial's kk-th derivative to match f(k)(x0)f^{(k)}(x_0), while the factorial k!k! cancels out the constants that drop down during repeated differentiation. To see this, draw a wavy curve f(x)f(x) and mark a point x0x_0. Draw a straight tangent line at x0x_0 (using up to k=1k=1); it hugs the curve right at x0x_0. Now draw a parabola that also matches the second derivative (up to k=2k=2); it bends with the curve and stays close over a wider stretch.

When we choose the origin x0=0x_0 = 0 as our center, the formula simplifies and is called a Maclaurin series:

f(x)=∑k=0∞f(k)(0)k!xkf(x) = \sum_{k=0}^{\infty} \frac{f^{(k)}(0)}{k!}x^k

Rather than computing derivatives every time, engineers memorize four foundational Maclaurin expansions and their region of convergence, which is the set of xx values where the infinite sum actually equals the function. You can also substitute algebraic expressions directly for xx inside these series.

FunctionMaclaurin SeriesRegion of Convergence
exe^x1+x+x22!+x33!+⋯=∑k=0∞xkk!1 + x + \frac{x^2}{2!} + \frac{x^3}{3!} + \cdots = \sum_{k=0}^{\infty} \frac{x^k}{k!}All real xx
sin⁡(x)\sin(x)x−x33!+x55!−⋯=∑k=0∞(−1)kx2k+1(2k+1)!x - \frac{x^3}{3!} + \frac{x^5}{5!} - \cdots = \sum_{k=0}^{\infty} (-1)^k \frac{x^{2k+1}}{(2k+1)!}All real xx
cos⁡(x)\cos(x)1−x22!+x44!−⋯=∑k=0∞(−1)kx2k(2k)!1 - \frac{x^2}{2!} + \frac{x^4}{4!} - \cdots = \sum_{k=0}^{\infty} (-1)^k \frac{x^{2k}}{(2k)!}All real xx
11−x\frac{1}{1-x}1+x+x2+x3+⋯=∑k=0∞xk1 + x + x^2 + x^3 + \cdots = \sum_{k=0}^{\infty} x^k$

Worked example

Find the first three nonzero terms of the Taylor series for f(x)=ln⁡(x)f(x) = \ln(x) centered at x0=1x_0 = 1, and find the Maclaurin series for g(x)=11+x2g(x) = \frac{1}{1+x^2}.

  1. Evaluate derivatives at the center x0=1x_0 = 1 to find the Taylor coefficients: We need the function value and derivatives at x0=1x_0 = 1. Here f(1)=ln⁡(1)=0f(1) = \ln(1) = 0, f′(x)=x−1f'(x) = x^{-1} so f′(1)=1f'(1) = 1, f′′(x)=−x−2f''(x) = -x^{-2} so f′′(1)=−1f''(1) = -1, and f′′′(x)=2x−3f'''(x) = 2x^{-3} so f′′′(1)=2f'''(1) = 2.
  2. Assemble the Taylor series for ln⁡(x)\ln(x): Plugging these numbers into the Taylor formula gives ln⁡(x)=0+11!(x−1)+−12!(x−1)2+23!(x−1)3+⋯=(x−1)−12(x−1)2+13(x−1)3−⋯\ln(x) = 0 + \frac{1}{1!}(x-1) + \frac{-1}{2!}(x-1)^2 + \frac{2}{3!}(x-1)^3 + \cdots = (x-1) - \frac{1}{2}(x-1)^2 + \frac{1}{3}(x-1)^3 - \cdots.
  3. Use algebraic substitution for g(x)g(x) to avoid taking derivatives: Rewrite g(x)g(x) as 11−(−x2)\frac{1}{1 - (-x^2)} to match the standard geometric form 11−u\frac{1}{1-u} with u=−x2u = -x^2.
  4. Substitute into the known Maclaurin series: Replace xx with −x2-x^2 in ∑k=0∞xk\sum_{k=0}^{\infty} x^k to get g(x)=1−x2+x4−x6+⋯=∑k=0∞(−1)kx2kg(x) = 1 - x^2 + x^4 - x^6 + \cdots = \sum_{k=0}^{\infty} (-1)^k x^{2k}, which converges when ∣−x2∣<1|-x^2| < 1, or ∣x∣<1|x| < 1.

Remember

  • A Taylor series builds a polynomial around x=x0x = x_0 using coefficients f(k)(x0)k!\frac{f^{(k)}(x_0)}{k!}; a Maclaurin series is simply a Taylor series centered at x0=0x_0 = 0.
  • Memorize the Maclaurin series for exe^x, sin⁡(x)\sin(x), cos⁡(x)\cos(x) (valid for all xx) and 11−x\frac{1}{1-x} (valid for ∣x∣<1|x| < 1).
  • Obtain new series quickly by substituting algebraic terms into the four standard series instead of differentiating from scratch.

Periodic Functions and Euler's Formulas for Fourier Series

In the previous lesson, we built Taylor series for smooth functions around a single point. Now we will represent repeating signals—even those with sharp corners or sudden jumps—using an infinite sum of sines and cosines across a whole interval.

Think of an electrocardiogram (ECG) trace or a blinking turn signal: the same pattern repeats over and over. A periodic function satisfies f(x+T)=f(x)f(x + T) = f(x) for all xx, where the smallest positive shift TT is the fundamental period. For convenience in formulas, we write this period as T=2LT = 2L, where LL is the half-period. Any interval of length 2L2L, written [c,c+2L][c, c+2L], captures one full cycle and is called a fundamental interval. On a graph, if you trace the curve from x=−Lx = -L to x=Lx = L (or from 00 to 2L2L) and slide that cutout sideways by 2L2L, it lands right back on the graph.

Real engineering signals, like a switch flipping on and off, cannot be expanded in Taylor series because derivatives fail at jumps. Instead, we only require the signal to obey Dirichlet's conditions on one period: it must have a finite number of maxima and minima, and be piecewise continuous. Piecewise continuous means the graph is made of unbroken smooth pieces separated by a finite number of jump discontinuities—places where the graph steps instantaneously from a finite left-hand value to a finite right-hand value without shooting to infinity.

Just as a musical chord can be separated into pure tuning-fork notes, any periodic function meeting Dirichlet's conditions can be written as a Fourier trigonometric series S(x)S(x):

S(x)=a02+∑n=1∞(ancos⁡nπxL+bnsin⁡nπxL)S(x) = \frac{a_0}{2} + \sum_{n=1}^{\infty} \left( a_n \cos\frac{n\pi x}{L} + b_n \sin\frac{n\pi x}{L} \right)

In words, the function is built from a constant baseline a02\frac{a_0}{2} plus waves of frequency nπL\frac{n\pi}{L}, called harmonics. To find how much of each wave is inside f(x)f(x), we use Euler's formulas over any one period [c,c+2L][c, c+2L]:

a0=1L∫cc+2Lf(x) dx,an=1L∫cc+2Lf(x)cos⁡nπxL dx,bn=1L∫cc+2Lf(x)sin⁡nπxL dxa_0 = \frac{1}{L}\int_{c}^{c+2L} f(x)\,dx, \quad a_n = \frac{1}{L}\int_{c}^{c+2L} f(x)\cos\frac{n\pi x}{L}\,dx, \quad b_n = \frac{1}{L}\int_{c}^{c+2L} f(x)\sin\frac{n\pi x}{L}\,dx

Here, a02\frac{a_0}{2} is simply the average height of the graph over one cycle. On a standard interval like [−π,π][-\pi, \pi] or [0,2π][0, 2\pi], the half-period is L=πL = \pi, so nπxL\frac{n\pi x}{L} simplifies nicely to nxnx.

Worked example

Find the Fourier series for the square wave f(x)=0f(x) = 0 on (−2,0)(-2, 0) and f(x)=4f(x) = 4 on (0,2)(0, 2), repeated with period 2L=42L = 4.

  1. Identify the half-period and check Dirichlet's conditions: The fundamental interval is [−2,2][-2, 2] of length 2L=42L = 4, so L=2L = 2. The graph has two flat pieces and finite jumps at x=0x = 0 and x=2x = 2, so Dirichlet's conditions hold.

  2. Compute a0a_0 to find the average height: Set c=−2c = -2 and L=2L = 2 in Euler's formula. Since f(x)=0f(x) = 0 on (−2,0)(-2, 0), integrate only from 00 to 22:

    a0=12∫024 dx=12[4x]02=4a_0 = \frac{1}{2}\int_{0}^{2} 4\,dx = \frac{1}{2}[4x]_0^2 = 4
  3. Compute ana_n for the cosine weights:

    an=12∫024cos⁡nπx2 dx=2[2nπsin⁡nπx2]02=4nπsin⁡(nπ)=0a_n = \frac{1}{2}\int_{0}^{2} 4\cos\frac{n\pi x}{2}\,dx = 2\left[\frac{2}{n\pi}\sin\frac{n\pi x}{2}\right]_0^2 = \frac{4}{n\pi}\sin(n\pi) = 0
  4. Compute bnb_n for the sine weights:

    bn=12∫024sin⁡nπx2 dx=2[−2nπcos⁡nπx2]02=4nπ(1−cos⁡(nπ))b_n = \frac{1}{2}\int_{0}^{2} 4\sin\frac{n\pi x}{2}\,dx = 2\left[-\frac{2}{n\pi}\cos\frac{n\pi x}{2}\right]_0^2 = \frac{4}{n\pi}(1 - \cos(n\pi))

Assemble the series with a02=2\frac{a_0}{2} = 2:

S(x)=2+∑n=1∞4nπ(1−(−1)n)sin⁡nπx2S(x) = 2 + \sum_{n=1}^{\infty} \frac{4}{n\pi}(1 - (-1)^n)\sin\frac{n\pi x}{2}

Remember

  • Always divide the full period TT by 22 to get the half-period LL before writing Euler's formulas.
  • The constant term in the series is a02\frac{a_0}{2} (the average value over one period), so take care not to forget the factor of 12\frac{1}{2}.
  • When f(x)f(x) is defined in pieces, split each Euler integral into matching sub-intervals.

Integration Shortcuts and Dirichlet's Convergence Theorem

Now that you can set up Euler's integrals for a Fourier series, you need fast shortcuts to evaluate them and a rule to know what the infinite sum actually equals at any point, enabling you to sum famous numerical series.

When a periodic signal is a ramp or parabola, Euler's formulas require integrating a polynomial u(x)u(x) times a wave v(x)v(x). Doing integration by parts repeatedly is slow and error-prone. Instead, we use Bernoulli's generalized integration by parts (often called tabular integration), where you differentiate uu until it vanishes and repeatedly integrate vv:

∫uv dx=uv1−u′v2+u′′v3−u′′′v4+⋯\int u v \, dx = u v_1 - u' v_2 + u'' v_3 - u''' v_4 + \cdots

Here u′,u′′u', u'' are successive derivatives of uu, and v1,v2,v3v_1, v_2, v_3 are successive integrals of vv. In words: multiply each derivative of the polynomial by the next integral of the wave, alternating plus and minus signs.

Other signals decay like a plucked guitar string or beat like two tuning forks. To integrate a decaying wave eaxe^{ax} times cos⁡(bx)\cos(bx) or sin⁡(bx)\sin(bx), or the product of two waves, use these direct shortcuts:

Integral TypeShortcut Formula / Identity
Exponential-Cosine∫eaxcos⁡(bx) dx=eaxa2+b2(acos⁡bx+bsin⁡bx)\int e^{ax}\cos(bx)\,dx = \frac{e^{ax}}{a^2+b^2}(a\cos bx + b\sin bx)
Exponential-Sine∫eaxsin⁡(bx) dx=eaxa2+b2(asin⁡bx−bcos⁡bx)\int e^{ax}\sin(bx)\,dx = \frac{e^{ax}}{a^2+b^2}(a\sin bx - b\cos bx)
Product-to-Sumcos⁡Acos⁡B=12[cos⁡(A−B)+cos⁡(A+B)]\cos A\cos B = \frac{1}{2}[\cos(A-B)+\cos(A+B)], sin⁡Acos⁡B=12[sin⁡(A+B)+sin⁡(A−B)]\sin A\cos B = \frac{1}{2}[\sin(A+B)+\sin(A-B)]

When you plug integration limits like π\pi or −π-\pi into your results for an integer nn, always simplify using sin⁡(nπ)=0\sin(n\pi) = 0 and cos⁡(nπ)=(−1)n\cos(n\pi) = (-1)^n. On a unit circle, stepping by nn half-turns always lands on the horizontal axis, alternating between −1-1 and +1+1.

Once you build the series, does it equal f(x)f(x)? Imagine tracing a square wave: at a vertical cliff, the smooth waves cannot be in two places at once, so they split the difference. A jump discontinuity is a point x0x_0 where the left-hand limit f(x0−)f(x_0^-) (value approached from the left) and right-hand limit f(x0+)f(x_0^+) (value approached from the right) are finite but unequal. Dirichlet's convergence theorem states that for a periodic, piecewise-smooth function, the Fourier series at any x0x_0 converges to the midpoint of the left and right limits:

S(x0)=f(x0−)+f(x0+)2S(x_0) = \frac{f(x_0^-) + f(x_0^+)}{2}

If you draw a vertical jump from height 11 to height 33 at x0x_0, place a solid dot at height 22; the series lands on that dot. Where ff is continuous, both limits equal f(x0)f(x_0), so the series equals f(x0)f(x_0). Substituting a clever x0x_0 turns the function series into an exact sum for a numerical series.

Worked example

Given that f(x)=x2f(x) = x^2 on (−π,π)(-\pi, \pi) with period 2π2\pi has a0=2π23a_0 = \frac{2\pi^2}{3} and bn=0b_n = 0, find ana_n and evaluate ∑n=1∞1n2\sum_{n=1}^{\infty} \frac{1}{n^2}.

  1. Integrate using Bernoulli's formula: To find an=1π∫−ππx2cos⁡(nx) dxa_n = \frac{1}{\pi}\int_{-\pi}^{\pi} x^2 \cos(nx)\,dx, set u=x2u = x^2 and v=cos⁡(nx)v = \cos(nx) so we avoid integrating by parts twice.

    an=1π[(x2)(sin⁡nxn)−(2x)(−cos⁡nxn2)+(2)(−sin⁡nxn3)]−ππa_n = \frac{1}{\pi}\left[ (x^2)\left(\frac{\sin nx}{n}\right) - (2x)\left(-\frac{\cos nx}{n^2}\right) + (2)\left(-\frac{\sin nx}{n^3}\right) \right]_{-\pi}^{\pi}
  2. Simplify at the limits: Because sin⁡(nπ)=0\sin(n\pi) = 0 and cos⁡(nπ)=(−1)n\cos(n\pi) = (-1)^n, the sine terms vanish and the cosine term doubles:

    an=1π[2π(−1)nn2−2(−π)(−1)nn2]=4(−1)nn2a_n = \frac{1}{\pi}\left[ \frac{2\pi(-1)^n}{n^2} - \frac{2(-\pi)(-1)^n}{n^2} \right] = \frac{4(-1)^n}{n^2}
  3. Apply Dirichlet's theorem at x=πx = \pi: The periodic extension of x2x^2 is continuous at x=πx = \pi, since f(π−)=π2f(\pi^-) = \pi^2 and by periodicity f(π+)=f(−π+)=(−π)2=π2f(\pi^+) = f(-\pi^+) = (-\pi)^2 = \pi^2. Plugging x=πx = \pi into the Fourier series gives:

    π2=π23+∑n=1∞4(−1)nn2cos⁡(nπ)\pi^2 = \frac{\pi^2}{3} + \sum_{n=1}^{\infty} \frac{4(-1)^n}{n^2} \cos(n\pi)
  4. Solve for the numerical sum: Replace cos⁡(nπ)\cos(n\pi) with (−1)n(-1)^n, note that (−1)n(−1)n=1(-1)^n(-1)^n = 1, and isolate the sum:

    2π23=4∑n=1∞1n2  ⟹  ∑n=1∞1n2=π26\frac{2\pi^2}{3} = 4 \sum_{n=1}^{\infty} \frac{1}{n^2} \implies \sum_{n=1}^{\infty} \frac{1}{n^2} = \frac{\pi^2}{6}

Remember

  • Use Bernoulli's formula ∫uv dx=uv1−u′v2+u′′v3−⋯\int uv\,dx = uv_1 - u'v_2 + u''v_3 - \cdots when uu is a polynomial.
  • For any integer nn, always simplify sin⁡(nπ)=0\sin(n\pi) = 0 and cos⁡(nπ)=(−1)n\cos(n\pi) = (-1)^n.
  • By Dirichlet's theorem, a Fourier series converges to f(x0)f(x_0) at continuous points and to f(x0−)+f(x0+)2\frac{f(x_0^-) + f(x_0^+)}{2} at jumps.

Even and Odd Extensions and Half-Range Series

In the previous lessons, you learned how to find full Fourier series by integrating both cosines and sines over a full period [−L,L][-L, L]. Now, you will use symmetry to cut that work in half and represent a function defined only on [0,L][0, L] using purely cosines or purely sines.

Imagine folding a sheet of paper along the vertical yy-axis. An even function matches up with itself when folded across the yy-axis, so f(−x)=f(x)f(-x) = f(x), like cos⁡(x)\cos(x) or x2x^2. On a symmetric interval [−L,L][-L, L], the signed area of an even function on the left equals the area on the right: ∫−LLf(x) dx=2∫0Lf(x) dx\int_{-L}^{L} f(x)\,dx = 2\int_{0}^{L} f(x)\,dx. An odd function matches up only if you fold across the yy-axis and then flip across the xx-axis, so f(−x)=−f(x)f(-x) = -f(x), like sin⁡(x)\sin(x) or xx. Because its left and right areas have opposite signs, the symmetric integral of an odd function is zero: ∫−LLf(x) dx=0\int_{-L}^{L} f(x)\,dx = 0.

In engineering, a signal or a vibrating string of length LL is often defined only on [0,L][0, L]. Since we do not care what happens for negative xx, we can invent the left half on [−L,0][-L, 0] to create symmetry. An even periodic extension reflects the graph across the yy-axis onto [−L,0][-L, 0] and repeats it every 2L2L, while an odd periodic extension reflects the graph across the yy-axis and then flips it upside down across the xx-axis before repeating.

Because the product of an even and an odd function is always odd, choosing an extension zeroes out half the Euler coefficients and yields a half-range series valid on [0,L][0, L]:

Extension TypeVisual on [−L,L][-L, L]Zero TermsRemaining Coefficients (Double the [0,L][0, L] integral)Series on [0,L][0, L]
Even (Half-Range Cosine)Mirror across yy-axisbn=0b_n = 0a0=2L∫0Lf(x) dxa_0 = \frac{2}{L}\int_0^L f(x)\,dx, an=2L∫0Lf(x)cos⁡(nπxL)dxa_n = \frac{2}{L}\int_0^L f(x)\cos\left(\frac{n\pi x}{L}\right)dxa02+∑n=1∞ancos⁡(nπxL)\frac{a_0}{2} + \sum_{n=1}^\infty a_n\cos\left(\frac{n\pi x}{L}\right)
Odd (Half-Range Sine)Flip through origina0=0,an=0a_0 = 0, a_n = 0bn=2L∫0Lf(x)sin⁡(nπxL)dxb_n = \frac{2}{L}\int_0^L f(x)\sin\left(\frac{n\pi x}{L}\right)dx∑n=1∞bnsin⁡(nπxL)\sum_{n=1}^\infty b_n\sin\left(\frac{n\pi x}{L}\right)

Worked example

Find the half-range sine series for f(x)=1f(x) = 1 on [0,π][0, \pi].

  1. Choose the extension: A half-range sine series requires an odd extension, so a0=0a_0 = 0 and an=0a_n = 0 automatically.
  2. Set up the sine coefficient bnb_n: With L=πL = \pi, double the integral over the half-period [0,π][0, \pi]: bn=2π∫0π1⋅sin⁡(nx) dxb_n = \frac{2}{\pi}\int_0^\pi 1 \cdot \sin(nx)\,dx.
  3. Integrate and simplify: Evaluating gives bn=2π[−cos⁡(nx)n]0π=2nπ(1−(−1)n)b_n = \frac{2}{\pi}\left[-\frac{\cos(nx)}{n}\right]_0^\pi = \frac{2}{n\pi}(1 - (-1)^n). This equals 00 for even nn and 4nπ\frac{4}{n\pi} for odd nn.
  4. Write the series: Summing over odd integers n=1,3,5,…n = 1, 3, 5, \dots gives f(x)∼4π(sin⁡(x)+sin⁡(3x)3+sin⁡(5x)5+… )f(x) \sim \frac{4}{\pi}\left(\sin(x) + \frac{\sin(3x)}{3} + \frac{\sin(5x)}{5} + \dots\right).

Remember

  • Even ×\times Even = Even, Odd ×\times Odd = Even, and Even ×\times Odd = Odd.
  • On [−L,L][-L, L], the integral of an odd function is 00; the integral of an even function is 2∫0L2\int_0^L.
  • On [0,L][0, L], mirror evenly across the yy-axis for a pure cosine series (bn=0b_n = 0), or flip oddly through the origin for a pure sine series (a0=an=0a_0 = a_n = 0).

Practice: Computing Maclaurin and Taylor Series

With the theory of Taylor and Maclaurin series in place, we now practice deriving power series expansions from higher-order derivative patterns and algebraic substitutions. You will find the general kk-th derivative formula or rewrite an expression in terms of a standard geometric series to generate expansions and identify their intervals of convergence.

The idea

Writing out the first three or four terms of a Taylor or Maclaurin series is straightforward, but writing the infinite sum requires a general formula for the kk-th derivative, f(k)(x)f^{(k)}(x). By computing the first few derivatives before plugging in the center x0x_0, you can spot how signs alternate, how factorials grow from repeated power-rule steps, or how trigonometric functions cycle every four derivatives. Once you write f(k)(x0)f^{(k)}(x_0) in terms of kk, dividing by k!k! often cancels factorial factors cleanly.

For rational functions, repeated differentiation produces a geometric series whose terms are powers of (x−x0)(x - x_0). Once you know the basic Maclaurin expansion 11−u=1+u+u2+u3+…\frac{1}{1-u} = 1 + u + u^2 + u^3 + \dots, which converges on the interval of convergence ∣u∣<1|u| < 1, you do not need to differentiate from scratch every time. You can factor out constants to create a leading 11 in the denominator and substitute a rescaled variable uu directly into the known series. The series is valid wherever the substituted expression satisfies ∣u∣<1|u| < 1.

Worked example

Given: The exponential function f(x)=exf(x) = e^x centered at x0=0x_0 = 0. Find: The Maclaurin series expansion of f(x)f(x).

  1. Evaluate the function at the center x0=0x_0 = 0: f(0)=e0=1f(0) = e^0 = 1, which gives the constant term.
  2. Compute the first few derivatives at x=0x = 0: since f′(x)=exf'(x) = e^x and f′′(x)=exf''(x) = e^x, we get f′(0)=1f'(0) = 1 and f′′(0)=1f''(0) = 1.
  3. State the general kk-th derivative pattern: because exe^x is its own derivative, f(k)(x)=exf^{(k)}(x) = e^x, so f(k)(0)=1f^{(k)}(0) = 1 for all k≥0k \ge 0.
  4. Substitute f(k)(0)=1f^{(k)}(0) = 1 into the Maclaurin formula ∑k=0∞f(k)(0)k!xk\sum_{k=0}^{\infty} \frac{f^{(k)}(0)}{k!} x^k to write out the expansion.

Answer: 1+x+x22!+⋯+xkk!+…1 + x + \frac{x^2}{2!} + \dots + \frac{x^k}{k!} + \dots

More problems

Problem Q(i): Maclaurin series for the decaying exponential

Given: The function f(x)=e−xf(x) = e^{-x} for all x∈Rx \in \mathbb{R}. Find: The Maclaurin series of f(x)f(x).

  1. By the chain rule, each derivative of e−xe^{-x} multiplies by −1-1, giving f(k)(0)=(−1)kf^{(k)}(0) = (-1)^k (or substitute −x-x into the series for exe^x).
  2. Substitute these coefficients into the Maclaurin series formula to get the alternating expansion.

Answer: 1−x+x22!−x33!+…1 - x + \frac{x^2}{2!} - \frac{x^3}{3!} + \dots

Problem Q(ii): Maclaurin series for the basic geometric fraction

Given: The function f(x)=11−xf(x) = \frac{1}{1-x} in the region ∣x∣<1|x| < 1. Find: The Maclaurin series of f(x)f(x).

  1. Differentiate f(x)=(1−x)−1f(x) = (1-x)^{-1} repeatedly using the chain rule to find f(k)(x)=k!(1−x)k+1f^{(k)}(x) = \frac{k!}{(1-x)^{k+1}}, so f(k)(0)=k!f^{(k)}(0) = k!.
  2. Divide f(k)(0)=k!f^{(k)}(0) = k! by k!k! in the Maclaurin formula, leaving a coefficient of 11 on every power xkx^k.

Answer: 1+x+x2+x3+…1 + x + x^2 + x^3 + \dots

Problem 1: Maclaurin series for the sine function

Given: The trigonometric function f(x)=sin⁡xf(x) = \sin x. Find: The Maclaurin series of f(x)f(x).

  1. Evaluate the function and its first four derivatives at 00: f(0)=0f(0) = 0, f′(0)=cos⁡0=1f'(0) = \cos 0 = 1, f′′(0)=−sin⁡0=0f''(0) = -\sin 0 = 0, f′′′(0)=−cos⁡0=−1f'''(0) = -\cos 0 = -1, and f(4)(0)=sin⁡0=0f^{(4)}(0) = \sin 0 = 0.
  2. Group the derivatives into even and odd orders: for k≥0k \ge 0, all even derivatives vanish (f(2k)(0)=0f^{(2k)}(0) = 0) because sin⁡0=0\sin 0 = 0.
  3. Write the odd derivative formula: f(2k+1)(x)=(−1)kcos⁡xf^{(2k+1)}(x) = (-1)^k \cos x, which gives f(2k+1)(0)=(−1)kf^{(2k+1)}(0) = (-1)^k for k≥0k \ge 0.
  4. Substitute the non-zero odd terms into the Maclaurin formula to obtain the odd-power series.

Answer: x−x33!+x55!−⋯=∑k=0∞(−1)kx2k+1(2k+1)!x - \frac{x^3}{3!} + \frac{x^5}{5!} - \dots = \sum_{k=0}^{\infty} (-1)^k \frac{x^{2k+1}}{(2k+1)!}

Problem 2: Maclaurin series for the cosine function

Given: The trigonometric function f(x)=cos⁡xf(x) = \cos x. Find: The Maclaurin series of f(x)f(x).

  1. Evaluate the derivatives of cos⁡x\cos x at x=0x = 0: odd derivatives contain sin⁡0\sin 0 and vanish, while even derivatives alternate as f(2k)(0)=(−1)kf^{(2k)}(0) = (-1)^k.
  2. Substitute the even-order derivatives into the Maclaurin series formula.

Answer: 1−x22!+x44!−⋯=∑k=0∞(−1)kx2k(2k)!1 - \frac{x^2}{2!} + \frac{x^4}{4!} - \dots = \sum_{k=0}^{\infty} (-1)^k \frac{x^{2k}}{(2k)!}

Problem 3: Maclaurin series for an alternating rational function

Given: The function f(x)=11+xf(x) = \frac{1}{1+x} for ∣x∣<1|x| < 1. Find: The Maclaurin series of f(x)f(x).

  1. Compute the value and first two derivatives at x=0x = 0: f(0)=1f(0) = 1, f′(x)=−1(1+x)2  ⟹  f′(0)=−1f'(x) = \frac{-1}{(1+x)^2} \implies f'(0) = -1, and f′′(x)=2(1+x)3  ⟹  f′′(0)=2f''(x) = \frac{2}{(1+x)^3} \implies f''(0) = 2.
  2. Compute the third and fourth derivatives to see the factorial pattern: f′′′(x)=−2⋅3(1+x)4  ⟹  f′′′(0)=−3!f'''(x) = \frac{-2 \cdot 3}{(1+x)^4} \implies f'''(0) = -3! and f(4)(x)=2⋅3⋅4(1+x)5  ⟹  f(4)(0)=4!f^{(4)}(x) = \frac{2 \cdot 3 \cdot 4}{(1+x)^5} \implies f^{(4)}(0) = 4!.
  3. State the general kk-th derivative at x=0x = 0: f(k)(0)=(−1)kk!f^{(k)}(0) = (-1)^k k!.
  4. Substitute f(k)(0)f^{(k)}(0) into the Maclaurin formula and cancel k!k! in the numerator and denominator.

Watch out. The kk-th derivative of (1+x)−1(1+x)^{-1} has denominator (1+x)k+1(1+x)^{k+1}, not (1+x)k(1+x)^k; at x=0x = 0 both equal 11, so f(k)(0)=(−1)kk!f^{(k)}(0) = (-1)^k k! is unaffected.

Answer: 1−x+x2−x3+⋯=∑k=0∞(−1)kxk1 - x + x^2 - x^3 + \dots = \sum_{k=0}^{\infty} (-1)^k x^k

Problem Q(1): Taylor series of the reciprocal function at x = 1

Given: The function f(x)=1xf(x) = \frac{1}{x} about x0=1x_0 = 1 in the region ∣x−1∣<1|x-1| < 1. Find: The Taylor series of f(x)f(x) at x=1x = 1.

  1. Evaluate f(x)f(x) and its first four derivatives at x0=1x_0 = 1: f(1)=1f(1) = 1, f′(1)=−1f'(1) = -1, f′′(1)=2f''(1) = 2, f′′′(1)=−3!f'''(1) = -3!, and f(4)(1)=4!f^{(4)}(1) = 4!.
  2. Write the general derivative value at x0=1x_0 = 1: f(k)(1)=(−1)kk!f^{(k)}(1) = (-1)^k k! for k≥1k \ge 1 (and k=0k = 0).
  3. Substitute f(k)(1)f^{(k)}(1) into the Taylor formula ∑k=0∞f(k)(1)k!(x−1)k\sum_{k=0}^{\infty} \frac{f^{(k)}(1)}{k!} (x-1)^k and cancel k!k! to get powers of (x−1)(x-1).

Watch out. The kk-th derivative of x−1x^{-1} is (−1)kk!xk+1\frac{(-1)^k k!}{x^{k+1}} (exponent k+1k+1, not kk), which still evaluates to (−1)kk!(-1)^k k! at x=1x = 1.

Answer: 1−(x−1)+(x−1)2−(x−1)3+⋯=∑k=0∞(−1)k(x−1)k1 - (x-1) + (x-1)^2 - (x-1)^3 + \dots = \sum_{k=0}^{\infty} (-1)^k (x-1)^k

Problem Q(2): Taylor series of a shifted rational function at x = 1

Given: The function f(x)=11+xf(x) = \frac{1}{1+x} at x0=1x_0 = 1 in the region ∣x−1∣<1|x-1| < 1. Find: The Taylor series of f(x)f(x) at x=1x = 1.

  1. Evaluate f(x)f(x) and its first two derivatives at x0=1x_0 = 1: f(1)=12f(1) = \frac{1}{2}, f′(x)=−1(1+x)2  ⟹  f′(1)=−14f'(x) = \frac{-1}{(1+x)^2} \implies f'(1) = -\frac{1}{4}, and f′′(x)=2(1+x)3  ⟹  f′′(1)=223f''(x) = \frac{2}{(1+x)^3} \implies f''(1) = \frac{2}{2^3}.
  2. Evaluate the third and fourth derivatives at x0=1x_0 = 1: f′′′(1)=−3!24f'''(1) = \frac{-3!}{2^4} and f(4)(1)=4!25f^{(4)}(1) = \frac{4!}{2^5}.
  3. Write the general kk-th derivative formula at x0=1x_0 = 1: from f(k)(x)=(−1)kk!(1+x)k+1f^{(k)}(x) = \frac{(-1)^k k!}{(1+x)^{k+1}}, we have f(k)(1)=(−1)kk!2k+1f^{(k)}(1) = \frac{(-1)^k k!}{2^{k+1}} for k≥0k \ge 0.
  4. Substitute f(k)(1)f^{(k)}(1) into the Taylor formula ∑k=0∞f(k)(1)k!(x−1)k\sum_{k=0}^{\infty} \frac{f^{(k)}(1)}{k!}(x-1)^k and cancel k!k! in each term.

Answer: ∑k=0∞(−1)k2k+1(x−1)k=12−122(x−1)+123(x−1)2−…\sum_{k=0}^{\infty} \frac{(-1)^k}{2^{k+1}} (x-1)^k = \frac{1}{2} - \frac{1}{2^2}(x-1) + \frac{1}{2^3}(x-1)^2 - \dots

Problem Q(3): Maclaurin series by algebraic factoring and substitution

Given: The function f(x)=32−xf(x) = \frac{3}{2-x} in the region ∣x∣<2|x| < 2. Find: The Maclaurin series of f(x)f(x).

  1. Factor 22 from the denominator so the constant term becomes 11: f(x)=32(11−x/2)f(x) = \frac{3}{2}\left(\frac{1}{1 - x/2}\right).
  2. Recall the standard geometric Maclaurin series 11−u=1+u+u2+u3+…\frac{1}{1-u} = 1 + u + u^2 + u^3 + \dots for ∣u∣<1|u| < 1.
  3. Check the convergence condition: since ∣x∣<2|x| < 2, the rescaled variable satisfies ∣x2∣<1|\frac{x}{2}| < 1.
  4. Replace uu with x2\frac{x}{2} in the geometric series and multiply by 32\frac{3}{2}.

Answer: 32(1+x2+(x2)2+(x2)3+… )\frac{3}{2} \left(1 + \frac{x}{2} + \left(\frac{x}{2}\right)^2 + \left(\frac{x}{2}\right)^3 + \dots \right)

Practice: Full Fourier Series on 2pi-Length Intervals

Having mastered power series at a point, we now practice computing full trigonometric Fourier series on standard 2π2\pi intervals for square waves and polynomials. The new skill here is breaking Euler's integrals across piecewise subintervals on [−π,π][-\pi, \pi] or [0,2π][0, 2\pi] and applying tabular integration by parts to find full Fourier expansions and sum classical infinite series.

The idea

When a function f(x)f(x) has period 2L=2π2L = 2\pi, the harmonic factor nπxL\frac{n\pi x}{L} simplifies directly to nxnx. Whether the base interval is [−π,π][-\pi, \pi] (where c=−πc = -\pi) or [0,2π][0, 2\pi] (where c=0c = 0), Euler's formulas take the streamlined form:

a0=12π∫cc+2πf(x) dx,an=1π∫cc+2πf(x)cos⁡(nx) dx,bn=1π∫cc+2πf(x)sin⁡(nx) dxa_0 = \frac{1}{2\pi} \int_{c}^{c+2\pi} f(x)\,dx, \quad a_n = \frac{1}{\pi} \int_{c}^{c+2\pi} f(x)\cos(nx)\,dx, \quad b_n = \frac{1}{\pi} \int_{c}^{c+2\pi} f(x)\sin(nx)\,dx

Two integration techniques handle almost every problem on these intervals. First, if f(x)f(x) is a piecewise-constant square wave with jump discontinuities, split each Euler integral into separate integrals over each subinterval where the formula for f(x)f(x) is constant. Second, if f(x)f(x) is a polynomial, use Bernoulli's integration by parts (tabular integration):

∫u v dx=uv1−u′v2+u′′v3−…\int u\,v\,dx = u v_1 - u' v_2 + u'' v_3 - \dots

where uu is the polynomial differentiated until it vanishes, and v1,v2,v3,…v_1, v_2, v_3, \dots are successive antiderivatives of cos⁡(nx)\cos(nx) or sin⁡(nx)\sin(nx).

Once you assemble the Fourier series S(x)=a0+∑n=1∞[ancos⁡(nx)+bnsin⁡(nx)]S(x) = a_0 + \sum_{n=1}^{\infty} [a_n \cos(nx) + b_n \sin(nx)], you can sum numerical series by applying Dirichlet's convergence theorem: at any point xx where f(x)f(x) is continuous, the series converges directly to the function value, S(x)=f(x)S(x) = f(x).

Worked example

Problem 2: Given: f(x)={−K,−π<x<0K,0<x<πf(x) = \begin{cases} -K, & -\pi < x < 0 \\ K, & 0 < x < \pi \end{cases} on (−π,π)(-\pi, \pi) with K>0K > 0. Find: The Fourier series of f(x)f(x) and the sum of 1−13+15−…1 - \frac{1}{3} + \frac{1}{5} - \dots

  1. Split the a0a_0 integral at the jump x=0x = 0 because f(x)f(x) changes formula there:
a0=12π[∫−π0(−K) dx+∫0πK dx]=12π[−Kπ+Kπ]=0a_0 = \frac{1}{2\pi}\left[\int_{-\pi}^{0} (-K)\,dx + \int_{0}^{\pi} K\,dx\right] = \frac{1}{2\pi}[-K\pi + K\pi] = 0
  1. Split the ana_n integral at x=0x = 0 and integrate cos⁡(nx)\cos(nx), which vanishes because sin⁡(nπ)=sin⁡(0)=0\sin(n\pi) = \sin(0) = 0:

    an=1π[[−Ksin⁡(nx)n]−π0+[Ksin⁡(nx)n]0π]=0a_n = \frac{1}{\pi}\left[\left[\frac{-K\sin(nx)}{n}\right]_{-\pi}^{0} + \left[\frac{K\sin(nx)}{n}\right]_{0}^{\pi}\right] = 0
  2. Split the bnb_n integral at x=0x = 0 and integrate sin⁡(nx)\sin(nx) to get cosine terms:

    bn=1π[[Kcos⁡(nx)n]−π0+[−Kcos⁡(nx)n]0π]b_n = \frac{1}{\pi}\left[\left[\frac{K\cos(nx)}{n}\right]_{-\pi}^{0} + \left[\frac{-K\cos(nx)}{n}\right]_{0}^{\pi}\right]
  3. Evaluate at the limits using cos⁡(−nπ)=cos⁡(nπ)=(−1)n\cos(-n\pi) = \cos(n\pi) = (-1)^n to simplify bnb_n:

    bn=Knπ[2−2cos⁡(nπ)]=2Knπ(1−(−1)n)b_n = \frac{K}{n\pi}[2 - 2\cos(n\pi)] = \frac{2K}{n\pi}(1 - (-1)^n)
  4. Substitute a0a_0, ana_n, and bnb_n into S(x)S(x), noting that 1−(−1)n1 - (-1)^n equals 22 for odd nn and 00 for even nn:

    f(x)=4Kπ[sin⁡x+13sin⁡(3x)+15sin⁡(5x)+… ]f(x) = \frac{4K}{\pi}\left[\sin x + \frac{1}{3}\sin(3x) + \frac{1}{5}\sin(5x) + \dots\right]
  5. Substitute x=π2x = \frac{\pi}{2}, where f(x)f(x) is continuous with f(π2)=Kf\left(\frac{\pi}{2}\right) = K, to evaluate the alternating series:

    K=4Kπ(1−13+15−… )  ⟹  1−13+15−⋯=π4K = \frac{4K}{\pi}\left(1 - \frac{1}{3} + \frac{1}{5} - \dots\right) \implies 1 - \frac{1}{3} + \frac{1}{5} - \dots = \frac{\pi}{4}

Answer: f(x)=4Kπ[sin⁡x+13sin⁡(3x)+15sin⁡(5x)+… ]f(x) = \frac{4K}{\pi}\left[\sin x + \frac{1}{3}\sin(3x) + \frac{1}{5}\sin(5x) + \dots\right], and 1−13+15−⋯=π41 - \frac{1}{3} + \frac{1}{5} - \dots = \frac{\pi}{4}.

More problems

Problem 3: Periodic square wave on [0, 2pi]

Given: f(x)={K,0≤x<π/2−K,π/2≤x<3π/2K,3π/2≤x<2πf(x) = \begin{cases} K, & 0 \le x < \pi/2 \\ -K, & \pi/2 \le x < 3\pi/2 \\ K, & 3\pi/2 \le x < 2\pi \end{cases} on [0,2π][0, 2\pi]. Find: The Fourier series of f(x)f(x) and the sum of 1−13+15−…1 - \frac{1}{3} + \frac{1}{5} - \dots

  1. Split the a0a_0 integral across the three subintervals to find the average value:

    a0=K2π[(π2−0)−(3π2−π2)+(2π−3π2)]=0a_0 = \frac{K}{2\pi}\left[\left(\frac{\pi}{2} - 0\right) - \left(\frac{3\pi}{2} - \frac{\pi}{2}\right) + \left(2\pi - \frac{3\pi}{2}\right)\right] = 0
  2. Integrate f(x)cos⁡(nx)f(x)\cos(nx) across all three subintervals:

    an=Knπ[2sin⁡(nπ2)−2sin⁡(3nπ2)]a_n = \frac{K}{n\pi}\left[2\sin\left(\frac{n\pi}{2}\right) - 2\sin\left(\frac{3n\pi}{2}\right)\right]
  3. Apply the identity sin⁡A−sin⁡B\sin A - \sin B to simplify ana_n:

    an=−4Knπcos⁡(nπ)sin⁡(nπ2)={0,n even4Knπsin⁡(nπ2),n odda_n = \frac{-4K}{n\pi}\cos(n\pi)\sin\left(\frac{n\pi}{2}\right) = \begin{cases} 0, & n \text{ even} \\ \frac{4K}{n\pi}\sin\left(\frac{n\pi}{2}\right), & n \text{ odd} \end{cases}
  4. Integrate f(x)sin⁡(nx)f(x)\sin(nx) across the three subintervals and apply cos⁡A−cos⁡B\cos A - \cos B, which vanishes because sin⁡(nπ)=0\sin(n\pi) = 0:

    bn=−Knπ[2cos⁡(nπ2)−2cos⁡(3nπ2)]=−4Knπsin⁡(nπ)sin⁡(nπ2)=0b_n = \frac{-K}{n\pi}\left[2\cos\left(\frac{n\pi}{2}\right) - 2\cos\left(\frac{3n\pi}{2}\right)\right] = \frac{-4K}{n\pi}\sin(n\pi)\sin\left(\frac{n\pi}{2}\right) = 0
  5. Write the Fourier series using only the odd cosine harmonics:

    S(x)=4Kπ[cos⁡x1−cos⁡(3x)3+cos⁡(5x)5−… ]S(x) = \frac{4K}{\pi}\left[\frac{\cos x}{1} - \frac{\cos(3x)}{3} + \frac{\cos(5x)}{5} - \dots\right]
  6. Set x=0x = 0, where f(x)f(x) is continuous with f(0)=Kf(0) = K, to find the numerical sum:

    K=4Kπ[1−13+15−… ]  ⟹  1−13+15−⋯=π4K = \frac{4K}{\pi}\left[1 - \frac{1}{3} + \frac{1}{5} - \dots\right] \implies 1 - \frac{1}{3} + \frac{1}{5} - \dots = \frac{\pi}{4}

Answer: S(x)=4Kπ[cos⁡x1−cos⁡(3x)3+cos⁡(5x)5−… ]S(x) = \frac{4K}{\pi}\left[\frac{\cos x}{1} - \frac{\cos(3x)}{3} + \frac{\cos(5x)}{5} - \dots\right], and 1−13+15−⋯=π41 - \frac{1}{3} + \frac{1}{5} - \dots = \frac{\pi}{4}.

Problem 4: Quadratic polynomial on (-pi, pi)

Given: f(x)=x−x2f(x) = x - x^2 on the interval (−π,π)(-\pi, \pi). Find: The Fourier series of x−x2x - x^2 and the sum of 112−122+132−142+…\frac{1}{1^2} - \frac{1}{2^2} + \frac{1}{3^2} - \frac{1}{4^2} + \dots

  1. Integrate x−x2x - x^2 from −π-\pi to π\pi to find a0a_0:

    a0=12π[x22−x33]−ππ=12π(−2π33)=−π23a_0 = \frac{1}{2\pi}\left[\frac{x^2}{2} - \frac{x^3}{3}\right]_{-\pi}^{\pi} = \frac{1}{2\pi}\left(\frac{-2\pi^3}{3}\right) = \frac{-\pi^2}{3}
  2. Apply Bernoulli's integration by parts to find ana_n:

    an=1π[(x−x2)(sin⁡(nx)n)−(1−2x)(−cos⁡(nx)n2)+(−2)(−sin⁡(nx)n3)]−ππa_n = \frac{1}{\pi}\left[(x - x^2)\left(\frac{\sin(nx)}{n}\right) - (1 - 2x)\left(\frac{-\cos(nx)}{n^2}\right) + (-2)\left(\frac{-\sin(nx)}{n^3}\right)\right]_{-\pi}^{\pi}
  3. Evaluate at ±π\pm\pi where sin⁡(±nπ)=0\sin(\pm n\pi) = 0 and cos⁡(±nπ)=(−1)n\cos(\pm n\pi) = (-1)^n:

    an=1π[((1−2π)−(1+2π))cos⁡(nπ)n2]=−4(−1)nn2a_n = \frac{1}{\pi}\left[((1 - 2\pi) - (1 + 2\pi))\frac{\cos(n\pi)}{n^2}\right] = \frac{-4(-1)^n}{n^2}
  4. Apply Bernoulli's integration by parts to find bnb_n:

    bn=1π[(x−x2)(−cos⁡(nx)n)−(1−2x)(−sin⁡(nx)n2)+(−2)(cos⁡(nx)n3)]−ππb_n = \frac{1}{\pi}\left[(x - x^2)\left(\frac{-\cos(nx)}{n}\right) - (1 - 2x)\left(\frac{-\sin(nx)}{n^2}\right) + (-2)\left(\frac{\cos(nx)}{n^3}\right)\right]_{-\pi}^{\pi}
  5. Evaluate at ±π\pm\pi, where the n3n^3 cosine terms cancel each other:

    bn=1π[(−(π−π2)+(−π−π2))cos⁡(nπ)n]=−2(−1)nnb_n = \frac{1}{\pi}\left[(-(\pi - \pi^2) + (-\pi - \pi^2))\frac{\cos(n\pi)}{n}\right] = \frac{-2(-1)^n}{n}
  6. Assemble the full Fourier series expansion:

    S(x)=−π23+4[cos⁡x12−cos⁡(2x)22+cos⁡(3x)32−… ]+2[sin⁡x1−sin⁡(2x)2+… ]S(x) = \frac{-\pi^2}{3} + 4\left[\frac{\cos x}{1^2} - \frac{\cos(2x)}{2^2} + \frac{\cos(3x)}{3^2} - \dots\right] + 2\left[\frac{\sin x}{1} - \frac{\sin(2x)}{2} + \dots\right]
  7. Substitute x=0x = 0, where f(0)=0f(0) = 0 is continuous, to solve for the alternating series:

    0=−π23+4[112−122+132−… ]  ⟹  112−122+132−142+⋯=π2120 = \frac{-\pi^2}{3} + 4\left[\frac{1}{1^2} - \frac{1}{2^2} + \frac{1}{3^2} - \dots\right] \implies \frac{1}{1^2} - \frac{1}{2^2} + \frac{1}{3^2} - \frac{1}{4^2} + \dots = \frac{\pi^2}{12}

Answer: S(x)=−π23+4∑n=1∞(−1)n+1cos⁡(nx)n2+2∑n=1∞(−1)n+1sin⁡(nx)nS(x) = \frac{-\pi^2}{3} + 4\sum_{n=1}^{\infty}\frac{(-1)^{n+1}\cos(nx)}{n^2} + 2\sum_{n=1}^{\infty}\frac{(-1)^{n+1}\sin(nx)}{n}, and 112−122+132−142+⋯=π212\frac{1}{1^2} - \frac{1}{2^2} + \frac{1}{3^2} - \frac{1}{4^2} + \dots = \frac{\pi^2}{12}.

Problem 4.2.7: Shifted parabola on [0, 2pi]

Given: f(x)=(π−x)24f(x) = \frac{(\pi - x)^2}{4} with period 2π2\pi on [0,2π][0, 2\pi]. Find: The Fourier series of f(x)f(x) and the sum ∑n=1∞1n2\sum_{n=1}^{\infty} \frac{1}{n^2}.

  1. Integrate f(x)f(x) on [0,2π][0, 2\pi] to find a0a_0:

    a0=18π[(π−x)3(−1)3]02π=−124π[(−π)3−π3]=π212a_0 = \frac{1}{8\pi}\left[\frac{(\pi - x)^3(-1)}{3}\right]_{0}^{2\pi} = -\frac{1}{24\pi}[(-\pi)^3 - \pi^3] = \frac{\pi^2}{12}
  2. Apply Bernoulli's rule to integrate f(x)cos⁡(nx)f(x)\cos(nx), remembering the chain-rule factor (−1)(-1) when differentiating (π−x)(\pi - x):

    an=14π[(π−x)2sin⁡(nx)n−2(π−x)cos⁡(nx)n2−2sin⁡(nx)n3]02πa_n = \frac{1}{4\pi}\left[\frac{(\pi - x)^2\sin(nx)}{n} - \frac{2(\pi - x)\cos(nx)}{n^2} - \frac{2\sin(nx)}{n^3}\right]_{0}^{2\pi}
  3. Evaluate at 00 and 2π2\pi using cos⁡(2nπ)=cos⁡(0)=1\cos(2n\pi) = \cos(0) = 1 and sin⁡(2nπ)=sin⁡(0)=0\sin(2n\pi) = \sin(0) = 0:

    an=14π[2πn2+2πn2]=1n2a_n = \frac{1}{4\pi}\left[\frac{2\pi}{n^2} + \frac{2\pi}{n^2}\right] = \frac{1}{n^2}
  4. Apply Bernoulli's rule to integrate f(x)sin⁡(nx)f(x)\sin(nx) on [0,2π][0, 2\pi]:

    bn=14π[−(π−x)2cos⁡(nx)n−2(π−x)sin⁡(nx)n2+2cos⁡(nx)n3]02π=0b_n = \frac{1}{4\pi}\left[-\frac{(\pi - x)^2\cos(nx)}{n} - \frac{2(\pi - x)\sin(nx)}{n^2} + \frac{2\cos(nx)}{n^3}\right]_{0}^{2\pi} = 0
  5. Combine a0a_0, ana_n, and bnb_n into the Fourier series:

    S(x)=π212+∑n=1∞1n2cos⁡(nx)S(x) = \frac{\pi^2}{12} + \sum_{n=1}^{\infty} \frac{1}{n^2}\cos(nx)
  6. Substitute x=0x = 0, where the periodic extension is continuous with f(0)=π24f(0) = \frac{\pi^2}{4}, to evaluate the sum:

    π24=π212+∑n=1∞1n2  ⟹  ∑n=1∞1n2=π26\frac{\pi^2}{4} = \frac{\pi^2}{12} + \sum_{n=1}^{\infty}\frac{1}{n^2} \implies \sum_{n=1}^{\infty}\frac{1}{n^2} = \frac{\pi^2}{6}

Periodic parabolic graph of (π − x)² / 4

Watch out. When differentiating (π−x)2(\pi - x)^2 during tabular integration, do not forget the inner derivative (−1)(-1): its first derivative is −2(π−x)-2(\pi - x) and its second derivative is +2+2.

Answer: S(x)=π212+∑n=1∞1n2cos⁡(nx)S(x) = \frac{\pi^2}{12} + \sum_{n=1}^{\infty} \frac{1}{n^2}\cos(nx), and ∑n=1∞1n2=π26\sum_{n=1}^{\infty} \frac{1}{n^2} = \frac{\pi^2}{6}.

Problem 5: Absolute value function on [-pi, pi]

Given: f(x)=∣x∣f(x) = |x| on [−π,π][-\pi, \pi]. Find: The Fourier series of f(x)f(x) and the sum of 1+132+152+…1 + \frac{1}{3^2} + \frac{1}{5^2} + \dots

  1. Split the integral at x=0x = 0 where ∣x∣|x| changes from −x-x to xx to compute a0a_0:

    a0=12π[∫−π0(−x) dx+∫0πx dx]=12π[π22+π22]=π2a_0 = \frac{1}{2\pi}\left[\int_{-\pi}^{0} (-x)\,dx + \int_{0}^{\pi} x\,dx\right] = \frac{1}{2\pi}\left[\frac{\pi^2}{2} + \frac{\pi^2}{2}\right] = \frac{\pi}{2}
  2. Integrate ∣x∣cos⁡(nx)|x|\cos(nx) by parts across [−π,0][-\pi, 0] and [0,π][0, \pi]:

    an=2π[xsin⁡(nx)n+cos⁡(nx)n2]0π=2πn2[(−1)n−1]a_n = \frac{2}{\pi}\left[x\frac{\sin(nx)}{n} + \frac{\cos(nx)}{n^2}\right]_{0}^{\pi} = \frac{2}{\pi n^2}[(-1)^n - 1]
  3. Integrate ∣x∣sin⁡(nx)|x|\sin(nx) across [−π,0][-\pi, 0] and [0,π][0, \pi], where the two halves cancel by odd symmetry:

    bn=1π[∫−π0(−x)sin⁡(nx) dx+∫0πxsin⁡(nx) dx]=0b_n = \frac{1}{\pi}\left[\int_{-\pi}^{0} (-x)\sin(nx)\,dx + \int_{0}^{\pi} x\sin(nx)\,dx\right] = 0
  4. Write the Fourier series keeping only odd nn where (−1)n−1=−2(-1)^n - 1 = -2:

    S(x)=π2−4π[cos⁡x12+cos⁡(3x)32+cos⁡(5x)52+… ]S(x) = \frac{\pi}{2} - \frac{4}{\pi}\left[\frac{\cos x}{1^2} + \frac{\cos(3x)}{3^2} + \frac{\cos(5x)}{5^2} + \dots\right]
  5. Substitute x=0x = 0, where f(x)=∣x∣f(x) = |x| is continuous with f(0)=0f(0) = 0, to evaluate the sum:

    0=π2−4π[1+132+152+… ]  ⟹  1+132+152+⋯=π280 = \frac{\pi}{2} - \frac{4}{\pi}\left[1 + \frac{1}{3^2} + \frac{1}{5^2} + \dots\right] \implies 1 + \frac{1}{3^2} + \frac{1}{5^2} + \dots = \frac{\pi^2}{8}

Answer: S(x)=π2−4π∑n=1,3,5,…∞cos⁡(nx)n2S(x) = \frac{\pi}{2} - \frac{4}{\pi}\sum_{n=1,3,5,\dots}^{\infty}\frac{\cos(nx)}{n^2}, and 1+132+152+⋯=π281 + \frac{1}{3^2} + \frac{1}{5^2} + \dots = \frac{\pi^2}{8}.

Problem 6: Product x sin(x) on (-pi, pi)

Given: f(x)=xsin⁡xf(x) = x\sin x on −π<x<π-\pi < x < \pi. Find: The Fourier series of f(x)f(x) and the sums (i) 1+21⋅3−23⋅5+25⋅7−…1 + \frac{2}{1\cdot 3} - \frac{2}{3\cdot 5} + \frac{2}{5\cdot 7} - \dots and (ii) 11⋅3−12⋅4+13⋅5−…\frac{1}{1\cdot 3} - \frac{1}{2\cdot 4} + \frac{1}{3\cdot 5} - \dots

  1. Integrate xsin⁡xx\sin x by parts on (−π,π)(-\pi, \pi) to find a0a_0:

    a0=12π[−xcos⁡x+sin⁡x]−ππ=12π[−2πcos⁡π]=1a_0 = \frac{1}{2\pi}\Big[-x\cos x + \sin x\Big]_{-\pi}^{\pi} = \frac{1}{2\pi}[-2\pi\cos\pi] = 1
  2. Compute a1a_1 separately because sin⁡xcos⁡x=12sin⁡(2x)\sin x \cos x = \frac{1}{2}\sin(2x) prevents division by n2−1n^2 - 1:

    a1=1π∫−ππxsin⁡xcos⁡x dx=12π[−xcos⁡(2x)2+sin⁡(2x)4]−ππ=−12a_1 = \frac{1}{\pi}\int_{-\pi}^{\pi} x\sin x\cos x\,dx = \frac{1}{2\pi}\Big[-x\frac{\cos(2x)}{2} + \frac{\sin(2x)}{4}\Big]_{-\pi}^{\pi} = -\frac{1}{2}
  3. For n≥2n \ge 2, rewrite sin⁡xcos⁡(nx)=12[sin⁡((n+1)x)−sin⁡((n−1)x)]\sin x\cos(nx) = \frac{1}{2}[\sin((n+1)x) - \sin((n-1)x)] and integrate by parts:

    an=1π[−πcos⁡((n+1)π)n+1+πcos⁡((n−1)π)n−1]=2(−1)n+1n2−1a_n = \frac{1}{\pi}\left[\frac{-\pi\cos((n+1)\pi)}{n+1} + \frac{\pi\cos((n-1)\pi)}{n-1}\right] = \frac{2(-1)^{n+1}}{n^2 - 1}
  4. Note that bn=0b_n = 0 for all nn because xsin⁡xsin⁡(nx)x\sin x\sin(nx) is odd on (−π,π)(-\pi, \pi).

  5. Assemble the Fourier series with n2−1=(n−1)(n+1)n^2 - 1 = (n-1)(n+1):

    S(x)=1−12cos⁡x−2[cos⁡(2x)1⋅3−cos⁡(3x)2⋅4+cos⁡(4x)3⋅5−… ]S(x) = 1 - \frac{1}{2}\cos x - 2\left[\frac{\cos(2x)}{1\cdot 3} - \frac{\cos(3x)}{2\cdot 4} + \frac{\cos(4x)}{3\cdot 5} - \dots\right]
  6. Substitute x=π2x = \frac{\pi}{2}, where f(π2)=π2f\left(\frac{\pi}{2}\right) = \frac{\pi}{2} and odd cosines vanish, to find sum (i):

    π2=1+21⋅3−23⋅5+25⋅7−…\frac{\pi}{2} = 1 + \frac{2}{1\cdot 3} - \frac{2}{3\cdot 5} + \frac{2}{5\cdot 7} - \dots
  7. Substitute x=0x = 0, where f(0)=0f(0) = 0, to solve for sum (ii):

    0=1−12−2[11⋅3−12⋅4+13⋅5−… ]  ⟹  11⋅3−12⋅4+13⋅5−⋯=140 = 1 - \frac{1}{2} - 2\left[\frac{1}{1\cdot 3} - \frac{1}{2\cdot 4} + \frac{1}{3\cdot 5} - \dots\right] \implies \frac{1}{1\cdot 3} - \frac{1}{2\cdot 4} + \frac{1}{3\cdot 5} - \dots = \frac{1}{4}

Answer: S(x)=1−12cos⁡x+2∑n=2∞(−1)n+1cos⁡(nx)n2−1S(x) = 1 - \frac{1}{2}\cos x + 2\sum_{n=2}^{\infty}\frac{(-1)^{n+1}\cos(nx)}{n^2 - 1}; (i) π2\frac{\pi}{2}; (ii) 14\frac{1}{4}.

Practice: Full Fourier Series on Arbitrary Intervals [-L, L] and [0, 2L]

Now that you can expand functions with period 2π2\pi, we extend the exact same method to functions of any period 2L2L by scaling the harmonic arguments. In this section, you will replace nxnx with nπxL\frac{n\pi x}{L} in Euler's formulas to handle arbitrary interval lengths, and combine evaluations at continuous and jump points to solve for multiple infinite series at once.

The idea

Standard sines and cosines repeat every 2π2\pi units, so they cannot directly build a function that repeats every 2L2L units. By replacing the argument nxnx with the scaled frequency nπxL\frac{n\pi x}{L}, each wave completes exactly nn full cycles as xx travels across an interval of length 2L2L. Whether the base interval is symmetric like [−L,L][-L, L] or shifted like [0,2L][0, 2L], the half-period LL is always half the total interval length.

With this scaling, the Fourier series becomes S(x)=a0+∑n=1∞[ancos⁡(nπxL)+bnsin⁡(nπxL)]S(x) = a_0 + \sum_{n=1}^{\infty} \left[a_n \cos\left(\frac{n\pi x}{L}\right) + b_n \sin\left(\frac{n\pi x}{L}\right)\right]. In Euler's integrals, the front multiplier 1π\frac{1}{\pi} becomes 1L\frac{1}{L} (and 12π\frac{1}{2\pi} becomes 12L\frac{1}{2L} for a0a_0). When you integrate cos⁡(nπxL)\cos\left(\frac{n\pi x}{L}\right) or sin⁡(nπxL)\sin\left(\frac{n\pi x}{L}\right) by parts, each antiderivative step brings out a factor of Lnπ\frac{L}{n\pi} instead of 1n\frac{1}{n}. At the interval boundaries x=±Lx = \pm L or x=2Lx = 2L, the scaled angles simplify cleanly to multiples of nπn\pi, where sin⁡(nπ)=0\sin(n\pi) = 0 and cos⁡(nπ)=(−1)n\cos(n\pi) = (-1)^n.

Once you have the series, you can evaluate multiple numerical sums from a single expansion. Evaluating S(x)S(x) at an interior point where f(x)f(x) is continuous gives one series, while evaluating at a jump discontinuity (including the endpoints where the periodic copies meet) gives a second series via the average f(x+)+f(x−)2\frac{f(x^+) + f(x^-)}{2}. Adding or subtracting those two results isolates even-term or odd-term sub-series.

Worked example

Problem 4.2.10. Given: f(x)=x∣x∣f(x) = x|x| on the interval (−1,1)(-1, 1). Find: The Fourier series S(x)S(x) on (−1,1)(-1, 1).

  1. Find the half-period LL from the interval length 2L=1−(−1)=22L = 1 - (-1) = 2, which gives L=1L = 1 and harmonic arguments nπx1=nπx\frac{n\pi x}{1} = n\pi x.

  2. Check symmetry on (−1,1)(-1, 1): since f(−x)=(−x)∣−x∣=−x∣x∣=−f(x)f(-x) = (-x)|-x| = -x|x| = -f(x), the function is odd, so a0=0a_0 = 0 and an=0a_n = 0 because the product of an odd function and an even cosine is odd.

  3. Set up the sine coefficient integral using even symmetry of f(x)sin⁡(nπx)f(x)\sin(n\pi x), and replace ∣x∣|x| with xx since x>0x > 0 on (0,1)(0, 1):

    bn=11∫−11x∣x∣sin⁡(nπx) dx=2∫01x2sin⁡(nπx) dxb_n = \frac{1}{1} \int_{-1}^{1} x|x| \sin(n\pi x)\,dx = 2 \int_{0}^{1} x^2 \sin(n\pi x)\,dx
  4. Apply tabular integration by parts three times to integrate x2sin⁡(nπx)x^2 \sin(n\pi x), dividing by nπn\pi at each step:

    bn=2[x2(−cos⁡(nπx)nπ)−2x(−sin⁡(nπx)n2π2)+2(cos⁡(nπx)n3π3)]01b_n = 2 \left[ x^2 \left(\frac{-\cos(n\pi x)}{n\pi}\right) - 2x \left(\frac{-\sin(n\pi x)}{n^2\pi^2}\right) + 2 \left(\frac{\cos(n\pi x)}{n^3\pi^3}\right) \right]_{0}^{1}
  5. Substitute the limits x=1x = 1 and x=0x = 0, using sin⁡(nπ)=0\sin(n\pi) = 0, cos⁡(nπ)=(−1)n\cos(n\pi) = (-1)^n, and cos⁡(0)=1\cos(0) = 1:

    bn=2[−(−1)nnπ+0+2(−1)nn3π3−(0+0+2n3π3)]=2[(−1)n+1nπ+2n3π3((−1)n−1)]b_n = 2 \left[ \frac{-(-1)^n}{n\pi} + 0 + \frac{2(-1)^n}{n^3\pi^3} - \left(0 + 0 + \frac{2}{n^3\pi^3}\right) \right] = 2 \left[ \frac{(-1)^{n+1}}{n\pi} + \frac{2}{n^3\pi^3}\left((-1)^n - 1\right) \right]
  6. Substitute a0=0a_0 = 0, an=0a_n = 0, and bnb_n into the scaled Fourier series formula.

Answer: S(x)=∑n=1∞2[(−1)n+1nπ+2n3π3((−1)n−1)]sin⁡(nπx)S(x) = \sum_{n=1}^{\infty} 2 \left[ \frac{(-1)^{n+1}}{n\pi} + \frac{2}{n^3\pi^3}\left((-1)^n - 1\right) \right] \sin(n\pi x).

More problems

Problem 4.2.12: Exponential function on (0, 2)

Given: f(x)=e−xf(x) = e^{-x} on the interval (0,2)(0, 2). Find: The Fourier series S(x)S(x).

  1. From c=0c = 0 and 2L=22L = 2, set L=1L = 1 so the harmonic arguments are nπx1=nπx\frac{n\pi x}{1} = n\pi x.

  2. Compute the average term a0a_0 across (0,2)(0, 2):

    a0=12∫02e−x dx=12[−e−x]02=1−e−22a_0 = \frac{1}{2} \int_{0}^{2} e^{-x}\,dx = \frac{1}{2} \left[ -e^{-x} \right]_{0}^{2} = \frac{1 - e^{-2}}{2}
  3. Set up the cosine integral an=∫02e−xcos⁡(nπx) dxa_n = \int_{0}^{2} e^{-x} \cos(n\pi x)\,dx and apply the standard exponential-cosine antiderivative formula:

    an=[e−x(−1)2+(nπ)2(−cos⁡(nπx)+nπsin⁡(nπx))]01=1−e−1(−1)n1+n2π2a_n = \left[ \frac{e^{-x}}{(-1)^2 + (n\pi)^2} \left(-\cos(n\pi x) + n\pi \sin(n\pi x)\right) \right]_{0}^{1} = \frac{1 - e^{-1}(-1)^n}{1 + n^2\pi^2}
  4. Set up the sine integral bn=∫02e−xsin⁡(nπx) dxb_n = \int_{0}^{2} e^{-x} \sin(n\pi x)\,dx and apply the standard exponential-sine antiderivative formula:

    bn=[e−x(−1)2+(nπ)2(−sin⁡(nπx)−nπcos⁡(nπx))]01=nπ1+n2π2[1−e−1(−1)n]b_n = \left[ \frac{e^{-x}}{(-1)^2 + (n\pi)^2} \left(-\sin(n\pi x) - n\pi \cos(n\pi x)\right) \right]_{0}^{1} = \frac{n\pi}{1 + n^2\pi^2} \left[1 - e^{-1}(-1)^n\right]
  5. Substitute a0a_0, ana_n, and bnb_n into the Fourier series expansion.

Periodic graph of e⁻ˣ

Watch out. In steps 3 and 4, the integral starts with upper limit 22, but the evaluation switches the upper limit to 11, producing e−1(−1)ne^{-1}(-1)^n instead of e−2e^{-2}.

Answer: S(x)=1−e−22+∑n=1∞[1−e−1(−1)n1+n2π2cos⁡(nπx)+nπ1+n2π2[1−e−1(−1)n]sin⁡(nπx)]S(x) = \frac{1 - e^{-2}}{2} + \sum_{n=1}^{\infty} \left[ \frac{1 - e^{-1}(-1)^n}{1 + n^2\pi^2} \cos(n\pi x) + \frac{n\pi}{1 + n^2\pi^2}\left[1 - e^{-1}(-1)^n\right] \sin(n\pi x) \right].

Problem 4.2.8: Piecewise linear function on [-l, l]

Given: f(x)=−xf(x) = -x on −l≤x<0-l \le x < 0 and f(x)=π+xf(x) = \pi + x on 0≤x<l0 \le x < l. Find: The Fourier series S(x)S(x) and the sum 1+132+152+⋯1 + \frac{1}{3^2} + \frac{1}{5^2} + \cdots

  1. Split the a0a_0 integral at x=0x = 0 and integrate each piece:

    a0=12l[∫−l0(−x) dx+∫0l(π+x) dx]=12l[l22+πl+l22]=12(π+l)a_0 = \frac{1}{2l} \left[ \int_{-l}^{0} (-x)\,dx + \int_{0}^{l} (\pi + x)\,dx \right] = \frac{1}{2l}\left[\frac{l^2}{2} + \pi l + \frac{l^2}{2}\right] = \frac{1}{2}(\pi + l)
  2. Substitute x→−xx \to -x on [−l,0][-l, 0] to fold the two cosine integrals into one integral over [0,l][0, l]:

    an=1l[∫−l0(−x)cos⁡nπxl dx+∫0l(π+x)cos⁡nπxl dx]=1l∫0l(2x+π)cos⁡nπxl dxa_n = \frac{1}{l} \left[ \int_{-l}^{0} (-x)\cos\frac{n\pi x}{l}\,dx + \int_{0}^{l} (\pi + x)\cos\frac{n\pi x}{l}\,dx \right] = \frac{1}{l} \int_{0}^{l} (2x + \pi)\cos\frac{n\pi x}{l}\,dx
  3. Integrate ana_n by parts, bringing out lnπ\frac{l}{n\pi} each time, and evaluate at 00 and ll:

    an=1l[(2x+π)lnπsin⁡nπxl+2(lnπ)2cos⁡nπxl]0l=2ln2π2[(−1)n−1]a_n = \frac{1}{l} \left[ (2x + \pi)\frac{l}{n\pi}\sin\frac{n\pi x}{l} + 2\left(\frac{l}{n\pi}\right)^2\cos\frac{n\pi x}{l} \right]_{0}^{l} = \frac{2l}{n^2\pi^2}\left[(-1)^n - 1\right]
  4. Fold the sine integrals on [−l,0][-l, 0] and [0,l][0, l]; the xsin⁡(nπxl)x\sin\left(\frac{n\pi x}{l}\right) terms cancel because xsin⁡(nπxl)x\sin\left(\frac{n\pi x}{l}\right) is even:

    bn=1l[−∫−l0xsin⁡nπxl dx+∫0l(π+x)sin⁡nπxl dx]=πl∫0lsin⁡nπxl dx=1n[1−(−1)n]b_n = \frac{1}{l} \left[ -\int_{-l}^{0} x\sin\frac{n\pi x}{l}\,dx + \int_{0}^{l} (\pi + x)\sin\frac{n\pi x}{l}\,dx \right] = \frac{\pi}{l} \int_{0}^{l} \sin\frac{n\pi x}{l}\,dx = \frac{1}{n}\left[1 - (-1)^n\right]
  5. Note that for even nn, an=0a_n = 0 and bn=0b_n = 0; for odd nn, an=−4ln2π2a_n = \frac{-4l}{n^2\pi^2} and bn=2nb_n = \frac{2}{n}.

  6. Evaluate the series at the jump x=0x = 0, where f(0+)+f(0−)2=π+02=π2\frac{f(0^+) + f(0^-)}{2} = \frac{\pi + 0}{2} = \frac{\pi}{2} and sin⁡(0)=0\sin(0) = 0:

    π2=12(π+l)−4lπ2(1+132+152+⋯ )  ⟹  1+132+152+⋯=π28\frac{\pi}{2} = \frac{1}{2}(\pi + l) - \frac{4l}{\pi^2}\left(1 + \frac{1}{3^2} + \frac{1}{5^2} + \cdots\right) \implies 1 + \frac{1}{3^2} + \frac{1}{5^2} + \cdots = \frac{\pi^2}{8}

Watch out. The printed final series writes l2(π+l)\frac{l}{2}(\pi + l) for a0a_0 and cos⁡nx\cos nx for the cosine term, instead of 12(π+l)\frac{1}{2}(\pi + l) and cos⁡(nπxl)\cos\left(\frac{n\pi x}{l}\right).

Answer: S(x)=l2(π+l)+∑n=1,3,5,…[−4ln2π2cos⁡nx+2nsin⁡nπxl]S(x) = \frac{l}{2}(\pi + l) + \sum_{n=1,3,5,\dots} \left[-\frac{4l}{n^2\pi^2}\cos nx + \frac{2}{n}\sin\frac{n\pi x}{l}\right]; 1+132+152+⋯=π281 + \frac{1}{3^2} + \frac{1}{5^2} + \cdots = \frac{\pi^2}{8}.

Problem 4.2.9: Step-ramp function on [-2, 2]

Given: f(x)=2f(x) = 2 on −2≤x<0-2 \le x < 0 and f(x)=xf(x) = x on 0≤x<20 \le x < 2. Find: The Fourier series S(x)S(x), (i) 1+132+152+⋯1 + \frac{1}{3^2} + \frac{1}{5^2} + \cdots, and (ii) 1−13+15−⋯1 - \frac{1}{3} + \frac{1}{5} - \cdots

  1. Since 2L=42L = 4, set L=2L = 2 and integrate the two pieces to find a0a_0:

    a0=14[∫−202 dx+∫02x dx]=14[4+2]=32a_0 = \frac{1}{4}\left[\int_{-2}^{0} 2\,dx + \int_{0}^{2} x\,dx\right] = \frac{1}{4}\left[4 + 2\right] = \frac{3}{2}
  2. Integrate ana_n across [−2,0][-2, 0] and [0,2][0, 2] using integration by parts on the second piece:

    an=12[4nπsin⁡(nπx2)∣−20+(2xnπsin⁡(nπx2)+4n2π2cos⁡(nπx2))∣02]=2n2π2[(−1)n−1]a_n = \frac{1}{2}\left[\left.\frac{4}{n\pi}\sin\left(\frac{n\pi x}{2}\right)\right|_{-2}^{0} + \left.\left(\frac{2x}{n\pi}\sin\left(\frac{n\pi x}{2}\right) + \frac{4}{n^2\pi^2}\cos\left(\frac{n\pi x}{2}\right)\right)\right|_{0}^{2}\right] = \frac{2}{n^2\pi^2}\left[(-1)^n - 1\right]
  3. Integrate bnb_n across both pieces and evaluate at the limits:

    bn=12[−4nπcos⁡(nπx2)∣−20+(−2xnπcos⁡(nπx2)+4n2π2sin⁡(nπx2))∣02]=−2nπb_n = \frac{1}{2}\left[\left.-\frac{4}{n\pi}\cos\left(\frac{n\pi x}{2}\right)\right|_{-2}^{0} + \left.\left(-\frac{2x}{n\pi}\cos\left(\frac{n\pi x}{2}\right) + \frac{4}{n^2\pi^2}\sin\left(\frac{n\pi x}{2}\right)\right)\right|_{0}^{2}\right] = -\frac{2}{n\pi}
  4. Write out the full series using the odd-index values an=−4n2π2a_n = -\frac{4}{n^2\pi^2} and all-index values bn=−2nπb_n = -\frac{2}{n\pi}.

  5. At the jump x=0x = 0, set S(0)=f(0+)+f(0−)2=0+22=1S(0) = \frac{f(0^+) + f(0^-)}{2} = \frac{0 + 2}{2} = 1 to solve for series (i):

    1=32−4π2(1+132+152+⋯ )  ⟹  1+132+152+⋯=π281 = \frac{3}{2} - \frac{4}{\pi^2}\left(1 + \frac{1}{3^2} + \frac{1}{5^2} + \cdots\right) \implies 1 + \frac{1}{3^2} + \frac{1}{5^2} + \cdots = \frac{\pi^2}{8}
  6. At the continuity point x=1x = 1, set S(1)=f(1)=1S(1) = f(1) = 1 (where cos⁡(nπ2)=0\cos\left(\frac{n\pi}{2}\right) = 0 for odd nn) to solve for series (ii):

    1=32−2π(1−13+15−⋯ )  ⟹  1−13+15−⋯=π41 = \frac{3}{2} - \frac{2}{\pi}\left(1 - \frac{1}{3} + \frac{1}{5} - \cdots\right) \implies 1 - \frac{1}{3} + \frac{1}{5} - \cdots = \frac{\pi}{4}
xy-4-220246

Answer: S(x)=32+∑n=1∞[2n2π2[(−1)n−1]cos⁡(nπx2)−2nπsin⁡(nπx2)]S(x) = \frac{3}{2} + \sum_{n=1}^{\infty}\left[\frac{2}{n^2\pi^2}\left[(-1)^n - 1\right]\cos\left(\frac{n\pi x}{2}\right) - \frac{2}{n\pi}\sin\left(\frac{n\pi x}{2}\right)\right]; (i) π28\frac{\pi^2}{8}; (ii) π4\frac{\pi}{4}.

Problem 4.2.11: Quadratic function on (0, 3)

Given: f(x)=2x−x2f(x) = 2x - x^2 on the interval (0,3)(0, 3). Find: The Fourier series S(x)S(x), (i) ∑(−1)n−1n2\sum \frac{(-1)^{n-1}}{n^2}, (ii) ∑1n2\sum \frac{1}{n^2}, and (iii) ∑odd n1n2\sum_{\text{odd } n} \frac{1}{n^2}.

  1. From 2L=32L = 3, set L=32L = \frac{3}{2} so the harmonic arguments are nπx3/2=2nπx3\frac{n\pi x}{3/2} = \frac{2n\pi x}{3}.

  2. Compute the average term a0a_0 over (0,3)(0, 3):

    a0=13∫03(2x−x2) dx=13[x2−x33]03=0a_0 = \frac{1}{3}\int_{0}^{3} (2x - x^2)\,dx = \frac{1}{3}\left[x^2 - \frac{x^3}{3}\right]_{0}^{3} = 0
  3. Apply three-step tabular integration by parts to find ana_n, noting that sin⁡(2nπ)=sin⁡(0)=0\sin(2n\pi) = \sin(0) = 0 and cos⁡(2nπ)=1\cos(2n\pi) = 1:

    an=23[(2x−x2)32nπsin⁡2nπx3+(2−2x)(32nπ)2cos⁡2nπx3+2(32nπ)3sin⁡2nπx3]03=−9n2π2a_n = \frac{2}{3}\left[(2x - x^2)\frac{3}{2n\pi}\sin\frac{2n\pi x}{3} + (2 - 2x)\left(\frac{3}{2n\pi}\right)^2\cos\frac{2n\pi x}{3} + 2\left(\frac{3}{2n\pi}\right)^3\sin\frac{2n\pi x}{3}\right]_{0}^{3} = -\frac{9}{n^2\pi^2}
  4. Apply three-step tabular integration by parts to find bnb_n, where the (32nπ)3cos⁡(2nπx3)\left(\frac{3}{2n\pi}\right)^3\cos\left(\frac{2n\pi x}{3}\right) terms cancel at 33 and 00:

    bn=23[−(2x−x2)32nπcos⁡2nπx3+(2−2x)(32nπ)2sin⁡2nπx3−2(32nπ)3cos⁡2nπx3]03=3nπb_n = \frac{2}{3}\left[-(2x - x^2)\frac{3}{2n\pi}\cos\frac{2n\pi x}{3} + (2 - 2x)\left(\frac{3}{2n\pi}\right)^2\sin\frac{2n\pi x}{3} - 2\left(\frac{3}{2n\pi}\right)^3\cos\frac{2n\pi x}{3}\right]_{0}^{3} = \frac{3}{n\pi}
  5. For (i), evaluate at the continuous midpoint x=32x = \frac{3}{2}, where f(32)=34f\left(\frac{3}{2}\right) = \frac{3}{4}, cos⁡(nπ)=(−1)n\cos(n\pi) = (-1)^n, and sin⁡(nπ)=0\sin(n\pi) = 0:

    34=−9π2∑n=1∞(−1)nn2=9π2(112−122+132−⋯ )  ⟹  112−122+132−⋯=π212\frac{3}{4} = -\frac{9}{\pi^2}\sum_{n=1}^{\infty} \frac{(-1)^n}{n^2} = \frac{9}{\pi^2}\left(\frac{1}{1^2} - \frac{1}{2^2} + \frac{1}{3^2} - \cdots\right) \implies \frac{1}{1^2} - \frac{1}{2^2} + \frac{1}{3^2} - \cdots = \frac{\pi^2}{12}
  6. For (ii), evaluate at the endpoint jump x=0x = 0, using f(0+)=0f(0^+) = 0 and f(0−)=f(3)=−3f(0^-) = f(3) = -3:

    0+(−3)2=−9π2∑n=1∞1n2  ⟹  112+122+132+⋯=π26\frac{0 + (-3)}{2} = -\frac{9}{\pi^2}\sum_{n=1}^{\infty}\frac{1}{n^2} \implies \frac{1}{1^2} + \frac{1}{2^2} + \frac{1}{3^2} + \cdots = \frac{\pi^2}{6}
  7. For (iii), average the series from (i) and (ii) so the even-indexed terms cancel out:

    12(π212+π26)=112+132+152+⋯=π28\frac{1}{2}\left(\frac{\pi^2}{12} + \frac{\pi^2}{6}\right) = \frac{1}{1^2} + \frac{1}{3^2} + \frac{1}{5^2} + \cdots = \frac{\pi^2}{8}

Periodic graph of 2x − x²

Answer: S(x)=∑n=1∞[−9n2π2cos⁡2nπx3+3nπsin⁡2nπx3]S(x) = \sum_{n=1}^{\infty}\left[-\frac{9}{n^2\pi^2}\cos\frac{2n\pi x}{3} + \frac{3}{n\pi}\sin\frac{2n\pi x}{3}\right]; (i) π212\frac{\pi^2}{12}; (ii) π26\frac{\pi^2}{6}; (iii) π28\frac{\pi^2}{8}.

Practice: Half-Range Cosine Series on [0,L][0, L]

You already know how to integrate over a full interval [−L,L][-L, L] to find both cosine and sine coefficients. Instead of integrating over a full period, we now practice extending a function evenly on [0,L][0, L] so that bn=0b_n = 0 and only cosine coefficients need to be computed. We also take care to compute the n=1n = 1 coefficient separately whenever a product-to-sum formula divides by n−1n - 1.

The idea

When a function f(x)f(x) is given only on the half-interval [0,L][0, L], we can mirror its graph across the vertical axis to create an even extension F(x)F(x) on [−L,L][-L, L], where F(x)=f(−x)F(x) = f(-x) for −L<x≤0-L < x \le 0 and F(x)=f(x)F(x) = f(x) for 0≤x<L0 \le x < L. Repeating this symmetric shape every 2L2L units produces an even periodic extension.

Graph of f(x) on [0, L]

Even extension of f(x) on [−L, L]

Even periodic extension of f(x) with period 2L

Because F(x)F(x) is symmetric across the vertical axis, its product with sin⁡(nπx/L)\sin(n\pi x/L) is odd, forcing every sine coefficient bnb_n to be zero. The products for a0a_0 and ana_n are even, so integrating from −L-L to LL is just twice the integral from 00 to LL. This gives the half-range cosine series S(x)=a0+∑n=1∞ancos⁡(nπxL)S(x) = a_0 + \sum_{n=1}^{\infty} a_n \cos\left(\frac{n\pi x}{L}\right) on 0<x<L0 < x < L, with coefficients:

a0=1L∫0Lf(x) dx,an=2L∫0Lf(x)cos⁡(nπxL) dxa_0 = \frac{1}{L} \int_0^L f(x)\,dx, \qquad a_n = \frac{2}{L} \int_0^L f(x) \cos\left(\frac{n\pi x}{L}\right)\,dx

When f(x)f(x) contains a sine or cosine factor, rewrite the integrand using a product-to-sum identity before integrating. If the resulting general formula for ana_n has n−1n - 1 in the denominator, that formula is invalid for n=1n = 1; you must plug n=1n = 1 directly into the original integral to compute a1a_1 separately. Finally, because an even extension matches at x=0x = 0 (F(0+)=F(0−)=f(0)F(0^+) = F(0^-) = f(0)) and at x=Lx = L (F(L−)=F((−L)+)=f(L)F(L^-) = F((-L)^+) = f(L)), the periodic extension is continuous at both endpoints whenever f(x)f(x) is continuous on [0,L][0, L], allowing you to evaluate S(x)=f(x)S(x) = f(x) right at x=0x = 0 or x=Lx = L to sum numerical series.

Worked example

Problem 4.3.1: Find the half-range cosine series of exe^x in [0,1][0, 1], and hence evaluate ∑n=1∞e(−1)n−11+n2π2\sum_{n=1}^{\infty} \frac{e(-1)^n - 1}{1 + n^2\pi^2}.

Given: f(x)=exf(x) = e^x on [0,1][0, 1], so the half-period is L=1L = 1. Find: The half-range cosine series S(x)S(x) and the sum ∑n=1∞e(−1)n−11+n2π2\sum_{n=1}^{\infty} \frac{e(-1)^n - 1}{1 + n^2\pi^2}.

  1. Write the half-range cosine series form for L=1L = 1, where cos⁡(nπx/L)\cos(n\pi x/L) simplifies to cos⁡(nπx)\cos(n\pi x):

    S(x)=a0+∑n=1∞ancos⁡(nπx)S(x) = a_0 + \sum_{n=1}^{\infty} a_n \cos(n\pi x)
  2. Compute the average value a0a_0 by integrating exe^x over [0,1][0, 1]:

    a0=11∫01ex dx=[ex]01=e−1a_0 = \frac{1}{1} \int_0^1 e^x\,dx = \left[e^x\right]_0^1 = e - 1
  3. Set up the integral for ana_n on [0,1][0, 1] and apply the standard exponential-cosine antiderivative formula:

    an=2∫01excos⁡(nπx) dx=2[ex12+(nπ)2(cos⁡(nπx)+nπsin⁡(nπx))]01a_n = 2 \int_0^1 e^x \cos(n\pi x)\,dx = 2 \left[ \frac{e^x}{1^2 + (n\pi)^2} \left(\cos(n\pi x) + n\pi \sin(n\pi x)\right) \right]_0^1
  4. Evaluate at the limits x=1x = 1 and x=0x = 0 using cos⁡(nπ)=(−1)n\cos(n\pi) = (-1)^n and sin⁡(nπ)=0\sin(n\pi) = 0:

    an=2[e1+n2π2((−1)n+0)−11+n2π2(1+0)]=2[e(−1)n−1]1+n2π2a_n = 2 \left[ \frac{e}{1 + n^2\pi^2}\left((-1)^n + 0\right) - \frac{1}{1 + n^2\pi^2}(1 + 0) \right] = \frac{2\left[e(-1)^n - 1\right]}{1 + n^2\pi^2}
  5. Substitute a0a_0 and ana_n into S(x)S(x) to write the half-range cosine series:

    S(x)=e−1+∑n=1∞2[e(−1)n−1]1+n2π2cos⁡(nπx)S(x) = e - 1 + \sum_{n=1}^{\infty} \frac{2\left[e(-1)^n - 1\right]}{1 + n^2\pi^2} \cos(n\pi x)
  6. Because the even periodic extension is continuous at x=0x = 0, set S(0)=f(0)=e0=1S(0) = f(0) = e^0 = 1 and solve for the sum:

    1=e−1+2∑n=1∞e(−1)n−11+n2π2  ⟹  ∑n=1∞e(−1)n−11+n2π2=2−e21 = e - 1 + 2 \sum_{n=1}^{\infty} \frac{e(-1)^n - 1}{1 + n^2\pi^2} \implies \sum_{n=1}^{\infty} \frac{e(-1)^n - 1}{1 + n^2\pi^2} = \frac{2 - e}{2}

Even periodic extension of eˣ

Answer: S(x)=e−1+∑n=1∞2[e(−1)n−1]1+n2π2cos⁡(nπx)S(x) = e - 1 + \sum_{n=1}^{\infty} \frac{2[e(-1)^n - 1]}{1 + n^2\pi^2} \cos(n\pi x), and the sum is 2−e2\frac{2 - e}{2}.

More problems

Problem 4.3.4: Half-range cosine series of x2x^2 on [0,5][0, 5]

Given: f(x)=x2f(x) = x^2 on [0,5][0, 5], so L=5L = 5. Find: The half-range cosine series of f(x)f(x) and the sum 1−122+132−⋯1 - \frac{1}{2^2} + \frac{1}{3^2} - \cdots.

  1. Compute a0a_0 by integrating x2x^2 over [0,5][0, 5]:

    a0=15∫05x2 dx=15[x33]05=253a_0 = \frac{1}{5} \int_0^5 x^2\,dx = \frac{1}{5} \left[\frac{x^3}{3}\right]_0^5 = \frac{25}{3}
  2. Integrate an=25∫05x2cos⁡(nπx5) dxa_n = \frac{2}{5} \int_0^5 x^2 \cos\left(\frac{n\pi x}{5}\right)\,dx using tabular integration by parts:

    an=25[x2(5nπ)sin⁡(nπx5)−2x(5nπ)2(−cos⁡(nπx5))+2(5nπ)3(−sin⁡(nπx5))]05a_n = \frac{2}{5} \left[ x^2 \left(\frac{5}{n\pi}\right) \sin\left(\frac{n\pi x}{5}\right) - 2x \left(\frac{5}{n\pi}\right)^2 \left(-\cos\left(\frac{n\pi x}{5}\right)\right) + 2 \left(\frac{5}{n\pi}\right)^3 \left(-\sin\left(\frac{n\pi x}{5}\right)\right) \right]_0^5
  3. Evaluate at x=5x = 5 and x=0x = 0, where all sine terms vanish and cos⁡(nπ)=(−1)n\cos(n\pi) = (-1)^n:

    an=25[10(25n2π2)(−1)n]=100(−1)nn2π2a_n = \frac{2}{5} \left[ 10 \left(\frac{25}{n^2\pi^2}\right) (-1)^n \right] = \frac{100(-1)^n}{n^2\pi^2}
  4. Substitute a0a_0 and ana_n into S(x)=a0+∑n=1∞ancos⁡(nπx5)S(x) = a_0 + \sum_{n=1}^{\infty} a_n \cos\left(\frac{n\pi x}{5}\right):

    S(x)=253+100π2∑n=1∞(−1)nn2cos⁡(nπx5)S(x) = \frac{25}{3} + \frac{100}{\pi^2} \sum_{n=1}^{\infty} \frac{(-1)^n}{n^2} \cos\left(\frac{n\pi x}{5}\right)
  5. Set S(0)=f(0)=0S(0) = f(0) = 0 at the point of continuity x=0x = 0 and rearrange to isolate the alternating series:

    0=253+100π2∑n=1∞(−1)nn2  ⟹  1−122+132−142+⋯=π2120 = \frac{25}{3} + \frac{100}{\pi^2} \sum_{n=1}^{\infty} \frac{(-1)^n}{n^2} \implies 1 - \frac{1}{2^2} + \frac{1}{3^2} - \frac{1}{4^2} + \cdots = \frac{\pi^2}{12}

Even periodic extension of x²

Answer: S(x)=253+100π2∑n=1∞(−1)nn2cos⁡(nπx5)S(x) = \frac{25}{3} + \frac{100}{\pi^2} \sum_{n=1}^{\infty} \frac{(-1)^n}{n^2} \cos\left(\frac{n\pi x}{5}\right), and the sum is π212\frac{\pi^2}{12}.

Problem 4.3.2: Half-range cosine series of sin⁡x\sin x on [0,π/2][0, \pi/2]

Given: f(x)=sin⁡xf(x) = \sin x on [0,π/2][0, \pi/2], so L=π/2L = \pi/2. Find: The half-range cosine series of sin⁡x\sin x and the sum 11⋅3+13⋅5+15⋅7+⋯\frac{1}{1 \cdot 3} + \frac{1}{3 \cdot 5} + \frac{1}{5 \cdot 7} + \cdots.

  1. With L=π/2L = \pi/2, note that cos⁡(nπx/L)=cos⁡(2nx)\cos(n\pi x/L) = \cos(2nx) and compute a0a_0:

    a0=2π∫0π/2sin⁡x dx=2π[−cos⁡x]0π/2=2πa_0 = \frac{2}{\pi} \int_0^{\pi/2} \sin x\,dx = \frac{2}{\pi} \left[-\cos x\right]_0^{\pi/2} = \frac{2}{\pi}
  2. Set up ana_n and rewrite sin⁡xcos⁡(2nx)\sin x \cos(2nx) using 2sin⁡Acos⁡B=sin⁡(A+B)+sin⁡(A−B)2\sin A \cos B = \sin(A+B) + \sin(A-B):

    an=4π∫0π/2sin⁡xcos⁡(2nx) dx=2π∫0π/2[sin⁡((2n+1)x)−sin⁡((2n−1)x)] dxa_n = \frac{4}{\pi} \int_0^{\pi/2} \sin x \cos(2nx)\,dx = \frac{2}{\pi} \int_0^{\pi/2} \left[\sin((2n+1)x) - \sin((2n-1)x)\right]\,dx
  3. Integrate each sine term from 00 to π/2\pi/2:

    an=2π[−cos⁡((2n+1)x)2n+1+cos⁡((2n−1)x)2n−1]0π/2a_n = \frac{2}{\pi} \left[ \frac{-\cos((2n+1)x)}{2n+1} + \frac{\cos((2n-1)x)}{2n-1} \right]_0^{\pi/2}
  4. Since 2n+12n+1 and 2n−12n-1 are odd integers, cos⁡((2n±1)π/2)=0\cos((2n\pm 1)\pi/2) = 0, leaving only the lower limit x=0x = 0:

    an=2π[12n+1−12n−1]=−4π(4n2−1)a_n = \frac{2}{\pi} \left[ \frac{1}{2n+1} - \frac{1}{2n-1} \right] = \frac{-4}{\pi(4n^2 - 1)}
  5. Substitute a0a_0 and ana_n into S(x)S(x):

    S(x)=2π−4π∑n=1∞14n2−1cos⁡(2nx)S(x) = \frac{2}{\pi} - \frac{4}{\pi} \sum_{n=1}^{\infty} \frac{1}{4n^2 - 1} \cos(2nx)
  6. Set S(0)=sin⁡0=0S(0) = \sin 0 = 0 at x=0x = 0 and factor 4n2−1=(2n−1)(2n+1)4n^2 - 1 = (2n-1)(2n+1) to find the sum:

    0=2π−4π∑n=1∞1(2n−1)(2n+1)  ⟹  11⋅3+13⋅5+15⋅7+⋯=120 = \frac{2}{\pi} - \frac{4}{\pi} \sum_{n=1}^{\infty} \frac{1}{(2n-1)(2n+1)} \implies \frac{1}{1 \cdot 3} + \frac{1}{3 \cdot 5} + \frac{1}{5 \cdot 7} + \cdots = \frac{1}{2}

Even periodic extension of sin(x)

Answer: S(x)=2π−4π∑n=1∞14n2−1cos⁡(2nx)S(x) = \frac{2}{\pi} - \frac{4}{\pi} \sum_{n=1}^{\infty} \frac{1}{4n^2 - 1} \cos(2nx), and the sum is 12\frac{1}{2}.

Problem 4.3.5: Piecewise linear function on [0,l][0, l]

Given: f(x)=5xf(x) = 5x on [0,l/2][0, l/2] and f(x)=5(l−x)f(x) = 5(l - x) on [l/2,l)[l/2, l), so L=lL = l. Find: The half-range cosine series of f(x)f(x).

  1. Split the a0a_0 integral at x=l/2x = l/2 and integrate both linear pieces:

    a0=1l[∫0l/25x dx+∫l/2l5(l−x) dx]=5l[(x22)0l/2+(lx−x22)l/2l]=5l4a_0 = \frac{1}{l} \left[ \int_0^{l/2} 5x\,dx + \int_{l/2}^l 5(l-x)\,dx \right] = \frac{5}{l} \left[ \left(\frac{x^2}{2}\right)_0^{l/2} + \left(lx - \frac{x^2}{2}\right)_{l/2}^l \right] = \frac{5l}{4}
  2. Split the ana_n integral at x=l/2x = l/2:

    an=2l[∫0l/25xcos⁡(nπxl) dx+∫l/2l5(l−x)cos⁡(nπxl) dx]a_n = \frac{2}{l} \left[ \int_0^{l/2} 5x \cos\left(\frac{n\pi x}{l}\right)\,dx + \int_{l/2}^l 5(l-x) \cos\left(\frac{n\pi x}{l}\right)\,dx \right]
  3. Apply tabular integration by parts to each integral:

    an=10l([lxnπsin⁡(nπxl)+l2n2π2cos⁡(nπxl)]0l/2+[l(l−x)nπsin⁡(nπxl)−l2n2π2cos⁡(nπxl)]l/2l)a_n = \frac{10}{l} \left( \left[ \frac{lx}{n\pi} \sin\left(\frac{n\pi x}{l}\right) + \frac{l^2}{n^2\pi^2} \cos\left(\frac{n\pi x}{l}\right) \right]_0^{l/2} + \left[ \frac{l(l-x)}{n\pi} \sin\left(\frac{n\pi x}{l}\right) - \frac{l^2}{n^2\pi^2} \cos\left(\frac{n\pi x}{l}\right) \right]_{l/2}^l \right)
  4. Evaluate at the limits, noting that the sin⁡(nπ/2)\sin(n\pi/2) terms cancel and cos⁡(nπ)=(−1)n\cos(n\pi) = (-1)^n:

    an=10ln2π2[2cos⁡(nπ2)−1−(−1)n]a_n = \frac{10l}{n^2\pi^2} \left[ 2\cos\left(\frac{n\pi}{2}\right) - 1 - (-1)^n \right]
  5. Substitute a0a_0 and ana_n into S(x)S(x):

    S(x)=5l4+∑n=1∞10ln2π2[2cos⁡(nπ2)−1−(−1)n]cos⁡(nπxl)S(x) = \frac{5l}{4} + \sum_{n=1}^{\infty} \frac{10l}{n^2\pi^2} \left[ 2\cos\left(\frac{n\pi}{2}\right) - 1 - (-1)^n \right] \cos\left(\frac{n\pi x}{l}\right)

Answer: S(x)=5l4+∑n=1∞10ln2π2[2cos⁡(nπ2)−1−(−1)n]cos⁡(nπxl)S(x) = \frac{5l}{4} + \sum_{n=1}^{\infty} \frac{10l}{n^2\pi^2} \left[ 2\cos\left(\frac{n\pi}{2}\right) - 1 - (-1)^n \right] \cos\left(\frac{n\pi x}{l}\right).

Problem 4.3.3: Half-range cosine series of xsin⁡xx \sin x on (0,π)(0, \pi)

Given: f(x)=xsin⁡xf(x) = x \sin x on (0,π)(0, \pi), so L=πL = \pi. Find: The half-range cosine series of xsin⁡xx \sin x and the sum 11⋅3−13⋅5+15⋅7−⋯\frac{1}{1 \cdot 3} - \frac{1}{3 \cdot 5} + \frac{1}{5 \cdot 7} - \cdots.

  1. Compute a0a_0 on (0,π)(0, \pi) using integration by parts:

    a0=1π∫0πxsin⁡x dx=1π[−xcos⁡x+sin⁡x]0π=1a_0 = \frac{1}{\pi} \int_0^{\pi} x \sin x\,dx = \frac{1}{\pi} \left[-x\cos x + \sin x\right]_0^{\pi} = 1
  2. Set up ana_n and apply 2sin⁡xcos⁡(nx)=sin⁡((n+1)x)−sin⁡((n−1)x)2\sin x \cos(nx) = \sin((n+1)x) - \sin((n-1)x):

    an=2π∫0πxsin⁡xcos⁡(nx) dx=1π∫0πx[sin⁡((n+1)x)−sin⁡((n−1)x)] dxa_n = \frac{2}{\pi} \int_0^{\pi} x \sin x \cos(nx)\,dx = \frac{1}{\pi} \int_0^{\pi} x \left[\sin((n+1)x) - \sin((n-1)x)\right]\,dx
  3. Integrate by parts for n≠1n \neq 1 (so n−1≠0n - 1 \neq 0):

    an=1π[x(−cos⁡((n+1)x)n+1+cos⁡((n−1)x)n−1)−(−sin⁡((n+1)x)(n+1)2+sin⁡((n−1)x)(n−1)2)]0πa_n = \frac{1}{\pi} \left[ x\left(\frac{-\cos((n+1)x)}{n+1} + \frac{\cos((n-1)x)}{n-1}\right) - \left(\frac{-\sin((n+1)x)}{(n+1)^2} + \frac{\sin((n-1)x)}{(n-1)^2}\right) \right]_0^{\pi}
  4. Evaluate at 00 and π\pi using cos⁡((n±1)π)=(−1)n−1\cos((n\pm 1)\pi) = (-1)^{n-1}:

    an=(−1)n−1n−1−(−1)n−1n+1=2(−1)n−1(n−1)(n+1)(n≠1)a_n = \frac{(-1)^{n-1}}{n-1} - \frac{(-1)^{n-1}}{n+1} = \frac{2(-1)^{n-1}}{(n-1)(n+1)} \quad (n \neq 1)
  5. Compute a1a_1 separately by setting n=1n = 1 in the original integral and using 2sin⁡xcos⁡x=sin⁡(2x)2\sin x \cos x = \sin(2x):

    a1=1π∫0πxsin⁡(2x) dx=1π[−xcos⁡(2x)2+sin⁡(2x)4]0π=−12a_1 = \frac{1}{\pi} \int_0^{\pi} x \sin(2x)\,dx = \frac{1}{\pi} \left[ \frac{-x\cos(2x)}{2} + \frac{\sin(2x)}{4} \right]_0^{\pi} = -\frac{1}{2}
  6. Combine a0a_0, a1a_1, and ana_n (n≥2n \ge 2) into the series:

    S(x)=1−12cos⁡x+2∑n=2∞(−1)n−1(n−1)(n+1)cos⁡(nx)S(x) = 1 - \frac{1}{2}\cos x + 2 \sum_{n=2}^{\infty} \frac{(-1)^{n-1}}{(n-1)(n+1)} \cos(nx)
  7. Evaluate at the continuity point x=π/2x = \pi/2, where cos⁡(π/2)=0\cos(\pi/2) = 0 and even harmonics alternate signs:

    π2sin⁡(π2)=1+2[11⋅3−13⋅5+15⋅7−⋯ ]  ⟹  11⋅3−13⋅5+15⋅7−⋯=π−24\frac{\pi}{2}\sin\left(\frac{\pi}{2}\right) = 1 + 2\left[\frac{1}{1 \cdot 3} - \frac{1}{3 \cdot 5} + \frac{1}{5 \cdot 7} - \cdots\right] \implies \frac{1}{1 \cdot 3} - \frac{1}{3 \cdot 5} + \frac{1}{5 \cdot 7} - \cdots = \frac{\pi - 2}{4}

Watch out. Because the general formula for ana_n divides by n−1n - 1, you must start the summation at n=2n = 2 and add the separately computed a1cos⁡xa_1 \cos x term in front.

Even periodic extension of x sin(x)

Answer: S(x)=1−12cos⁡x+2∑n=2∞(−1)n−1(n−1)(n+1)cos⁡(nx)S(x) = 1 - \frac{1}{2}\cos x + 2\sum_{n=2}^{\infty} \frac{(-1)^{n-1}}{(n-1)(n+1)} \cos(nx), and the sum is π−24\frac{\pi - 2}{4}.

Practice: Half-Range Sine Series on [0, L]

Having built pure cosine expansions via even extensions, we conclude by extending functions on [0,L][0, L] oddly to build pure sine expansions. By mirroring f(x)f(x) through the origin, both cosine coefficients a0a_0 and ana_n vanish automatically, leaving only the single sine coefficient bnb_n to compute.

The idea

When a function f(x)f(x) is given only on the half-interval [0,L][0, L], we can represent it using sines alone by constructing its odd extension F(x)F(x) on [−L,L][-L, L]:

F(x)={−f(−x)if −L<x≤0f(x)if 0≤x<LF(x) = \begin{cases} -f(-x) & \text{if } -L < x \le 0 \\ f(x) & \text{if } 0 \le x < L \end{cases}

Graph of f(x) on [0, L]

Odd extension of f(x) on [−L, L]

Repeating F(x)F(x) every 2L2L units forms the odd periodic extension. Because F(x)F(x) is odd, its product with cos⁡(nπx/L)\cos(n\pi x/L) is odd (so a0=0a_0 = 0 and an=0a_n = 0), while its product with sin⁡(nπx/L)\sin(n\pi x/L) is even. Doubling the integral over the half-interval [0,L][0, L] gives the half-range sine series:

S(x)=∑n=1∞bnsin⁡(nπxL),wherebn=2L∫0Lf(x)sin⁡(nπxL)dxS(x) = \sum_{n=1}^{\infty} b_n \sin\left(\frac{n\pi x}{L}\right), \quad \text{where} \quad b_n = \frac{2}{L} \int_{0}^{L} f(x) \sin\left(\frac{n\pi x}{L}\right) dx

Odd periodic extension of f(x) with period 2L

Notice what happens at the endpoints x=0x = 0 and x=Lx = L: every term sin⁡(nπx/L)\sin(n\pi x/L) evaluates to zero there. If f(0)≠0f(0) \ne 0 or f(L)≠0f(L) \ne 0, the odd periodic extension jumps from −f(0)-f(0) to +f(0)+f(0) at x=0x = 0, and from f(L)f(L) to −f(L)-f(L) at x=Lx = L. At any interior continuity point x∈(0,L)x \in (0, L), Dirichlet's theorem guarantees S(x)=f(x)S(x) = f(x), whereas at jump discontinuities S(x)=f(x+)+f(x−)2S(x) = \frac{f(x^+) + f(x^-)}{2}.

Worked example

Problem 4.3.6. Given: f(x)=x2f(x) = x^2 on [0,5][0, 5]. Find: The half-range sine series of f(x)f(x).

  1. Identify the half-period L=5L = 5 so the series takes the form S(x)=∑n=1∞bnsin⁡(nπx5)S(x) = \sum_{n=1}^{\infty} b_n \sin\left(\frac{n\pi x}{5}\right).

  2. Set up the sine coefficient integral on [0,5][0, 5]:

    bn=25∫05x2sin⁡(nπx5)dxb_n = \frac{2}{5} \int_{0}^{5} x^2 \sin\left(\frac{n\pi x}{5}\right) dx
  3. Apply tabular integration by parts (differentiating x2x^2 down to 00 and integrating the sine factor three times):

    bn=25[x2(5nπ)(−cos⁡nπx5)−2x(5nπ)2(−sin⁡nπx5)+2(5nπ)3(cos⁡nπx5)]05b_n = \frac{2}{5} \left[ x^2 \left(\frac{5}{n\pi}\right)\left(-\cos\frac{n\pi x}{5}\right) - 2x \left(\frac{5}{n\pi}\right)^2 \left(-\sin\frac{n\pi x}{5}\right) + 2\left(\frac{5}{n\pi}\right)^3 \left(\cos\frac{n\pi x}{5}\right) \right]_{0}^{5}
  4. Evaluate at x=5x = 5 and x=0x = 0, using sin⁡(nπ)=0\sin(n\pi) = 0, sin⁡(0)=0\sin(0) = 0, cos⁡(0)=1\cos(0) = 1, and cos⁡(nπ)=(−1)n\cos(n\pi) = (-1)^n:

    bn=25[−125(−1)nnπ+250n3π3((−1)n−1)]=50(−1)n+1nπ+100n3π3[(−1)n−1]b_n = \frac{2}{5} \left[ \frac{-125(-1)^n}{n\pi} + \frac{250}{n^3\pi^3}\big((-1)^n - 1\big) \right] = \frac{50(-1)^{n+1}}{n\pi} + \frac{100}{n^3\pi^3}\big[(-1)^n - 1\big]

Odd periodic extension of x²

Answer: S(x)=∑n=1∞(50(−1)n+1nπ+100n3π3[(−1)n−1])sin⁡(nπx5)S(x) = \sum_{n=1}^{\infty} \left( \frac{50(-1)^{n+1}}{n\pi} + \frac{100}{n^3\pi^3} [(-1)^n - 1] \right) \sin\left(\frac{n\pi x}{5}\right).

More problems

Problem 4.3.8: Exponential function on [0, 1]

Given: f(x)=exf(x) = e^x on [0,1][0, 1]. Find: The half-range sine series of f(x)f(x).

  1. Set L=1L = 1 in the half-range formula to write S(x)=∑n=1∞bnsin⁡(nπx)S(x) = \sum_{n=1}^{\infty} b_n \sin(n\pi x) with bn=2∫01exsin⁡(nπx) dxb_n = 2 \int_{0}^{1} e^x \sin(n\pi x) \, dx.

  2. Integrate using the standard exponential-sine reduction formula:

    bn=2[ex12+(nπ)2(sin⁡(nπx)−nπcos⁡(nπx))]01b_n = 2 \left[ \frac{e^x}{1^2 + (n\pi)^2} \big(\sin(n\pi x) - n\pi \cos(n\pi x)\big) \right]_{0}^{1}
  3. Substitute the limits x=1x = 1 and x=0x = 0, noting sin⁡(nπ)=0\sin(n\pi) = 0 and cos⁡(nπ)=(−1)n\cos(n\pi) = (-1)^n:

    bn=21+n2π2[e1(0−nπ(−1)n)−(0−nπ(1))]=2nπ1+n2π2[e(−1)n+1+1]b_n = \frac{2}{1 + n^2\pi^2} \left[ e^1\big(0 - n\pi(-1)^n\big) - \big(0 - n\pi(1)\big) \right] = \frac{2n\pi}{1 + n^2\pi^2} \left[ e(-1)^{n+1} + 1 \right]
  4. Substitute bnb_n into the sine series expansion; note that the odd periodic extension has jump discontinuities at all integers.

Odd periodic extension of eˣ

Answer: S(x)=∑n=1∞2nπ1+n2π2[e(−1)n+1+1]sin⁡(nπx)S(x) = \sum_{n=1}^{\infty} \frac{2n\pi}{1 + n^2\pi^2} \left[ e(-1)^{n+1} + 1 \right] \sin(n\pi x).

Problem 4.3.7: Piecewise triangular wave on (0, pi)

Given: f(x)={x,if 0<x≤π/2π−x,if π/2<x<πf(x) = \begin{cases} x, & \text{if } 0 < x \le \pi/2 \\ \pi - x, & \text{if } \pi/2 < x < \pi \end{cases}. Find: The half-range sine series of f(x)f(x) and the sum 1+132+152+…1 + \frac{1}{3^2} + \frac{1}{5^2} + \dots

  1. With L=πL = \pi, split the bnb_n integral at x=π/2x = \pi/2 to match the two linear pieces:

    bn=2π[∫0π/2xsin⁡(nx) dx+∫π/2π(π−x)sin⁡(nx) dx]b_n = \frac{2}{\pi} \left[ \int_{0}^{\pi/2} x \sin(nx) \, dx + \int_{\pi/2}^{\pi} (\pi - x) \sin(nx) \, dx \right]
  2. Integrate both parts by parts (noting the derivative of π−x\pi - x is −1-1):

    bn=2π([−xcos⁡(nx)n+sin⁡(nx)n2]0π/2+[−(π−x)cos⁡(nx)n−sin⁡(nx)n2]π/2π)b_n = \frac{2}{\pi} \left( \left[ -\frac{x \cos(nx)}{n} + \frac{\sin(nx)}{n^2} \right]_{0}^{\pi/2} + \left[ -\frac{(\pi - x) \cos(nx)}{n} - \frac{\sin(nx)}{n^2} \right]_{\pi/2}^{\pi} \right)
  3. Evaluate at the limits so the cosine terms cancel and the sine terms add:

    bn=2π[2n2sin⁡(nπ2)]=4πn2sin⁡(nπ2)b_n = \frac{2}{\pi} \left[ \frac{2}{n^2} \sin\left(\frac{n\pi}{2}\right) \right] = \frac{4}{\pi n^2} \sin\left(\frac{n\pi}{2}\right)
  4. Write out the expansion by plugging n=1,2,3,…n = 1, 2, 3, \dots into sin⁡(nπ/2)\sin(n\pi/2):

    S(x)=4π(sin⁡x−132sin⁡3x+152sin⁡5x−… )S(x) = \frac{4}{\pi} \left( \sin x - \frac{1}{3^2}\sin 3x + \frac{1}{5^2}\sin 5x - \dots \right)
  5. Evaluate S(x)=f(x)S(x) = f(x) at the continuity point x=π/2x = \pi/2, where f(π/2)=π/2f(\pi/2) = \pi/2, to solve for the numerical series:

    π2=4π(1+132+152+… )\frac{\pi}{2} = \frac{4}{\pi} \left( 1 + \frac{1}{3^2} + \frac{1}{5^2} + \dots \right)

Odd periodic triangular wave

Answer: S(x)=∑n=1∞4πn2sin⁡(nπ2)sin⁡(nx)S(x) = \sum_{n=1}^{\infty} \frac{4}{\pi n^2} \sin\left(\frac{n\pi}{2}\right) \sin(nx), and 1+132+152+⋯=π281 + \frac{1}{3^2} + \frac{1}{5^2} + \dots = \frac{\pi^2}{8}.

Problem 4.3.9: Trigonometric product x sin(x) on (0, pi)

Given: f(x)=xsin⁡xf(x) = x \sin x on (0,π)(0, \pi). Find: The half-range sine series of f(x)f(x).

  1. With L=πL = \pi, rewrite the integrand using 2sin⁡xsin⁡(nx)=cos⁡((n−1)x)−cos⁡((n+1)x)2\sin x \sin(nx) = \cos((n-1)x) - \cos((n+1)x):

    bn=2π∫0πxsin⁡xsin⁡(nx) dx=1π∫0πx(cos⁡(n−1)x−cos⁡(n+1)x) dxb_n = \frac{2}{\pi} \int_{0}^{\pi} x \sin x \sin(nx) \, dx = \frac{1}{\pi} \int_{0}^{\pi} x \big(\cos(n-1)x - \cos(n+1)x\big) \, dx
  2. Integrate by parts for n≠1n \ne 1:

    bn=1π[x(sin⁡(n−1)xn−1−sin⁡(n+1)xn+1)−1⋅(−cos⁡(n−1)x(n−1)2−−cos⁡(n+1)x(n+1)2)]0πb_n = \frac{1}{\pi} \left[ x \left( \frac{\sin(n-1)x}{n-1} - \frac{\sin(n+1)x}{n+1} \right) - 1 \cdot \left( \frac{-\cos(n-1)x}{(n-1)^2} - \frac{-\cos(n+1)x}{(n+1)^2} \right) \right]_{0}^{\pi}
  3. Evaluate at x=πx = \pi and x=0x = 0 for n≠1n \ne 1, using cos⁡((n∓1)π)=(−1)n∓1\cos((n\mp 1)\pi) = (-1)^{n\mp 1}:

    bn=1π[(−1)n−1−1(n−1)2+1−(−1)n+1(n+1)2]b_n = \frac{1}{\pi} \left[ \frac{(-1)^{n-1} - 1}{(n-1)^2} + \frac{1 - (-1)^{n+1}}{(n+1)^2} \right]
  4. Compute b1b_1 separately using 2sin⁡2x=1−cos⁡2x2\sin^2 x = 1 - \cos 2x because the general formula divides by n−1=0n - 1 = 0:

    b1=2π∫0πxsin⁡2x dx=1π∫0πx(1−cos⁡2x) dxb_1 = \frac{2}{\pi} \int_{0}^{\pi} x \sin^2 x \, dx = \frac{1}{\pi} \int_{0}^{\pi} x(1 - \cos 2x) \, dx
  5. Integrate b1b_1 by parts and evaluate at 00 and π\pi:

    b1=1π[x(x−sin⁡2x2)−1(x22−cos⁡2x4)]0π=1π(π2−π22)=π2b_1 = \frac{1}{\pi} \left[ x\left(x - \frac{\sin 2x}{2}\right) - 1\left(\frac{x^2}{2} - \frac{\cos 2x}{4}\right) \right]_{0}^{\pi} = \frac{1}{\pi}\left(\pi^2 - \frac{\pi^2}{2}\right) = \frac{\pi}{2}
  6. Combine the n=1n = 1 harmonic with the sum over n≥2n \ge 2.

Watch out. Never plug n=1n = 1 into the general bnb_n formula when a denominator contains n−1n - 1; always evaluate b1b_1 from its original integral.

Answer: S(x)=π2sin⁡x+∑n=2∞1π[(−1)n−1−1(n−1)2+1−(−1)n+1(n+1)2]sin⁡(nx)S(x) = \frac{\pi}{2} \sin x + \sum_{n=2}^{\infty} \frac{1}{\pi} \left[ \frac{(-1)^{n-1} - 1}{(n-1)^2} + \frac{1 - (-1)^{n+1}}{(n+1)^2} \right] \sin(nx).