100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -1.49613502984700486:\\
\;\;\;\;100 \cdot \left(\frac{{\left(1 + \frac{i}{n}\right)}^{n}}{\frac{i}{n}} - \frac{1}{\frac{i}{n}}\right)\\
\mathbf{elif}\;i \le 2.7217117903300314 \cdot 10^{-9}:\\
\;\;\;\;\left(\left(100 + \left(50 \cdot i + 100 \cdot \frac{\log 1 \cdot n}{i}\right)\right) - 50 \cdot \left(i \cdot \log 1\right)\right) \cdot n\\
\mathbf{else}:\\
\;\;\;\;\left(100 \cdot \frac{\frac{{\left(1 + \frac{i}{n}\right)}^{\left(2 \cdot n\right)} - 1 \cdot 1}{{\left(1 + \frac{i}{n}\right)}^{n} + 1}}{i}\right) \cdot n\\
\end{array}double f(double i, double n) {
double r120561 = 100.0;
double r120562 = 1.0;
double r120563 = i;
double r120564 = n;
double r120565 = r120563 / r120564;
double r120566 = r120562 + r120565;
double r120567 = pow(r120566, r120564);
double r120568 = r120567 - r120562;
double r120569 = r120568 / r120565;
double r120570 = r120561 * r120569;
return r120570;
}
double f(double i, double n) {
double r120571 = i;
double r120572 = -1.4961350298470049;
bool r120573 = r120571 <= r120572;
double r120574 = 100.0;
double r120575 = 1.0;
double r120576 = n;
double r120577 = r120571 / r120576;
double r120578 = r120575 + r120577;
double r120579 = pow(r120578, r120576);
double r120580 = r120579 / r120577;
double r120581 = r120575 / r120577;
double r120582 = r120580 - r120581;
double r120583 = r120574 * r120582;
double r120584 = 2.7217117903300314e-09;
bool r120585 = r120571 <= r120584;
double r120586 = 50.0;
double r120587 = r120586 * r120571;
double r120588 = log(r120575);
double r120589 = r120588 * r120576;
double r120590 = r120589 / r120571;
double r120591 = r120574 * r120590;
double r120592 = r120587 + r120591;
double r120593 = r120574 + r120592;
double r120594 = r120571 * r120588;
double r120595 = r120586 * r120594;
double r120596 = r120593 - r120595;
double r120597 = r120596 * r120576;
double r120598 = 2.0;
double r120599 = r120598 * r120576;
double r120600 = pow(r120578, r120599);
double r120601 = r120575 * r120575;
double r120602 = r120600 - r120601;
double r120603 = r120579 + r120575;
double r120604 = r120602 / r120603;
double r120605 = r120604 / r120571;
double r120606 = r120574 * r120605;
double r120607 = r120606 * r120576;
double r120608 = r120585 ? r120597 : r120607;
double r120609 = r120573 ? r120583 : r120608;
return r120609;
}




Bits error versus i




Bits error versus n
Results
| Original | 42.4 |
|---|---|
| Target | 42.5 |
| Herbie | 21.4 |
if i < -1.4961350298470049Initial program 26.7
rmApplied div-sub26.8
if -1.4961350298470049 < i < 2.7217117903300314e-09Initial program 50.4
rmApplied associate-/r/50.1
Applied associate-*r*50.1
Taylor expanded around 0 17.1
Taylor expanded around 0 17.1
if 2.7217117903300314e-09 < i Initial program 32.0
rmApplied associate-/r/32.0
Applied associate-*r*32.0
rmApplied flip--32.0
Simplified32.0
Final simplification21.4
herbie shell --seed 2020045
(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))))