Finding the function of a graph with sharp peaks and an exponentially increasing period

383 Views Asked by At

Context: I'm a secondary student working on a small exploration of the fast inverse square root algorithm. This algorithm uses a certain constant to "tune" the approximation to a small margin of error. Out of curiosity, I tried setting the value of the fast inverse square root equal to $\frac{1}{\sqrt{x}}$ for several values of $x$ in order to solve for a better constant that would completely eliminate the error at each point.

The issue: Plotting the results against $x$ leads to the graphs below. I've attached one version with a linear scale, and one with a logarithmic scale on the $x$-axis.

- [Graph with linear scale;][2] - [Graph with semi-logarithmic scale.][3]

I am currently struggling to find a function that would produce this type of relationship. The process I used to generate the data involved some computer memory hacking (reinterpreting the bits of a float as a long and vice-versa), which is difficult to express mathematically.

However, the graph doesn't seem too outlandish. It has a repeating pattern, though the "period" quadruples each cycle. It has two distinct "peaks", with the low one occurring when $x$ is an odd power of $2$ and the high one on even powers of $2$.

I've done some tinkering but I don't feel that I've made any significant progress; $-|\cos{(\pi\cdot4^\frac{1}{x})}|$ has been my best guess and it's not remotely close. I would appreciate any help expressing this relationship in mathematical terms.

This is my first time asking, so I'll do my best to provide additional information and fix mistakes as needed.