100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;n \le -1.8403630755190044 \cdot 10^{260}:\\
\;\;\;\;100 \cdot \frac{\left(\left(1 \cdot i + \left(0.5 \cdot {i}^{2} + \log 1 \cdot n\right)\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)\right) \cdot n}{i}\\
\mathbf{elif}\;n \le 1.2344778126423281 \cdot 10^{-267}:\\
\;\;\;\;\frac{100}{i} \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} \cdot n - 1 \cdot n\right)\\
\mathbf{elif}\;n \le 4.27971623982010377 \cdot 10^{-165}:\\
\;\;\;\;100 \cdot \frac{\left(1 \cdot i + \left(\log 1 \cdot n + 1\right)\right) - 1}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;\frac{100 \cdot \left(\left(1 \cdot i + \left(0.5 \cdot {i}^{2} + \log 1 \cdot n\right)\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)\right)}{i} \cdot n\\
\end{array}double f(double i, double n) {
double r172346 = 100.0;
double r172347 = 1.0;
double r172348 = i;
double r172349 = n;
double r172350 = r172348 / r172349;
double r172351 = r172347 + r172350;
double r172352 = pow(r172351, r172349);
double r172353 = r172352 - r172347;
double r172354 = r172353 / r172350;
double r172355 = r172346 * r172354;
return r172355;
}
double f(double i, double n) {
double r172356 = n;
double r172357 = -1.8403630755190044e+260;
bool r172358 = r172356 <= r172357;
double r172359 = 100.0;
double r172360 = 1.0;
double r172361 = i;
double r172362 = r172360 * r172361;
double r172363 = 0.5;
double r172364 = 2.0;
double r172365 = pow(r172361, r172364);
double r172366 = r172363 * r172365;
double r172367 = log(r172360);
double r172368 = r172367 * r172356;
double r172369 = r172366 + r172368;
double r172370 = r172362 + r172369;
double r172371 = r172365 * r172367;
double r172372 = r172363 * r172371;
double r172373 = r172370 - r172372;
double r172374 = r172373 * r172356;
double r172375 = r172374 / r172361;
double r172376 = r172359 * r172375;
double r172377 = 1.234477812642328e-267;
bool r172378 = r172356 <= r172377;
double r172379 = r172359 / r172361;
double r172380 = r172361 / r172356;
double r172381 = r172360 + r172380;
double r172382 = pow(r172381, r172356);
double r172383 = r172382 * r172356;
double r172384 = r172360 * r172356;
double r172385 = r172383 - r172384;
double r172386 = r172379 * r172385;
double r172387 = 4.279716239820104e-165;
bool r172388 = r172356 <= r172387;
double r172389 = 1.0;
double r172390 = r172368 + r172389;
double r172391 = r172362 + r172390;
double r172392 = r172391 - r172360;
double r172393 = r172392 / r172380;
double r172394 = r172359 * r172393;
double r172395 = r172359 * r172373;
double r172396 = r172395 / r172361;
double r172397 = r172396 * r172356;
double r172398 = r172388 ? r172394 : r172397;
double r172399 = r172378 ? r172386 : r172398;
double r172400 = r172358 ? r172376 : r172399;
return r172400;
}




Bits error versus i




Bits error versus n
Results
| Original | 41.1 |
|---|---|
| Target | 40.9 |
| Herbie | 24.6 |
if n < -1.8403630755190044e+260Initial program 56.0
rmApplied div-inv56.1
Applied *-un-lft-identity56.1
Applied times-frac55.6
Applied associate-*r*55.6
Simplified55.6
Taylor expanded around 0 37.0
rmApplied div-inv37.1
Applied associate-*l*37.0
Simplified36.9
if -1.8403630755190044e+260 < n < 1.234477812642328e-267Initial program 26.1
rmApplied div-inv26.1
Applied *-un-lft-identity26.1
Applied times-frac26.3
Applied associate-*r*26.4
Simplified26.4
rmApplied div-sub26.4
Simplified29.0
Simplified26.4
if 1.234477812642328e-267 < n < 4.279716239820104e-165Initial program 42.2
Taylor expanded around 0 33.4
if 4.279716239820104e-165 < n Initial program 58.8
rmApplied div-inv58.8
Applied *-un-lft-identity58.8
Applied times-frac58.5
Applied associate-*r*58.5
Simplified58.5
Taylor expanded around 0 23.5
rmApplied associate-/r/23.4
Applied associate-*r*19.6
Simplified19.4
Final simplification24.6
herbie shell --seed 2020027
(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))))