What is the function that generates this graph?

58 Views Asked by At

I have the following coordinates:

( 1, 1)
( 2, 1)
( 3, 3)
( 4, 1)
( 5, 3)
( 6, 5)
( 7, 7)
( 8, 1)
( 9, 3)
(10, 5)
(11, 7)
(12, 9)
(13,11)
(14,13)
(15,15)
...
...
etc.

basically: the y values are all odd numbers in ascending order but they start over from 1 if the next value exceeds the value of x.

Here is a graph: enter image description here

2

There are 2 best solutions below

1
On BEST ANSWER

You might observe that $f(2^n)=1$ and $f(2^n+k)=2k+1$ if $0 \le k \lt 2^n$, though you might want to prove it.

So consider whether you can define $k=x-2^{\lfloor \log_2 x \rfloor}$ and so $$f(x)=2x-2^{1+\lfloor \log_2 x \rfloor}+1.$$

2
On

On can observe that $y=2(x-2^k)+1$ in $2^k\leq x<2^{k+1}$ or $k\leq \frac{\ln(x)}{\ln(2)}<k+1$ hense $k=\left \lfloor\frac{\ln(x)}{\ln(2)}\right \rfloor$

So, the function is : $$y=2\left(x-2^{\left \lfloor\frac{\ln(x)}{\ln(2)}\right \rfloor}\right)+1$$ where $\lfloor \, \rfloor$ is the symbol of the floor function.