100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -310.361827324758:\\
\;\;\;\;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 10.814933530045678:\\
\;\;\;\;\left(\left(100 + i \cdot 50\right) + i \cdot \left(i \cdot \frac{50}{3}\right)\right) \cdot n\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\frac{{\left(\frac{i}{n} + 1\right)}^{n}}{i} - \frac{1}{i}\right) \cdot n\right) \cdot 100\\
\end{array}double f(double i, double n) {
double r6229380 = 100.0;
double r6229381 = 1.0;
double r6229382 = i;
double r6229383 = n;
double r6229384 = r6229382 / r6229383;
double r6229385 = r6229381 + r6229384;
double r6229386 = pow(r6229385, r6229383);
double r6229387 = r6229386 - r6229381;
double r6229388 = r6229387 / r6229384;
double r6229389 = r6229380 * r6229388;
return r6229389;
}
double f(double i, double n) {
double r6229390 = i;
double r6229391 = -310.361827324758;
bool r6229392 = r6229390 <= r6229391;
double r6229393 = 100.0;
double r6229394 = n;
double r6229395 = r6229390 / r6229394;
double r6229396 = 1.0;
double r6229397 = r6229395 + r6229396;
double r6229398 = pow(r6229397, r6229394);
double r6229399 = r6229398 / r6229395;
double r6229400 = /* ERROR: no posit support in C */;
double r6229401 = /* ERROR: no posit support in C */;
double r6229402 = r6229396 / r6229395;
double r6229403 = r6229401 - r6229402;
double r6229404 = r6229393 * r6229403;
double r6229405 = 10.814933530045678;
bool r6229406 = r6229390 <= r6229405;
double r6229407 = 50.0;
double r6229408 = r6229390 * r6229407;
double r6229409 = r6229393 + r6229408;
double r6229410 = 16.666666666666668;
double r6229411 = r6229390 * r6229410;
double r6229412 = r6229390 * r6229411;
double r6229413 = r6229409 + r6229412;
double r6229414 = r6229413 * r6229394;
double r6229415 = r6229398 / r6229390;
double r6229416 = r6229396 / r6229390;
double r6229417 = r6229415 - r6229416;
double r6229418 = r6229417 * r6229394;
double r6229419 = r6229418 * r6229393;
double r6229420 = r6229406 ? r6229414 : r6229419;
double r6229421 = r6229392 ? r6229404 : r6229420;
return r6229421;
}




Bits error versus i




Bits error versus n
| Original | 42.1 |
|---|---|
| Target | 42.2 |
| Herbie | 17.9 |
if i < -310.361827324758Initial program 27.2
rmApplied div-sub27.2
rmApplied insert-posit1613.0
if -310.361827324758 < i < 10.814933530045678Initial program 50.0
rmApplied div-sub50.0
Taylor expanded around 0 17.1
Simplified17.1
Taylor expanded around -inf 17.1
Simplified17.1
Taylor expanded around -inf 17.1
Simplified17.1
if 10.814933530045678 < i Initial program 30.5
rmApplied div-sub30.5
rmApplied associate-/r/34.0
Applied associate-/r/30.5
Applied distribute-rgt-out--30.5
Final simplification17.9
herbie shell --seed 2019139
(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))))