100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -0.47005989088912481:\\
\;\;\;\;\frac{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}{\frac{i}{n}}\\
\mathbf{elif}\;i \le -5.52432561167857448 \cdot 10^{-152}:\\
\;\;\;\;100 \cdot \left(\frac{1}{i} \cdot \left(\left(\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)\right) \cdot n\right)\right)\\
\mathbf{elif}\;i \le 1.003540520873365 \cdot 10^{58}:\\
\;\;\;\;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 2.257527045522283 \cdot 10^{246}:\\
\;\;\;\;\frac{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}{\frac{i}{n}}\\
\mathbf{elif}\;i \le 8.7386804225890722 \cdot 10^{272}:\\
\;\;\;\;100 \cdot \frac{\left(1 \cdot i + \left(\log 1 \cdot n + 1\right)\right) - 1}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;\frac{100}{i} \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{1}{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.4700598908891248)) {
VAR = ((100.0 * (pow((1.0 + (i / n)), n) - 1.0)) / (i / n));
} else {
double VAR_1;
if ((i <= -5.5243256116785745e-152)) {
VAR_1 = (100.0 * ((1.0 / i) * ((((1.0 * i) + ((0.5 * pow(i, 2.0)) + (log(1.0) * n))) - (0.5 * (pow(i, 2.0) * log(1.0)))) * n)));
} else {
double VAR_2;
if ((i <= 1.003540520873365e+58)) {
VAR_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 VAR_3;
if ((i <= 2.257527045522283e+246)) {
VAR_3 = ((100.0 * (pow((1.0 + (i / n)), n) - 1.0)) / (i / n));
} else {
double VAR_4;
if ((i <= 8.738680422589072e+272)) {
VAR_4 = (100.0 * ((((1.0 * i) + ((log(1.0) * n) + 1.0)) - 1.0) / (i / n)));
} else {
VAR_4 = ((100.0 / i) * ((pow((1.0 + (i / n)), n) - 1.0) / (1.0 / n)));
}
VAR_3 = VAR_4;
}
VAR_2 = VAR_3;
}
VAR_1 = VAR_2;
}
VAR = VAR_1;
}
return VAR;
}




Bits error versus i




Bits error versus n
Results
| Original | 47.5 |
|---|---|
| Target | 47.0 |
| Herbie | 16.8 |
if i < -0.4700598908891248 or 1.003540520873365e+58 < i < 2.257527045522283e+246Initial program 28.8
rmApplied associate-*r/28.8
if -0.4700598908891248 < i < -5.5243256116785745e-152Initial program 55.1
Taylor expanded around 0 23.6
rmApplied div-inv23.7
Applied *-un-lft-identity23.7
Applied times-frac12.2
Simplified12.1
if -5.5243256116785745e-152 < i < 1.003540520873365e+58Initial program 58.2
Taylor expanded around 0 28.9
rmApplied associate-/r/9.6
if 2.257527045522283e+246 < i < 8.738680422589072e+272Initial program 30.5
Taylor expanded around 0 34.8
if 8.738680422589072e+272 < i Initial program 30.0
rmApplied div-inv30.0
Applied *-un-lft-identity30.0
Applied times-frac30.0
Applied associate-*r*30.0
Simplified30.0
Final simplification16.8
herbie shell --seed 2020075
(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))))