Fourier series in Mathematica
June 8, 2026 at 11:35 AM by Dr. Drang
After my last post—the one about using Fourier series—I started thinking about how to use Mathematica to develop Fourier series.1 I could, of course, use the Integrate function to determine the Fourier coefficients, but Mathematica has other functions that can do the job directly once you understand how they work.
Mathematica has several Fourier functions, but I’m going to stick with the ones associated with sine series, FourierSinCoefficient and FourierSinSeries. They’re meant to be easy to use, and they are, but you need to know how they’re defined.
The coefficients used in both of these functions are defined this way:
This doesn’t match up exactly with the definition I used for getting the Fourier coefficients of a loading function, :
To use the Mathematica functions to get the , we have to do a change of variable. Let
so
(Here, z is just another variable name; I’m not using it to represent a complex number.)
This changes the expression for to
which means we can use the Mathematica functions as long as we substitute in for in the expression for .
Let’s give it a try on this parabolic loading function:
It shouldn’t take many Fourier terms to get a good approximation of this.

Here are the Mathematica commands I used:
q = 4 qmax x (L - x)
qn = FourierSinCoefficient[q /. x -> L z/Pi, z, n]
You can see the substitution in the first argument to FourierSinCoefficient.
After simplification, the results were
We could also get the series (through ) directly with FourierSinSeries:
qapprox2 = FourierSinSeries[q /. x -> L z/Pi, z, 7] /. z -> Pi x /L
where the inverse substitution comes at the end to put the expression back in the form we want. Here’s a screenshot from the Mathematica notebook:

You can see that the coefficients match what we got earlier.
A quick plot of the difference between this truncated Fourier series and the original parabolic function shows that, as expected, the series does a good job of replicating the original:

In this plot, the horizontal axis is the fraction of and the vertical axis is the fraction of .
If you’re interested, here’s the entire Mathematica notebook:
Now that I understand the way these functions work, I can do more complicated Fourier analysis in Mathematica without questioning myself on whether I’m using them correctly.
-
Something I couldn’t do in any of the posts in that series, as that would be breaking the rules I had set up for myself. ↩