100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -93263.25339554752:\\
\;\;\;\;\left(\frac{n}{i} \cdot \left({\left(\frac{1}{\frac{n}{i}}\right)}^{n} - 1\right)\right) \cdot 100\\
\mathbf{elif}\;i \le -1.312300068674317 \cdot 10^{-227}:\\
\;\;\;\;\frac{100}{i} \cdot \frac{\left(i \cdot i\right) \cdot \left(i \cdot \frac{1}{6} + \frac{1}{2}\right) + i}{\frac{1}{n}}\\
\mathbf{elif}\;i \le 2.1570816796635502 \cdot 10^{-262}:\\
\;\;\;\;100 \cdot \left(\log \left(e^{\left(n \cdot i\right) \cdot \left(i \cdot \frac{1}{6} + \frac{1}{2}\right)}\right) + n\right)\\
\mathbf{elif}\;i \le 332694488255.6885:\\
\;\;\;\;\frac{100}{i} \cdot \frac{\left(i \cdot i\right) \cdot \left(i \cdot \frac{1}{6} + \frac{1}{2}\right) + i}{\frac{1}{n}}\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{\frac{{\left(\frac{i}{n} + 1\right)}^{n} - 1}{i}}{\frac{1}{n}}\\
\end{array}double f(double i, double n) {
double r48422558 = 100.0;
double r48422559 = 1.0;
double r48422560 = i;
double r48422561 = n;
double r48422562 = r48422560 / r48422561;
double r48422563 = r48422559 + r48422562;
double r48422564 = pow(r48422563, r48422561);
double r48422565 = r48422564 - r48422559;
double r48422566 = r48422565 / r48422562;
double r48422567 = r48422558 * r48422566;
return r48422567;
}
double f(double i, double n) {
double r48422568 = i;
double r48422569 = -93263.25339554752;
bool r48422570 = r48422568 <= r48422569;
double r48422571 = n;
double r48422572 = r48422571 / r48422568;
double r48422573 = 1.0;
double r48422574 = r48422573 / r48422572;
double r48422575 = pow(r48422574, r48422571);
double r48422576 = r48422575 - r48422573;
double r48422577 = r48422572 * r48422576;
double r48422578 = 100.0;
double r48422579 = r48422577 * r48422578;
double r48422580 = -1.312300068674317e-227;
bool r48422581 = r48422568 <= r48422580;
double r48422582 = r48422578 / r48422568;
double r48422583 = r48422568 * r48422568;
double r48422584 = 0.16666666666666666;
double r48422585 = r48422568 * r48422584;
double r48422586 = 0.5;
double r48422587 = r48422585 + r48422586;
double r48422588 = r48422583 * r48422587;
double r48422589 = r48422588 + r48422568;
double r48422590 = r48422573 / r48422571;
double r48422591 = r48422589 / r48422590;
double r48422592 = r48422582 * r48422591;
double r48422593 = 2.1570816796635502e-262;
bool r48422594 = r48422568 <= r48422593;
double r48422595 = r48422571 * r48422568;
double r48422596 = r48422595 * r48422587;
double r48422597 = exp(r48422596);
double r48422598 = log(r48422597);
double r48422599 = r48422598 + r48422571;
double r48422600 = r48422578 * r48422599;
double r48422601 = 332694488255.6885;
bool r48422602 = r48422568 <= r48422601;
double r48422603 = r48422568 / r48422571;
double r48422604 = r48422603 + r48422573;
double r48422605 = pow(r48422604, r48422571);
double r48422606 = r48422605 - r48422573;
double r48422607 = r48422606 / r48422568;
double r48422608 = r48422607 / r48422590;
double r48422609 = r48422578 * r48422608;
double r48422610 = r48422602 ? r48422592 : r48422609;
double r48422611 = r48422594 ? r48422600 : r48422610;
double r48422612 = r48422581 ? r48422592 : r48422611;
double r48422613 = r48422570 ? r48422579 : r48422612;
return r48422613;
}




Bits error versus i




Bits error versus n
Results
| Original | 42.1 |
|---|---|
| Target | 41.6 |
| Herbie | 19.9 |
if i < -93263.25339554752Initial program 27.4
Taylor expanded around inf 63.0
Simplified19.3
if -93263.25339554752 < i < -1.312300068674317e-227 or 2.1570816796635502e-262 < i < 332694488255.6885Initial program 49.7
Taylor expanded around 0 31.8
Simplified31.8
rmApplied div-inv31.8
Applied *-un-lft-identity31.8
Applied times-frac17.0
Applied associate-*r*17.0
Simplified17.0
if -1.312300068674317e-227 < i < 2.1570816796635502e-262Initial program 47.2
Taylor expanded around 0 42.4
Simplified42.4
Taylor expanded around inf 16.0
Simplified16.0
rmApplied add-log-exp19.0
if 332694488255.6885 < i Initial program 33.0
rmApplied div-inv33.1
Applied associate-/r*33.1
Final simplification19.9
herbie shell --seed 2019125
(FPCore (i n)
:name "Compound Interest"
: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))))