100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -9.9024185898810585 \cdot 10^{-13} \lor \neg \left(i \le 0.0066162252799360707\right):\\
\;\;\;\;\frac{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \left(\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)}{i} \cdot n\right)\\
\end{array}double f(double i, double n) {
double r127624 = 100.0;
double r127625 = 1.0;
double r127626 = i;
double r127627 = n;
double r127628 = r127626 / r127627;
double r127629 = r127625 + r127628;
double r127630 = pow(r127629, r127627);
double r127631 = r127630 - r127625;
double r127632 = r127631 / r127628;
double r127633 = r127624 * r127632;
return r127633;
}
double f(double i, double n) {
double r127634 = i;
double r127635 = -9.902418589881058e-13;
bool r127636 = r127634 <= r127635;
double r127637 = 0.006616225279936071;
bool r127638 = r127634 <= r127637;
double r127639 = !r127638;
bool r127640 = r127636 || r127639;
double r127641 = 100.0;
double r127642 = 1.0;
double r127643 = n;
double r127644 = r127634 / r127643;
double r127645 = r127642 + r127644;
double r127646 = pow(r127645, r127643);
double r127647 = r127646 - r127642;
double r127648 = r127641 * r127647;
double r127649 = r127648 / r127644;
double r127650 = r127642 * r127634;
double r127651 = 0.5;
double r127652 = 2.0;
double r127653 = pow(r127634, r127652);
double r127654 = r127651 * r127653;
double r127655 = log(r127642);
double r127656 = r127655 * r127643;
double r127657 = r127654 + r127656;
double r127658 = r127650 + r127657;
double r127659 = r127653 * r127655;
double r127660 = r127651 * r127659;
double r127661 = r127658 - r127660;
double r127662 = r127661 / r127634;
double r127663 = r127662 * r127643;
double r127664 = r127641 * r127663;
double r127665 = r127640 ? r127649 : r127664;
return r127665;
}




Bits error versus i




Bits error versus n
Results
| Original | 48.0 |
|---|---|
| Target | 47.6 |
| Herbie | 16.6 |
if i < -9.902418589881058e-13 or 0.006616225279936071 < i Initial program 30.1
rmApplied associate-*r/30.0
if -9.902418589881058e-13 < i < 0.006616225279936071Initial program 58.3
Taylor expanded around 0 26.1
rmApplied associate-/r/8.9
Final simplification16.6
herbie shell --seed 2020059
(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))))