100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;n \le -4.6511036455496 \cdot 10^{+137}:\\
\;\;\;\;\frac{\mathsf{fma}\left(e^{\mathsf{log1p}\left(\frac{i}{n}\right) \cdot n}, 100, -100\right)}{i} \cdot n\\
\mathbf{elif}\;n \le 1.9360594076256 \cdot 10^{-310}:\\
\;\;\;\;n \cdot \frac{\mathsf{fma}\left(100, {\left(\frac{i}{n} + 1\right)}^{n}, -100\right)}{i}\\
\mathbf{elif}\;n \le 1.547355740653275 \cdot 10^{-211}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\left(n \cdot n\right) \cdot 50, \log n \cdot \log n, \mathsf{fma}\left(\left(n \cdot \left(n \cdot n\right)\right) \cdot \frac{50}{3}, \log i \cdot \left(\log i \cdot \log i\right), \mathsf{fma}\left(\log i \cdot n, 100, \mathsf{fma}\left(\frac{100}{3}, \left(n \cdot \left(n \cdot n\right)\right) \cdot \left(\log i \cdot \left(\log n \cdot \log n\right)\right), \mathsf{fma}\left(\left(n \cdot \left(n \cdot n\right)\right) \cdot \frac{50}{3}, \log i \cdot \left(\log n \cdot \log n\right), \left(50 \cdot \left(\log i \cdot \log i\right)\right) \cdot \left(n \cdot n\right)\right)\right)\right)\right) - \mathsf{fma}\left(n \cdot \left(\frac{100}{3} \cdot \left(n \cdot n\right)\right), \left(\log i \cdot \log n\right) \cdot \log i, \mathsf{fma}\left(\left(n \cdot n\right) \cdot 50, \log i \cdot \log n, \mathsf{fma}\left(\left(n \cdot n\right) \cdot 50, \log i \cdot \log n, \left(\left(\log n \cdot \log n\right) \cdot \log n + \left(\log i \cdot \log n\right) \cdot \log i\right) \cdot \left(\left(n \cdot \left(n \cdot n\right)\right) \cdot \frac{50}{3}\right) + n \cdot \left(\log n \cdot 100\right)\right)\right)\right)\right)}{\frac{i}{n}}\\
\mathbf{elif}\;n \le 3.2388182495466635 \cdot 10^{-96}:\\
\;\;\;\;\frac{\mathsf{fma}\left(i \cdot i, 50, \mathsf{fma}\left(i \cdot i, \frac{50}{3} \cdot i, 100 \cdot i\right)\right)}{\frac{i}{n}}\\
\mathbf{elif}\;n \le 4.809293212884638 \cdot 10^{-44}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\left(n \cdot n\right) \cdot 50, \log n \cdot \log n, \mathsf{fma}\left(\left(n \cdot \left(n \cdot n\right)\right) \cdot \frac{50}{3}, \log i \cdot \left(\log i \cdot \log i\right), \mathsf{fma}\left(n \cdot 100, \log i, \mathsf{fma}\left(\frac{100}{3}, \left(\log n \cdot \log n\right) \cdot \left(\log i \cdot \left(n \cdot \left(n \cdot n\right)\right)\right), \mathsf{fma}\left(\frac{50}{3}, \left(\log n \cdot \log n\right) \cdot \left(\log i \cdot \left(n \cdot \left(n \cdot n\right)\right)\right), 50 \cdot \left(\left(n \cdot n\right) \cdot \left(\log i \cdot \log i\right)\right)\right)\right)\right)\right) - \mathsf{fma}\left(\left(\log i \cdot \log i\right) \cdot \left(\left(n \cdot \left(n \cdot n\right)\right) \cdot \log n\right), \frac{100}{3}, \mathsf{fma}\left(\left(n \cdot n\right) \cdot 50, \log i \cdot \log n, \mathsf{fma}\left(\left(n \cdot n\right) \cdot 50, \log i \cdot \log n, \frac{50}{3} \cdot \left(\left(\log i \cdot \log i\right) \cdot \left(\left(n \cdot \left(n \cdot n\right)\right) \cdot \log n\right) + \left(n \cdot \left(n \cdot n\right)\right) \cdot \left(\left(\log n \cdot \log n\right) \cdot \log n\right)\right) + \log n \cdot \left(n \cdot 100\right)\right)\right)\right)\right)}{\frac{i}{n}}\\
\mathbf{elif}\;n \le 7.855089357782943 \cdot 10^{+198}:\\
\;\;\;\;\frac{\mathsf{fma}\left(i \cdot i, 50, \mathsf{fma}\left(i \cdot i, \frac{50}{3} \cdot i, 100 \cdot i\right)\right)}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(100, e^{\left(\left(\mathsf{log1p}\left(\frac{i}{n}\right) \cdot n\right)\right)}, -100\right)}{\frac{i}{n}}\\
\end{array}double f(double i, double n) {
double r2290847 = 100.0;
double r2290848 = 1.0;
double r2290849 = i;
double r2290850 = n;
double r2290851 = r2290849 / r2290850;
double r2290852 = r2290848 + r2290851;
double r2290853 = pow(r2290852, r2290850);
double r2290854 = r2290853 - r2290848;
double r2290855 = r2290854 / r2290851;
double r2290856 = r2290847 * r2290855;
return r2290856;
}
double f(double i, double n) {
double r2290857 = n;
double r2290858 = -4.6511036455496e+137;
bool r2290859 = r2290857 <= r2290858;
double r2290860 = i;
double r2290861 = r2290860 / r2290857;
double r2290862 = log1p(r2290861);
double r2290863 = r2290862 * r2290857;
double r2290864 = exp(r2290863);
double r2290865 = 100.0;
double r2290866 = -100.0;
double r2290867 = fma(r2290864, r2290865, r2290866);
double r2290868 = r2290867 / r2290860;
double r2290869 = r2290868 * r2290857;
double r2290870 = 1.9360594076256e-310;
bool r2290871 = r2290857 <= r2290870;
double r2290872 = 1.0;
double r2290873 = r2290861 + r2290872;
double r2290874 = pow(r2290873, r2290857);
double r2290875 = fma(r2290865, r2290874, r2290866);
double r2290876 = r2290875 / r2290860;
double r2290877 = r2290857 * r2290876;
double r2290878 = 1.547355740653275e-211;
bool r2290879 = r2290857 <= r2290878;
double r2290880 = r2290857 * r2290857;
double r2290881 = 50.0;
double r2290882 = r2290880 * r2290881;
double r2290883 = log(r2290857);
double r2290884 = r2290883 * r2290883;
double r2290885 = r2290857 * r2290880;
double r2290886 = 16.666666666666668;
double r2290887 = r2290885 * r2290886;
double r2290888 = log(r2290860);
double r2290889 = r2290888 * r2290888;
double r2290890 = r2290888 * r2290889;
double r2290891 = r2290888 * r2290857;
double r2290892 = 33.333333333333336;
double r2290893 = r2290888 * r2290884;
double r2290894 = r2290885 * r2290893;
double r2290895 = r2290881 * r2290889;
double r2290896 = r2290895 * r2290880;
double r2290897 = fma(r2290887, r2290893, r2290896);
double r2290898 = fma(r2290892, r2290894, r2290897);
double r2290899 = fma(r2290891, r2290865, r2290898);
double r2290900 = fma(r2290887, r2290890, r2290899);
double r2290901 = r2290892 * r2290880;
double r2290902 = r2290857 * r2290901;
double r2290903 = r2290888 * r2290883;
double r2290904 = r2290903 * r2290888;
double r2290905 = r2290884 * r2290883;
double r2290906 = r2290905 + r2290904;
double r2290907 = r2290906 * r2290887;
double r2290908 = r2290883 * r2290865;
double r2290909 = r2290857 * r2290908;
double r2290910 = r2290907 + r2290909;
double r2290911 = fma(r2290882, r2290903, r2290910);
double r2290912 = fma(r2290882, r2290903, r2290911);
double r2290913 = fma(r2290902, r2290904, r2290912);
double r2290914 = r2290900 - r2290913;
double r2290915 = fma(r2290882, r2290884, r2290914);
double r2290916 = r2290915 / r2290861;
double r2290917 = 3.2388182495466635e-96;
bool r2290918 = r2290857 <= r2290917;
double r2290919 = r2290860 * r2290860;
double r2290920 = r2290886 * r2290860;
double r2290921 = r2290865 * r2290860;
double r2290922 = fma(r2290919, r2290920, r2290921);
double r2290923 = fma(r2290919, r2290881, r2290922);
double r2290924 = r2290923 / r2290861;
double r2290925 = 4.809293212884638e-44;
bool r2290926 = r2290857 <= r2290925;
double r2290927 = r2290857 * r2290865;
double r2290928 = r2290888 * r2290885;
double r2290929 = r2290884 * r2290928;
double r2290930 = r2290880 * r2290889;
double r2290931 = r2290881 * r2290930;
double r2290932 = fma(r2290886, r2290929, r2290931);
double r2290933 = fma(r2290892, r2290929, r2290932);
double r2290934 = fma(r2290927, r2290888, r2290933);
double r2290935 = fma(r2290887, r2290890, r2290934);
double r2290936 = r2290885 * r2290883;
double r2290937 = r2290889 * r2290936;
double r2290938 = r2290885 * r2290905;
double r2290939 = r2290937 + r2290938;
double r2290940 = r2290886 * r2290939;
double r2290941 = r2290883 * r2290927;
double r2290942 = r2290940 + r2290941;
double r2290943 = fma(r2290882, r2290903, r2290942);
double r2290944 = fma(r2290882, r2290903, r2290943);
double r2290945 = fma(r2290937, r2290892, r2290944);
double r2290946 = r2290935 - r2290945;
double r2290947 = fma(r2290882, r2290884, r2290946);
double r2290948 = r2290947 / r2290861;
double r2290949 = 7.855089357782943e+198;
bool r2290950 = r2290857 <= r2290949;
double r2290951 = /* ERROR: no posit support in C */;
double r2290952 = /* ERROR: no posit support in C */;
double r2290953 = exp(r2290952);
double r2290954 = fma(r2290865, r2290953, r2290866);
double r2290955 = r2290954 / r2290861;
double r2290956 = r2290950 ? r2290924 : r2290955;
double r2290957 = r2290926 ? r2290948 : r2290956;
double r2290958 = r2290918 ? r2290924 : r2290957;
double r2290959 = r2290879 ? r2290916 : r2290958;
double r2290960 = r2290871 ? r2290877 : r2290959;
double r2290961 = r2290859 ? r2290869 : r2290960;
return r2290961;
}




Bits error versus i




Bits error versus n
| Original | 42.3 |
|---|---|
| Target | 42.2 |
| Herbie | 29.4 |
if n < -4.6511036455496e+137Initial program 50.9
Simplified50.9
rmApplied pow-to-exp56.5
Simplified42.6
rmApplied fma-udef42.7
rmApplied associate-/r/42.2
Simplified42.2
if -4.6511036455496e+137 < n < 1.9360594076256e-310Initial program 23.7
Simplified23.7
rmApplied associate-/r/23.8
if 1.9360594076256e-310 < n < 1.547355740653275e-211Initial program 39.2
Simplified39.2
rmApplied pow-to-exp39.2
Simplified39.2
rmApplied fma-udef39.2
Taylor expanded around 0 9.5
Simplified9.5
if 1.547355740653275e-211 < n < 3.2388182495466635e-96 or 4.809293212884638e-44 < n < 7.855089357782943e+198Initial program 55.9
Simplified55.9
Taylor expanded around 0 28.4
Simplified28.4
if 3.2388182495466635e-96 < n < 4.809293212884638e-44Initial program 58.2
Simplified58.2
rmApplied pow-to-exp58.2
Simplified58.2
Taylor expanded around 0 36.5
Simplified36.5
if 7.855089357782943e+198 < n Initial program 59.7
Simplified59.7
rmApplied pow-to-exp59.8
Simplified41.8
rmApplied insert-posit1642.4
Final simplification29.4
herbie shell --seed 2019151 +o rules:numerics
(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))))