How can we graph the sawtooth function xx?

1 Answer
Aug 22, 2015

It's possible to impersonate it with...

(sin(xπ2)cos(xπ2))(tan(xπ2)tan(xπ2))+12

...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(xpi/2))-abs(cos(xpi/2)))(tan(xpi/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...

35(sin(xπ2)cos(xπ2)16sin(xπ2)3+16cos(xπ2)3)tan(xπ2)tan(xπ2)+12

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(xpi/2))-abs(cos(xpi/2))-abs(sin(xpi/2)^3)/6+abs(cos(xpi/2)^3)/6)tan(xpi/2)/abs(tan(x*pi/2))+1/2 [-2.48, 2.52, -0.75, 1.75]}