# find equation based on multiple sets of 2 variables and results

I'm currently trying to reverse engineer a few equations used in a game, and have collected what seems to be all the relevant data.

In the example below, result speed is definitely based solely on the variables of thrust and weight. note that the game does use variables, but rounds the number

``````thrust | weight | speed
|        |
428 | 13575  | 188
617 | 13575  | 209
536 | 23850  | 152
995 | 35750  | 175
698 | 17475  | 202
1373 |  8575  | 278
``````

Is it possible for me to use this data to find the equation through any means except brute force? I've looked around but only found things which used a single variable.There also seems to be diminishing returns on thrust, apart from the increase in weight which comes with it.

Not sure how to tag this

I originally asked this here (https://math.stackexchange.com/questions/2727993/find-equation-based-on-multiple-sets-of-2-variables-and-results), and one of the responses suggested I bring the question here.

• I was not entirely convinced your question fits on this site (and – hah – I might even have referred you to Mathematics), but on the other hand, as we already have coffee pads and license plates, this one should fit as well :) First thought: have you considered reverse-engineering the executable? If not, can you put up a download link so someone else might have a go at it? It could be easier than finding out the relationship between these numbers. – usr2564301 Apr 8 '18 at 19:47
• mathematically speaking you can always fit a curve with another. The results get better when you have a large set of values. In your case, the best way would be to track down the function doing the arithmetic. – sudhackar Apr 9 '18 at 10:54
• Can you tell us more about the physics of the game. Is it vertical motion (e.g. a rocket against gravity) or horizontal motion (e.g. a car against friction and air resistance)? – Ian Cook Apr 10 '18 at 8:04
• Just understand that depending on how realistic the game is, there are other (hidden) parts of the calculation. For example, there is opposing aerodynamic drag in real life, which IIRC increases with the square of the velocity (e.g. 4x as much drag at 10 mph compared to 20 mph). Aero drag would be part of the speed calculation, counteracting the thrust force, but it's not linear (obviously). RE'ing the binary (as others have said) is the best. If not, try accounting for the aero drag, and you might get close. – Dan Apr 13 '18 at 1:37

While it may be possible to come up with some equation and find out the coefficients from the sample values, they may also be connected in some non-obvious way, so the best solution would be to track down the code which calculates the speed and see how exactly it uses thrust and weight.

The best approach would be to actually RE the binary but since we don't have I'll propose an alternative approach.

We could use sat solver like z3 to find out the solution for us.

Having script like this:

``````from collections import namedtuple
DataPoint = namedtuple('DataPoint', 'thrust weight speed')

data = [DataPoint(428, 13575, 188),
DataPoint(617, 13575, 209),
DataPoint(636, 23850, 152),
DataPoint(995, 35750, 175),
DataPoint(698, 17474, 202),
DataPoint(1373, 8575, 278)]

from z3 import *

a = Int('a')
b = Int('b')

s = Solver()
for e in data: