100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;n \le -1.2657089139394981:\\
\;\;\;\;100 \cdot \frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{\frac{i}{n}}\\
\mathbf{elif}\;n \le -5.215706912201119 \cdot 10^{-75}:\\
\;\;\;\;100 \cdot \frac{\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i}}{\frac{1}{n}}\\
\mathbf{elif}\;n \le -1.2129113627355937 \cdot 10^{-111}:\\
\;\;\;\;\left(n \cdot \mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)\right) \cdot \frac{100}{i}\\
\mathbf{elif}\;n \le 7.188766975051312 \cdot 10^{-261}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{\frac{i}{n}}\\
\end{array}double f(double i, double n) {
double r2191463 = 100.0;
double r2191464 = 1.0;
double r2191465 = i;
double r2191466 = n;
double r2191467 = r2191465 / r2191466;
double r2191468 = r2191464 + r2191467;
double r2191469 = pow(r2191468, r2191466);
double r2191470 = r2191469 - r2191464;
double r2191471 = r2191470 / r2191467;
double r2191472 = r2191463 * r2191471;
return r2191472;
}
double f(double i, double n) {
double r2191473 = n;
double r2191474 = -1.2657089139394981;
bool r2191475 = r2191473 <= r2191474;
double r2191476 = 100.0;
double r2191477 = i;
double r2191478 = r2191477 / r2191473;
double r2191479 = log1p(r2191478);
double r2191480 = r2191473 * r2191479;
double r2191481 = expm1(r2191480);
double r2191482 = r2191481 / r2191478;
double r2191483 = r2191476 * r2191482;
double r2191484 = -5.215706912201119e-75;
bool r2191485 = r2191473 <= r2191484;
double r2191486 = 1.0;
double r2191487 = r2191486 + r2191478;
double r2191488 = pow(r2191487, r2191473);
double r2191489 = r2191488 - r2191486;
double r2191490 = r2191489 / r2191477;
double r2191491 = r2191486 / r2191473;
double r2191492 = r2191490 / r2191491;
double r2191493 = r2191476 * r2191492;
double r2191494 = -1.2129113627355937e-111;
bool r2191495 = r2191473 <= r2191494;
double r2191496 = r2191473 * r2191481;
double r2191497 = r2191476 / r2191477;
double r2191498 = r2191496 * r2191497;
double r2191499 = 7.188766975051312e-261;
bool r2191500 = r2191473 <= r2191499;
double r2191501 = 0.0;
double r2191502 = r2191500 ? r2191501 : r2191483;
double r2191503 = r2191495 ? r2191498 : r2191502;
double r2191504 = r2191485 ? r2191493 : r2191503;
double r2191505 = r2191475 ? r2191483 : r2191504;
return r2191505;
}




Bits error versus i




Bits error versus n
Results
| Original | 42.2 |
|---|---|
| Target | 42.2 |
| Herbie | 18.5 |
if n < -1.2657089139394981 or 7.188766975051312e-261 < n Initial program 51.3
rmApplied add-exp-log54.5
Applied pow-exp54.5
Applied expm1-def50.5
rmApplied log1p-expm1-u50.5
Simplified19.8
if -1.2657089139394981 < n < -5.215706912201119e-75Initial program 18.2
rmApplied div-inv18.2
Applied associate-/r*18.4
if -5.215706912201119e-75 < n < -1.2129113627355937e-111Initial program 20.2
rmApplied add-exp-log20.2
Applied pow-exp20.2
Applied expm1-def2.2
rmApplied log1p-expm1-u2.2
Simplified29.6
rmApplied associate-*r/29.5
rmApplied div-inv29.6
Applied times-frac20.6
Simplified20.5
if -1.2129113627355937e-111 < n < 7.188766975051312e-261Initial program 16.4
rmApplied add-exp-log16.4
Applied pow-exp16.4
Applied expm1-def6.6
Taylor expanded around 0 12.4
Final simplification18.5
herbie shell --seed 2019154 +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))))