100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;n \le -1.496898897117080818951261662080240322195 \cdot 10^{97}:\\
\;\;\;\;100 \cdot \frac{n \cdot \mathsf{fma}\left(-\left(i \cdot 0.5\right) \cdot \log 1, i, \mathsf{fma}\left(n, \log 1, \mathsf{fma}\left(0.5, i, 1\right) \cdot i\right)\right)}{i}\\
\mathbf{elif}\;n \le -3.085998543664637255444788181328484588588 \cdot 10^{59}:\\
\;\;\;\;100 \cdot \left(\frac{{\left(\frac{i}{n} + 1\right)}^{n}}{\frac{i}{n}} - \frac{1}{\frac{i}{n}}\right)\\
\mathbf{elif}\;n \le -2.461738487841221623142473617917858064175:\\
\;\;\;\;100 \cdot \frac{n \cdot \mathsf{fma}\left(-\left(i \cdot 0.5\right) \cdot \log 1, i, \mathsf{fma}\left(n, \log 1, \mathsf{fma}\left(0.5, i, 1\right) \cdot i\right)\right)}{i}\\
\mathbf{elif}\;n \le -3.388139377181462070651587205567840486657 \cdot 10^{-307}:\\
\;\;\;\;100 \cdot \left(\frac{{\left(\frac{i}{n} + 1\right)}^{n}}{\frac{i}{n}} - \frac{1}{\frac{i}{n}}\right)\\
\mathbf{elif}\;n \le 4.930404890743995467239903225253781019029 \cdot 10^{-103}:\\
\;\;\;\;100 \cdot \frac{\mathsf{fma}\left(\log 1, n, \mathsf{fma}\left(i, 1, 1\right)\right) - 1}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \left(n \cdot \left(\left(\frac{\mathsf{fma}\left(-\left(i \cdot 0.5\right) \cdot \log 1, i, \mathsf{fma}\left(n, \log 1, \mathsf{fma}\left(0.5, i, 1\right) \cdot i\right)\right)}{i}\right)\right)\right)\\
\end{array}double f(double i, double n) {
double r5898518 = 100.0;
double r5898519 = 1.0;
double r5898520 = i;
double r5898521 = n;
double r5898522 = r5898520 / r5898521;
double r5898523 = r5898519 + r5898522;
double r5898524 = pow(r5898523, r5898521);
double r5898525 = r5898524 - r5898519;
double r5898526 = r5898525 / r5898522;
double r5898527 = r5898518 * r5898526;
return r5898527;
}
double f(double i, double n) {
double r5898528 = n;
double r5898529 = -1.4968988971170808e+97;
bool r5898530 = r5898528 <= r5898529;
double r5898531 = 100.0;
double r5898532 = i;
double r5898533 = 0.5;
double r5898534 = r5898532 * r5898533;
double r5898535 = 1.0;
double r5898536 = log(r5898535);
double r5898537 = r5898534 * r5898536;
double r5898538 = -r5898537;
double r5898539 = fma(r5898533, r5898532, r5898535);
double r5898540 = r5898539 * r5898532;
double r5898541 = fma(r5898528, r5898536, r5898540);
double r5898542 = fma(r5898538, r5898532, r5898541);
double r5898543 = r5898528 * r5898542;
double r5898544 = r5898543 / r5898532;
double r5898545 = r5898531 * r5898544;
double r5898546 = -3.0859985436646373e+59;
bool r5898547 = r5898528 <= r5898546;
double r5898548 = r5898532 / r5898528;
double r5898549 = r5898548 + r5898535;
double r5898550 = pow(r5898549, r5898528);
double r5898551 = r5898550 / r5898548;
double r5898552 = r5898535 / r5898548;
double r5898553 = r5898551 - r5898552;
double r5898554 = r5898531 * r5898553;
double r5898555 = -2.4617384878412216;
bool r5898556 = r5898528 <= r5898555;
double r5898557 = -3.388139377181462e-307;
bool r5898558 = r5898528 <= r5898557;
double r5898559 = 4.930404890743995e-103;
bool r5898560 = r5898528 <= r5898559;
double r5898561 = 1.0;
double r5898562 = fma(r5898532, r5898535, r5898561);
double r5898563 = fma(r5898536, r5898528, r5898562);
double r5898564 = r5898563 - r5898535;
double r5898565 = r5898564 / r5898548;
double r5898566 = r5898531 * r5898565;
double r5898567 = r5898542 / r5898532;
double r5898568 = /* ERROR: no posit support in C */;
double r5898569 = /* ERROR: no posit support in C */;
double r5898570 = r5898528 * r5898569;
double r5898571 = r5898531 * r5898570;
double r5898572 = r5898560 ? r5898566 : r5898571;
double r5898573 = r5898558 ? r5898554 : r5898572;
double r5898574 = r5898556 ? r5898545 : r5898573;
double r5898575 = r5898547 ? r5898554 : r5898574;
double r5898576 = r5898530 ? r5898545 : r5898575;
return r5898576;
}




Bits error versus i




Bits error versus n
| Original | 42.9 |
|---|---|
| Target | 43.1 |
| Herbie | 22.1 |
if n < -1.4968988971170808e+97 or -3.0859985436646373e+59 < n < -2.4617384878412216Initial program 46.6
Taylor expanded around 0 46.2
Simplified46.2
rmApplied associate-/r/26.4
Simplified26.4
rmApplied associate-*l/26.5
if -1.4968988971170808e+97 < n < -3.0859985436646373e+59 or -2.4617384878412216 < n < -3.388139377181462e-307Initial program 18.2
rmApplied div-sub18.2
if -3.388139377181462e-307 < n < 4.930404890743995e-103Initial program 44.9
Taylor expanded around 0 34.1
Simplified34.1
if 4.930404890743995e-103 < n Initial program 60.1
Taylor expanded around 0 33.6
Simplified33.6
rmApplied associate-/r/15.9
Simplified15.9
rmApplied insert-posit1616.2
Final simplification22.1
herbie shell --seed 2019168 +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))))