100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -5.163360055787723405136702348322010579229 \cdot 10^{-11}:\\
\;\;\;\;\frac{{\left(\frac{1}{n} \cdot i\right)}^{n} \cdot 100 - 100}{i} \cdot n\\
\mathbf{elif}\;i \le 6.305809243265488292923253978118289242438 \cdot 10^{-10}:\\
\;\;\;\;n \cdot \left(100 \cdot \left(0.5 \cdot i + \left(\mathsf{fma}\left(\frac{\log 1}{i}, n, 1\right) - \log 1 \cdot \left(0.5 \cdot i\right)\right)\right)\right)\\
\mathbf{elif}\;i \le 2.565130334196551364557031790272495063197 \cdot 10^{190}:\\
\;\;\;\;\frac{{\left(\frac{1}{n} \cdot i\right)}^{n} \cdot 100 - 100}{i} \cdot n\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(1, i, \mathsf{fma}\left(\log 1, n, 1\right)\right) - 1}{\frac{i}{n}} \cdot 100\\
\end{array}double f(double i, double n) {
double r7903614 = 100.0;
double r7903615 = 1.0;
double r7903616 = i;
double r7903617 = n;
double r7903618 = r7903616 / r7903617;
double r7903619 = r7903615 + r7903618;
double r7903620 = pow(r7903619, r7903617);
double r7903621 = r7903620 - r7903615;
double r7903622 = r7903621 / r7903618;
double r7903623 = r7903614 * r7903622;
return r7903623;
}
double f(double i, double n) {
double r7903624 = i;
double r7903625 = -5.1633600557877234e-11;
bool r7903626 = r7903624 <= r7903625;
double r7903627 = 1.0;
double r7903628 = n;
double r7903629 = r7903627 / r7903628;
double r7903630 = r7903629 * r7903624;
double r7903631 = pow(r7903630, r7903628);
double r7903632 = 100.0;
double r7903633 = r7903631 * r7903632;
double r7903634 = r7903633 - r7903632;
double r7903635 = r7903634 / r7903624;
double r7903636 = r7903635 * r7903628;
double r7903637 = 6.305809243265488e-10;
bool r7903638 = r7903624 <= r7903637;
double r7903639 = 0.5;
double r7903640 = r7903639 * r7903624;
double r7903641 = 1.0;
double r7903642 = log(r7903641);
double r7903643 = r7903642 / r7903624;
double r7903644 = fma(r7903643, r7903628, r7903641);
double r7903645 = r7903642 * r7903640;
double r7903646 = r7903644 - r7903645;
double r7903647 = r7903640 + r7903646;
double r7903648 = r7903632 * r7903647;
double r7903649 = r7903628 * r7903648;
double r7903650 = 2.5651303341965514e+190;
bool r7903651 = r7903624 <= r7903650;
double r7903652 = fma(r7903642, r7903628, r7903627);
double r7903653 = fma(r7903641, r7903624, r7903652);
double r7903654 = r7903653 - r7903641;
double r7903655 = r7903624 / r7903628;
double r7903656 = r7903654 / r7903655;
double r7903657 = r7903656 * r7903632;
double r7903658 = r7903651 ? r7903636 : r7903657;
double r7903659 = r7903638 ? r7903649 : r7903658;
double r7903660 = r7903626 ? r7903636 : r7903659;
return r7903660;
}




Bits error versus i




Bits error versus n
| Original | 42.8 |
|---|---|
| Target | 42.7 |
| Herbie | 19.7 |
if i < -5.1633600557877234e-11 or 6.305809243265488e-10 < i < 2.5651303341965514e+190Initial program 29.3
rmApplied associate-/r/29.8
Applied associate-*r*29.8
Taylor expanded around inf 55.4
Simplified23.4
if -5.1633600557877234e-11 < i < 6.305809243265488e-10Initial program 50.7
rmApplied associate-/r/50.4
Applied associate-*r*50.4
Taylor expanded around 0 16.3
Simplified16.3
Taylor expanded around 0 16.3
Simplified16.3
if 2.5651303341965514e+190 < i Initial program 33.1
Taylor expanded around 0 33.3
Simplified33.3
Final simplification19.7
herbie shell --seed 2019200 +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))))