100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -2.2717441078324636 \cdot 10^{-10}:\\
\;\;\;\;100 \cdot \left(\frac{{\left(1 + \frac{i}{n}\right)}^{n}}{\frac{i}{n}} - \frac{1}{\frac{i}{n}}\right)\\
\mathbf{elif}\;i \le 2.5704520336039343 \cdot 10^{-23}:\\
\;\;\;\;\left(100 \cdot \frac{\mathsf{fma}\left(i, 1, \mathsf{fma}\left(0.5, {i}^{2}, \log 1 \cdot n\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)\right)}{i}\right) \cdot n\\
\mathbf{elif}\;i \le 1.5471622621860444 \cdot 10^{204}:\\
\;\;\;\;100 \cdot \left(\frac{{\left(1 + \frac{i}{n}\right)}^{n}}{\frac{i}{n}} - \frac{1}{\frac{i}{n}}\right)\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{\mathsf{fma}\left(1, i, \mathsf{fma}\left(\log 1, n, 1\right)\right) - 1}{\frac{i}{n}}\\
\end{array}double f(double i, double n) {
double r131465 = 100.0;
double r131466 = 1.0;
double r131467 = i;
double r131468 = n;
double r131469 = r131467 / r131468;
double r131470 = r131466 + r131469;
double r131471 = pow(r131470, r131468);
double r131472 = r131471 - r131466;
double r131473 = r131472 / r131469;
double r131474 = r131465 * r131473;
return r131474;
}
double f(double i, double n) {
double r131475 = i;
double r131476 = -2.2717441078324636e-10;
bool r131477 = r131475 <= r131476;
double r131478 = 100.0;
double r131479 = 1.0;
double r131480 = n;
double r131481 = r131475 / r131480;
double r131482 = r131479 + r131481;
double r131483 = pow(r131482, r131480);
double r131484 = r131483 / r131481;
double r131485 = r131479 / r131481;
double r131486 = r131484 - r131485;
double r131487 = r131478 * r131486;
double r131488 = 2.5704520336039343e-23;
bool r131489 = r131475 <= r131488;
double r131490 = 0.5;
double r131491 = 2.0;
double r131492 = pow(r131475, r131491);
double r131493 = log(r131479);
double r131494 = r131493 * r131480;
double r131495 = fma(r131490, r131492, r131494);
double r131496 = r131492 * r131493;
double r131497 = r131490 * r131496;
double r131498 = r131495 - r131497;
double r131499 = fma(r131475, r131479, r131498);
double r131500 = r131499 / r131475;
double r131501 = r131478 * r131500;
double r131502 = r131501 * r131480;
double r131503 = 1.5471622621860444e+204;
bool r131504 = r131475 <= r131503;
double r131505 = 1.0;
double r131506 = fma(r131493, r131480, r131505);
double r131507 = fma(r131479, r131475, r131506);
double r131508 = r131507 - r131479;
double r131509 = r131508 / r131481;
double r131510 = r131478 * r131509;
double r131511 = r131504 ? r131487 : r131510;
double r131512 = r131489 ? r131502 : r131511;
double r131513 = r131477 ? r131487 : r131512;
return r131513;
}




Bits error versus i




Bits error versus n
| Original | 48.0 |
|---|---|
| Target | 48.1 |
| Herbie | 17.6 |
if i < -2.2717441078324636e-10 or 2.5704520336039343e-23 < i < 1.5471622621860444e+204Initial program 31.5
rmApplied div-sub31.5
if -2.2717441078324636e-10 < i < 2.5704520336039343e-23Initial program 58.5
Taylor expanded around 0 26.1
Simplified26.1
rmApplied associate-/r/8.5
Applied associate-*r*8.5
if 1.5471622621860444e+204 < i Initial program 33.2
Taylor expanded around 0 32.5
Simplified32.5
Final simplification17.6
herbie shell --seed 2020065 +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))))