# Finding a function to convert arbitrary input to output

1. Nov 9, 2008

### Twinbee

I have arbitrary input numbers, and an arbitrary output. I want a program to automatically give me a function (various constants and mathematical symbols) to convert from the input to the output. What's the best way of doing this?

Are there any programs to do this for you, perhaps which use genetic programming? Any general techniques and tricks to solve this manually?

Here are two examples. The solution to the second one would be great, but I would prefer a general technique to achieve the conversion for any example.

1, 4 -> 15
2, 2 -> 12
5,1 -> 18

Easy peasy - you just add the first two numbers together, and multiply that by 3. Anyone can do that in their head. But for something like this, it gets much harder:

a=3. b=8. c=1.6 -> 0
a=2 b=1.5 c=3 -> 0
a=1.6666 b=3 c=3 -> 0
a=1.85 b=3.863 c=2.5 -> 0
a=2.1 b=2.445 c=2.4 -> 0

2. Nov 9, 2008

### CRGreathouse

A truly arbitrary function could be the given values at the given points, and 0 elsewhere. There are lots of possibilities. Having said that:

* Put the data in a matrix and reduce it; if there's a linear solution that should find it.
* You may be able to use Lagrange interpolating polynomials to give a closed form answer
* Looking up values in Sloane's OEIS could give an answer
* Really complex functions can be fitted with the techniques in A=B

3. Nov 9, 2008

### Twinbee

Thanks for those. Yes, I've heard before that there are an infinite number of possible functions to create a given output. However, I'm looking for the shortest naturally. In the above case, multiplying by 0, or dividing by infinity would also result in the desired function, but one can exclude those cases.

I'll study the above points you've made in more depth. In the meantime, does anyone know of any software (free or commerical, but preferably cheap) that would use genetic programming or similar to do all of this automatically?

Last edited: Nov 9, 2008
4. Nov 9, 2008

### CRGreathouse

I don't imagine genetic programming would be very effective on this problem, since you're looking for exact matches. If you're going to use a standard AI method, tree-searching method with backtracking would probably be better.

5. Nov 9, 2008

### CRGreathouse

In fact, the number of such functions is two to the power of the continuum. It's 'more than infinite', it's uncountable. It's 'more than uncountable', it's beth_2.

(Not that you care.)