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}sawtooth(x) = \int_0^x \frac{2x}T-1 \ \mathrm dx &= \frac{x(x - T)}T \end{align}$$
$$\begin{align} square(x) &= \int_0^x \begin{cases}1&\text{if } x<T/2\\-1&\text{if }x\ge T/2\end{cases} \ \mathrm dx &= \begin{cases}x&\text{if } x<T/2\\-x&\text{if }x\ge T/2\end{cases} \end{align}$$
$$\begin{align} triangle(x) &= \int_0^x \begin{cases}\frac{4x}T-1&\text{if } x<T/2\\3-\frac{4x}T&\text{if }x\ge T/2\end{cases} \ \mathrm dx &= \begin{cases}x(\frac{2x}T-1)&\text{if } x<T/2\\x(3-\frac{2x}T)&\text{if }x\ge T/2\end{cases} \end{align}$$
By using a modulo operator it's easy to make them periodic $f(x) = sawtooth(x \% T)$ and they all work as expected when placed as modulators in the frequency modulation equation: $$\begin{align} f(x) = cos(2\pi f_c x + 2\pi f_\Delta \int_0^xg(x)\,\mathrm dx) \end{align}$$
You can see below how the amplitude of the waveforms is now modulating the frequency of the carrier wave. Thanks everyone, especially Rahul, for the helpful comments!

fmod), but I can explain the discontinuity at what I assume is $T/2$. The value of $\int_0^x \begin{cases}g_1(t)&\text{if }t<T/2\\g_2(t)&\text{if }t\ge T/2\end{cases}\,\mathrm dt$ when $x\ge T/2$ is $\int_0^{T/2}g_1(t)\,\mathrm dt + \int_{T/2}^xg_2(t)\,\mathrm dt$, not simply $\int_0^xg_2(t)\,\mathrm dt$. – Rahul Narain Aug 5 '12 at 16:47