# How can we graph the sawtooth function #x - floor(x)#?

##### 1 Answer

It's possible to impersonate it with...

...or better if you add some cubed terms.

#### Explanation:

Without the hashes, that's:

((abs(sin(x * pi/2))-abs(cos(x * pi/2))) * (tan(x * pi/2)/abs(tan(x * pi/2)))+1)/2

Here's how it looks...

graph{((abs(sin(x*pi/2))-abs(cos(x*pi/2)))*(tan(x*pi/2)/abs(tan(x*pi/2)))+1)/2 [-4.98, 5.02, -2, 3]}

Not entirely convincing, but probably close enough.

For better linearity, add some cubed terms...

3/5(abs(sin(x * pi/2))-abs(cos(x * pi/2))-abs(sin(x * pi/2)^3)/6+abs(cos(x * pi/2)^3)/6) * tan(x * pi/2)/abs(tan(x * pi/2))+1/2

graph{3/5(abs(sin(x*pi/2))-abs(cos(x*pi/2))-abs(sin(x*pi/2)^3)/6+abs(cos(x*pi/2)^3)/6)*tan(x*pi/2)/abs(tan(x*pi/2))+1/2 [-2.48, 2.52, -0.75, 1.75]}