100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -0.1040807419505014597138625731531647033989:\\
\;\;\;\;100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\\
\mathbf{elif}\;i \le -1.235437068794871502671548956380542009081 \cdot 10^{-255}:\\
\;\;\;\;\frac{100}{i} \cdot \frac{\mathsf{fma}\left(1, i, \mathsf{fma}\left(0.5, {i}^{2}, \log 1 \cdot n\right)\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)}{\frac{1}{n}}\\
\mathbf{elif}\;i \le 3.912989910623956103641462485659015187104 \cdot 10^{-198}:\\
\;\;\;\;100 \cdot \left(\frac{\mathsf{fma}\left(1, i, \mathsf{fma}\left(0.5, {i}^{2}, \log 1 \cdot n\right)\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)}{i} \cdot n\right)\\
\mathbf{elif}\;i \le 18.6629372047199559858654538402333855629:\\
\;\;\;\;\frac{100}{i} \cdot \frac{\mathsf{fma}\left(1, i, \mathsf{fma}\left(0.5, {i}^{2}, \log 1 \cdot n\right)\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)}{\frac{1}{n}}\\
\mathbf{elif}\;i \le 5.064717226083425690234124091873168768786 \cdot 10^{144}:\\
\;\;\;\;\left(100 \cdot \frac{\sqrt{{\left(1 + \frac{i}{n}\right)}^{n}} + \sqrt{1}}{i}\right) \cdot \frac{\sqrt{{\left(1 + \frac{i}{n}\right)}^{n}} - \sqrt{1}}{\frac{1}{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 r94817 = 100.0;
double r94818 = 1.0;
double r94819 = i;
double r94820 = n;
double r94821 = r94819 / r94820;
double r94822 = r94818 + r94821;
double r94823 = pow(r94822, r94820);
double r94824 = r94823 - r94818;
double r94825 = r94824 / r94821;
double r94826 = r94817 * r94825;
return r94826;
}
double f(double i, double n) {
double r94827 = i;
double r94828 = -0.10408074195050146;
bool r94829 = r94827 <= r94828;
double r94830 = 100.0;
double r94831 = 1.0;
double r94832 = n;
double r94833 = r94827 / r94832;
double r94834 = r94831 + r94833;
double r94835 = pow(r94834, r94832);
double r94836 = r94835 - r94831;
double r94837 = r94836 / r94833;
double r94838 = r94830 * r94837;
double r94839 = -1.2354370687948715e-255;
bool r94840 = r94827 <= r94839;
double r94841 = r94830 / r94827;
double r94842 = 0.5;
double r94843 = 2.0;
double r94844 = pow(r94827, r94843);
double r94845 = log(r94831);
double r94846 = r94845 * r94832;
double r94847 = fma(r94842, r94844, r94846);
double r94848 = fma(r94831, r94827, r94847);
double r94849 = r94844 * r94845;
double r94850 = r94842 * r94849;
double r94851 = r94848 - r94850;
double r94852 = 1.0;
double r94853 = r94852 / r94832;
double r94854 = r94851 / r94853;
double r94855 = r94841 * r94854;
double r94856 = 3.912989910623956e-198;
bool r94857 = r94827 <= r94856;
double r94858 = r94851 / r94827;
double r94859 = r94858 * r94832;
double r94860 = r94830 * r94859;
double r94861 = 18.662937204719956;
bool r94862 = r94827 <= r94861;
double r94863 = 5.064717226083426e+144;
bool r94864 = r94827 <= r94863;
double r94865 = sqrt(r94835);
double r94866 = sqrt(r94831);
double r94867 = r94865 + r94866;
double r94868 = r94867 / r94827;
double r94869 = r94830 * r94868;
double r94870 = r94865 - r94866;
double r94871 = r94870 / r94853;
double r94872 = r94869 * r94871;
double r94873 = fma(r94845, r94832, r94852);
double r94874 = fma(r94831, r94827, r94873);
double r94875 = r94874 - r94831;
double r94876 = r94875 / r94833;
double r94877 = r94830 * r94876;
double r94878 = r94864 ? r94872 : r94877;
double r94879 = r94862 ? r94855 : r94878;
double r94880 = r94857 ? r94860 : r94879;
double r94881 = r94840 ? r94855 : r94880;
double r94882 = r94829 ? r94838 : r94881;
return r94882;
}




Bits error versus i




Bits error versus n
| Original | 43.1 |
|---|---|
| Target | 42.7 |
| Herbie | 21.2 |
if i < -0.10408074195050146Initial program 29.8
if -0.10408074195050146 < i < -1.2354370687948715e-255 or 3.912989910623956e-198 < i < 18.662937204719956Initial program 51.0
Taylor expanded around 0 30.6
Simplified30.6
rmApplied div-inv30.7
Applied *-un-lft-identity30.7
Applied times-frac15.6
Applied associate-*r*15.7
Simplified15.7
if -1.2354370687948715e-255 < i < 3.912989910623956e-198Initial program 49.3
Taylor expanded around 0 40.8
Simplified40.8
rmApplied associate-/r/14.4
if 18.662937204719956 < i < 5.064717226083426e+144Initial program 30.0
rmApplied div-inv30.0
Applied add-sqr-sqrt30.0
Applied add-sqr-sqrt30.0
Applied difference-of-squares30.0
Applied times-frac30.1
Applied associate-*r*30.1
if 5.064717226083426e+144 < i Initial program 30.1
Taylor expanded around 0 36.9
Simplified36.9
Final simplification21.2
herbie shell --seed 2019235 +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))))