100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -587178759827394.125:\\
\;\;\;\;\frac{\mathsf{fma}\left(100, {\left(\frac{1}{n} \cdot i\right)}^{n}, -100\right)}{i} \cdot n\\
\mathbf{elif}\;i \le 1.839542617760591374384239285215744794771 \cdot 10^{-53}:\\
\;\;\;\;\left(100 \cdot \frac{\mathsf{fma}\left(1, i, \mathsf{fma}\left(n, \log 1, \log \left(e^{\left(i \cdot i\right) \cdot \left(0.5 - 0.5 \cdot \log 1\right)}\right)\right)\right)}{i}\right) \cdot n\\
\mathbf{elif}\;i \le 3.511545104334265421804014757584958652582 \cdot 10^{-14}:\\
\;\;\;\;\left(\sqrt[3]{\left(100 \cdot \frac{\mathsf{fma}\left(1, i, \mathsf{fma}\left(n, \log 1, \left(i \cdot i\right) \cdot \left(0.5 - 0.5 \cdot \log 1\right)\right)\right)}{i}\right) \cdot n} \cdot \sqrt[3]{\left(100 \cdot \frac{\mathsf{fma}\left(1, i, \mathsf{fma}\left(n, \log 1, \left(i \cdot i\right) \cdot \left(0.5 - 0.5 \cdot \log 1\right)\right)\right)}{i}\right) \cdot n}\right) \cdot \log \left(e^{\sqrt[3]{\left(100 \cdot \frac{\mathsf{fma}\left(1, i, \mathsf{fma}\left(n, \log 1, \left(i \cdot i\right) \cdot \left(0.5 - 0.5 \cdot \log 1\right)\right)\right)}{i}\right) \cdot n}}\right)\\
\mathbf{elif}\;i \le 0.01027192758964808570742999194180811173283:\\
\;\;\;\;\left(\sqrt[3]{\left(100 \cdot \frac{\mathsf{fma}\left(1, i, \mathsf{fma}\left(n, \log 1, \left(i \cdot i\right) \cdot \left(0.5 - 0.5 \cdot \log 1\right)\right)\right)}{i}\right) \cdot n} \cdot \sqrt[3]{\left(100 \cdot \frac{\mathsf{fma}\left(1, i, \mathsf{fma}\left(n, \log 1, \left(i \cdot i\right) \cdot \left(0.5 - 0.5 \cdot \log 1\right)\right)\right)}{i}\right) \cdot n}\right) \cdot \sqrt[3]{\left(100 \cdot \frac{\mathsf{fma}\left(1, i, \mathsf{fma}\left(n, \log 1, \left(i \cdot i\right) \cdot \left(0.5 - 0.5 \cdot \log 1\right)\right)\right)}{i}\right) \cdot n}\\
\mathbf{elif}\;i \le 7.312595874998127847724356328504784603445 \cdot 10^{224} \lor \neg \left(i \le 1.674538242776564142877968073717764571719 \cdot 10^{263}\right):\\
\;\;\;\;\left(100 \cdot \frac{\frac{{\left({\left(1 + \frac{i}{n}\right)}^{n}\right)}^{3} - {1}^{3}}{\mathsf{fma}\left(1, {\left(1 + \frac{i}{n}\right)}^{n} + 1, {\left(1 + \frac{i}{n}\right)}^{\left(2 \cdot n\right)}\right)}}{i}\right) \cdot n\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{\mathsf{fma}\left(1, i, \mathsf{fma}\left(\log 1, n, 1\right)\right) - 1}{\frac{i}{n}}\\
\end{array}double f(double i, double n) {
double r118692 = 100.0;
double r118693 = 1.0;
double r118694 = i;
double r118695 = n;
double r118696 = r118694 / r118695;
double r118697 = r118693 + r118696;
double r118698 = pow(r118697, r118695);
double r118699 = r118698 - r118693;
double r118700 = r118699 / r118696;
double r118701 = r118692 * r118700;
return r118701;
}
double f(double i, double n) {
double r118702 = i;
double r118703 = -587178759827394.1;
bool r118704 = r118702 <= r118703;
double r118705 = 100.0;
double r118706 = 1.0;
double r118707 = n;
double r118708 = r118706 / r118707;
double r118709 = r118708 * r118702;
double r118710 = pow(r118709, r118707);
double r118711 = -r118705;
double r118712 = fma(r118705, r118710, r118711);
double r118713 = r118712 / r118702;
double r118714 = r118713 * r118707;
double r118715 = 1.8395426177605914e-53;
bool r118716 = r118702 <= r118715;
double r118717 = 1.0;
double r118718 = log(r118717);
double r118719 = r118702 * r118702;
double r118720 = 0.5;
double r118721 = r118720 * r118718;
double r118722 = r118720 - r118721;
double r118723 = r118719 * r118722;
double r118724 = exp(r118723);
double r118725 = log(r118724);
double r118726 = fma(r118707, r118718, r118725);
double r118727 = fma(r118717, r118702, r118726);
double r118728 = r118727 / r118702;
double r118729 = r118705 * r118728;
double r118730 = r118729 * r118707;
double r118731 = 3.5115451043342654e-14;
bool r118732 = r118702 <= r118731;
double r118733 = fma(r118707, r118718, r118723);
double r118734 = fma(r118717, r118702, r118733);
double r118735 = r118734 / r118702;
double r118736 = r118705 * r118735;
double r118737 = r118736 * r118707;
double r118738 = cbrt(r118737);
double r118739 = r118738 * r118738;
double r118740 = exp(r118738);
double r118741 = log(r118740);
double r118742 = r118739 * r118741;
double r118743 = 0.010271927589648086;
bool r118744 = r118702 <= r118743;
double r118745 = r118739 * r118738;
double r118746 = 7.312595874998128e+224;
bool r118747 = r118702 <= r118746;
double r118748 = 1.6745382427765641e+263;
bool r118749 = r118702 <= r118748;
double r118750 = !r118749;
bool r118751 = r118747 || r118750;
double r118752 = r118702 / r118707;
double r118753 = r118717 + r118752;
double r118754 = pow(r118753, r118707);
double r118755 = 3.0;
double r118756 = pow(r118754, r118755);
double r118757 = pow(r118717, r118755);
double r118758 = r118756 - r118757;
double r118759 = r118754 + r118717;
double r118760 = 2.0;
double r118761 = r118760 * r118707;
double r118762 = pow(r118753, r118761);
double r118763 = fma(r118717, r118759, r118762);
double r118764 = r118758 / r118763;
double r118765 = r118764 / r118702;
double r118766 = r118705 * r118765;
double r118767 = r118766 * r118707;
double r118768 = fma(r118718, r118707, r118706);
double r118769 = fma(r118717, r118702, r118768);
double r118770 = r118769 - r118717;
double r118771 = r118770 / r118752;
double r118772 = r118705 * r118771;
double r118773 = r118751 ? r118767 : r118772;
double r118774 = r118744 ? r118745 : r118773;
double r118775 = r118732 ? r118742 : r118774;
double r118776 = r118716 ? r118730 : r118775;
double r118777 = r118704 ? r118714 : r118776;
return r118777;
}




Bits error versus i




Bits error versus n
| Original | 43.2 |
|---|---|
| Target | 42.5 |
| Herbie | 21.6 |
if i < -587178759827394.1Initial program 27.7
rmApplied associate-/r/28.3
Applied associate-*r*28.3
Taylor expanded around inf 64.0
Simplified19.1
if -587178759827394.1 < i < 1.8395426177605914e-53Initial program 50.4
rmApplied associate-/r/50.1
Applied associate-*r*50.1
Taylor expanded around 0 17.7
Simplified17.7
rmApplied add-log-exp17.8
if 1.8395426177605914e-53 < i < 3.5115451043342654e-14Initial program 53.8
rmApplied associate-/r/53.7
Applied associate-*r*53.7
Taylor expanded around 0 17.8
Simplified17.8
rmApplied add-cube-cbrt18.6
rmApplied add-log-exp52.2
if 3.5115451043342654e-14 < i < 0.010271927589648086Initial program 51.1
rmApplied associate-/r/51.1
Applied associate-*r*51.1
Taylor expanded around 0 21.3
Simplified21.3
rmApplied add-cube-cbrt21.6
if 0.010271927589648086 < i < 7.312595874998128e+224 or 1.6745382427765641e+263 < i Initial program 32.9
rmApplied associate-/r/32.9
Applied associate-*r*32.9
rmApplied flip3--33.0
Simplified33.0
if 7.312595874998128e+224 < i < 1.6745382427765641e+263Initial program 33.4
Taylor expanded around 0 33.7
Simplified33.7
Final simplification21.6
herbie shell --seed 2019306 +o rules:numerics
(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))))