double f(double i, double n) {
double r34722033 = 100.0;
double r34722034 = 1.0;
double r34722035 = i;
double r34722036 = n;
double r34722037 = r34722035 / r34722036;
double r34722038 = r34722034 + r34722037;
double r34722039 = pow(r34722038, r34722036);
double r34722040 = r34722039 - r34722034;
double r34722041 = r34722040 / r34722037;
double r34722042 = r34722033 * r34722041;
return r34722042;
}
double f(double i, double n) {
double r34722043 = i;
double r34722044 = -8.017010211892022e-13;
bool r34722045 = r34722043 <= r34722044;
double r34722046 = 100.0;
double r34722047 = n;
double r34722048 = r34722043 / r34722047;
double r34722049 = log1p(r34722048);
double r34722050 = r34722049 * r34722047;
double r34722051 = exp(r34722050);
double r34722052 = -100.0;
double r34722053 = fma(r34722046, r34722051, r34722052);
double r34722054 = r34722053 / r34722048;
double r34722055 = 3.850047993601629;
bool r34722056 = r34722043 <= r34722055;
double r34722057 = 16.666666666666668;
double r34722058 = 50.0;
double r34722059 = fma(r34722043, r34722057, r34722058);
double r34722060 = fma(r34722043, r34722059, r34722046);
double r34722061 = r34722060 / r34722043;
double r34722062 = r34722047 * r34722043;
double r34722063 = r34722061 * r34722062;
double r34722064 = 0.0;
double r34722065 = r34722056 ? r34722063 : r34722064;
double r34722066 = r34722045 ? r34722054 : r34722065;
return r34722066;
}
100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -8.017010211892022 \cdot 10^{-13}:\\
\;\;\;\;\frac{(100 \cdot \left(e^{\log_* (1 + \frac{i}{n}) \cdot n}\right) + -100)_*}{\frac{i}{n}}\\
\mathbf{elif}\;i \le 3.850047993601629:\\
\;\;\;\;\frac{(i \cdot \left((i \cdot \frac{50}{3} + 50)_*\right) + 100)_*}{i} \cdot \left(n \cdot i\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}



Bits error versus i




Bits error versus n
| Original | 42.6 |
|---|---|
| Target | 41.9 |
| Herbie | 15.3 |
if i < -8.017010211892022e-13Initial program 30.4
Simplified30.4
rmApplied add-exp-log30.4
Applied pow-exp30.4
Simplified7.3
if -8.017010211892022e-13 < i < 3.850047993601629Initial program 49.8
Simplified49.8
Taylor expanded around 0 32.5
Simplified32.5
rmApplied div-inv32.5
Applied times-frac15.4
Simplified15.3
if 3.850047993601629 < i Initial program 31.1
Simplified31.1
Taylor expanded around 0 29.4
Final simplification15.3
herbie shell --seed 2019101 +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))))