100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;n \le -6.246516767500982 \cdot 10^{+112}:\\
\;\;\;\;\frac{\mathsf{fma}\left(50, i \cdot i, \mathsf{fma}\left(\frac{50}{3} \cdot i, i \cdot i, i \cdot 100\right)\right)}{\frac{i}{n}}\\
\mathbf{elif}\;n \le -1.0933259526011947 \cdot 10^{+64}:\\
\;\;\;\;\frac{\mathsf{fma}\left(100, {\left(1 + \frac{i}{n}\right)}^{n}, -100\right)}{i} \cdot n\\
\mathbf{elif}\;n \le -0.13295556128930017:\\
\;\;\;\;\frac{\mathsf{fma}\left(50, i \cdot i, \mathsf{fma}\left(\frac{50}{3} \cdot i, i \cdot i, i \cdot 100\right)\right)}{\frac{i}{n}}\\
\mathbf{elif}\;n \le -1.7065727457962 \cdot 10^{-312}:\\
\;\;\;\;\frac{1}{i} \cdot \left(\mathsf{fma}\left(100, e^{n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)}, -100\right) \cdot n\right)\\
\mathbf{elif}\;n \le 5.811229823508011 \cdot 10^{-78}:\\
\;\;\;\;\frac{\mathsf{fma}\left(50 \cdot \left(n \cdot n\right), \log n \cdot \log n, \mathsf{fma}\left(\left(\left(n \cdot n\right) \cdot n\right) \cdot \frac{50}{3}, \log i \cdot \left(\log i \cdot \log i\right), \mathsf{fma}\left(n \cdot \log i, 100, \mathsf{fma}\left(\frac{100}{3}, \left(\log n \cdot \log n\right) \cdot \left(\log i \cdot \left(\left(n \cdot n\right) \cdot n\right)\right), \mathsf{fma}\left(\frac{50}{3}, \left(\log n \cdot \log n\right) \cdot \left(\log i \cdot \left(\left(n \cdot n\right) \cdot n\right)\right), \left(\log i \cdot \log i\right) \cdot \left(50 \cdot \left(n \cdot n\right)\right)\right)\right)\right)\right)\right) - \mathsf{fma}\left(\left(\left(n \cdot n\right) \cdot n\right) \cdot \frac{100}{3}, \log n \cdot \left(\log i \cdot \log i\right), \mathsf{fma}\left(50 \cdot \left(n \cdot n\right), \log n \cdot \log i, \mathsf{fma}\left(50 \cdot \left(n \cdot n\right), \log n \cdot \log i, \left(n \cdot 100\right) \cdot \log n + \left(\left(\left(n \cdot n\right) \cdot n\right) \cdot \frac{50}{3}\right) \cdot \left(\log n \cdot \left(\log i \cdot \log i\right) + \left(\log n \cdot \log n\right) \cdot \log n\right)\right)\right)\right)}{\frac{i}{n}}\\
\mathbf{elif}\;n \le 2.5555363937413246 \cdot 10^{+221}:\\
\;\;\;\;\frac{\mathsf{fma}\left(50, i \cdot i, \mathsf{fma}\left(\frac{50}{3} \cdot i, i \cdot i, i \cdot 100\right)\right)}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt[3]{\mathsf{fma}\left(100, e^{n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)}, -100\right)} \cdot \sqrt[3]{\mathsf{fma}\left(100, e^{n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)}, -100\right)}}{\sqrt[3]{\frac{i}{n}} \cdot \left(\sqrt[3]{\sqrt[3]{\frac{i}{n}} \cdot \sqrt[3]{\frac{i}{n}}} \cdot \sqrt[3]{\sqrt[3]{\sqrt[3]{\frac{i}{n}}} \cdot \left(\sqrt[3]{\sqrt[3]{\frac{i}{n}}} \cdot \sqrt[3]{\sqrt[3]{\frac{i}{n}}}\right)}\right)} \cdot \frac{\sqrt[3]{\mathsf{fma}\left(100, e^{n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)}, -100\right)}}{\sqrt[3]{\frac{i}{n}}}\\
\end{array}double f(double i, double n) {
double r2496962 = 100.0;
double r2496963 = 1.0;
double r2496964 = i;
double r2496965 = n;
double r2496966 = r2496964 / r2496965;
double r2496967 = r2496963 + r2496966;
double r2496968 = pow(r2496967, r2496965);
double r2496969 = r2496968 - r2496963;
double r2496970 = r2496969 / r2496966;
double r2496971 = r2496962 * r2496970;
return r2496971;
}
double f(double i, double n) {
double r2496972 = n;
double r2496973 = -6.246516767500982e+112;
bool r2496974 = r2496972 <= r2496973;
double r2496975 = 50.0;
double r2496976 = i;
double r2496977 = r2496976 * r2496976;
double r2496978 = 16.666666666666668;
double r2496979 = r2496978 * r2496976;
double r2496980 = 100.0;
double r2496981 = r2496976 * r2496980;
double r2496982 = fma(r2496979, r2496977, r2496981);
double r2496983 = fma(r2496975, r2496977, r2496982);
double r2496984 = r2496976 / r2496972;
double r2496985 = r2496983 / r2496984;
double r2496986 = -1.0933259526011947e+64;
bool r2496987 = r2496972 <= r2496986;
double r2496988 = 1.0;
double r2496989 = r2496988 + r2496984;
double r2496990 = pow(r2496989, r2496972);
double r2496991 = -100.0;
double r2496992 = fma(r2496980, r2496990, r2496991);
double r2496993 = r2496992 / r2496976;
double r2496994 = r2496993 * r2496972;
double r2496995 = -0.13295556128930017;
bool r2496996 = r2496972 <= r2496995;
double r2496997 = -1.7065727457962e-312;
bool r2496998 = r2496972 <= r2496997;
double r2496999 = r2496988 / r2496976;
double r2497000 = log1p(r2496984);
double r2497001 = r2496972 * r2497000;
double r2497002 = exp(r2497001);
double r2497003 = fma(r2496980, r2497002, r2496991);
double r2497004 = r2497003 * r2496972;
double r2497005 = r2496999 * r2497004;
double r2497006 = 5.811229823508011e-78;
bool r2497007 = r2496972 <= r2497006;
double r2497008 = r2496972 * r2496972;
double r2497009 = r2496975 * r2497008;
double r2497010 = log(r2496972);
double r2497011 = r2497010 * r2497010;
double r2497012 = r2497008 * r2496972;
double r2497013 = r2497012 * r2496978;
double r2497014 = log(r2496976);
double r2497015 = r2497014 * r2497014;
double r2497016 = r2497014 * r2497015;
double r2497017 = r2496972 * r2497014;
double r2497018 = 33.333333333333336;
double r2497019 = r2497014 * r2497012;
double r2497020 = r2497011 * r2497019;
double r2497021 = r2497015 * r2497009;
double r2497022 = fma(r2496978, r2497020, r2497021);
double r2497023 = fma(r2497018, r2497020, r2497022);
double r2497024 = fma(r2497017, r2496980, r2497023);
double r2497025 = fma(r2497013, r2497016, r2497024);
double r2497026 = fma(r2497009, r2497011, r2497025);
double r2497027 = r2497012 * r2497018;
double r2497028 = r2497010 * r2497015;
double r2497029 = r2497010 * r2497014;
double r2497030 = r2496972 * r2496980;
double r2497031 = r2497030 * r2497010;
double r2497032 = r2497011 * r2497010;
double r2497033 = r2497028 + r2497032;
double r2497034 = r2497013 * r2497033;
double r2497035 = r2497031 + r2497034;
double r2497036 = fma(r2497009, r2497029, r2497035);
double r2497037 = fma(r2497009, r2497029, r2497036);
double r2497038 = fma(r2497027, r2497028, r2497037);
double r2497039 = r2497026 - r2497038;
double r2497040 = r2497039 / r2496984;
double r2497041 = 2.5555363937413246e+221;
bool r2497042 = r2496972 <= r2497041;
double r2497043 = cbrt(r2497003);
double r2497044 = r2497043 * r2497043;
double r2497045 = cbrt(r2496984);
double r2497046 = r2497045 * r2497045;
double r2497047 = cbrt(r2497046);
double r2497048 = cbrt(r2497045);
double r2497049 = r2497048 * r2497048;
double r2497050 = r2497048 * r2497049;
double r2497051 = cbrt(r2497050);
double r2497052 = r2497047 * r2497051;
double r2497053 = r2497045 * r2497052;
double r2497054 = r2497044 / r2497053;
double r2497055 = r2497043 / r2497045;
double r2497056 = r2497054 * r2497055;
double r2497057 = r2497042 ? r2496985 : r2497056;
double r2497058 = r2497007 ? r2497040 : r2497057;
double r2497059 = r2496998 ? r2497005 : r2497058;
double r2497060 = r2496996 ? r2496985 : r2497059;
double r2497061 = r2496987 ? r2496994 : r2497060;
double r2497062 = r2496974 ? r2496985 : r2497061;
return r2497062;
}




Bits error versus i




Bits error versus n
| Original | 42.6 |
|---|---|
| Target | 42.3 |
| Herbie | 29.6 |
if n < -6.246516767500982e+112 or -1.0933259526011947e+64 < n < -0.13295556128930017 or 5.811229823508011e-78 < n < 2.5555363937413246e+221Initial program 52.3
Simplified52.3
Taylor expanded around 0 36.0
Simplified36.0
if -6.246516767500982e+112 < n < -1.0933259526011947e+64Initial program 35.9
Simplified35.9
rmApplied associate-/r/35.8
if -0.13295556128930017 < n < -1.7065727457962e-312Initial program 16.5
Simplified16.5
rmApplied add-exp-log16.5
Applied pow-exp16.5
Simplified16.5
rmApplied div-inv16.5
Applied *-un-lft-identity16.5
Applied times-frac17.2
Simplified17.2
if -1.7065727457962e-312 < n < 5.811229823508011e-78Initial program 46.8
Simplified46.8
rmApplied add-exp-log46.8
Applied pow-exp46.8
Simplified46.8
Taylor expanded around 0 20.9
Simplified20.9
if 2.5555363937413246e+221 < n Initial program 59.6
Simplified59.6
rmApplied add-exp-log59.6
Applied pow-exp59.6
Simplified41.5
rmApplied add-cube-cbrt41.8
Applied add-cube-cbrt41.7
Applied times-frac41.7
rmApplied add-cube-cbrt41.8
Applied cbrt-prod41.8
rmApplied add-cube-cbrt41.8
Final simplification29.6
herbie shell --seed 2019153 +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))))