100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -0.9893212200252493593310987307631876319647:\\
\;\;\;\;100 \cdot \frac{\frac{{\left(\frac{i}{n} + 1\right)}^{\left(n \cdot 2\right)} - 1 \cdot 1}{{\left(\frac{i}{n} + 1\right)}^{n} + 1}}{\frac{i}{n}}\\
\mathbf{elif}\;i \le 1.508652436303369411416630768794228112384 \cdot 10^{-9}:\\
\;\;\;\;100 \cdot \left(\left(n \cdot \left(\mathsf{fma}\left(n, \log 1, i \cdot \left(0.5 \cdot i + 1\right)\right) - \left(0.5 \cdot \left(i \cdot i\right)\right) \cdot \log 1\right)\right) \cdot \frac{1}{i}\right)\\
\mathbf{elif}\;i \le 8.608246042115979009006453659316669705257 \cdot 10^{235}:\\
\;\;\;\;100 \cdot \frac{{\left({\left(\frac{i}{n} + 1\right)}^{n}\right)}^{3} - {1}^{3}}{\frac{i \cdot \mathsf{fma}\left(1, {\left(\frac{i}{n} + 1\right)}^{n} + 1, {\left(\frac{i}{n} + 1\right)}^{\left(n \cdot 2\right)}\right)}{n}}\\
\mathbf{elif}\;i \le 1.844738975002478002763642496553644874398 \cdot 10^{296}:\\
\;\;\;\;\frac{\mathsf{fma}\left(n, \log 1, \mathsf{fma}\left(i, 1, 1\right)\right) - 1}{\frac{i}{n}} \cdot 100\\
\mathbf{else}:\\
\;\;\;\;\left(100 \cdot n\right) \cdot \frac{{\left(\frac{i}{n} + 1\right)}^{n} - 1}{i}\\
\end{array}double f(double i, double n) {
double r102475 = 100.0;
double r102476 = 1.0;
double r102477 = i;
double r102478 = n;
double r102479 = r102477 / r102478;
double r102480 = r102476 + r102479;
double r102481 = pow(r102480, r102478);
double r102482 = r102481 - r102476;
double r102483 = r102482 / r102479;
double r102484 = r102475 * r102483;
return r102484;
}
double f(double i, double n) {
double r102485 = i;
double r102486 = -0.9893212200252494;
bool r102487 = r102485 <= r102486;
double r102488 = 100.0;
double r102489 = n;
double r102490 = r102485 / r102489;
double r102491 = 1.0;
double r102492 = r102490 + r102491;
double r102493 = 2.0;
double r102494 = r102489 * r102493;
double r102495 = pow(r102492, r102494);
double r102496 = r102491 * r102491;
double r102497 = r102495 - r102496;
double r102498 = pow(r102492, r102489);
double r102499 = r102498 + r102491;
double r102500 = r102497 / r102499;
double r102501 = r102500 / r102490;
double r102502 = r102488 * r102501;
double r102503 = 1.5086524363033694e-09;
bool r102504 = r102485 <= r102503;
double r102505 = log(r102491);
double r102506 = 0.5;
double r102507 = r102506 * r102485;
double r102508 = r102507 + r102491;
double r102509 = r102485 * r102508;
double r102510 = fma(r102489, r102505, r102509);
double r102511 = r102485 * r102485;
double r102512 = r102506 * r102511;
double r102513 = r102512 * r102505;
double r102514 = r102510 - r102513;
double r102515 = r102489 * r102514;
double r102516 = 1.0;
double r102517 = r102516 / r102485;
double r102518 = r102515 * r102517;
double r102519 = r102488 * r102518;
double r102520 = 8.608246042115979e+235;
bool r102521 = r102485 <= r102520;
double r102522 = 3.0;
double r102523 = pow(r102498, r102522);
double r102524 = pow(r102491, r102522);
double r102525 = r102523 - r102524;
double r102526 = fma(r102491, r102499, r102495);
double r102527 = r102485 * r102526;
double r102528 = r102527 / r102489;
double r102529 = r102525 / r102528;
double r102530 = r102488 * r102529;
double r102531 = 1.844738975002478e+296;
bool r102532 = r102485 <= r102531;
double r102533 = fma(r102485, r102491, r102516);
double r102534 = fma(r102489, r102505, r102533);
double r102535 = r102534 - r102491;
double r102536 = r102535 / r102490;
double r102537 = r102536 * r102488;
double r102538 = r102488 * r102489;
double r102539 = r102498 - r102491;
double r102540 = r102539 / r102485;
double r102541 = r102538 * r102540;
double r102542 = r102532 ? r102537 : r102541;
double r102543 = r102521 ? r102530 : r102542;
double r102544 = r102504 ? r102519 : r102543;
double r102545 = r102487 ? r102502 : r102544;
return r102545;
}




Bits error versus i




Bits error versus n
| Original | 43.4 |
|---|---|
| Target | 43.3 |
| Herbie | 20.5 |
if i < -0.9893212200252494Initial program 27.9
rmApplied flip--27.9
Simplified27.9
Simplified27.9
if -0.9893212200252494 < i < 1.5086524363033694e-09Initial program 51.2
Taylor expanded around 0 32.6
Simplified32.6
rmApplied div-inv32.7
Applied *-un-lft-identity32.7
Applied times-frac15.1
Simplified15.1
if 1.5086524363033694e-09 < i < 8.608246042115979e+235Initial program 33.3
rmApplied flip3--33.3
Applied associate-/l/33.3
Simplified33.3
if 8.608246042115979e+235 < i < 1.844738975002478e+296Initial program 32.1
Taylor expanded around 0 34.0
Simplified34.0
if 1.844738975002478e+296 < i Initial program 28.4
rmApplied pow128.4
Applied pow128.4
Applied pow-prod-down28.4
Simplified28.4
Final simplification20.5
herbie shell --seed 2019194 +o rules:numerics
(FPCore (i n)
:name "Compound Interest"
:herbie-target
(* 100.0 (/ (- (exp (* n (if (== (+ 1.0 (/ i n)) 1.0) (/ i n) (/ (* (/ i n) (log (+ 1.0 (/ i n)))) (- (+ (/ i n) 1.0) 1.0))))) 1.0) (/ i n)))
(* 100.0 (/ (- (pow (+ 1.0 (/ i n)) n) 1.0) (/ i n))))