100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -1.77715864264781547 \cdot 10^{-6}:\\
\;\;\;\;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}}{\frac{i}{n}}\\
\mathbf{elif}\;i \le 2.88216887028242915 \cdot 10^{-18}:\\
\;\;\;\;100 \cdot \frac{\frac{1}{\sqrt[3]{i} \cdot \sqrt[3]{i}}}{\frac{\frac{1}{n}}{\frac{\sqrt[3]{\mathsf{fma}\left(1, i, \mathsf{fma}\left(0.5, i \cdot i, \log 1 \cdot n\right)\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)} \cdot \sqrt[3]{\mathsf{fma}\left(1, i, \mathsf{fma}\left(0.5, i \cdot i, \log 1 \cdot n\right)\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)}}{\sqrt[3]{\sqrt[3]{i} \cdot \sqrt[3]{i}}} \cdot \frac{\sqrt[3]{\mathsf{fma}\left(1, i, \mathsf{fma}\left(0.5, i \cdot i, \log 1 \cdot n\right)\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)}}{\sqrt[3]{\sqrt[3]{i}}}}}\\
\mathbf{elif}\;i \le 2.1606840039657686 \cdot 10^{162}:\\
\;\;\;\;100 \cdot \frac{\frac{\frac{{\left({\left(1 + \frac{i}{n}\right)}^{n}\right)}^{3} - {1}^{3}}{1 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} + 1\right) + {\left(1 + \frac{i}{n}\right)}^{\left(2 \cdot n\right)}}}{i}}{\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 r214860 = 100.0;
double r214861 = 1.0;
double r214862 = i;
double r214863 = n;
double r214864 = r214862 / r214863;
double r214865 = r214861 + r214864;
double r214866 = pow(r214865, r214863);
double r214867 = r214866 - r214861;
double r214868 = r214867 / r214864;
double r214869 = r214860 * r214868;
return r214869;
}
double f(double i, double n) {
double r214870 = i;
double r214871 = -1.7771586426478155e-06;
bool r214872 = r214870 <= r214871;
double r214873 = 100.0;
double r214874 = 1.0;
double r214875 = n;
double r214876 = r214870 / r214875;
double r214877 = r214874 + r214876;
double r214878 = 2.0;
double r214879 = r214878 * r214875;
double r214880 = pow(r214877, r214879);
double r214881 = r214874 * r214874;
double r214882 = r214880 - r214881;
double r214883 = pow(r214877, r214875);
double r214884 = r214883 + r214874;
double r214885 = r214882 / r214884;
double r214886 = r214885 / r214876;
double r214887 = r214873 * r214886;
double r214888 = 2.882168870282429e-18;
bool r214889 = r214870 <= r214888;
double r214890 = 1.0;
double r214891 = cbrt(r214870);
double r214892 = r214891 * r214891;
double r214893 = r214890 / r214892;
double r214894 = r214890 / r214875;
double r214895 = 0.5;
double r214896 = r214870 * r214870;
double r214897 = log(r214874);
double r214898 = r214897 * r214875;
double r214899 = fma(r214895, r214896, r214898);
double r214900 = fma(r214874, r214870, r214899);
double r214901 = pow(r214870, r214878);
double r214902 = r214901 * r214897;
double r214903 = r214895 * r214902;
double r214904 = r214900 - r214903;
double r214905 = cbrt(r214904);
double r214906 = r214905 * r214905;
double r214907 = cbrt(r214892);
double r214908 = r214906 / r214907;
double r214909 = cbrt(r214891);
double r214910 = r214905 / r214909;
double r214911 = r214908 * r214910;
double r214912 = r214894 / r214911;
double r214913 = r214893 / r214912;
double r214914 = r214873 * r214913;
double r214915 = 2.1606840039657686e+162;
bool r214916 = r214870 <= r214915;
double r214917 = 3.0;
double r214918 = pow(r214883, r214917);
double r214919 = pow(r214874, r214917);
double r214920 = r214918 - r214919;
double r214921 = r214874 * r214884;
double r214922 = r214921 + r214880;
double r214923 = r214920 / r214922;
double r214924 = r214923 / r214870;
double r214925 = r214924 / r214894;
double r214926 = r214873 * r214925;
double r214927 = fma(r214897, r214875, r214890);
double r214928 = fma(r214874, r214870, r214927);
double r214929 = r214928 - r214874;
double r214930 = r214929 / r214876;
double r214931 = r214873 * r214930;
double r214932 = r214916 ? r214926 : r214931;
double r214933 = r214889 ? r214914 : r214932;
double r214934 = r214872 ? r214887 : r214933;
return r214934;
}




Bits error versus i




Bits error versus n
| Original | 42.6 |
|---|---|
| Target | 42.5 |
| Herbie | 21.6 |
if i < -1.7771586426478155e-06Initial program 27.7
rmApplied flip--27.7
Simplified27.7
if -1.7771586426478155e-06 < i < 2.882168870282429e-18Initial program 50.5
rmApplied div-inv50.5
Applied associate-/r*50.2
Taylor expanded around 0 16.7
Simplified16.7
rmApplied add-cube-cbrt17.6
Applied *-un-lft-identity17.6
Applied times-frac17.6
Applied associate-/l*16.1
rmApplied add-cube-cbrt16.2
Applied cbrt-prod16.3
Applied add-cube-cbrt15.8
Applied times-frac15.8
if 2.882168870282429e-18 < i < 2.1606840039657686e+162Initial program 36.1
rmApplied div-inv36.1
Applied associate-/r*36.1
rmApplied flip3--36.1
Simplified36.1
if 2.1606840039657686e+162 < i Initial program 31.9
Taylor expanded around 0 35.5
Simplified35.5
Final simplification21.6
herbie shell --seed 2020042 +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))))