#invert an equation?
17 messages · Page 1 of 1 (latest)
What exactly does this function do?
its some math for map generation that pseudo randomly varies a seed given another seed
This doesn't seem reversible to me
so if I ran var f = d(10000000) the value of f would be 9990000
hmm
everything is doable
Like is this a continuous function, mathematically?
Is it possible for two different s values to give the same result?
oh im not actually sure
the part of most unsure about is the modulo part because im not quite sure how that would be reversible
You also have an integer division in there
I suspect this is probably possible, but it probably isn't a simple formula
It's not possible; even assuming that s is an integer, too much data is lost
If you put 9016 and 8999 into the function d, you will notice that both return 9007
This function just does the brute force method, and will always return a valid number that, when plugged through d, will be correct - but due to data loss it will not always be the original number. (Assuming that all numbers are integers, given that d will crash if the number isn't an integer)
func reverse(r):
var tests = [r - r/1001, r + r/999]
for i in range(tests.size()):
if (d(tests[i]) == r):
return tests[i]
In short, yes, two different s values can give the same result. You can always find one of those values, but you can't know which one was the original.