100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;n \le -5.4638361325642236 \cdot 10^{+190}:\\
\;\;\;\;\frac{\mathsf{fma}\left(e^{\left(\left(\mathsf{log1p}\left(\frac{i}{n}\right)\right)\right) \cdot n}, 100, -100\right)}{\frac{i}{n}}\\
\mathbf{elif}\;n \le -4.0425022022190223 \cdot 10^{+43}:\\
\;\;\;\;\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}\;n \le -3.763036538905304 \cdot 10^{+26}:\\
\;\;\;\;\frac{1}{\frac{i}{n}} \cdot \mathsf{fma}\left(e^{\left(\left(\mathsf{log1p}\left(\frac{i}{n}\right)\right)\right) \cdot n}, 100, -100\right)\\
\mathbf{elif}\;n \le -2.103154135664:\\
\;\;\;\;\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}\;n \le -7.6539834001623 \cdot 10^{-311}:\\
\;\;\;\;\frac{\log \left(e^{\mathsf{fma}\left({\left(1 + \frac{i}{n}\right)}^{n}, 100, -100\right)}\right)}{\frac{i}{n}}\\
\mathbf{elif}\;n \le 1.965651820956631 \cdot 10^{-65}:\\
\;\;\;\;\frac{1}{\frac{i}{n}} \cdot \left(\mathsf{fma}\left(\left(n \cdot \log n\right) \cdot \left(n \cdot \log n\right), 50, \mathsf{fma}\left(\frac{50}{3}, \left(n \cdot \left(n \cdot n\right)\right) \cdot \left(\left(\log i \cdot \log i\right) \cdot \log i\right), \mathsf{fma}\left(100, n \cdot \log i, 50 \cdot \left(\log i \cdot \left(n \cdot \left(\left(n \cdot \log n\right) \cdot \left(n \cdot \log n\right)\right)\right)\right) + \left(n \cdot n\right) \cdot \left(\left(\log i \cdot \log i\right) \cdot 50\right)\right)\right)\right) - \mathsf{fma}\left(\left(n \cdot \left(n \cdot n\right)\right) \cdot \frac{100}{3}, \log n \cdot \left(\log i \cdot \log i\right), \log n \cdot \left(n \cdot 100\right) + \left(\left(\left(\log i \cdot \log n\right) \cdot \left(n \cdot n\right)\right) \cdot 100 + \left(\log n \cdot \left(\log i \cdot \log i\right) + \left(\log n \cdot \log n\right) \cdot \log n\right) \cdot \left(\frac{50}{3} \cdot \left(n \cdot \left(n \cdot n\right)\right)\right)\right)\right)\right)\\
\mathbf{elif}\;n \le 7.810496096004307 \cdot 10^{+243}:\\
\;\;\;\;\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{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(e^{\left(\left(\mathsf{log1p}\left(\frac{i}{n}\right)\right)\right) \cdot n}, 100, -100\right)}{\frac{i}{n}}\\
\end{array}double f(double i, double n) {
double r4467016 = 100.0;
double r4467017 = 1.0;
double r4467018 = i;
double r4467019 = n;
double r4467020 = r4467018 / r4467019;
double r4467021 = r4467017 + r4467020;
double r4467022 = pow(r4467021, r4467019);
double r4467023 = r4467022 - r4467017;
double r4467024 = r4467023 / r4467020;
double r4467025 = r4467016 * r4467024;
return r4467025;
}
double f(double i, double n) {
double r4467026 = n;
double r4467027 = -5.4638361325642236e+190;
bool r4467028 = r4467026 <= r4467027;
double r4467029 = i;
double r4467030 = r4467029 / r4467026;
double r4467031 = log1p(r4467030);
double r4467032 = /* ERROR: no posit support in C */;
double r4467033 = /* ERROR: no posit support in C */;
double r4467034 = r4467033 * r4467026;
double r4467035 = exp(r4467034);
double r4467036 = 100.0;
double r4467037 = -100.0;
double r4467038 = fma(r4467035, r4467036, r4467037);
double r4467039 = r4467038 / r4467030;
double r4467040 = -4.0425022022190223e+43;
bool r4467041 = r4467026 <= r4467040;
double r4467042 = r4467029 * r4467029;
double r4467043 = 50.0;
double r4467044 = 16.666666666666668;
double r4467045 = r4467029 * r4467044;
double r4467046 = r4467043 + r4467045;
double r4467047 = r4467042 * r4467046;
double r4467048 = fma(r4467036, r4467029, r4467047);
double r4467049 = r4467048 / r4467030;
double r4467050 = -3.763036538905304e+26;
bool r4467051 = r4467026 <= r4467050;
double r4467052 = 1.0;
double r4467053 = r4467052 / r4467030;
double r4467054 = r4467053 * r4467038;
double r4467055 = -2.103154135664;
bool r4467056 = r4467026 <= r4467055;
double r4467057 = -7.6539834001623e-311;
bool r4467058 = r4467026 <= r4467057;
double r4467059 = r4467052 + r4467030;
double r4467060 = pow(r4467059, r4467026);
double r4467061 = fma(r4467060, r4467036, r4467037);
double r4467062 = exp(r4467061);
double r4467063 = log(r4467062);
double r4467064 = r4467063 / r4467030;
double r4467065 = 1.965651820956631e-65;
bool r4467066 = r4467026 <= r4467065;
double r4467067 = log(r4467026);
double r4467068 = r4467026 * r4467067;
double r4467069 = r4467068 * r4467068;
double r4467070 = r4467026 * r4467026;
double r4467071 = r4467026 * r4467070;
double r4467072 = log(r4467029);
double r4467073 = r4467072 * r4467072;
double r4467074 = r4467073 * r4467072;
double r4467075 = r4467071 * r4467074;
double r4467076 = r4467026 * r4467072;
double r4467077 = r4467026 * r4467069;
double r4467078 = r4467072 * r4467077;
double r4467079 = r4467043 * r4467078;
double r4467080 = r4467073 * r4467043;
double r4467081 = r4467070 * r4467080;
double r4467082 = r4467079 + r4467081;
double r4467083 = fma(r4467036, r4467076, r4467082);
double r4467084 = fma(r4467044, r4467075, r4467083);
double r4467085 = fma(r4467069, r4467043, r4467084);
double r4467086 = 33.333333333333336;
double r4467087 = r4467071 * r4467086;
double r4467088 = r4467067 * r4467073;
double r4467089 = r4467026 * r4467036;
double r4467090 = r4467067 * r4467089;
double r4467091 = r4467072 * r4467067;
double r4467092 = r4467091 * r4467070;
double r4467093 = r4467092 * r4467036;
double r4467094 = r4467067 * r4467067;
double r4467095 = r4467094 * r4467067;
double r4467096 = r4467088 + r4467095;
double r4467097 = r4467044 * r4467071;
double r4467098 = r4467096 * r4467097;
double r4467099 = r4467093 + r4467098;
double r4467100 = r4467090 + r4467099;
double r4467101 = fma(r4467087, r4467088, r4467100);
double r4467102 = r4467085 - r4467101;
double r4467103 = r4467053 * r4467102;
double r4467104 = 7.810496096004307e+243;
bool r4467105 = r4467026 <= r4467104;
double r4467106 = r4467105 ? r4467049 : r4467039;
double r4467107 = r4467066 ? r4467103 : r4467106;
double r4467108 = r4467058 ? r4467064 : r4467107;
double r4467109 = r4467056 ? r4467049 : r4467108;
double r4467110 = r4467051 ? r4467054 : r4467109;
double r4467111 = r4467041 ? r4467049 : r4467110;
double r4467112 = r4467028 ? r4467039 : r4467111;
return r4467112;
}




Bits error versus i




Bits error versus n
| Original | 42.1 |
|---|---|
| Target | 42.2 |
| Herbie | 27.9 |
if n < -5.4638361325642236e+190 or 7.810496096004307e+243 < n Initial program 56.1
Simplified56.1
rmApplied add-exp-log56.1
Simplified41.2
rmApplied div-inv41.3
rmApplied insert-posit1639.9
rmApplied un-div-inv39.8
if -5.4638361325642236e+190 < n < -4.0425022022190223e+43 or -3.763036538905304e+26 < n < -2.103154135664 or 1.965651820956631e-65 < n < 7.810496096004307e+243Initial program 50.5
Simplified50.5
Taylor expanded around 0 33.0
Simplified33.0
if -4.0425022022190223e+43 < n < -3.763036538905304e+26Initial program 29.3
Simplified29.3
rmApplied add-exp-log29.3
Simplified47.3
rmApplied div-inv47.3
rmApplied insert-posit1627.9
if -2.103154135664 < n < -7.6539834001623e-311Initial program 15.6
Simplified15.6
rmApplied add-log-exp15.6
if -7.6539834001623e-311 < n < 1.965651820956631e-65Initial program 46.2
Simplified46.2
rmApplied add-exp-log46.2
Simplified46.2
rmApplied div-inv46.2
Taylor expanded around 0 21.4
Simplified21.4
Final simplification27.9
herbie shell --seed 2019139 +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))))