100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -0.14141811154607586:\\
\;\;\;\;100 \cdot \frac{\frac{{\left(1 + \frac{i}{n}\right)}^{\left(2 \cdot n\right)} + \left(-1 \cdot 1\right)}{{\left(1 + \frac{i}{n}\right)}^{n} + 1}}{\frac{i}{n}}\\
\mathbf{elif}\;i \le 2.6939372834177335 \cdot 10^{-290}:\\
\;\;\;\;\frac{100 \cdot \left(\left(\left(1 \cdot i + 0.5 \cdot {i}^{2}\right) + \log 1 \cdot \left(n - 0.5 \cdot {i}^{2}\right)\right) \cdot n\right)}{i}\\
\mathbf{elif}\;i \le 8.5870164069987757 \cdot 10^{-230}:\\
\;\;\;\;\left(100 \cdot \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}\right) \cdot n\\
\mathbf{elif}\;i \le 6.0935215346955289 \cdot 10^{-4}:\\
\;\;\;\;\frac{100 \cdot \left(\left(\left(1 \cdot i + 0.5 \cdot {i}^{2}\right) + \log 1 \cdot \left(n - 0.5 \cdot {i}^{2}\right)\right) \cdot n\right)}{i}\\
\mathbf{else}:\\
\;\;\;\;\left(100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i}\right) \cdot 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 temp;
if ((i <= -0.14141811154607586)) {
temp = (100.0 * (((pow((1.0 + (i / n)), (2.0 * n)) + -(1.0 * 1.0)) / (pow((1.0 + (i / n)), n) + 1.0)) / (i / n)));
} else {
double temp_1;
if ((i <= 2.6939372834177335e-290)) {
temp_1 = ((100.0 * ((((1.0 * i) + (0.5 * pow(i, 2.0))) + (log(1.0) * (n - (0.5 * pow(i, 2.0))))) * n)) / i);
} else {
double temp_2;
if ((i <= 8.587016406998776e-230)) {
temp_2 = ((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 temp_3;
if ((i <= 0.0006093521534695529)) {
temp_3 = ((100.0 * ((((1.0 * i) + (0.5 * pow(i, 2.0))) + (log(1.0) * (n - (0.5 * pow(i, 2.0))))) * n)) / i);
} else {
temp_3 = ((100.0 * ((pow((1.0 + (i / n)), n) - 1.0) / i)) * n);
}
temp_2 = temp_3;
}
temp_1 = temp_2;
}
temp = temp_1;
}
return temp;
}




Bits error versus i




Bits error versus n
Results
| Original | 42.8 |
|---|---|
| Target | 42.5 |
| Herbie | 21.0 |
if i < -0.14141811154607586Initial program 28.6
rmApplied flip--28.6
Simplified28.6
if -0.14141811154607586 < i < 2.6939372834177335e-290 or 8.587016406998776e-230 < i < 0.0006093521534695529Initial program 50.8
Taylor expanded around 0 33.7
rmApplied associate-/r/17.2
Applied associate-*r*17.2
rmApplied associate-*r/17.3
Applied associate-*l/15.7
rmApplied associate-*l*15.7
Simplified15.7
if 2.6939372834177335e-290 < i < 8.587016406998776e-230Initial program 47.7
Taylor expanded around 0 40.8
rmApplied associate-/r/16.4
Applied associate-*r*16.4
if 0.0006093521534695529 < i Initial program 31.9
rmApplied associate-/r/31.8
Applied associate-*r*31.9
Final simplification21.0
herbie shell --seed 2020049
(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))))