Re^2: Reverse engineering a formula...

by devnul (Monk)
 on Jun 13, 2006 at 10:26 UTC ( #554992=note: print w/replies, xml ) Need Help??

in reply to Re: Reverse engineering a formula...
in thread Reverse engineering a formula...

I was trying to keep my question "theoretical". But here's the numbers if you really want them:

```\$VAR1 = [
'18.930167',
'17.967469',
'0.008720',
'0.008720',
'122.640000',
'12493.320000',
'359.520000',
'288.700000',
'359.520000',
'89.880000',
'32.960000',
'56.920000',
'13.470000',
'1231.360000',
'20587.440000',
'359.520000',
'792.170000',
'629.160000',
'972.290000',
];
- Devnul

Replies are listed 'Best First'.
Re^3: Reverse engineering a formula...
by BrowserUk (Pope) on Jun 13, 2006 at 12:02 UTC

How's this for a guess? A 24-month lease

```An initial price of         12,493.32

A first payment of           1,231.36
+ 23 monthly payements of      843.24
=====================================
Total cost
(- tax relief)              20,587.44

Daily interest rate              0.008720
Annual Equivalent rate          17.967469
Annual effective rate
(inc. one off payments)         18.930167

Other numbers include one-off admin charges and daily/weekly effective costs?

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
Re^3: Reverse engineering a formula...
by Gilimanjaro (Hermit) on Jun 13, 2006 at 12:27 UTC

Well, look at it this way:

• You have 19 floats
• Each float may:
• Need to be added (multiply by 1)
• Need to be subtracted (multiply by -1)
• Need to be ignored (multiply by 0)

This means there are 3 to the power 19 different ways to combine these numbers... That's a lot of possible combinations to try, but it can be done I suppose... You'd probably want to write a recursive algorithm to try all these permutations, and see if the rounded total matches the number you specified...

Update: Possible solution code posted below

Re^3: Reverse engineering a formula...
by Skeeve (Vicar) on Jun 13, 2006 at 10:31 UTC
That will never give the sum you told us, because of 18.930167 and 17.96746

You will never get aything with just 2 decimal digits behind the decimal point with those 2 numbers.

s\$\$([},&%#}/&/]+}%&{})*;#\$&&s&&\$^X.(\$'^"%]=\&(|?*{%
+.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`\$''`"e

And as the information is financial in nature, the end-result is most probably rounded to two digits. So in fact these two numbers may well be part of the formula...

In fact, without knowing for sure how exactly rounding is done, you'll have to look for a 'fuzzy' match; the last few digits may be off. Perhaps rounding the target and the tested result to integers would be the best way to go about this.

On a side note. the two numbers below 0.01 are most probably percentages... So we may also need to do multiplication, which would make it an almost impossible task, mainly because this would mean we also have to take operator-precedence into account...

With the info we have, there is no guarantee that all the columns are used.

This is not a Signature...
Not every number necessarily needs to be part of the formula (obviously its 2 or more numbers in some combination of addition and/or subtraction). Those two numbers could simply not be part of the formula.

- Devnul
As I said before: Not enough information...

It seems as if your formular is something like this (untested code of course):
```my @sign=( .... ); # Some combination of -1, 0 1
my @sum= map { \$sign[\$i] * \$VAR1[\$i] } (0..\$#VAR1);
print eval join ' + ', @sum;
Now you "only" need to get the correct combination of -1, 0 and 1 for @sign, which is a "simple" combinational task but will be very lengthy...

s\$\$([},&%#}/&/]+}%&{})*;#\$&&s&&\$^X.(\$'^"%]=\&(|?*{%
+.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`\$''`"e

Create A New User
Node Status?
node history
Node Type: note [id://554992]
help
Chatterbox?
 [Discipulus]: LA use Perl: traversing a dir tree is simple; foreach file mp3 \$sec+= use Mp3::Info [Lady_Aleena]: Discipulus, I was able to get the sum of the seconds on the command line using awk. Then I ran the result through a perl script and got the result. It came bach with 4 days, 9 hours, 56 minutes, 43 seconds. [Lady_Aleena]: s/bach/back/; [Discipulus]: gired anyway is the intermediate state between hired and fired (and vice versa;) [Lady_Aleena]: Discipuluis, I don't know if I want to fight with File::Find. File::Find and I are not friends. [Discipulus]: 4 day Bach is too muche even for me [Discipulus]: LA you know who is paco? [Lady_Aleena]: Disc, nope. [Discipulus]: ahi ahi ahi!!

How do I use this? | Other CB clients
Other Users?
As of 2017-04-23 20:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
I'm a fool:

Results (432 votes). Check out past polls.