100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -996.2239743031829:\\
\;\;\;\;\frac{\mathsf{fma}\left(100, e^{\mathsf{log1p}\left(\frac{i}{n}\right) \cdot n}, -100\right)}{i} \cdot n\\
\mathbf{elif}\;i \le 1.6984288167482355 \cdot 10^{-42}:\\
\;\;\;\;\left(\mathsf{fma}\left(100, i, \mathsf{fma}\left(i \cdot \left(i \cdot i\right), \frac{50}{3}, 50 \cdot \left(i \cdot i\right)\right)\right) \cdot n\right) \cdot \frac{1}{i}\\
\mathbf{elif}\;i \le 3.952197478939899 \cdot 10^{-39}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\left(n \cdot n\right) \cdot 50, \log n \cdot \log n, \mathsf{fma}\left(\log i \cdot \left(\left(\left(n \cdot n\right) \cdot n\right) \cdot \frac{50}{3}\right), \log i \cdot \log i, \mathsf{fma}\left(100 \cdot n, \log i, \mathsf{fma}\left(\left(\log n \cdot \log n\right) \cdot \left(\log i \cdot \left(\left(n \cdot n\right) \cdot n\right)\right), 50, \left(\left(n \cdot n\right) \cdot 50\right) \cdot \left(\log i \cdot \log i\right)\right)\right)\right)\right) - \mathsf{fma}\left(\left(n \cdot n\right) \cdot n, \frac{100}{3} \cdot \left(\left(\log i \cdot \log i\right) \cdot \log n\right), \mathsf{fma}\left(\log i \cdot \left(\left(n \cdot n\right) \cdot \log n\right), 100, \mathsf{fma}\left(\left(\left(n \cdot n\right) \cdot n\right) \cdot \frac{50}{3}, \mathsf{fma}\left(\log n, \log n \cdot \log n, \left(\log i \cdot \log i\right) \cdot \log n\right), \log n \cdot \left(100 \cdot n\right)\right)\right)\right)}{i} \cdot n\\
\mathbf{elif}\;i \le 1.1417957873827229 \cdot 10^{-05}:\\
\;\;\;\;\left(\mathsf{fma}\left(100, i, \mathsf{fma}\left(i \cdot \left(i \cdot i\right), \frac{50}{3}, 50 \cdot \left(i \cdot i\right)\right)\right) \cdot n\right) \cdot \frac{1}{i}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\left(n \cdot n\right) \cdot 50, \log n \cdot \log n, \mathsf{fma}\left(\left(\left(n \cdot n\right) \cdot n\right) \cdot \frac{50}{3}, \log i \cdot \left(\log i \cdot \log i\right), \mathsf{fma}\left(n \cdot \log i, 100, \mathsf{fma}\left(\frac{100}{3}, \left(\log n \cdot \log n\right) \cdot \left(\log i \cdot \left(\left(n \cdot n\right) \cdot n\right)\right), \mathsf{fma}\left(\frac{50}{3}, \left(\log n \cdot \log n\right) \cdot \left(\log i \cdot \left(\left(n \cdot n\right) \cdot n\right)\right), \left(\left(n \cdot n\right) \cdot 50\right) \cdot \left(\log i \cdot \log i\right)\right)\right)\right)\right)\right) - \mathsf{fma}\left(\left(\left(n \cdot n\right) \cdot n\right) \cdot \frac{100}{3}, \left(\log i \cdot \log i\right) \cdot \log n, \mathsf{fma}\left(\left(n \cdot n\right) \cdot 50, \log i \cdot \log n, \mathsf{fma}\left(\left(n \cdot n\right) \cdot 50, \log i \cdot \log n, \left(\left(\left(n \cdot n\right) \cdot n\right) \cdot \frac{50}{3}\right) \cdot \left(\log n \cdot \left(\log n \cdot \log n\right) + \left(\log i \cdot \log i\right) \cdot \log n\right) + \log n \cdot \left(100 \cdot n\right)\right)\right)\right)}{\frac{i}{n}}\\
\end{array}double f(double i, double n) {
double r2355501 = 100.0;
double r2355502 = 1.0;
double r2355503 = i;
double r2355504 = n;
double r2355505 = r2355503 / r2355504;
double r2355506 = r2355502 + r2355505;
double r2355507 = pow(r2355506, r2355504);
double r2355508 = r2355507 - r2355502;
double r2355509 = r2355508 / r2355505;
double r2355510 = r2355501 * r2355509;
return r2355510;
}
double f(double i, double n) {
double r2355511 = i;
double r2355512 = -996.2239743031829;
bool r2355513 = r2355511 <= r2355512;
double r2355514 = 100.0;
double r2355515 = n;
double r2355516 = r2355511 / r2355515;
double r2355517 = log1p(r2355516);
double r2355518 = r2355517 * r2355515;
double r2355519 = exp(r2355518);
double r2355520 = -100.0;
double r2355521 = fma(r2355514, r2355519, r2355520);
double r2355522 = r2355521 / r2355511;
double r2355523 = r2355522 * r2355515;
double r2355524 = 1.6984288167482355e-42;
bool r2355525 = r2355511 <= r2355524;
double r2355526 = r2355511 * r2355511;
double r2355527 = r2355511 * r2355526;
double r2355528 = 16.666666666666668;
double r2355529 = 50.0;
double r2355530 = r2355529 * r2355526;
double r2355531 = fma(r2355527, r2355528, r2355530);
double r2355532 = fma(r2355514, r2355511, r2355531);
double r2355533 = r2355532 * r2355515;
double r2355534 = 1.0;
double r2355535 = r2355534 / r2355511;
double r2355536 = r2355533 * r2355535;
double r2355537 = 3.952197478939899e-39;
bool r2355538 = r2355511 <= r2355537;
double r2355539 = r2355515 * r2355515;
double r2355540 = r2355539 * r2355529;
double r2355541 = log(r2355515);
double r2355542 = r2355541 * r2355541;
double r2355543 = log(r2355511);
double r2355544 = r2355539 * r2355515;
double r2355545 = r2355544 * r2355528;
double r2355546 = r2355543 * r2355545;
double r2355547 = r2355543 * r2355543;
double r2355548 = r2355514 * r2355515;
double r2355549 = r2355543 * r2355544;
double r2355550 = r2355542 * r2355549;
double r2355551 = r2355540 * r2355547;
double r2355552 = fma(r2355550, r2355529, r2355551);
double r2355553 = fma(r2355548, r2355543, r2355552);
double r2355554 = fma(r2355546, r2355547, r2355553);
double r2355555 = fma(r2355540, r2355542, r2355554);
double r2355556 = 33.333333333333336;
double r2355557 = r2355547 * r2355541;
double r2355558 = r2355556 * r2355557;
double r2355559 = r2355539 * r2355541;
double r2355560 = r2355543 * r2355559;
double r2355561 = fma(r2355541, r2355542, r2355557);
double r2355562 = r2355541 * r2355548;
double r2355563 = fma(r2355545, r2355561, r2355562);
double r2355564 = fma(r2355560, r2355514, r2355563);
double r2355565 = fma(r2355544, r2355558, r2355564);
double r2355566 = r2355555 - r2355565;
double r2355567 = r2355566 / r2355511;
double r2355568 = r2355567 * r2355515;
double r2355569 = 1.1417957873827229e-05;
bool r2355570 = r2355511 <= r2355569;
double r2355571 = r2355543 * r2355547;
double r2355572 = r2355515 * r2355543;
double r2355573 = fma(r2355528, r2355550, r2355551);
double r2355574 = fma(r2355556, r2355550, r2355573);
double r2355575 = fma(r2355572, r2355514, r2355574);
double r2355576 = fma(r2355545, r2355571, r2355575);
double r2355577 = fma(r2355540, r2355542, r2355576);
double r2355578 = r2355544 * r2355556;
double r2355579 = r2355543 * r2355541;
double r2355580 = r2355541 * r2355542;
double r2355581 = r2355580 + r2355557;
double r2355582 = r2355545 * r2355581;
double r2355583 = r2355582 + r2355562;
double r2355584 = fma(r2355540, r2355579, r2355583);
double r2355585 = fma(r2355540, r2355579, r2355584);
double r2355586 = fma(r2355578, r2355557, r2355585);
double r2355587 = r2355577 - r2355586;
double r2355588 = r2355587 / r2355516;
double r2355589 = r2355570 ? r2355536 : r2355588;
double r2355590 = r2355538 ? r2355568 : r2355589;
double r2355591 = r2355525 ? r2355536 : r2355590;
double r2355592 = r2355513 ? r2355523 : r2355591;
return r2355592;
}




Bits error versus i




Bits error versus n
| Original | 42.7 |
|---|---|
| Target | 41.8 |
| Herbie | 14.6 |
if i < -996.2239743031829Initial program 29.0
Simplified29.0
rmApplied add-exp-log29.1
Applied pow-exp29.1
Simplified5.6
rmApplied associate-/r/6.2
if -996.2239743031829 < i < 1.6984288167482355e-42 or 3.952197478939899e-39 < i < 1.1417957873827229e-05Initial program 49.9
Simplified49.9
rmApplied add-exp-log49.9
Applied pow-exp49.9
Simplified48.8
rmApplied div-inv48.8
Applied *-un-lft-identity48.8
Applied times-frac49.0
Simplified49.0
Taylor expanded around 0 16.1
Simplified16.1
if 1.6984288167482355e-42 < i < 3.952197478939899e-39Initial program 46.6
Simplified46.6
rmApplied add-exp-log46.6
Applied pow-exp46.6
Simplified46.6
rmApplied associate-/r/46.6
Taylor expanded around 0 38.3
Simplified38.3
if 1.1417957873827229e-05 < i Initial program 32.3
Simplified32.3
rmApplied add-exp-log51.0
Applied pow-exp51.0
Simplified49.1
Taylor expanded around 0 21.2
Simplified21.2
Final simplification14.6
herbie shell --seed 2019155 +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))))