On Tue, Jul 14, 2009 at 11:49 PM, Daniel Moore<
yahivin@...> wrote:
> And now what you've all been waiting for... the mystery function:
>
> def mystery(x, y)
> 3 * x * y + 5 * (y**3) - 7 * x
> end
Cool. I was not thinking and I rebooted while my script and output
were in /tmp; the machine is set to clear tmp on boot: so, I lost my
lowest-delta functions. But, I recovered these:
> cat foo
DATA = [[8, 16, 20808], [22, 31, 150847], [5, 16, 20685], [12, 19, 34895],
[18, 25, 79349], [20, 33, 181525], [31, 1, -119] , [19, 33, 181433],
[0, 12, 8640], [13, 12, 9017]]
# An example of one of the closer ones I found:
f = "(y) * + x - - - - + x - x - 3 * 82 / y + - 5 + + + x - y * y + y
- 2 * (x + y) / 459 + + - + - - 5 + (y) - 2 + - + 5 + (y) / + 5 - - -
+ + - + x - 3 * 8 + x - + (y) * 5 - x - - x + (y) * 5 + y * (y) / (y)
* y * (y) * 5 + y * (y) * 5 / 3 / (y) * - - + x - 3 + (y) * y / (y) *
y"
puts DATA.map{|(x, y, ev)| puts "#{x}\t#{y}\t#{ev}\t#{av =
eval(f)}\t#{delta = (ev - av).abs}"; delta}.inject{|s,v| v += s}
puts
# I think this was the second best I found; unfortunately, I did not save
# the original output. The version here was after some hand editing while
# pasting it into a spreadsheet, e.g.:
# "x + + + - + y" => "x - y"; "x + - + - + y" => "x + y"; "(x)" => "x"
f = "-5 * y / 4 - x - y - 5 * 8 + y / 5 * -y / 5 + 5 * y - 8 / -8 - y
/ 5 / 4 * 4 + 5 - 7 - 3 / 6 - y / 5 * -4 / y * y + 3 / 6 * -x + 4 + 5
+ 1 - 3 / 6 / -8 * y + 8 / -8 + 8 * + 1 + y / 5 * -y / 5 * -4 * 4 / +
y + 6 - y - 8 + 8 / -8 + 5 / 8 * -8 + y / 5 * 8 / -8 - y + 7 + y * x +
5 * y * y * y + 3 * -x + y + 8 / 3 / 6 - y - 8 / -8 - y / 5 * -4 + y *
y / y * x + 8 * y / -4 + 5 / 84 * 8 * -3 * 4 - x + y * x"
puts DATA.map{|(x, y, ev)| puts "#{x}\t#{y}\t#{ev}\t#{av =
eval(f)}\t#{delta = (ev - av).abs}"; delta}.inject{|s,v| v += s}
puts
# I added "- 5" to the above:
f = "-5 * y / 4 - x - y - 5 * 8 + y / 5 * -y / 5 + 5 * y - 8 / -8 - y
/ 5 / 4 * 4 + 5 - 7 - 3 / 6 - y / 5 * -4 / y * y + 3 / 6 * -x + 4 + 5
+ 1 - 3 / 6 / -8 * y + 8 / -8 + 8 * + 1 + y / 5 * -y / 5 * -4 * 4 / +
y + 6 - y - 8 + 8 / -8 + 5 / 8 * -8 + y / 5 * 8 / -8 - y + 7 + y * x +
5 * y * y * y + 3 * -x + y + 8 / 3 / 6 - y - 8 / -8 - y / 5 * -4 + y *
y / y * x + 8 * y / -4 + 5 / 84 * 8 * -3 * 4 - x + y * x - 5"
puts DATA.map{|(x, y, ev)| puts "#{x}\t#{y}\t#{ev}\t#{av =
eval(f)}\t#{delta = (ev - av).abs}"; delta}.inject{|s,v| v += s}
puts
> ruby foo
8 16 20808 20816 8
22 31 150847 150842 5
5 16 20685 20681 4
12 19 34895 34916 21
18 25 79349 79369 20
20 33 181525 181526 1
31 1 -119 -128 9
19 33 181433 181435 2
0 12 8640 8602 38
13 12 9017 9057 40
148
8 16 20808 20810 2
22 31 150847 150859 12
5 16 20685 20681 4
12 19 34895 34902 7
18 25 79349 79361 12
20 33 181525 181530 5
31 1 -119 -78 41
19 33 181433 181436 3
0 12 8640 8625 15
13 12 9017 9028 11
112
8 16 20808 20805 3
22 31 150847 150854 7
5 16 20685 20676 9
12 19 34895 34897 2
18 25 79349 79356 7
20 33 181525 181525 0
31 1 -119 -83 36
19 33 181433 181431 2
0 12 8640 8620 20
13 12 9017 9023 6
92