100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -5.642265308759161 \cdot 10^{-06}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(e^{n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)}, 100, -100\right)}{i}}{\frac{1}{n}}\\
\mathbf{elif}\;i \le -3.088990014014521 \cdot 10^{-147}:\\
\;\;\;\;\frac{\mathsf{fma}\left(100, i, \left(i \cdot i\right) \cdot \left(50 + i \cdot \frac{50}{3}\right)\right)}{\frac{i}{n}}\\
\mathbf{elif}\;i \le -1.0135127503428662 \cdot 10^{-166}:\\
\;\;\;\;\left(\mathsf{fma}\left(e^{n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)}, 100, -100\right) \cdot \sqrt{\frac{1}{\frac{i}{n}}}\right) \cdot \sqrt{\frac{1}{\frac{i}{n}}}\\
\mathbf{elif}\;i \le -3.0864902391323963 \cdot 10^{-260}:\\
\;\;\;\;\frac{\mathsf{fma}\left(100, i, \left(i \cdot i\right) \cdot \left(50 + i \cdot \frac{50}{3}\right)\right)}{\frac{i}{n}}\\
\mathbf{elif}\;i \le 3.1626526043984503 \cdot 10^{-260}:\\
\;\;\;\;\frac{\mathsf{fma}\left(e^{n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)}, 100, -100\right)}{\sqrt[3]{\frac{1}{n}} \cdot \sqrt[3]{\frac{1}{n}}} \cdot \frac{\frac{1}{i}}{\sqrt[3]{\frac{1}{n}}}\\
\mathbf{elif}\;i \le 0.07034960194177167:\\
\;\;\;\;\frac{\mathsf{fma}\left(100, i, \left(i \cdot i\right) \cdot \left(50 + i \cdot \frac{50}{3}\right)\right)}{\frac{i}{n}}\\
\mathbf{elif}\;i \le 2.6398510549660955 \cdot 10^{+147}:\\
\;\;\;\;\frac{\mathsf{fma}\left(50 \cdot \left(n \cdot n\right), \log n \cdot \log n, \mathsf{fma}\left(\frac{50}{3}, \left(\log i \cdot \left(\log i \cdot \log i\right)\right) \cdot \left(\left(n \cdot n\right) \cdot n\right), \mathsf{fma}\left(100 \cdot n, \log i, \mathsf{fma}\left(\frac{100}{3}, \left(\log i \cdot \left(\log n \cdot \log n\right)\right) \cdot \left(\left(n \cdot n\right) \cdot n\right), \mathsf{fma}\left(\frac{50}{3}, \left(\log i \cdot \left(\log n \cdot \log n\right)\right) \cdot \left(\left(n \cdot n\right) \cdot n\right), \left(\log i \cdot \log i\right) \cdot \left(50 \cdot \left(n \cdot n\right)\right)\right)\right)\right)\right) - \mathsf{fma}\left(\left(\left(\log i \cdot \log i\right) \cdot \log n\right) \cdot \left(\left(n \cdot n\right) \cdot n\right), \frac{100}{3}, \mathsf{fma}\left(n \cdot \left(\left(n \cdot n\right) \cdot \frac{50}{3}\right), \left(\log n \cdot \log n\right) \cdot \log n, \mathsf{fma}\left(\frac{50}{3}, \left(\left(\log i \cdot \log i\right) \cdot \log n\right) \cdot \left(\left(n \cdot n\right) \cdot n\right), \left(\log n \cdot 100\right) \cdot n\right)\right) + \left(\left(n \cdot n\right) \cdot \left(\log i \cdot \log n\right)\right) \cdot 100\right)\right)}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;\frac{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + -100}{\frac{i}{n}}\\
\end{array}double f(double i, double n) {
double r4072985 = 100.0;
double r4072986 = 1.0;
double r4072987 = i;
double r4072988 = n;
double r4072989 = r4072987 / r4072988;
double r4072990 = r4072986 + r4072989;
double r4072991 = pow(r4072990, r4072988);
double r4072992 = r4072991 - r4072986;
double r4072993 = r4072992 / r4072989;
double r4072994 = r4072985 * r4072993;
return r4072994;
}
double f(double i, double n) {
double r4072995 = i;
double r4072996 = -5.642265308759161e-06;
bool r4072997 = r4072995 <= r4072996;
double r4072998 = n;
double r4072999 = r4072995 / r4072998;
double r4073000 = log1p(r4072999);
double r4073001 = r4072998 * r4073000;
double r4073002 = exp(r4073001);
double r4073003 = 100.0;
double r4073004 = -100.0;
double r4073005 = fma(r4073002, r4073003, r4073004);
double r4073006 = r4073005 / r4072995;
double r4073007 = 1.0;
double r4073008 = r4073007 / r4072998;
double r4073009 = r4073006 / r4073008;
double r4073010 = -3.088990014014521e-147;
bool r4073011 = r4072995 <= r4073010;
double r4073012 = r4072995 * r4072995;
double r4073013 = 50.0;
double r4073014 = 16.666666666666668;
double r4073015 = r4072995 * r4073014;
double r4073016 = r4073013 + r4073015;
double r4073017 = r4073012 * r4073016;
double r4073018 = fma(r4073003, r4072995, r4073017);
double r4073019 = r4073018 / r4072999;
double r4073020 = -1.0135127503428662e-166;
bool r4073021 = r4072995 <= r4073020;
double r4073022 = r4073007 / r4072999;
double r4073023 = sqrt(r4073022);
double r4073024 = r4073005 * r4073023;
double r4073025 = r4073024 * r4073023;
double r4073026 = -3.0864902391323963e-260;
bool r4073027 = r4072995 <= r4073026;
double r4073028 = 3.1626526043984503e-260;
bool r4073029 = r4072995 <= r4073028;
double r4073030 = cbrt(r4073008);
double r4073031 = r4073030 * r4073030;
double r4073032 = r4073005 / r4073031;
double r4073033 = r4073007 / r4072995;
double r4073034 = r4073033 / r4073030;
double r4073035 = r4073032 * r4073034;
double r4073036 = 0.07034960194177167;
bool r4073037 = r4072995 <= r4073036;
double r4073038 = 2.6398510549660955e+147;
bool r4073039 = r4072995 <= r4073038;
double r4073040 = r4072998 * r4072998;
double r4073041 = r4073013 * r4073040;
double r4073042 = log(r4072998);
double r4073043 = r4073042 * r4073042;
double r4073044 = log(r4072995);
double r4073045 = r4073044 * r4073044;
double r4073046 = r4073044 * r4073045;
double r4073047 = r4073040 * r4072998;
double r4073048 = r4073046 * r4073047;
double r4073049 = r4073003 * r4072998;
double r4073050 = 33.333333333333336;
double r4073051 = r4073044 * r4073043;
double r4073052 = r4073051 * r4073047;
double r4073053 = r4073045 * r4073041;
double r4073054 = fma(r4073014, r4073052, r4073053);
double r4073055 = fma(r4073050, r4073052, r4073054);
double r4073056 = fma(r4073049, r4073044, r4073055);
double r4073057 = fma(r4073014, r4073048, r4073056);
double r4073058 = r4073045 * r4073042;
double r4073059 = r4073058 * r4073047;
double r4073060 = r4073040 * r4073014;
double r4073061 = r4072998 * r4073060;
double r4073062 = r4073043 * r4073042;
double r4073063 = r4073042 * r4073003;
double r4073064 = r4073063 * r4072998;
double r4073065 = fma(r4073014, r4073059, r4073064);
double r4073066 = fma(r4073061, r4073062, r4073065);
double r4073067 = r4073044 * r4073042;
double r4073068 = r4073040 * r4073067;
double r4073069 = r4073068 * r4073003;
double r4073070 = r4073066 + r4073069;
double r4073071 = fma(r4073059, r4073050, r4073070);
double r4073072 = r4073057 - r4073071;
double r4073073 = fma(r4073041, r4073043, r4073072);
double r4073074 = r4073073 / r4072999;
double r4073075 = r4073007 + r4072999;
double r4073076 = pow(r4073075, r4072998);
double r4073077 = r4073003 * r4073076;
double r4073078 = r4073077 + r4073004;
double r4073079 = r4073078 / r4072999;
double r4073080 = r4073039 ? r4073074 : r4073079;
double r4073081 = r4073037 ? r4073019 : r4073080;
double r4073082 = r4073029 ? r4073035 : r4073081;
double r4073083 = r4073027 ? r4073019 : r4073082;
double r4073084 = r4073021 ? r4073025 : r4073083;
double r4073085 = r4073011 ? r4073019 : r4073084;
double r4073086 = r4072997 ? r4073009 : r4073085;
return r4073086;
}




Bits error versus i




Bits error versus n
| Original | 42.2 |
|---|---|
| Target | 42.0 |
| Herbie | 26.6 |
if i < -5.642265308759161e-06Initial program 28.3
Simplified28.2
rmApplied add-exp-log28.3
Applied pow-exp28.3
Simplified5.8
rmApplied div-inv5.9
Applied associate-/r*6.3
if -5.642265308759161e-06 < i < -3.088990014014521e-147 or -1.0135127503428662e-166 < i < -3.0864902391323963e-260 or 3.1626526043984503e-260 < i < 0.07034960194177167Initial program 50.4
Simplified50.4
Taylor expanded around 0 30.9
Simplified30.9
if -3.088990014014521e-147 < i < -1.0135127503428662e-166Initial program 47.1
Simplified47.1
rmApplied add-exp-log47.1
Applied pow-exp47.1
Simplified47.1
rmApplied div-inv47.1
rmApplied add-sqr-sqrt47.1
Applied associate-*r*47.1
if -3.0864902391323963e-260 < i < 3.1626526043984503e-260Initial program 49.3
Simplified49.3
rmApplied add-exp-log49.3
Applied pow-exp49.3
Simplified49.3
rmApplied div-inv49.3
Applied associate-/r*49.6
rmApplied add-cube-cbrt49.6
Applied div-inv49.6
Applied times-frac49.3
if 0.07034960194177167 < i < 2.6398510549660955e+147Initial program 30.7
Simplified30.6
rmApplied add-exp-log40.6
Applied pow-exp40.6
Simplified38.2
Taylor expanded around 0 13.8
Simplified13.8
if 2.6398510549660955e+147 < i Initial program 30.9
Simplified30.9
rmApplied fma-udef30.9
Final simplification26.6
herbie shell --seed 2019141 +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))))