Context
After a discussion about how to plot the results of a frequency modulation between two signals on Stack Overflow, I understood that I need to find the time-integral of the following wave functions before using them in the general FM formula (as illustrated in the first answer).
Research
Integrating a sine wave function is indeed easy, but things gets a lot complicated when it comes to other waveforms. Here follow the equations I'm using to display the waveforms:
Sawtooth wave:
$ f(x) = \bmod(f_c x, 1.0); $
Square wave:
$ f(x) = \operatorname{sign}(\cos(f_c x)); $
Triangle wave:
$ f(x) = \frac{1}{f_c}|\bmod(x, f_c) - \frac{1}{2}f_c|$
These functions looks right, but as I don't have any particular background in mathematics or calculus I won't be surprised if I made some bad mistakes. Please be patient.
Questions
- Is there a better way to describe mathematically the wave functions above?
- If these are right, what is the correct time-integral?
Updates
Thanks to the the functions with period $T$ in the form Rahul suggested I get:
$\begin{align}\operatorname{sawtooth}(x) = \int_0^x \frac{2x}T-1 \ \mathrm dx &= \frac{x(x - T)}T \end{align}$
$\begin{align} \operatorname{square}(x) &= \int_0^x \begin{cases}1&\text{if } x
$\begin{align} \operatorname{triangle}(x) &= \int_0^x \begin{cases}\frac{4x}T-1&\text{if } x
By using a modulo operator it's easy to make them periodic $f(x) = \operatorname{sawtooth}(x \% T)$ and they all work as expected when placed as modulators in the frequency modulation equation: $\begin{align} f(x) = \cos\left(2\pi f_c x + 2\pi f_\Delta \int_0^xg(x)\,\mathrm dx\right) \end{align}$