100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;n \le -7.76693767745361788861631953913126532955 \cdot 10^{94}:\\
\;\;\;\;\left(100 \cdot \frac{\mathsf{fma}\left(i, 1, \left(0.5 \cdot {i}^{2} + \log 1 \cdot n\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)\right)}{i}\right) \cdot n\\
\mathbf{elif}\;n \le -9.519350012649904306163831713839410413139 \cdot 10^{-251}:\\
\;\;\;\;100 \cdot \left(\frac{{\left(1 + \frac{i}{n}\right)}^{n}}{\frac{i}{n}} - \frac{1}{\frac{i}{n}}\right)\\
\mathbf{elif}\;n \le 1.613414883038850832801467887537631845006 \cdot 10^{-130}:\\
\;\;\;\;100 \cdot \frac{\mathsf{fma}\left(1, i, \mathsf{fma}\left(\log 1, n, 1\right)\right) - 1}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;\left(100 \cdot \frac{\mathsf{fma}\left(i, 1, \left(0.5 \cdot {i}^{2} + \log 1 \cdot n\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)\right)}{i}\right) \cdot n\\
\end{array}double f(double i, double n) {
double r137441 = 100.0;
double r137442 = 1.0;
double r137443 = i;
double r137444 = n;
double r137445 = r137443 / r137444;
double r137446 = r137442 + r137445;
double r137447 = pow(r137446, r137444);
double r137448 = r137447 - r137442;
double r137449 = r137448 / r137445;
double r137450 = r137441 * r137449;
return r137450;
}
double f(double i, double n) {
double r137451 = n;
double r137452 = -7.766937677453618e+94;
bool r137453 = r137451 <= r137452;
double r137454 = 100.0;
double r137455 = i;
double r137456 = 1.0;
double r137457 = 0.5;
double r137458 = 2.0;
double r137459 = pow(r137455, r137458);
double r137460 = r137457 * r137459;
double r137461 = log(r137456);
double r137462 = r137461 * r137451;
double r137463 = r137460 + r137462;
double r137464 = r137459 * r137461;
double r137465 = r137457 * r137464;
double r137466 = r137463 - r137465;
double r137467 = fma(r137455, r137456, r137466);
double r137468 = r137467 / r137455;
double r137469 = r137454 * r137468;
double r137470 = r137469 * r137451;
double r137471 = -9.519350012649904e-251;
bool r137472 = r137451 <= r137471;
double r137473 = r137455 / r137451;
double r137474 = r137456 + r137473;
double r137475 = pow(r137474, r137451);
double r137476 = r137475 / r137473;
double r137477 = r137456 / r137473;
double r137478 = r137476 - r137477;
double r137479 = r137454 * r137478;
double r137480 = 1.6134148830388508e-130;
bool r137481 = r137451 <= r137480;
double r137482 = 1.0;
double r137483 = fma(r137461, r137451, r137482);
double r137484 = fma(r137456, r137455, r137483);
double r137485 = r137484 - r137456;
double r137486 = r137485 / r137473;
double r137487 = r137454 * r137486;
double r137488 = r137481 ? r137487 : r137470;
double r137489 = r137472 ? r137479 : r137488;
double r137490 = r137453 ? r137470 : r137489;
return r137490;
}




Bits error versus i




Bits error versus n
| Original | 43.0 |
|---|---|
| Target | 42.8 |
| Herbie | 22.9 |
if n < -7.766937677453618e+94 or 1.6134148830388508e-130 < n Initial program 55.3
rmApplied associate-/r/55.0
Applied associate-*r*55.0
Taylor expanded around 0 21.5
Simplified21.5
rmApplied fma-udef21.5
if -7.766937677453618e+94 < n < -9.519350012649904e-251Initial program 23.8
rmApplied div-sub23.9
if -9.519350012649904e-251 < n < 1.6134148830388508e-130Initial program 35.4
Taylor expanded around 0 26.0
Simplified26.0
Final simplification22.9
herbie shell --seed 2019353 +o rules:numerics
(FPCore (i n)
:name "Compound Interest"
:precision binary64
: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))))