tags:

views:

104

answers:

2

Being unable to reproduce a given result. (either because it's wrong or because I was doing something wrong) I was asking myself if it would be easy to just write a small program which takes all the constants and given number and permutes it with a possible operators (* / - + exp(..)) etc) until the result is found.

Permutations of n distinct objects with repetition allowed is n^r. At least as long as r is small I think you should be able to do this. I wonder if anybody did something similar here..

+2  A: 

Yes, it has been done here: Code Golf: All +-*/ Combinations for 3 integers

However, because a formula gives the desired result doesn't guarantee that it's the correct formula. Also, you don't learn anything by just guessing what to do to get to the desired result.

Guffa
Also you are possibly missing numerical factors such as Pi, or just plain integers. Funnily enough this method is used for real in some areas of physics when arbitrary precision numerical results can be calculated but analytical solutions can't. First calculate quantity A to 50 decimal places, then find the formula consisting of powers of Pi and some other known constants that replicates those 50 decimals. Finally calculate A to 100 decimals and compare again. If the results match you very likely have "guessed" the right solution. Needless to say this requires serious computing power.
Timo
Thx for your answers! :)@Timo: Nice to know. You should be able to select some constants which can be included in the calculation.> "Also, you don't learn anything by just guessing what to do to get to the desired result."Sure it's more just for fun.. I'll try to write such a program when I have time.
Nils
A: 

If you're trying to fit some data with a function whose form is uncertain, you can try using Eureqa.

duffymo