100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;n \le -5.464773096034009611019906036964894498925 \cdot 10^{59}:\\
\;\;\;\;\frac{\left(\log 1 \cdot \left(n - i \cdot \left(0.5 \cdot i\right)\right) + i \cdot \left(0.5 \cdot i\right)\right) + i \cdot 1}{i} \cdot \left(n \cdot 100\right)\\
\mathbf{elif}\;n \le -499596521052505172268102593940553728:\\
\;\;\;\;\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{1}{n}} \cdot \frac{100}{i}\\
\mathbf{elif}\;n \le -15240705750258725123260416:\\
\;\;\;\;\frac{\left(\log 1 \cdot \left(n - i \cdot \left(0.5 \cdot i\right)\right) + i \cdot \left(0.5 \cdot i\right)\right) + i \cdot 1}{i} \cdot \left(n \cdot 100\right)\\
\mathbf{elif}\;n \le 8.439481621089909706689165353901153669925 \cdot 10^{-297}:\\
\;\;\;\;\left(\frac{{\left(1 + \frac{i}{n}\right)}^{n}}{\frac{i}{n}} - \frac{1}{\frac{i}{n}}\right) \cdot 100\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\log 1 \cdot \left(n - i \cdot \left(0.5 \cdot i\right)\right) + i \cdot \left(0.5 \cdot i\right)\right) + i \cdot 1}{i} \cdot \left(n \cdot 100\right)\\
\end{array}double f(double i, double n) {
double r6170622 = 100.0;
double r6170623 = 1.0;
double r6170624 = i;
double r6170625 = n;
double r6170626 = r6170624 / r6170625;
double r6170627 = r6170623 + r6170626;
double r6170628 = pow(r6170627, r6170625);
double r6170629 = r6170628 - r6170623;
double r6170630 = r6170629 / r6170626;
double r6170631 = r6170622 * r6170630;
return r6170631;
}
double f(double i, double n) {
double r6170632 = n;
double r6170633 = -5.46477309603401e+59;
bool r6170634 = r6170632 <= r6170633;
double r6170635 = 1.0;
double r6170636 = log(r6170635);
double r6170637 = i;
double r6170638 = 0.5;
double r6170639 = r6170638 * r6170637;
double r6170640 = r6170637 * r6170639;
double r6170641 = r6170632 - r6170640;
double r6170642 = r6170636 * r6170641;
double r6170643 = r6170642 + r6170640;
double r6170644 = r6170637 * r6170635;
double r6170645 = r6170643 + r6170644;
double r6170646 = r6170645 / r6170637;
double r6170647 = 100.0;
double r6170648 = r6170632 * r6170647;
double r6170649 = r6170646 * r6170648;
double r6170650 = -4.995965210525052e+35;
bool r6170651 = r6170632 <= r6170650;
double r6170652 = r6170637 / r6170632;
double r6170653 = r6170635 + r6170652;
double r6170654 = pow(r6170653, r6170632);
double r6170655 = r6170654 - r6170635;
double r6170656 = 1.0;
double r6170657 = r6170656 / r6170632;
double r6170658 = r6170655 / r6170657;
double r6170659 = r6170647 / r6170637;
double r6170660 = r6170658 * r6170659;
double r6170661 = -1.5240705750258725e+25;
bool r6170662 = r6170632 <= r6170661;
double r6170663 = 8.43948162108991e-297;
bool r6170664 = r6170632 <= r6170663;
double r6170665 = r6170654 / r6170652;
double r6170666 = r6170635 / r6170652;
double r6170667 = r6170665 - r6170666;
double r6170668 = r6170667 * r6170647;
double r6170669 = r6170664 ? r6170668 : r6170649;
double r6170670 = r6170662 ? r6170649 : r6170669;
double r6170671 = r6170651 ? r6170660 : r6170670;
double r6170672 = r6170634 ? r6170649 : r6170671;
return r6170672;
}




Bits error versus i




Bits error versus n
Results
| Original | 43.0 |
|---|---|
| Target | 42.8 |
| Herbie | 24.3 |
if n < -5.46477309603401e+59 or -4.995965210525052e+35 < n < -1.5240705750258725e+25 or 8.43948162108991e-297 < n Initial program 52.3
Taylor expanded around 0 39.8
Simplified39.8
rmApplied *-un-lft-identity39.8
Applied associate-*l*39.8
Simplified25.8
if -5.46477309603401e+59 < n < -4.995965210525052e+35Initial program 34.9
rmApplied div-inv34.9
Applied *-un-lft-identity34.9
Applied times-frac34.8
Applied associate-*r*34.8
Simplified34.8
if -1.5240705750258725e+25 < n < 8.43948162108991e-297Initial program 18.9
rmApplied div-sub18.9
Final simplification24.3
herbie shell --seed 2019172
(FPCore (i n)
:name "Compound Interest"
:herbie-target
(* 100.0 (/ (- (exp (* n (if (== (+ 1.0 (/ i n)) 1.0) (/ i n) (/ (* (/ i n) (log (+ 1.0 (/ i n)))) (- (+ (/ i n) 1.0) 1.0))))) 1.0) (/ i n)))
(* 100.0 (/ (- (pow (+ 1.0 (/ i n)) n) 1.0) (/ i n))))