### Reverse engineering cyclical function from observed outputs

Posted:

**Fri Apr 15, 2016 5:26 am UTC**I've been struggling with this problem for a couple of days, and figured maybe some of the fine folks around here might be able to help. I have to admit I'm a bit of a tourist in these forums -- if there's a more appropriate place for this, please let me know.

There's a function f(x,y) where x and y are integers in the range [0,1000]. The function is a black box to me, and I'm trying to reverse-engineer it. The outputs are in the range [40, 90], and appear as integers, but I suspect there may be rounding going on behind the scenes. After looking at some large portions of the data, it's clear that the function is cyclical in some way, but there are perturbations I haven't been able to eliminate (hence my suspicion about rounding). For example, here's a screenshot of a spreadsheet showing some of the results (x values along the top, y values along the side): http://imgur.com/cp1Qj3n (the highlighting is simply to help reveal the pattern, and because I'm most interested in identifying the inputs which yield outputs at the top end of the range).

Any ideas on how to go about this? Finding the outputs experimentally is expensive, but not prohibitively so, for this function f. I could record all million-plus data points in a few hours. However, there are several other similar functions for which experimental observations are prohibitively expensive (dozens of seconds per observation for function g, and going up from there). So, I'm hoping that if I'm able to figure out how function f works, I'll have an easier time figuring out the others based on much more limited observation. My ultimate goal is to find inputs that (nearly) maximize all five functions at once.

One interesting thing about f -- for any x in the domain (up to 999), f(x, 1000) == f(x+1, 0). I'm not too sure how to use that, though. Also, the left and right edges do not match up the way the top and bottom edges do. I've tried taking two long vertical swathes that look identical at the start (places where I can visualize the pattern repeating) and comparing them, but haven't found any that match up exactly. For example, starting from (62,109) and working down (increasing y values), and also from (78,140), the outputs match up except for being off by 1 every 100 or so inputs.

Some more context about the domain, if it helps. The numbers I'm interested in represent an attribute of hexes in a large grid (a map). Each hex has an (x,y) coordinate which I can see, and the value of the attribute can be revealed with a little bit of time (very small for the attribute represented by f, but it takes longer for the other attributes). The x-axis runs west-to-east, and the y-axis runs northwest-to-southeast. I'm only assuming that the x-y coordinates are the only inputs to this function, but it seems like a reasonable assumption.

Any suggestions or ideas on how to proceed would be much appreciated!

There's a function f(x,y) where x and y are integers in the range [0,1000]. The function is a black box to me, and I'm trying to reverse-engineer it. The outputs are in the range [40, 90], and appear as integers, but I suspect there may be rounding going on behind the scenes. After looking at some large portions of the data, it's clear that the function is cyclical in some way, but there are perturbations I haven't been able to eliminate (hence my suspicion about rounding). For example, here's a screenshot of a spreadsheet showing some of the results (x values along the top, y values along the side): http://imgur.com/cp1Qj3n (the highlighting is simply to help reveal the pattern, and because I'm most interested in identifying the inputs which yield outputs at the top end of the range).

Any ideas on how to go about this? Finding the outputs experimentally is expensive, but not prohibitively so, for this function f. I could record all million-plus data points in a few hours. However, there are several other similar functions for which experimental observations are prohibitively expensive (dozens of seconds per observation for function g, and going up from there). So, I'm hoping that if I'm able to figure out how function f works, I'll have an easier time figuring out the others based on much more limited observation. My ultimate goal is to find inputs that (nearly) maximize all five functions at once.

One interesting thing about f -- for any x in the domain (up to 999), f(x, 1000) == f(x+1, 0). I'm not too sure how to use that, though. Also, the left and right edges do not match up the way the top and bottom edges do. I've tried taking two long vertical swathes that look identical at the start (places where I can visualize the pattern repeating) and comparing them, but haven't found any that match up exactly. For example, starting from (62,109) and working down (increasing y values), and also from (78,140), the outputs match up except for being off by 1 every 100 or so inputs.

Some more context about the domain, if it helps. The numbers I'm interested in represent an attribute of hexes in a large grid (a map). Each hex has an (x,y) coordinate which I can see, and the value of the attribute can be revealed with a little bit of time (very small for the attribute represented by f, but it takes longer for the other attributes). The x-axis runs west-to-east, and the y-axis runs northwest-to-southeast. I'm only assuming that the x-y coordinates are the only inputs to this function, but it seems like a reasonable assumption.

Any suggestions or ideas on how to proceed would be much appreciated!