100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;n \le -1.4608487543202562 \cdot 10^{+112}:\\
\;\;\;\;100 \cdot n + \left(\frac{50}{3} \cdot i + 50\right) \cdot \left(i \cdot n\right)\\
\mathbf{elif}\;n \le -0.5086740071675135:\\
\;\;\;\;\left(\frac{{\left(\frac{i}{n} + 1\right)}^{n}}{\frac{1}{n}} - n\right) \cdot \frac{100}{i}\\
\mathbf{elif}\;n \le 6.641285833915873 \cdot 10^{-252}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;100 \cdot n + \left(\frac{50}{3} \cdot i + 50\right) \cdot \left(i \cdot n\right)\\
\end{array}double f(double i, double n) {
double r4420563 = 100.0;
double r4420564 = 1.0;
double r4420565 = i;
double r4420566 = n;
double r4420567 = r4420565 / r4420566;
double r4420568 = r4420564 + r4420567;
double r4420569 = pow(r4420568, r4420566);
double r4420570 = r4420569 - r4420564;
double r4420571 = r4420570 / r4420567;
double r4420572 = r4420563 * r4420571;
return r4420572;
}
double f(double i, double n) {
double r4420573 = n;
double r4420574 = -1.4608487543202562e+112;
bool r4420575 = r4420573 <= r4420574;
double r4420576 = 100.0;
double r4420577 = r4420576 * r4420573;
double r4420578 = 16.666666666666668;
double r4420579 = i;
double r4420580 = r4420578 * r4420579;
double r4420581 = 50.0;
double r4420582 = r4420580 + r4420581;
double r4420583 = r4420579 * r4420573;
double r4420584 = r4420582 * r4420583;
double r4420585 = r4420577 + r4420584;
double r4420586 = -0.5086740071675135;
bool r4420587 = r4420573 <= r4420586;
double r4420588 = r4420579 / r4420573;
double r4420589 = 1.0;
double r4420590 = r4420588 + r4420589;
double r4420591 = pow(r4420590, r4420573);
double r4420592 = r4420589 / r4420573;
double r4420593 = r4420591 / r4420592;
double r4420594 = r4420593 - r4420573;
double r4420595 = r4420576 / r4420579;
double r4420596 = r4420594 * r4420595;
double r4420597 = 6.641285833915873e-252;
bool r4420598 = r4420573 <= r4420597;
double r4420599 = 0.0;
double r4420600 = r4420598 ? r4420599 : r4420585;
double r4420601 = r4420587 ? r4420596 : r4420600;
double r4420602 = r4420575 ? r4420585 : r4420601;
return r4420602;
}




Bits error versus i




Bits error versus n
Results
| Original | 42.3 |
|---|---|
| Target | 42.2 |
| Herbie | 22.6 |
if n < -1.4608487543202562e+112 or 6.641285833915873e-252 < n Initial program 54.3
rmApplied div-inv54.3
Applied *-un-lft-identity54.3
Applied times-frac54.6
Applied associate-*r*54.6
Simplified54.6
Taylor expanded around 0 27.4
Simplified27.4
Taylor expanded around inf 23.1
Simplified23.1
Taylor expanded around -inf 23.1
Simplified23.0
if -1.4608487543202562e+112 < n < -0.5086740071675135Initial program 35.5
rmApplied div-inv35.5
Applied *-un-lft-identity35.5
Applied times-frac35.4
Applied associate-*r*35.5
Simplified35.4
rmApplied div-sub35.4
Simplified35.3
if -0.5086740071675135 < n < 6.641285833915873e-252Initial program 18.3
rmApplied div-inv18.3
Applied *-un-lft-identity18.3
Applied times-frac18.5
Applied associate-*r*18.7
Simplified18.7
Taylor expanded around 0 15.7
Final simplification22.6
herbie shell --seed 2019151
(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))))