100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -249306.0470798354:\\
\;\;\;\;100 \cdot \left(\left(\left(\frac{{\left(\frac{i}{n} + 1\right)}^{n}}{\frac{i}{n}}\right)\right) - \frac{1}{\frac{i}{n}}\right)\\
\mathbf{elif}\;i \le 1.4921312295942013:\\
\;\;\;\;n \cdot \left(i \cdot 50\right) + \left(100 + \left(i \cdot i\right) \cdot \frac{50}{3}\right) \cdot n\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \left(\frac{1}{i} \cdot \left(n \cdot {\left(\frac{i}{n} + 1\right)}^{n} - n\right)\right)\\
\end{array}double f(double i, double n) {
double r5014388 = 100.0;
double r5014389 = 1.0;
double r5014390 = i;
double r5014391 = n;
double r5014392 = r5014390 / r5014391;
double r5014393 = r5014389 + r5014392;
double r5014394 = pow(r5014393, r5014391);
double r5014395 = r5014394 - r5014389;
double r5014396 = r5014395 / r5014392;
double r5014397 = r5014388 * r5014396;
return r5014397;
}
double f(double i, double n) {
double r5014398 = i;
double r5014399 = -249306.0470798354;
bool r5014400 = r5014398 <= r5014399;
double r5014401 = 100.0;
double r5014402 = n;
double r5014403 = r5014398 / r5014402;
double r5014404 = 1.0;
double r5014405 = r5014403 + r5014404;
double r5014406 = pow(r5014405, r5014402);
double r5014407 = r5014406 / r5014403;
double r5014408 = /* ERROR: no posit support in C */;
double r5014409 = /* ERROR: no posit support in C */;
double r5014410 = r5014404 / r5014403;
double r5014411 = r5014409 - r5014410;
double r5014412 = r5014401 * r5014411;
double r5014413 = 1.4921312295942013;
bool r5014414 = r5014398 <= r5014413;
double r5014415 = 50.0;
double r5014416 = r5014398 * r5014415;
double r5014417 = r5014402 * r5014416;
double r5014418 = r5014398 * r5014398;
double r5014419 = 16.666666666666668;
double r5014420 = r5014418 * r5014419;
double r5014421 = r5014401 + r5014420;
double r5014422 = r5014421 * r5014402;
double r5014423 = r5014417 + r5014422;
double r5014424 = r5014404 / r5014398;
double r5014425 = r5014402 * r5014406;
double r5014426 = r5014425 - r5014402;
double r5014427 = r5014424 * r5014426;
double r5014428 = r5014401 * r5014427;
double r5014429 = r5014414 ? r5014423 : r5014428;
double r5014430 = r5014400 ? r5014412 : r5014429;
return r5014430;
}




Bits error versus i




Bits error versus n
| Original | 42.8 |
|---|---|
| Target | 42.1 |
| Herbie | 18.1 |
if i < -249306.0470798354Initial program 27.4
rmApplied div-sub27.4
rmApplied insert-posit1611.7
if -249306.0470798354 < i < 1.4921312295942013Initial program 50.2
rmApplied div-sub50.1
Taylor expanded around 0 17.4
Simplified17.4
rmApplied distribute-rgt-in17.4
Simplified17.4
Simplified17.4
if 1.4921312295942013 < i Initial program 32.7
rmApplied div-sub32.7
rmApplied div-inv34.8
Applied *-un-lft-identity34.8
Applied times-frac36.3
Applied div-inv36.4
Applied *-un-lft-identity36.4
Applied times-frac32.7
Applied distribute-lft-out--32.7
Simplified32.7
Final simplification18.1
herbie shell --seed 2019144
(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))))