100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -1.1667814537595314 \cdot 10^{+37}:\\
\;\;\;\;100 \cdot \frac{n \cdot \left({\left(\frac{i}{n} + 1\right)}^{n} - 1\right)}{i}\\
\mathbf{elif}\;i \le -1.8925394344879332 \cdot 10^{-295}:\\
\;\;\;\;\frac{100}{i} \cdot \frac{\left(\log \left(e^{\left(i \cdot \left(i \cdot i\right)\right) \cdot \frac{1}{6}}\right) + \left(i \cdot i\right) \cdot \frac{1}{2}\right) + i}{\frac{1}{n}}\\
\mathbf{elif}\;i \le 3.902656912278071:\\
\;\;\;\;50 \cdot \left(n \cdot i\right) + n \cdot \left(\left(i \cdot i\right) \cdot \frac{50}{3} + 100\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}double f(double i, double n) {
double r5770487 = 100.0;
double r5770488 = 1.0;
double r5770489 = i;
double r5770490 = n;
double r5770491 = r5770489 / r5770490;
double r5770492 = r5770488 + r5770491;
double r5770493 = pow(r5770492, r5770490);
double r5770494 = r5770493 - r5770488;
double r5770495 = r5770494 / r5770491;
double r5770496 = r5770487 * r5770495;
return r5770496;
}
double f(double i, double n) {
double r5770497 = i;
double r5770498 = -1.1667814537595314e+37;
bool r5770499 = r5770497 <= r5770498;
double r5770500 = 100.0;
double r5770501 = n;
double r5770502 = r5770497 / r5770501;
double r5770503 = 1.0;
double r5770504 = r5770502 + r5770503;
double r5770505 = pow(r5770504, r5770501);
double r5770506 = r5770505 - r5770503;
double r5770507 = r5770501 * r5770506;
double r5770508 = r5770507 / r5770497;
double r5770509 = r5770500 * r5770508;
double r5770510 = -1.8925394344879332e-295;
bool r5770511 = r5770497 <= r5770510;
double r5770512 = r5770500 / r5770497;
double r5770513 = r5770497 * r5770497;
double r5770514 = r5770497 * r5770513;
double r5770515 = 0.16666666666666666;
double r5770516 = r5770514 * r5770515;
double r5770517 = exp(r5770516);
double r5770518 = log(r5770517);
double r5770519 = 0.5;
double r5770520 = r5770513 * r5770519;
double r5770521 = r5770518 + r5770520;
double r5770522 = r5770521 + r5770497;
double r5770523 = r5770503 / r5770501;
double r5770524 = r5770522 / r5770523;
double r5770525 = r5770512 * r5770524;
double r5770526 = 3.902656912278071;
bool r5770527 = r5770497 <= r5770526;
double r5770528 = 50.0;
double r5770529 = r5770501 * r5770497;
double r5770530 = r5770528 * r5770529;
double r5770531 = 16.666666666666668;
double r5770532 = r5770513 * r5770531;
double r5770533 = r5770532 + r5770500;
double r5770534 = r5770501 * r5770533;
double r5770535 = r5770530 + r5770534;
double r5770536 = 0.0;
double r5770537 = r5770527 ? r5770535 : r5770536;
double r5770538 = r5770511 ? r5770525 : r5770537;
double r5770539 = r5770499 ? r5770509 : r5770538;
return r5770539;
}




Bits error versus i




Bits error versus n
Results
| Original | 42.4 |
|---|---|
| Target | 42.2 |
| Herbie | 22.0 |
if i < -1.1667814537595314e+37Initial program 25.5
rmApplied div-inv25.5
Applied *-un-lft-identity25.5
Applied times-frac25.9
Applied associate-*r*25.9
Simplified25.9
rmApplied div-inv25.9
Applied associate-*l*25.9
Simplified25.8
if -1.1667814537595314e+37 < i < -1.8925394344879332e-295Initial program 49.1
rmApplied div-inv49.1
Applied *-un-lft-identity49.1
Applied times-frac49.4
Applied associate-*r*49.4
Simplified49.4
Taylor expanded around 0 20.6
Simplified20.6
rmApplied add-log-exp20.8
if -1.8925394344879332e-295 < i < 3.902656912278071Initial program 50.0
rmApplied div-inv50.0
Applied *-un-lft-identity50.0
Applied times-frac50.3
Applied associate-*r*50.4
Simplified50.4
Taylor expanded around 0 17.1
Simplified17.1
rmApplied add-cube-cbrt17.7
Applied add-cube-cbrt17.7
Applied times-frac17.7
Applied associate-*l*17.1
Simplified17.1
Taylor expanded around inf 17.1
Simplified17.1
if 3.902656912278071 < i Initial program 32.4
rmApplied div-inv32.4
Applied *-un-lft-identity32.4
Applied times-frac32.4
Applied associate-*r*32.4
Simplified32.4
Taylor expanded around 0 30.8
Final simplification22.0
herbie shell --seed 2019142
(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))))