How can I calculate a smooth tangent wave that has no periodic delays?

Solution 1:

Consider one branch of the tangent function. You're restricting the range of $\tan(x)$ to $[-1,1]$, which means $x\in\left[-\frac\pi4,\frac\pi4\right]$.

Since $\tan(x) = \tan(x\pm n\pi)$ for integer $n$, restricting the range to $[-1,1]$ for the entire plot of $\tan(x)$ would make for a domain of $\cdots\cup\left[-\frac{5\pi}4,-\frac{3\pi}4\right]\cup\left[-\frac\pi4,\frac\pi4\right]\cup\left[\frac{3\pi}4,\frac{5\pi}4\right]\cdots$. We can write this compactly by observing

$$x\in\left[-\frac{5\pi}4,-\frac{3\pi}4\right] \implies -\frac\pi4 \le x+\pi \le\frac\pi4 \implies |x+\pi| \le\frac\pi4$$

$$x \in \left[-\frac\pi4, \frac\pi4\right] \implies -\frac\pi4 \le x \le \frac\pi4 \implies |x| \le \frac\pi4$$

$$x\in\left[\frac{3\pi}4,\frac{5\pi}4\right] \implies -\frac\pi4 \le x-\pi \le\frac\pi4 \implies |x-\pi| \le\frac\pi4$$

and so on, such that the restricted domain is $|x+n\pi|\le\frac\pi4$, where $n$ is an integer.

We can fill in the gaps by shifting $\tan(x)$ by $\frac\pi2$, as the other answer suggests. Then we could define this function piecewise as

$$\operatorname{smoothtan}(x) = \begin{cases} \tan(x) & \text{if } |x+n\pi|\le\frac\pi4 \quad (n\in\mathbb Z) \\ \tan\left(x\pm\frac\pi2\right) & \text{otherwise}\end{cases}$$

(though "smooth" is not the best name for this function)

Solution 2:

I would write the following in Desmos: $$y = \left[\tan(x),\tan\left(x+\frac{\pi}{2}\right)\right] \{-1 \le y \le 1\}$$

Here is a link for the same page you sent with the formula written.