100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -0.09568466101685804692245085334434406831861:\\
\;\;\;\;\frac{\left({\left(\frac{i}{n}\right)}^{n} - 1\right) \cdot 100}{\frac{i}{n}}\\
\mathbf{elif}\;i \le 4.636828096634822172894426601649853756376 \cdot 10^{-231}:\\
\;\;\;\;\left(\left(\sqrt[3]{\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)} \cdot \sqrt[3]{\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)}\right) \cdot \frac{100}{i}\right) \cdot \frac{\sqrt[3]{\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 2.421886781167336491233076084341835921918 \cdot 10^{-182}:\\
\;\;\;\;\frac{100}{i} \cdot \sqrt[3]{{\left(\left(\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)\right) \cdot n\right)}^{3}}\\
\mathbf{elif}\;i \le 6.433403710498657594142250154269082661313 \cdot 10^{46}:\\
\;\;\;\;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 1.353418716849568981322833055613312096611 \cdot 10^{183}:\\
\;\;\;\;100 \cdot \frac{n}{\frac{i}{{\left(\frac{i}{n}\right)}^{n} - 1}}\\
\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 r155848 = 100.0;
double r155849 = 1.0;
double r155850 = i;
double r155851 = n;
double r155852 = r155850 / r155851;
double r155853 = r155849 + r155852;
double r155854 = pow(r155853, r155851);
double r155855 = r155854 - r155849;
double r155856 = r155855 / r155852;
double r155857 = r155848 * r155856;
return r155857;
}
double f(double i, double n) {
double r155858 = i;
double r155859 = -0.09568466101685805;
bool r155860 = r155858 <= r155859;
double r155861 = n;
double r155862 = r155858 / r155861;
double r155863 = pow(r155862, r155861);
double r155864 = 1.0;
double r155865 = r155863 - r155864;
double r155866 = 100.0;
double r155867 = r155865 * r155866;
double r155868 = r155867 / r155862;
double r155869 = 4.636828096634822e-231;
bool r155870 = r155858 <= r155869;
double r155871 = 0.5;
double r155872 = 2.0;
double r155873 = pow(r155858, r155872);
double r155874 = log(r155864);
double r155875 = r155874 * r155861;
double r155876 = fma(r155871, r155873, r155875);
double r155877 = fma(r155864, r155858, r155876);
double r155878 = r155873 * r155874;
double r155879 = r155871 * r155878;
double r155880 = r155877 - r155879;
double r155881 = cbrt(r155880);
double r155882 = r155881 * r155881;
double r155883 = r155866 / r155858;
double r155884 = r155882 * r155883;
double r155885 = 1.0;
double r155886 = r155885 / r155861;
double r155887 = r155881 / r155886;
double r155888 = r155884 * r155887;
double r155889 = 2.4218867811673365e-182;
bool r155890 = r155858 <= r155889;
double r155891 = r155880 * r155861;
double r155892 = 3.0;
double r155893 = pow(r155891, r155892);
double r155894 = cbrt(r155893);
double r155895 = r155883 * r155894;
double r155896 = 6.433403710498658e+46;
bool r155897 = r155858 <= r155896;
double r155898 = r155880 / r155858;
double r155899 = r155898 * r155861;
double r155900 = r155866 * r155899;
double r155901 = 1.353418716849569e+183;
bool r155902 = r155858 <= r155901;
double r155903 = r155858 / r155865;
double r155904 = r155861 / r155903;
double r155905 = r155866 * r155904;
double r155906 = fma(r155874, r155861, r155885);
double r155907 = fma(r155864, r155858, r155906);
double r155908 = r155907 - r155864;
double r155909 = r155908 / r155862;
double r155910 = r155866 * r155909;
double r155911 = r155902 ? r155905 : r155910;
double r155912 = r155897 ? r155900 : r155911;
double r155913 = r155890 ? r155895 : r155912;
double r155914 = r155870 ? r155888 : r155913;
double r155915 = r155860 ? r155868 : r155914;
return r155915;
}




Bits error versus i




Bits error versus n
| Original | 42.6 |
|---|---|
| Target | 42.1 |
| Herbie | 21.2 |
if i < -0.09568466101685805Initial program 28.6
rmApplied div-inv28.6
Applied *-un-lft-identity28.6
Applied times-frac29.3
Applied associate-*r*29.3
Simplified29.3
Taylor expanded around inf 64.0
Simplified18.7
if -0.09568466101685805 < i < 4.636828096634822e-231Initial program 49.2
rmApplied div-inv49.2
Applied *-un-lft-identity49.2
Applied times-frac48.8
Applied associate-*r*48.9
Simplified48.9
Taylor expanded around 0 17.2
Simplified17.2
rmApplied *-un-lft-identity17.2
Applied add-cube-cbrt17.2
Applied times-frac17.2
Applied add-cube-cbrt17.8
Applied times-frac17.8
Applied associate-*r*18.6
Simplified18.6
if 4.636828096634822e-231 < i < 2.4218867811673365e-182Initial program 48.3
rmApplied div-inv48.3
Applied *-un-lft-identity48.3
Applied times-frac47.8
Applied associate-*r*47.8
Simplified47.8
Taylor expanded around 0 16.9
Simplified16.9
rmApplied add-cbrt-cube39.9
Applied add-cbrt-cube39.9
Applied cbrt-undiv39.9
Applied add-cbrt-cube48.3
Applied cbrt-undiv48.3
Simplified24.7
if 2.4218867811673365e-182 < i < 6.433403710498658e+46Initial program 50.3
rmApplied div-inv50.3
Applied *-un-lft-identity50.3
Applied times-frac50.2
Applied associate-*r*50.2
Simplified50.2
Taylor expanded around 0 19.3
Simplified19.3
rmApplied div-inv19.3
Applied associate-*l*19.2
Simplified21.5
if 6.433403710498658e+46 < i < 1.353418716849569e+183Initial program 32.0
Taylor expanded around inf 29.2
Simplified32.0
if 1.353418716849569e+183 < i Initial program 33.1
Taylor expanded around 0 32.9
Simplified32.9
Final simplification21.2
herbie shell --seed 2019326 +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))))