# Fourier series of an arbitrary periodic piecewise function

Let's take a switch function as an example:
$$u(t)= \begin{cases} 1, & \text{0
How can I get Fourier series of it in Mathematica?
Is there a way to get Fourier series of arbitrary periodic piecewise function?

• I would start by having a look at Piecewise and Fourier. – b.gates.you.know.what Feb 26 at 9:09
• @b.gatessucks You probably meant FourierSeries, right? Fourier is the discrete fourier transform (FFT). I am also puzzeld by the many different Fourier-related commands in Mathematica. – Henrik Schumacher Feb 26 at 10:11
• @HenrikSchumacher Indeed, thanks for pointing that out. – b.gates.you.know.what Feb 26 at 10:37
• Strongly related, if not duplicate: mathematica.stackexchange.com/q/149468/1871 – xzczd Feb 26 at 10:39
• People here generally like users to post code as Mathematica code instead of just images or TeX, so they can copy-paste it. It makes it convenient for them and more likely you will get someone to help you. You may find this this meta Q&A helpful – Michael E2 Feb 26 at 14:29

## 2 Answers

for example:

u[t_] = Piecewise[{{1, 0 < t < dT}, {0, dT < t < T}}];
FourierTrigSeries[u[t], t, 3, FourierParameters -> {1, 2 \[Pi]/T},
Assumptions -> 0 < dT < T && 2 dT == T] Try u[t_] := UnitStep[Sin[t]]; FourierSeries[u[x], x, 3] 3 is series

• One might want to be mindful of the FourierParameters setting when using FourierSeries[] and other sundry functions, lest Mathematica's chosen normalization might not be the same as your preferred one. – J. M. is away Feb 26 at 9:15