100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -2.56140166535216897 \cdot 10^{135}:\\
\;\;\;\;\frac{100 \cdot \frac{\log \left(e^{{\left(1 + \frac{i}{n}\right)}^{\left(2 \cdot n\right)} - 1 \cdot 1}\right)}{{\left(1 + \frac{i}{n}\right)}^{n} + 1}}{\frac{i}{n}}\\
\mathbf{elif}\;i \le -1.3992561866449662 \cdot 10^{-10}:\\
\;\;\;\;\frac{100 \cdot \left({\left(\frac{i}{n}\right)}^{n} - 1\right)}{\frac{i}{n}}\\
\mathbf{elif}\;i \le 2.51591290926460688 \cdot 10^{-160}:\\
\;\;\;\;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)}{\frac{i}{n}}\\
\mathbf{elif}\;i \le 6.02622510223326963 \cdot 10^{-125}:\\
\;\;\;\;\frac{\frac{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}{i}}{\frac{1}{n}}\\
\mathbf{elif}\;i \le 8532543483832934860000:\\
\;\;\;\;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)}{\frac{i}{n}}\\
\mathbf{elif}\;i \le 7.39555913873958208 \cdot 10^{219}:\\
\;\;\;\;\frac{\frac{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}{i}}{\frac{1}{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 f(double i, double n) {
double r267532 = 100.0;
double r267533 = 1.0;
double r267534 = i;
double r267535 = n;
double r267536 = r267534 / r267535;
double r267537 = r267533 + r267536;
double r267538 = pow(r267537, r267535);
double r267539 = r267538 - r267533;
double r267540 = r267539 / r267536;
double r267541 = r267532 * r267540;
return r267541;
}
double f(double i, double n) {
double r267542 = i;
double r267543 = -2.561401665352169e+135;
bool r267544 = r267542 <= r267543;
double r267545 = 100.0;
double r267546 = 1.0;
double r267547 = n;
double r267548 = r267542 / r267547;
double r267549 = r267546 + r267548;
double r267550 = 2.0;
double r267551 = r267550 * r267547;
double r267552 = pow(r267549, r267551);
double r267553 = r267546 * r267546;
double r267554 = r267552 - r267553;
double r267555 = exp(r267554);
double r267556 = log(r267555);
double r267557 = pow(r267549, r267547);
double r267558 = r267557 + r267546;
double r267559 = r267556 / r267558;
double r267560 = r267545 * r267559;
double r267561 = r267560 / r267548;
double r267562 = -1.3992561866449662e-10;
bool r267563 = r267542 <= r267562;
double r267564 = pow(r267548, r267547);
double r267565 = r267564 - r267546;
double r267566 = r267545 * r267565;
double r267567 = r267566 / r267548;
double r267568 = 2.515912909264607e-160;
bool r267569 = r267542 <= r267568;
double r267570 = r267546 * r267542;
double r267571 = 0.5;
double r267572 = pow(r267542, r267550);
double r267573 = r267571 * r267572;
double r267574 = log(r267546);
double r267575 = r267574 * r267547;
double r267576 = r267573 + r267575;
double r267577 = r267570 + r267576;
double r267578 = r267572 * r267574;
double r267579 = r267571 * r267578;
double r267580 = r267577 - r267579;
double r267581 = r267580 / r267548;
double r267582 = r267545 * r267581;
double r267583 = 6.02622510223327e-125;
bool r267584 = r267542 <= r267583;
double r267585 = r267557 - r267546;
double r267586 = r267545 * r267585;
double r267587 = r267586 / r267542;
double r267588 = 1.0;
double r267589 = r267588 / r267547;
double r267590 = r267587 / r267589;
double r267591 = 8.532543483832935e+21;
bool r267592 = r267542 <= r267591;
double r267593 = 7.395559138739582e+219;
bool r267594 = r267542 <= r267593;
double r267595 = r267575 + r267588;
double r267596 = r267570 + r267595;
double r267597 = r267596 - r267546;
double r267598 = r267597 / r267548;
double r267599 = r267545 * r267598;
double r267600 = r267594 ? r267590 : r267599;
double r267601 = r267592 ? r267582 : r267600;
double r267602 = r267584 ? r267590 : r267601;
double r267603 = r267569 ? r267582 : r267602;
double r267604 = r267563 ? r267567 : r267603;
double r267605 = r267544 ? r267561 : r267604;
return r267605;
}




Bits error versus i




Bits error versus n
Results
| Original | 42.7 |
|---|---|
| Target | 42.6 |
| Herbie | 31.4 |
if i < -2.561401665352169e+135Initial program 15.4
rmApplied associate-*r/15.4
rmApplied flip--15.4
Simplified15.4
rmApplied add-log-exp15.4
Applied neg-log15.4
Applied add-log-exp15.4
Applied sum-log15.4
Simplified15.4
if -2.561401665352169e+135 < i < -1.3992561866449662e-10Initial program 41.3
rmApplied associate-*r/41.3
Taylor expanded around inf 64.0
Simplified27.6
if -1.3992561866449662e-10 < i < 2.515912909264607e-160 or 6.02622510223327e-125 < i < 8.532543483832935e+21Initial program 49.9
Taylor expanded around 0 33.7
if 2.515912909264607e-160 < i < 6.02622510223327e-125 or 8.532543483832935e+21 < i < 7.395559138739582e+219Initial program 38.2
rmApplied associate-*r/38.1
rmApplied div-inv38.2
Applied associate-/r*38.1
if 7.395559138739582e+219 < i Initial program 30.6
Taylor expanded around 0 34.7
Final simplification31.4
herbie shell --seed 2020056
(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))))