100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -1.9324505473046543 \cdot 10^{-07}:\\
\;\;\;\;100 \cdot \left(\frac{{\left(\frac{i}{n} + 1\right)}^{n}}{\frac{i}{n}} - \frac{1}{\frac{i}{n}}\right)\\
\mathbf{elif}\;i \le 4.5457902375689345:\\
\;\;\;\;100 \cdot \left(n \cdot \frac{i + \left(i \cdot \left(\left(\left(\left(\sqrt[3]{\frac{1}{6}}\right)\right) \cdot \left(i \cdot i\right)\right) \cdot \left(\sqrt[3]{\frac{1}{6}} \cdot \sqrt[3]{\frac{1}{6}}\right)\right) + \left(i \cdot i\right) \cdot \frac{1}{2}\right)}{i}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{100}{i} \cdot \frac{{\left(\frac{i}{n} + 1\right)}^{n} - 1}{\frac{1}{n}}\\
\end{array}double f(double i, double n) {
double r5562651 = 100.0;
double r5562652 = 1.0;
double r5562653 = i;
double r5562654 = n;
double r5562655 = r5562653 / r5562654;
double r5562656 = r5562652 + r5562655;
double r5562657 = pow(r5562656, r5562654);
double r5562658 = r5562657 - r5562652;
double r5562659 = r5562658 / r5562655;
double r5562660 = r5562651 * r5562659;
return r5562660;
}
double f(double i, double n) {
double r5562661 = i;
double r5562662 = -1.9324505473046543e-07;
bool r5562663 = r5562661 <= r5562662;
double r5562664 = 100.0;
double r5562665 = n;
double r5562666 = r5562661 / r5562665;
double r5562667 = 1.0;
double r5562668 = r5562666 + r5562667;
double r5562669 = pow(r5562668, r5562665);
double r5562670 = r5562669 / r5562666;
double r5562671 = r5562667 / r5562666;
double r5562672 = r5562670 - r5562671;
double r5562673 = r5562664 * r5562672;
double r5562674 = 4.5457902375689345;
bool r5562675 = r5562661 <= r5562674;
double r5562676 = 0.16666666666666666;
double r5562677 = cbrt(r5562676);
double r5562678 = /* ERROR: no posit support in C */;
double r5562679 = /* ERROR: no posit support in C */;
double r5562680 = r5562661 * r5562661;
double r5562681 = r5562679 * r5562680;
double r5562682 = r5562677 * r5562677;
double r5562683 = r5562681 * r5562682;
double r5562684 = r5562661 * r5562683;
double r5562685 = 0.5;
double r5562686 = r5562680 * r5562685;
double r5562687 = r5562684 + r5562686;
double r5562688 = r5562661 + r5562687;
double r5562689 = r5562688 / r5562661;
double r5562690 = r5562665 * r5562689;
double r5562691 = r5562664 * r5562690;
double r5562692 = r5562664 / r5562661;
double r5562693 = r5562669 - r5562667;
double r5562694 = r5562667 / r5562665;
double r5562695 = r5562693 / r5562694;
double r5562696 = r5562692 * r5562695;
double r5562697 = r5562675 ? r5562691 : r5562696;
double r5562698 = r5562663 ? r5562673 : r5562697;
return r5562698;
}




Bits error versus i




Bits error versus n
| Original | 42.0 |
|---|---|
| Target | 42.3 |
| Herbie | 21.3 |
if i < -1.9324505473046543e-07Initial program 27.4
rmApplied div-sub27.4
if -1.9324505473046543e-07 < i < 4.5457902375689345Initial program 50.1
Taylor expanded around 0 33.0
Simplified33.0
rmApplied associate-/r/16.9
rmApplied add-cube-cbrt16.9
Applied associate-*l*16.9
rmApplied insert-posit1616.9
if 4.5457902375689345 < i Initial program 31.0
rmApplied div-inv31.1
Applied *-un-lft-identity31.1
Applied times-frac31.1
Applied associate-*r*31.1
Simplified31.0
Final simplification21.3
herbie shell --seed 2019152
(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))))