100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -42606.74875587941642152145504951477050781:\\
\;\;\;\;100 \cdot \frac{n}{\frac{i}{{\left(\frac{i}{n}\right)}^{n} - 1}}\\
\mathbf{elif}\;i \le 2.857502826738759766942954155696909688723 \cdot 10^{-25}:\\
\;\;\;\;100 \cdot \left(\frac{\mathsf{fma}\left(i, 1, \mathsf{fma}\left(\log 1, n, \left(i \cdot i\right) \cdot \left(0.5 - 0.5 \cdot \log 1\right)\right)\right)}{i} \cdot n\right)\\
\mathbf{elif}\;i \le 1.494091961828663302085378658485801643661 \cdot 10^{142}:\\
\;\;\;\;\left(100 \cdot n\right) \cdot \frac{1}{\frac{i}{\left(\mathsf{fma}\left(\frac{1}{2}, {\left(\log i\right)}^{2} \cdot {n}^{2}, \mathsf{fma}\left(\frac{1}{2}, {n}^{2} \cdot {\left(\log n\right)}^{2}, \mathsf{fma}\left(\frac{1}{6}, {\left(\log i\right)}^{3} \cdot {n}^{3}, \mathsf{fma}\left(\log i, n, \frac{1}{2} \cdot \left(\log i \cdot \left({n}^{3} \cdot {\left(\log n\right)}^{2}\right)\right)\right)\right)\right)\right) - \log n \cdot \mathsf{fma}\left(n \cdot n, \log i, n\right)\right) - \mathsf{fma}\left(\frac{1}{2}, {\left(\log i\right)}^{2} \cdot \left({n}^{3} \cdot \log n\right), \frac{1}{6} \cdot \left({n}^{3} \cdot {\left(\log n\right)}^{3}\right)\right)}}\\
\mathbf{elif}\;i \le 1.804564161742964970188249145928450773024 \cdot 10^{231}:\\
\;\;\;\;100 \cdot \left(\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot n\right)\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{fma}\left(\frac{1}{2}, {\left(\log i\right)}^{2} \cdot {n}^{2}, \left(\mathsf{fma}\left(\frac{1}{2}, {n}^{2} \cdot {\left(\log n\right)}^{2}, \mathsf{fma}\left(\frac{1}{6}, {\left(\log i\right)}^{3} \cdot {n}^{3}, \mathsf{fma}\left(\log i, n, \frac{1}{2} \cdot \left(\log i \cdot \left({n}^{3} \cdot {\left(\log n\right)}^{2}\right)\right)\right)\right)\right) - \log n \cdot \left(\log i \cdot {n}^{2} + n\right)\right) - \mathsf{fma}\left(\frac{1}{2}, {\left(\log i\right)}^{2} \cdot \left({n}^{3} \cdot \log n\right), \frac{1}{6} \cdot \left({n}^{3} \cdot {\left(\log n\right)}^{3}\right)\right)\right)}}\\
\end{array}double f(double i, double n) {
double r131485 = 100.0;
double r131486 = 1.0;
double r131487 = i;
double r131488 = n;
double r131489 = r131487 / r131488;
double r131490 = r131486 + r131489;
double r131491 = pow(r131490, r131488);
double r131492 = r131491 - r131486;
double r131493 = r131492 / r131489;
double r131494 = r131485 * r131493;
return r131494;
}
double f(double i, double n) {
double r131495 = i;
double r131496 = -42606.74875587942;
bool r131497 = r131495 <= r131496;
double r131498 = 100.0;
double r131499 = n;
double r131500 = r131495 / r131499;
double r131501 = pow(r131500, r131499);
double r131502 = 1.0;
double r131503 = r131501 - r131502;
double r131504 = r131495 / r131503;
double r131505 = r131499 / r131504;
double r131506 = r131498 * r131505;
double r131507 = 2.8575028267387598e-25;
bool r131508 = r131495 <= r131507;
double r131509 = log(r131502);
double r131510 = r131495 * r131495;
double r131511 = 0.5;
double r131512 = r131511 * r131509;
double r131513 = r131511 - r131512;
double r131514 = r131510 * r131513;
double r131515 = fma(r131509, r131499, r131514);
double r131516 = fma(r131495, r131502, r131515);
double r131517 = r131516 / r131495;
double r131518 = r131517 * r131499;
double r131519 = r131498 * r131518;
double r131520 = 1.4940919618286633e+142;
bool r131521 = r131495 <= r131520;
double r131522 = r131498 * r131499;
double r131523 = 1.0;
double r131524 = 0.5;
double r131525 = log(r131495);
double r131526 = 2.0;
double r131527 = pow(r131525, r131526);
double r131528 = pow(r131499, r131526);
double r131529 = r131527 * r131528;
double r131530 = log(r131499);
double r131531 = pow(r131530, r131526);
double r131532 = r131528 * r131531;
double r131533 = 0.16666666666666666;
double r131534 = 3.0;
double r131535 = pow(r131525, r131534);
double r131536 = pow(r131499, r131534);
double r131537 = r131535 * r131536;
double r131538 = r131536 * r131531;
double r131539 = r131525 * r131538;
double r131540 = r131524 * r131539;
double r131541 = fma(r131525, r131499, r131540);
double r131542 = fma(r131533, r131537, r131541);
double r131543 = fma(r131524, r131532, r131542);
double r131544 = fma(r131524, r131529, r131543);
double r131545 = r131499 * r131499;
double r131546 = fma(r131545, r131525, r131499);
double r131547 = r131530 * r131546;
double r131548 = r131544 - r131547;
double r131549 = r131536 * r131530;
double r131550 = r131527 * r131549;
double r131551 = pow(r131530, r131534);
double r131552 = r131536 * r131551;
double r131553 = r131533 * r131552;
double r131554 = fma(r131524, r131550, r131553);
double r131555 = r131548 - r131554;
double r131556 = r131495 / r131555;
double r131557 = r131523 / r131556;
double r131558 = r131522 * r131557;
double r131559 = 1.804564161742965e+231;
bool r131560 = r131495 <= r131559;
double r131561 = r131502 + r131500;
double r131562 = pow(r131561, r131499);
double r131563 = r131562 - r131502;
double r131564 = r131563 / r131495;
double r131565 = r131564 * r131499;
double r131566 = r131498 * r131565;
double r131567 = r131525 * r131528;
double r131568 = r131567 + r131499;
double r131569 = r131530 * r131568;
double r131570 = r131543 - r131569;
double r131571 = r131570 - r131554;
double r131572 = fma(r131524, r131529, r131571);
double r131573 = r131495 / r131572;
double r131574 = r131499 / r131573;
double r131575 = r131498 * r131574;
double r131576 = r131560 ? r131566 : r131575;
double r131577 = r131521 ? r131558 : r131576;
double r131578 = r131508 ? r131519 : r131577;
double r131579 = r131497 ? r131506 : r131578;
return r131579;
}




Bits error versus i




Bits error versus n
| Original | 43.1 |
|---|---|
| Target | 42.8 |
| Herbie | 19.0 |
if i < -42606.74875587942Initial program 27.8
Taylor expanded around inf 64.0
Simplified18.8
if -42606.74875587942 < i < 2.8575028267387598e-25Initial program 50.7
rmApplied associate-/r/50.4
Taylor expanded around 0 17.0
Simplified17.0
if 2.8575028267387598e-25 < i < 1.4940919618286633e+142Initial program 38.2
Taylor expanded around inf 36.7
Simplified38.7
rmApplied div-inv38.7
Applied associate-*r*38.7
Taylor expanded around 0 22.0
Simplified22.0
if 1.4940919618286633e+142 < i < 1.804564161742965e+231Initial program 32.1
rmApplied associate-/r/32.1
if 1.804564161742965e+231 < i Initial program 29.1
Taylor expanded around inf 33.3
Simplified29.1
Taylor expanded around 0 32.1
Simplified32.1
Final simplification19.0
herbie shell --seed 2019325 +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))))