Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 19
Hiya, Does anyone know how to solve this: We input 2 numbers (EDIT: See my later post) into an unspecified algorithm, and get an answer. We know the 2 numbers ...
  1. #1
    Linux Guru
    Join Date
    Apr 2003
    Location
    London, UK
    Posts
    3,284

    Anyone good at math? - Reverse engineer an algorithm

    Hiya,

    Does anyone know how to solve this:

    We input 2 numbers (EDIT: See my later post) into an unspecified algorithm, and get an answer. We know the 2 numbers we put in, and we know the answer. What we need to do is find the algorithm used to generate the answer.

    I've got 3 examples:

    IN: 847 & 3240
    OUT: 12,851

    IN: 1360 & 4590
    OUT: 17,787

    IN: 313 & 1000
    OUT: 5,034

    How do I work out what the algorithm is?

    I've tried googling a few things as well, but I guess my terminology might be wrong... If anyone can find any links on how to solve these type of problems it would be much appriciated.

    A BIG BIG thanks in advance to anyone who can help with this.

    Ta,

    J.

    edited: spelling

  2. #2
    Linux Newbie
    Join Date
    Jun 2005
    Posts
    123
    There's an infinite amount of functions to give a value given two values, given that that we have 3 data points.

    Assuming this isn't overly complex (i.e. it just has a few plus, subtract, multiply and divide) it shouldn't be that difficult, I'll work on it when I get in.

  3. #3
    Linux Guru techieMoe's Avatar
    Join Date
    Aug 2004
    Location
    Texas
    Posts
    9,496
    Now now, Jason. We can't do your homework for you, it's in the rules.
    Registered Linux user #270181
    TechieMoe's Tech Rants

  4. #4
    Linux Guru fingal's Avatar
    Join Date
    Jul 2003
    Location
    Birmingham - UK
    Posts
    1,539
    What's the context for the question Jason? It might give a clue to the answer.

    Actually my maths isn't very good, but the first one got me going. Eg.:

    847 + 3240 = 4087
    4087*3.142 = 12841

    12841 + 10 = 12851

    Hmmmmm, am I seeing things or what? It doesn't work for the others.
    I am always doing that which I can not do, in order that I may learn how to do it. - Pablo Picasso

  5. #5
    Linux Guru
    Join Date
    Apr 2003
    Location
    London, UK
    Posts
    3,284
    It is actually a bit more complex than I first described... there are 3 in values, not 2. I missed the 3rd off by accident, sorry.

    --------------------
    IN: 6 & 847 & 3,240
    OUT: 12,851

    IN: 6 & 1,360 & 4,590
    OUT: 17,787

    IN: 5 & 313 & 1,000
    OUT: 5,034
    --------------------

    The good news:
    - All of the in values will always be whole numbers >= 0 (ie, the algorithm does not have to account for negative's).
    - There is no randomization in the algorithm; the same in values will always produce the same out value.
    - I can get hold of more example data if needed, if anyone want's it send an email to mail@jasonlambert.co.uk or PM me here.

    context - sorry I can't disclose it
    homework - ha, they never taught us anything this complex at school I wish they had

    Once again, thanks to anyone who can help solve this

    J.

  6. #6
    Linux Enthusiast carlosponti's Avatar
    Join Date
    Dec 2004
    Location
    Oklahoma
    Posts
    560
    Quote Originally Posted by jasonlambert
    context - sorry I can't disclose it
    will you have to kill us if you do tell us
    Blog
    Registered Linux user 396557

  7. #7
    Just Joined!
    Join Date
    Jun 2005
    Location
    Canada, Halifax
    Posts
    86
    As TomX pointed out, without additional boundary conditions there are an infinite set of equations that can solve the problem. Here is a trivial solution that _PROBABLY_ will not suit your purposes. It is a simple polynomial model:

    given the set of boundary conditions, X's inputs and Y's outputs:

    [ X11 X12 ... X1n | Y1 ]
    [ X21 X22 ... X2n | Y2 ]
    [... ]
    [ Xm1 Xm2 ... Xmn | Ym ]

    1. Sum your inputs such that:

    Z1 = X11 + X12 + ... + X1n
    Z2 = X21 + X22 + ... + X2n
    ...
    Zm = Xm1 + Xm2 + ... + Xmn

    2. Form a system of linear equations:

    A Z1^(n-1) + B Z1 ^(n-2) + ... = Y1
    A Z2^(n-1) + B Z2 ^(n-2) + ... = Y2
    ...
    A Zm1^(n-1) + B Z2 ^(n-2) + ... = Ym

    3. Solve the system uning any common technique (first year linear algebra course) for the coefficients A,B,C, etc.

    As I mentioned earlier this is a particular solution to an infinite family of problems and this technique makes _MANY_ assumptions. Without further information any less general of a solution is not possible.

    BTW: I'm not a mathematician and cannot prove the assertion presented in the preceding statement!

  8. #8
    Linux Enthusiast
    Join Date
    Aug 2005
    Posts
    542
    Somebody's being hypocritical... we aren't allowed to assist with homework here... So it's okay when Jason does it, but not when anybody else does it...
    What political corruption...

  9. #9
    Linux Guru
    Join Date
    Apr 2003
    Location
    London, UK
    Posts
    3,284
    davebardsley, thanks, i'll look into that.
    chopin1810, as I have already stated this is not a homework question

  10. #10
    Linux User Tommaso's Avatar
    Join Date
    Oct 2005
    Posts
    292
    This sounds like a classic learning algorythm problem. I am by no means any good at using them, much less understanding them, but you could take a look into neural networks, and other simpler or even more complex learning algorithms. All learning algorythms are written to try deduce the value of an output when given only inputs. More complex algorythms can solve multimensional problems by giving a specific "weight" to each element. This sums up just about all i know, so good luck, and i hope this will help you more than confuse you.

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •