100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;n \le -1.00297232240918336 \cdot 10^{174}:\\
\;\;\;\;\left(100 \cdot n\right) \cdot \frac{\mathsf{fma}\left(1, i, \mathsf{fma}\left(0.5, i \cdot i, \log 1 \cdot n\right)\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)}{i}\\
\mathbf{elif}\;n \le -4.03699116408299863 \cdot 10^{85}:\\
\;\;\;\;\frac{100 \cdot \left(n \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)\right)}{i}\\
\mathbf{elif}\;n \le -3.31747608845659503 \cdot 10^{63}:\\
\;\;\;\;\left(100 \cdot n\right) \cdot \frac{\mathsf{fma}\left(1, i, \mathsf{fma}\left(0.5, i \cdot i, \log 1 \cdot n\right)\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)}{i}\\
\mathbf{elif}\;n \le -1.0912719332224593 \cdot 10^{26}:\\
\;\;\;\;\frac{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}{\frac{i}{n}}\\
\mathbf{elif}\;n \le -934893.903368213796:\\
\;\;\;\;\left(100 \cdot n\right) \cdot \frac{\mathsf{fma}\left(1, i, \mathsf{fma}\left(0.5, i \cdot i, \log 1 \cdot n\right)\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)}{i}\\
\mathbf{elif}\;n \le 2.44249498211844666 \cdot 10^{-299}:\\
\;\;\;\;100 \cdot \left(\frac{{\left(1 + \frac{i}{n}\right)}^{n}}{\frac{i}{n}} - \frac{1}{\frac{i}{n}}\right)\\
\mathbf{elif}\;n \le 6.74497016401884472 \cdot 10^{-102}:\\
\;\;\;\;\mathsf{fma}\left(50, \frac{{n}^{3} \cdot {\left(\log n\right)}^{2}}{i}, \mathsf{fma}\left(50, \frac{{\left(\log i\right)}^{2} \cdot {n}^{3}}{i}, \mathsf{fma}\left(16.666666666666664, \frac{{\left(\log i\right)}^{3} \cdot {n}^{4}}{i}, \mathsf{fma}\left(100, \frac{\log i \cdot {n}^{2}}{i}, 50 \cdot \frac{\log i \cdot \left({n}^{4} \cdot {\left(\log n\right)}^{2}\right)}{i}\right)\right)\right)\right) - \mathsf{fma}\left(16.666666666666664, \frac{{n}^{4} \cdot {\left(\log n\right)}^{3}}{i}, \mathsf{fma}\left(100, \frac{\log i \cdot \left({n}^{3} \cdot \log n\right)}{i}, \mathsf{fma}\left(100, \frac{{n}^{2} \cdot \log n}{i}, 50 \cdot \frac{{\left(\log i\right)}^{2} \cdot \left({n}^{4} \cdot \log n\right)}{i}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(100 \cdot n\right) \cdot \frac{\mathsf{fma}\left(1, i, \mathsf{fma}\left(0.5, i \cdot i, \log 1 \cdot n\right)\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)}{i}\\
\end{array}double f(double i, double n) {
double r122358 = 100.0;
double r122359 = 1.0;
double r122360 = i;
double r122361 = n;
double r122362 = r122360 / r122361;
double r122363 = r122359 + r122362;
double r122364 = pow(r122363, r122361);
double r122365 = r122364 - r122359;
double r122366 = r122365 / r122362;
double r122367 = r122358 * r122366;
return r122367;
}
double f(double i, double n) {
double r122368 = n;
double r122369 = -1.0029723224091834e+174;
bool r122370 = r122368 <= r122369;
double r122371 = 100.0;
double r122372 = r122371 * r122368;
double r122373 = 1.0;
double r122374 = i;
double r122375 = 0.5;
double r122376 = r122374 * r122374;
double r122377 = log(r122373);
double r122378 = r122377 * r122368;
double r122379 = fma(r122375, r122376, r122378);
double r122380 = fma(r122373, r122374, r122379);
double r122381 = 2.0;
double r122382 = pow(r122374, r122381);
double r122383 = r122382 * r122377;
double r122384 = r122375 * r122383;
double r122385 = r122380 - r122384;
double r122386 = r122385 / r122374;
double r122387 = r122372 * r122386;
double r122388 = -4.0369911640829986e+85;
bool r122389 = r122368 <= r122388;
double r122390 = r122374 / r122368;
double r122391 = r122373 + r122390;
double r122392 = pow(r122391, r122368);
double r122393 = r122392 - r122373;
double r122394 = r122368 * r122393;
double r122395 = r122371 * r122394;
double r122396 = r122395 / r122374;
double r122397 = -3.317476088456595e+63;
bool r122398 = r122368 <= r122397;
double r122399 = -1.0912719332224593e+26;
bool r122400 = r122368 <= r122399;
double r122401 = r122371 * r122393;
double r122402 = r122401 / r122390;
double r122403 = -934893.9033682138;
bool r122404 = r122368 <= r122403;
double r122405 = 2.4424949821184467e-299;
bool r122406 = r122368 <= r122405;
double r122407 = r122392 / r122390;
double r122408 = r122373 / r122390;
double r122409 = r122407 - r122408;
double r122410 = r122371 * r122409;
double r122411 = 6.744970164018845e-102;
bool r122412 = r122368 <= r122411;
double r122413 = 50.0;
double r122414 = 3.0;
double r122415 = pow(r122368, r122414);
double r122416 = log(r122368);
double r122417 = pow(r122416, r122381);
double r122418 = r122415 * r122417;
double r122419 = r122418 / r122374;
double r122420 = log(r122374);
double r122421 = pow(r122420, r122381);
double r122422 = r122421 * r122415;
double r122423 = r122422 / r122374;
double r122424 = 16.666666666666664;
double r122425 = pow(r122420, r122414);
double r122426 = 4.0;
double r122427 = pow(r122368, r122426);
double r122428 = r122425 * r122427;
double r122429 = r122428 / r122374;
double r122430 = pow(r122368, r122381);
double r122431 = r122420 * r122430;
double r122432 = r122431 / r122374;
double r122433 = r122427 * r122417;
double r122434 = r122420 * r122433;
double r122435 = r122434 / r122374;
double r122436 = r122413 * r122435;
double r122437 = fma(r122371, r122432, r122436);
double r122438 = fma(r122424, r122429, r122437);
double r122439 = fma(r122413, r122423, r122438);
double r122440 = fma(r122413, r122419, r122439);
double r122441 = pow(r122416, r122414);
double r122442 = r122427 * r122441;
double r122443 = r122442 / r122374;
double r122444 = r122415 * r122416;
double r122445 = r122420 * r122444;
double r122446 = r122445 / r122374;
double r122447 = r122430 * r122416;
double r122448 = r122447 / r122374;
double r122449 = r122427 * r122416;
double r122450 = r122421 * r122449;
double r122451 = r122450 / r122374;
double r122452 = r122413 * r122451;
double r122453 = fma(r122371, r122448, r122452);
double r122454 = fma(r122371, r122446, r122453);
double r122455 = fma(r122424, r122443, r122454);
double r122456 = r122440 - r122455;
double r122457 = r122412 ? r122456 : r122387;
double r122458 = r122406 ? r122410 : r122457;
double r122459 = r122404 ? r122387 : r122458;
double r122460 = r122400 ? r122402 : r122459;
double r122461 = r122398 ? r122387 : r122460;
double r122462 = r122389 ? r122396 : r122461;
double r122463 = r122370 ? r122387 : r122462;
return r122463;
}




Bits error versus i




Bits error versus n
| Original | 43.1 |
|---|---|
| Target | 43.0 |
| Herbie | 22.3 |
if n < -1.0029723224091834e+174 or -4.0369911640829986e+85 < n < -3.317476088456595e+63 or -1.0912719332224593e+26 < n < -934893.9033682138 or 6.744970164018845e-102 < n Initial program 56.4
rmApplied div-inv56.4
Applied add-sqr-sqrt56.4
Applied add-sqr-sqrt56.4
Applied difference-of-squares56.4
Applied times-frac56.1
Simplified56.1
rmApplied associate-*l/56.1
Simplified56.0
Taylor expanded around 0 21.3
Simplified21.3
rmApplied *-un-lft-identity21.3
Applied times-frac20.1
Applied associate-*r*20.1
Simplified20.1
if -1.0029723224091834e+174 < n < -4.0369911640829986e+85Initial program 40.6
rmApplied div-inv40.6
Applied add-sqr-sqrt40.6
Applied add-sqr-sqrt40.6
Applied difference-of-squares40.6
Applied times-frac40.3
Simplified40.3
rmApplied associate-*l/40.2
Simplified40.2
rmApplied associate-*r/40.2
if -3.317476088456595e+63 < n < -1.0912719332224593e+26Initial program 30.6
rmApplied associate-*r/30.5
if -934893.9033682138 < n < 2.4424949821184467e-299Initial program 17.7
rmApplied div-sub17.7
if 2.4424949821184467e-299 < n < 6.744970164018845e-102Initial program 45.4
rmApplied div-inv45.4
Applied add-sqr-sqrt45.4
Applied add-sqr-sqrt45.4
Applied difference-of-squares45.4
Applied times-frac45.4
Simplified45.4
rmApplied associate-*l/45.4
Simplified45.4
Taylor expanded around 0 24.1
Simplified24.1
Final simplification22.3
herbie shell --seed 2020047 +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))))