100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -3.076493361831821548083157134309908748576 \cdot 10^{-11} \lor \neg \left(i \le 7.743283777926976085836940910667181015015\right):\\
\;\;\;\;n \cdot \frac{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}{i}\\
\mathbf{else}:\\
\;\;\;\;\frac{i \cdot \left(0.5 \cdot i + 1\right) + \left(n - i \cdot \left(0.5 \cdot i\right)\right) \cdot \log 1}{i} \cdot \left(n \cdot 100\right)\\
\end{array}double f(double i, double n) {
double r119060 = 100.0;
double r119061 = 1.0;
double r119062 = i;
double r119063 = n;
double r119064 = r119062 / r119063;
double r119065 = r119061 + r119064;
double r119066 = pow(r119065, r119063);
double r119067 = r119066 - r119061;
double r119068 = r119067 / r119064;
double r119069 = r119060 * r119068;
return r119069;
}
double f(double i, double n) {
double r119070 = i;
double r119071 = -3.0764933618318215e-11;
bool r119072 = r119070 <= r119071;
double r119073 = 7.743283777926976;
bool r119074 = r119070 <= r119073;
double r119075 = !r119074;
bool r119076 = r119072 || r119075;
double r119077 = n;
double r119078 = 100.0;
double r119079 = 1.0;
double r119080 = r119070 / r119077;
double r119081 = r119079 + r119080;
double r119082 = pow(r119081, r119077);
double r119083 = r119082 - r119079;
double r119084 = r119078 * r119083;
double r119085 = r119084 / r119070;
double r119086 = r119077 * r119085;
double r119087 = 0.5;
double r119088 = r119087 * r119070;
double r119089 = r119088 + r119079;
double r119090 = r119070 * r119089;
double r119091 = r119070 * r119088;
double r119092 = r119077 - r119091;
double r119093 = log(r119079);
double r119094 = r119092 * r119093;
double r119095 = r119090 + r119094;
double r119096 = r119095 / r119070;
double r119097 = r119077 * r119078;
double r119098 = r119096 * r119097;
double r119099 = r119076 ? r119086 : r119098;
return r119099;
}




Bits error versus i




Bits error versus n
Results
| Original | 42.8 |
|---|---|
| Target | 42.7 |
| Herbie | 21.9 |
if i < -3.0764933618318215e-11 or 7.743283777926976 < i Initial program 29.6
rmApplied associate-/r/30.0
Applied associate-*r*30.0
Simplified30.0
if -3.0764933618318215e-11 < i < 7.743283777926976Initial program 50.7
Taylor expanded around 0 34.0
Simplified34.0
rmApplied pow134.0
Applied pow134.0
Applied pow-prod-down34.0
Simplified17.0
Final simplification21.9
herbie shell --seed 2019179
(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))))