100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -2.7755718047646672 \cdot 10^{-12}:\\
\;\;\;\;\frac{\mathsf{fma}\left(e^{n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)}, 100, -100\right)}{\frac{i}{n}}\\
\mathbf{elif}\;i \le 4.5457902375689345:\\
\;\;\;\;\mathsf{fma}\left(\left(i \cdot i\right) \cdot n, \frac{50}{3}, n \cdot \left(100 + i \cdot 50\right)\right)\\
\mathbf{else}:\\
\;\;\;\;n \cdot \frac{\mathsf{fma}\left({\left(\frac{i}{n} + 1\right)}^{n}, 100, -100\right)}{i}\\
\end{array}double f(double i, double n) {
double r3741233 = 100.0;
double r3741234 = 1.0;
double r3741235 = i;
double r3741236 = n;
double r3741237 = r3741235 / r3741236;
double r3741238 = r3741234 + r3741237;
double r3741239 = pow(r3741238, r3741236);
double r3741240 = r3741239 - r3741234;
double r3741241 = r3741240 / r3741237;
double r3741242 = r3741233 * r3741241;
return r3741242;
}
double f(double i, double n) {
double r3741243 = i;
double r3741244 = -2.7755718047646672e-12;
bool r3741245 = r3741243 <= r3741244;
double r3741246 = n;
double r3741247 = r3741243 / r3741246;
double r3741248 = log1p(r3741247);
double r3741249 = r3741246 * r3741248;
double r3741250 = exp(r3741249);
double r3741251 = 100.0;
double r3741252 = -100.0;
double r3741253 = fma(r3741250, r3741251, r3741252);
double r3741254 = r3741253 / r3741247;
double r3741255 = 4.5457902375689345;
bool r3741256 = r3741243 <= r3741255;
double r3741257 = r3741243 * r3741243;
double r3741258 = r3741257 * r3741246;
double r3741259 = 16.666666666666668;
double r3741260 = 50.0;
double r3741261 = r3741243 * r3741260;
double r3741262 = r3741251 + r3741261;
double r3741263 = r3741246 * r3741262;
double r3741264 = fma(r3741258, r3741259, r3741263);
double r3741265 = 1.0;
double r3741266 = r3741247 + r3741265;
double r3741267 = pow(r3741266, r3741246);
double r3741268 = fma(r3741267, r3741251, r3741252);
double r3741269 = r3741268 / r3741243;
double r3741270 = r3741246 * r3741269;
double r3741271 = r3741256 ? r3741264 : r3741270;
double r3741272 = r3741245 ? r3741254 : r3741271;
return r3741272;
}




Bits error versus i




Bits error versus n
| Original | 42.0 |
|---|---|
| Target | 42.3 |
| Herbie | 16.2 |
if i < -2.7755718047646672e-12Initial program 27.8
Simplified27.8
rmApplied add-exp-log27.9
Applied pow-exp27.9
Simplified6.6
if -2.7755718047646672e-12 < i < 4.5457902375689345Initial program 50.1
Simplified50.1
Taylor expanded around 0 33.1
Simplified33.1
Taylor expanded around 0 16.8
Simplified16.8
if 4.5457902375689345 < i Initial program 31.0
Simplified31.0
rmApplied associate-/r/31.0
Final simplification16.2
herbie shell --seed 2019152 +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))))