How would one create a piecewise periodic function (without using recursions)?
For example I’d like to make this function Piecewise[{{x, 0 <= x <= Pi}, {x - 2 Pi, Pi < x < 2 Pi}}] repeat itself to infinity…
How would one create a piecewise periodic function (without using recursions)?
For example I’d like to make this function Piecewise[{{x, 0 <= x <= Pi}, {x - 2 Pi, Pi < x < 2 Pi}}] repeat itself to infinity…
Hint: Think Mod[x, 2 Pi]
That should be enough.
That’s what David had in mind
Clear[nPeriodic]
nPeriodic[x_?NumericQ] :=
Piecewise[{{Mod[x, 2 Pi], 0 <= Mod[x, 2 Pi] <= Pi},
{Mod[x, 2 Pi] - 2 Pi, Pi < Mod[x, 2 Pi] < 2 Pi}}]
…