Results 1 to 6 of 6

Math Help - Reverse engineering a function

  1. #1
    Newbie
    Joined
    Apr 2011
    Posts
    3

    Reverse engineering a function

    I'm not sure if this is the correct forum for my question, so please move it as needed.

    It has been many years since I did any advanced math, and I'm having some trouble determining how to come up with a function for a given set of inputs. I have a compiled program but no source code, and I want to use the function in a new program. I can enter values into the existing program and get a result, but I don't know the function for calculating the output. For example, 40x + 60y + 200z = 42 and 30x + 60y + 300z = 58.

    Should I create equations for 3 sets of coefficients with solutions and solve the set of simultaneous equations?
    Follow Math Help Forum on Facebook and Google+

  2. #2
    A Plied Mathematician
    Joined
    Jun 2010
    From
    CT, USA
    Posts
    6,318
    Thanks
    5
    Awards
    2
    It would be helpful to have a little more information here. Can you assume that the output is a linear combination of inputs? If so, then a linear system such as you suggest would work. (You'd want to test your model to make sure it works, once you have it all done. That is, compare your theoretical model with the output of the existing program and see if they're the same.) Do you have any other information as to what this function is computing?
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Apr 2011
    Posts
    3

    More info

    Quote Originally Posted by Ackbeet View Post
    It would be helpful to have a little more information here. Can you assume that the output is a linear combination of inputs? If so, then a linear system such as you suggest would work. (You'd want to test your model to make sure it works, once you have it all done. That is, compare your theoretical model with the output of the existing program and see if they're the same.) Do you have any other information as to what this function is computing?
    I have input a set of values for x, y, and z and produced a set of outputs (in the last column) as shown below.

    30 60 300 58
    30 64 300 60
    30 68 300 61
    30 72 300 63
    30 76 300 64
    30 80 300 66

    20 60 200 42
    20 66 220 48
    20 72 240 54
    20 78 260 60

    I don't know if I can assume the output is a linear combination of inputs. Some sets of combinations make it appear that the output is linear, and others make me unsure.
    Follow Math Help Forum on Facebook and Google+

  4. #4
    A Plied Mathematician
    Joined
    Jun 2010
    From
    CT, USA
    Posts
    6,318
    Thanks
    5
    Awards
    2
    It's definitely not a linear function; at least, if your function outputs are exact. I used the three data points

    30, 60, 300, 58
    30, 64, 300, 60
    20, 66, 220, 48

    to obtain the function

    f(x,y,z)=\dfrac{83x}{30}+\dfrac{y}{2}-\dfrac{11z}{60}.

    This function does not satisfy all the data points, hence the function is not linear (as is).

    You can see just by looking at the data that the function is not linear. In the first six data points, you're increasing the y component by the same amount each time, but the function value does not go up by the same amount each time.

    Question, though: are these function outputs rounded off in any way? The behavior I'm seeing there would be reasonably linear if there was some rounding going on. Is there any way you can give me more significant figures?
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Newbie
    Joined
    Apr 2011
    Posts
    3

    Significant figures

    Quote Originally Posted by Ackbeet View Post
    It's definitely not a linear function; at least, if your function outputs are exact. I used the three data points

    30, 60, 300, 58
    30, 64, 300, 60
    20, 66, 220, 48

    to obtain the function

    f(x,y,z)=\dfrac{83x}{30}+\dfrac{y}{2}-\dfrac{11z}{60}.

    This function does not satisfy all the data points, hence the function is not linear (as is).

    You can see just by looking at the data that the function is not linear. In the first six data points, you're increasing the y component by the same amount each time, but the function value does not go up by the same amount each time.

    Question, though: are these function outputs rounded off in any way? The behavior I'm seeing there would be reasonably linear if there was some rounding going on. Is there any way you can give me more significant figures?
    Unfortunately, the program interface forces all of the inputs and outputs to be integers. I agree w/ you that it may probably be a linear function but rounding or truncating of the output makes it appear that it's not linear.

    The function I'm seeking doesn't need to be exact, so I'm sure what you've given me is sufficient. I will run some tests and compare the outputs of your function vs. the existing program.

    BTW, what method did you use to find the function? Frankly, my inner geek is more interested in how to find the function than in actually using it. :-)
    Follow Math Help Forum on Facebook and Google+

  6. #6
    A Plied Mathematician
    Joined
    Jun 2010
    From
    CT, USA
    Posts
    6,318
    Thanks
    5
    Awards
    2
    To get the function I just solved the system

    30a + 60b + 300c = 58
    30a + 64b + 300c = 60
    20a + 66b + 220c = 48

    for a, b, c. Then I set

    f(x,y,z) = ax + by + cz.

    It occurred to me that you could get a more accurate function (assuming it actually is linear!) by running least-squares fits over the data. The procedure would work as follows:

    Step 1: find out how the function depends on x by obtaining at least nine points of data where all you vary is x.
    Step 2: find out how the function depends on y by obtaining at least nine points of data where all you vary is y.
    Step 3: find out how the function depends on z by obtaining at least nine points of data where all you vary is z.
    Step 4: put all the information together by conglomerating the expressions, and double-checking the constants.

    Then I think you'd get a pretty accurate assessment of the results.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. application of diff eq for software reverse engineering?
    Posted in the Differential Equations Forum
    Replies: 0
    Last Post: December 10th 2011, 05:21 AM
  2. Plot reverse engineering
    Posted in the Advanced Math Topics Forum
    Replies: 1
    Last Post: September 24th 2011, 11:09 PM
  3. Reverse engineering cost functions
    Posted in the Business Math Forum
    Replies: 1
    Last Post: May 9th 2011, 10:58 AM
  4. Reverse Engineering Hotel Industry Ratios
    Posted in the Algebra Forum
    Replies: 3
    Last Post: March 15th 2011, 12:27 PM
  5. reverse
    Posted in the Discrete Math Forum
    Replies: 1
    Last Post: August 3rd 2007, 07:33 AM

Search Tags


/mathhelpforum @mathhelpforum