100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -0.00377737376123091695:\\
\;\;\;\;100 \cdot \left(\frac{{\left(1 + \frac{i}{n}\right)}^{n}}{\frac{i}{n}} - \frac{1}{\frac{i}{n}}\right)\\
\mathbf{elif}\;i \le 4.4408729626575344 \cdot 10^{-11}:\\
\;\;\;\;100 \cdot \left(\frac{\left(1 \cdot i + \left(0.5 \cdot {i}^{2} + \log 1 \cdot n\right)\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)}{i} \cdot n\right)\\
\mathbf{elif}\;i \le 4.12968528167230101 \cdot 10^{131}:\\
\;\;\;\;\frac{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{\left(1 \cdot i + \left(\log 1 \cdot n + 1\right)\right) - 1}{\frac{i}{n}}\\
\end{array}double code(double i, double n) {
return (100.0 * ((pow((1.0 + (i / n)), n) - 1.0) / (i / n)));
}
double code(double i, double n) {
double VAR;
if ((i <= -0.003777373761230917)) {
VAR = (100.0 * ((pow((1.0 + (i / n)), n) / (i / n)) - (1.0 / (i / n))));
} else {
double VAR_1;
if ((i <= 4.4408729626575344e-11)) {
VAR_1 = (100.0 * (((((1.0 * i) + ((0.5 * pow(i, 2.0)) + (log(1.0) * n))) - (0.5 * (pow(i, 2.0) * log(1.0)))) / i) * n));
} else {
double VAR_2;
if ((i <= 4.129685281672301e+131)) {
VAR_2 = ((100.0 * (pow((1.0 + (i / n)), n) - 1.0)) / (i / n));
} else {
VAR_2 = (100.0 * ((((1.0 * i) + ((log(1.0) * n) + 1.0)) - 1.0) / (i / n)));
}
VAR_1 = VAR_2;
}
VAR = VAR_1;
}
return VAR;
}




Bits error versus i




Bits error versus n
Results
| Original | 47.7 |
|---|---|
| Target | 47.5 |
| Herbie | 17.2 |
if i < -0.003777373761230917Initial program 28.4
rmApplied div-sub28.4
if -0.003777373761230917 < i < 4.4408729626575344e-11Initial program 58.3
Taylor expanded around 0 26.3
rmApplied associate-/r/8.9
if 4.4408729626575344e-11 < i < 4.129685281672301e+131Initial program 33.6
rmApplied associate-*r/33.6
if 4.129685281672301e+131 < i Initial program 30.9
Taylor expanded around 0 36.4
Final simplification17.2
herbie shell --seed 2020091
(FPCore (i n)
:name "Compound Interest"
:precision binary64
:herbie-target
(* 100 (/ (- (exp (* n (if (== (+ 1 (/ i n)) 1) (/ i n) (/ (* (/ i n) (log (+ 1 (/ i n)))) (- (+ (/ i n) 1) 1))))) 1) (/ i n)))
(* 100 (/ (- (pow (+ 1 (/ i n)) n) 1) (/ i n))))