weird finding function from the graph

The graph is on the interval [-3,3], defined on R

This function maintain the pattern on all of R

How to find the $$f(x)$$?

See how the graph goes parallel at certain intervals. I am thinking adding one more variables to indicate one of the direction. However, I cannot merge the two together.

Any thoughts?

You can use a triangle wave written in terms of sine and arcsine:

$$f\left(x\right)\ =\ \frac{1}{\pi}\arcsin\left(\sin\left(\pi\left(x+\frac{1}{2}\right)\right)\right)+\frac{1}{2}.$$ This gives you the following plot:

• That function would be simpler if you used the cosine, right? $f(x) = 1-\frac{\text{arccos}\left( \cos (\pi x) \right)}{\pi}$ – Martin van IJcken Jan 21 at 13:00
• Yes, that also works fine. I was just using sine and arcsine because the Wikipedia page I linked used them. There are many ways we could write this function. – DMcMor Jan 21 at 13:08

Using the absolute value function together with the floor function, you can write $$f(x)=1-\left|x-\left(2\left\lfloor\frac{x+1}{2}\right\rfloor\right)\right|$$ Verification:

With $$f$$ as defined above, we get \begin{align*} f(x+2) &= 1-\left|(x+2)-\left(2\left\lfloor\frac{(x+2)+1}{2}\right\rfloor\right)\right| \\[4pt] &= 1-\left|x+2-\left(2\left\lfloor\frac{x+1}{2}+1\right\rfloor\right)\right| \\[4pt] &= 1-\left|x+2-\left(2\left(\left\lfloor\frac{x+1}{2}\right\rfloor+1\right)\right)\right| \\[4pt] &= 1-\left|x+2-\left(2\left(\left\lfloor\frac{x+1}{2}\right\rfloor+1\right)\right)\right| \\[4pt] &= 1-\left|x+2-\left(2\left(\left\lfloor\frac{x+1}{2}\right\rfloor+1\right)\right)\right| \\[4pt] &= 1-\left|x+2-\left(2\left\lfloor\frac{x+1}{2}\right\rfloor\right)-2\right| \\[4pt] &= 1-\left|x-\left(2\left\lfloor\frac{x+1}{2}\right\rfloor\right)\right| \\[4pt] &= f(x) \\[4pt] \end{align*} so $$f$$ is periodic with period $$2$$.

It remains to verify that $$f$$ works correctly on the interval $$[-1,1)$$.

Thus suppose $$f$$ is restricted to the interval $$[-1,1)$$. \begin{align*} \text{Then}\;\;& -1\le x < 1 \\[4pt] \implies\;& 0\le x+1 < 2 \\[4pt] \implies\;& 0\le \frac{x+1}{2} < 1 \\[4pt] \implies\;& \left\lfloor\frac{x+1}{2}\right\rfloor=0 \\[4pt] \end{align*} hence for $$-1\le x < 1$$ we get $$f(x) = 1-\left|x-\left(2\left\lfloor\frac{x+1}{2}\right\rfloor\right)\right| = 1-|x|$$ which matches the graph for the interval $$[-1,1)$$.

• could you explain how did you come up with the function please? – Hailey Chan Jan 21 at 4:24
• @Hailey Chan: I edited in some steps to verify that the formula works. – quasi Jan 21 at 5:58

You can define the function in part-wise intervals. For example, $$y=1-x, ~~\text{if}~ x \in [0,1]$$ Similarly, define the function for other intervals.