0

In a search I found some information where I verified a certain linearity in the data, to certify what I was seeing, I put 5,000 points of this data, in the form {X, Y}, in a graph ( https://plot.ly/create/?fid=bencz:1 )

What $ f(x) $ can be used to describe this graph?

daw
  • 49,113
  • 2
  • 38
  • 76
Alexandre
  • 107

1 Answers1

1

Since you've only provided us with data, I will construct a formula based on the patterns alone. Since it's hard to check all 5000 values to verify my formula, please let me know if I miss something.

Notice $f(0)=0,\ f(10)=3,\ f(20)=6,\dots, f(10n)=3n$

Now, notice that $f(1)=2,\ f(11)=5,\ f(21)=8,\dots, f(10n+1)=2+3n$

Similarly, notice that for any natural number $k<10$, we have $f(10n+k)=3n+2k$

Now, observe that $f(100)=4$, $f(1000)=5, \dots f(10^m)=(m\mod 6)+2$ (It looks like it's simply $m+2$, but in the OP's code presented below, the multiplier is reset to $2$ whenever it gets passed $7$. So we must account for that here.)

It appears that your function takes the number $x$ to the base $10$, multiplies the $10^m$'s digit by $(m\mod 6)+2$, and takes the sum. So far, if $g(x,n)$ is the $n$th digit of $x$ to the base $10$, we have $$f(x)=\sum_{i=0}^\infty ((i\mod 6)+2)g(x, i) $$

One closed form of $g(x,n)$ is $$g(x,n)=\left\lfloor\frac{x}{10^{n}}\right\rfloor \mod 10$$

So in total we have: $$f(x)=\sum_{i=0}^\infty ((i\mod 6)+2)\left( \left\lfloor\frac{x}{10^i}\right\rfloor \mod 10\right)$$

Riley
  • 2,747
  • Hi!, THanks!!.... I did some tests, and, when the number grows gigant, the function not work well... take a look at this test: https://plot.ly/create/?fid=bencz:3, btw, to test the function I wrote a small C function: https://gist.github.com/bencz/9112c5c354f8e5f61fbbda3432f9141d – Alexandre Nov 28 '17 at 01:47
  • If the problem only occurs when the number grows gigantic, are you sure that your program is not experiencing integer overflow? And how are you generating these points that you plot? Obviously, you have some idea of what your function is doing. – Riley Nov 28 '17 at 01:57
  • Hi! It`s not a problem with overflow, I tried the same function with bigintegers, for example, the number "3000000002158" generate the result "687", but, the expected is 51 ...., btw, I have a function that generate this numbers, it's a function to compute the MOD 11 Check Digit with base 7 – Alexandre Nov 28 '17 at 02:30
  • Do you mean 87 instead of 687? Anyway, how do you know 51 is the expected result? Clearly, you are computing the expected result in some way. What is the method you use to compute it? – Riley Nov 28 '17 at 02:37
  • Hi! Yes, as I said, these points were generated from a function to compute the mod11 check digit... see the code: https://gist.github.com/bencz/dba3058aef8e069a42a09c42799a7b4d – Alexandre Nov 28 '17 at 02:46
  • Okay. I think I know what's wrong. There is a complication of the function that only affects larger numbers, so it didn't manifest in the original plot of 5000 points. I'll update my answer. – Riley Nov 28 '17 at 03:09
  • Hi! Now I got what exactly you did to 'reset' from 2 to 7!! You are amazing!!! Thanks!!! – Alexandre Nov 28 '17 at 03:21