How to Make Any Function Repeat Periodically
At a glance
- 1. Choose a period
Pick a positive period T and a base interval of length T.
- 2. Reduce the input
Map every input x back into the base interval using the remainder modulo T.
- 3. Evaluate the base function
Apply the original function to that reduced input.
- 4. Check the join
Match endpoint values and derivatives if continuity or smoothness matters.
A function defined on all of is periodic if there is a number such that
for every . The number is called a period; the smallest positive period, when one exists, is the fundamental period.
The standard way to make a function repeat is to define it on one interval of length , then use the remainder modulo to select the corresponding point in that interval. This produces a periodic extension. It does not, however, preserve an arbitrary function already defined on all of : if the original values conflict with periodicity, some values must be replaced.
The basic construction
Suppose is defined on a base interval , where . Define
Here is the remainder in the interval . Thus the argument of always lies in .
For example, if and , then
The notation is sometimes written using the floor function:
Therefore an equivalent formula is
The simpler modulo notation is usually clearer.
Why the construction is periodic
The defining property of the remainder is
Consequently,
So is periodic with period , regardless of the formula used for on the base interval.
Worked example: repeating a parabola
Let the base function be
and choose period . Its periodic extension is
For several inputs:
The graph on every interval is a copy of the graph of on . In particular, .
At the joining points, this example has a jump. As approaches from the left, approaches , but because . The function is periodic, but discontinuous.
Making the periodic extension continuous
For the extension to be continuous at a join, assume that is continuous on in the one-sided sense at , and that the finite left-hand limit at exists. Under these assumptions, the extension is continuous at the join exactly when the values at the two ends agree:
If is defined and continuous on the closed interval , the condition is simply
For example, take
Since , repeating this function with period gives a continuous periodic function. One can write it as
Although the formula uses a remainder and changes at every even integer, the function itself has no jump there.
Making it differentiable or smoother
Matching endpoint values is enough for continuity, but not for differentiability. Assume that has continuous derivatives through the desired order in the interior, with one-sided derivatives extending to both endpoints. Endpoint quantities at below are understood as left-hand endpoint values. To obtain a continuously differentiable periodic extension, require matching first derivatives as well:
For a twice continuously differentiable extension, also require
More generally, under this regularity assumption, to obtain a periodic extension, the derivatives through order should match at the endpoints:
Here means the function values themselves. These conditions are sufficient when the corresponding derivatives extend continuously to both endpoints.
A familiar example is the trigonometric function. The function on satisfies
and all higher derivatives match too. Its periodic extension is already the usual smooth function .
If the original function is defined everywhere
Suppose you start with a function and want a periodic function that agrees with everywhere. This is possible only if is already periodic with the desired period. Indeed, agreement would imply
If agreement is required only on one interval, restrict to that interval and apply the periodic-extension formula:
This is the usual meaning of “make a function repeat”: preserve one chosen period of data and copy it outside that interval.
Common mistakes
Choosing the wrong interval length
In this construction, to copy a base interval every units, choose a base interval whose length is exactly . Repeating data from an interval of length gives a function with period ; it also has period only if the two length- halves agree.
Ignoring negative inputs
The mathematical remainder is conventionally chosen in . Some programming languages return a negative remainder for negative inputs, so an implementation may need
to guarantee a value in .
Assuming periodic means continuous
Modulo repetition always creates a periodic function, but it can have jumps at the boundaries. Check endpoint values—and derivatives if needed—before claiming continuity or smoothness.
Including both endpoints without a convention
The points and represent the same location in the repeated pattern. Using the half-open interval avoids assigning two potentially different values to that location. If the endpoint values agree, either endpoint convention gives the same pointwise function; when is continuous on the base interval, that function is continuous at the joins.
References
- Walter Rudin, Principles of Mathematical Analysis
- Elias M. Stein and Rami Shakarchi, Fourier Analysis: An Introduction
Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.