100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;n \le -2.260823056891884243812192182030091462802 \cdot 10^{130}:\\
\;\;\;\;\left(100 \cdot \frac{\mathsf{fma}\left(1, i, \mathsf{fma}\left(n, \log 1, \left(i \cdot i\right) \cdot \left(0.5 - 0.5 \cdot \log 1\right)\right)\right)}{i}\right) \cdot n\\
\mathbf{elif}\;n \le -4.971792173734567753657378996256742049344 \cdot 10^{92}:\\
\;\;\;\;\left(\sqrt{100} \cdot \left(\sqrt{100} \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i}\right)\right) \cdot n\\
\mathbf{elif}\;n \le -3.460770537187881137122290954175863408168 \cdot 10^{79} \lor \neg \left(n \le 6.434758453518077622758166934880438333831 \cdot 10^{-141}\right):\\
\;\;\;\;\left(100 \cdot \frac{\mathsf{fma}\left(1, i, \mathsf{fma}\left(n, \log 1, \left(i \cdot i\right) \cdot \left(0.5 - 0.5 \cdot \log 1\right)\right)\right)}{i}\right) \cdot n\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{\log \left(e^{{\left(1 + \frac{i}{n}\right)}^{n} - 1}\right)}{\frac{i}{n}}\\
\end{array}double f(double i, double n) {
double r244542 = 100.0;
double r244543 = 1.0;
double r244544 = i;
double r244545 = n;
double r244546 = r244544 / r244545;
double r244547 = r244543 + r244546;
double r244548 = pow(r244547, r244545);
double r244549 = r244548 - r244543;
double r244550 = r244549 / r244546;
double r244551 = r244542 * r244550;
return r244551;
}
double f(double i, double n) {
double r244552 = n;
double r244553 = -2.260823056891884e+130;
bool r244554 = r244552 <= r244553;
double r244555 = 100.0;
double r244556 = 1.0;
double r244557 = i;
double r244558 = log(r244556);
double r244559 = r244557 * r244557;
double r244560 = 0.5;
double r244561 = r244560 * r244558;
double r244562 = r244560 - r244561;
double r244563 = r244559 * r244562;
double r244564 = fma(r244552, r244558, r244563);
double r244565 = fma(r244556, r244557, r244564);
double r244566 = r244565 / r244557;
double r244567 = r244555 * r244566;
double r244568 = r244567 * r244552;
double r244569 = -4.971792173734568e+92;
bool r244570 = r244552 <= r244569;
double r244571 = sqrt(r244555);
double r244572 = r244557 / r244552;
double r244573 = r244556 + r244572;
double r244574 = pow(r244573, r244552);
double r244575 = r244574 - r244556;
double r244576 = r244575 / r244557;
double r244577 = r244571 * r244576;
double r244578 = r244571 * r244577;
double r244579 = r244578 * r244552;
double r244580 = -3.460770537187881e+79;
bool r244581 = r244552 <= r244580;
double r244582 = 6.434758453518078e-141;
bool r244583 = r244552 <= r244582;
double r244584 = !r244583;
bool r244585 = r244581 || r244584;
double r244586 = exp(r244575);
double r244587 = log(r244586);
double r244588 = r244587 / r244572;
double r244589 = r244555 * r244588;
double r244590 = r244585 ? r244568 : r244589;
double r244591 = r244570 ? r244579 : r244590;
double r244592 = r244554 ? r244568 : r244591;
return r244592;
}




Bits error versus i




Bits error versus n
| Original | 42.2 |
|---|---|
| Target | 42.3 |
| Herbie | 24.2 |
if n < -2.260823056891884e+130 or -4.971792173734568e+92 < n < -3.460770537187881e+79 or 6.434758453518078e-141 < n Initial program 55.8
rmApplied associate-/r/55.4
Applied associate-*r*55.4
Taylor expanded around 0 21.1
Simplified21.1
if -2.260823056891884e+130 < n < -4.971792173734568e+92Initial program 38.6
rmApplied associate-/r/38.4
Applied associate-*r*38.3
rmApplied add-sqr-sqrt38.3
Applied associate-*l*38.4
if -3.460770537187881e+79 < n < 6.434758453518078e-141Initial program 26.5
rmApplied add-log-exp26.5
Applied add-log-exp26.5
Applied diff-log26.5
Simplified26.5
Final simplification24.2
herbie shell --seed 2019350 +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))))