How do i plot a square wave in Desmos

479 Views Asked by At

I'm studying Fourier series and i'm using Desmos to graph the results and it does look like its approximating towards a square wave

but is there a way that i can just graph a square wave in desmos? and periodic functions in general?

2

There are 2 best solutions below

0
On

$\sin(\pi\lfloor x \rfloor +\frac{\pi}{2})$ should do the trick.

More generally, a $\sin(\pi(\lfloor bx+c \rfloor+\frac{\pi}{2})+d$. Modify $c$ and $d$ to translate, modify $a$ and $b$ to scale.

0
On

One way is:

$$(A_p-A_m)\operatorname{round}(\operatorname{mod}(fx,1))+A_m$$

where the function jumps between $A_p$ and $A_m$, the frequency is $f$, and the amplitude is $A=|A_p-A_m|$.