The equation of a triangular wave can be represented as a piecewise function. In this case, with an amplitude of 2 and a time period of 2, the equation can be defined as follows:
f(t) = 2 * (t - 2 * floor((t + 1) / 2)) * (-1)^(floor((t + 1) / 2))
Let me break down the equation for you:
- t represents the time variable.
- floor(x) denotes the largest integer that is less than or equal to x.
- The term (t + 1) / 2 ensures that the wave repeats every 2 units of time.
- The function (-1)^(floor((t + 1) / 2)) generates alternating signs (+1 and -1) for the ascending and descending sections of the wave.
- The term t - 2 * floor((t + 1) / 2) maps the time domain to the range [-1, 1], where the wave changes direction at integer values of t.
By multiplying this term by 2, we obtain the desired amplitude of 2 for the triangular wave.
Please note that this equation assumes the wave starts at t = 0. If you need to shift the wave horizontally, you can add a constant term inside the floor function or adjust the equation accordingly.