100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -42606.74875587941642152145504951477050781:\\
\;\;\;\;100 \cdot \frac{n}{\frac{i}{{\left(\frac{i}{n}\right)}^{n} - 1}}\\
\mathbf{elif}\;i \le 3.332988420430884258276291203877273900307 \cdot 10^{-27}:\\
\;\;\;\;100 \cdot \frac{\mathsf{fma}\left(1, i, \mathsf{fma}\left(0.5, {i}^{2}, \log 1 \cdot n\right)\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)}{\frac{i}{n}}\\
\mathbf{elif}\;i \le 9.944860624286458495633005962801713322847 \cdot 10^{141}:\\
\;\;\;\;\left(100 \cdot n\right) \cdot \frac{1}{\frac{i}{\left(\mathsf{fma}\left(\frac{1}{2}, {\left(\log i\right)}^{2} \cdot {n}^{2}, \mathsf{fma}\left(\frac{1}{2}, {n}^{2} \cdot {\left(\log n\right)}^{2}, \mathsf{fma}\left(\frac{1}{6}, {\left(\log i\right)}^{3} \cdot {n}^{3}, \mathsf{fma}\left(\log i, n, \frac{1}{2} \cdot \left(\log i \cdot \left({n}^{3} \cdot {\left(\log n\right)}^{2}\right)\right)\right)\right)\right)\right) - \log n \cdot \mathsf{fma}\left(n \cdot n, \log i, n\right)\right) - \mathsf{fma}\left(\frac{1}{2}, {\left(\log i\right)}^{2} \cdot \left({n}^{3} \cdot \log n\right), \frac{1}{6} \cdot \left({n}^{3} \cdot {\left(\log n\right)}^{3}\right)\right)}}\\
\mathbf{elif}\;i \le 2.568245662391043108180991997152758915531 \cdot 10^{231}:\\
\;\;\;\;100 \cdot \left(\frac{\sqrt[3]{{\left(1 + \frac{i}{n}\right)}^{n} - 1} \cdot \sqrt[3]{{\left(1 + \frac{i}{n}\right)}^{n} - 1}}{i} \cdot \left(\sqrt[3]{{\left(\sqrt[3]{1 + \frac{i}{n}} \cdot \sqrt[3]{1 + \frac{i}{n}}\right)}^{n} \cdot {\left(\sqrt[3]{1 + \frac{i}{n}}\right)}^{n} - 1} \cdot n\right)\right)\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{\mathsf{fma}\left(1, i, \mathsf{fma}\left(\log 1, n, 1\right)\right) - 1}{\frac{i}{n}}\\
\end{array}double f(double i, double n) {
double r130334 = 100.0;
double r130335 = 1.0;
double r130336 = i;
double r130337 = n;
double r130338 = r130336 / r130337;
double r130339 = r130335 + r130338;
double r130340 = pow(r130339, r130337);
double r130341 = r130340 - r130335;
double r130342 = r130341 / r130338;
double r130343 = r130334 * r130342;
return r130343;
}
double f(double i, double n) {
double r130344 = i;
double r130345 = -42606.74875587942;
bool r130346 = r130344 <= r130345;
double r130347 = 100.0;
double r130348 = n;
double r130349 = r130344 / r130348;
double r130350 = pow(r130349, r130348);
double r130351 = 1.0;
double r130352 = r130350 - r130351;
double r130353 = r130344 / r130352;
double r130354 = r130348 / r130353;
double r130355 = r130347 * r130354;
double r130356 = 3.332988420430884e-27;
bool r130357 = r130344 <= r130356;
double r130358 = 0.5;
double r130359 = 2.0;
double r130360 = pow(r130344, r130359);
double r130361 = log(r130351);
double r130362 = r130361 * r130348;
double r130363 = fma(r130358, r130360, r130362);
double r130364 = fma(r130351, r130344, r130363);
double r130365 = r130360 * r130361;
double r130366 = r130358 * r130365;
double r130367 = r130364 - r130366;
double r130368 = r130367 / r130349;
double r130369 = r130347 * r130368;
double r130370 = 9.944860624286458e+141;
bool r130371 = r130344 <= r130370;
double r130372 = r130347 * r130348;
double r130373 = 1.0;
double r130374 = 0.5;
double r130375 = log(r130344);
double r130376 = pow(r130375, r130359);
double r130377 = pow(r130348, r130359);
double r130378 = r130376 * r130377;
double r130379 = log(r130348);
double r130380 = pow(r130379, r130359);
double r130381 = r130377 * r130380;
double r130382 = 0.16666666666666666;
double r130383 = 3.0;
double r130384 = pow(r130375, r130383);
double r130385 = pow(r130348, r130383);
double r130386 = r130384 * r130385;
double r130387 = r130385 * r130380;
double r130388 = r130375 * r130387;
double r130389 = r130374 * r130388;
double r130390 = fma(r130375, r130348, r130389);
double r130391 = fma(r130382, r130386, r130390);
double r130392 = fma(r130374, r130381, r130391);
double r130393 = fma(r130374, r130378, r130392);
double r130394 = r130348 * r130348;
double r130395 = fma(r130394, r130375, r130348);
double r130396 = r130379 * r130395;
double r130397 = r130393 - r130396;
double r130398 = r130385 * r130379;
double r130399 = r130376 * r130398;
double r130400 = pow(r130379, r130383);
double r130401 = r130385 * r130400;
double r130402 = r130382 * r130401;
double r130403 = fma(r130374, r130399, r130402);
double r130404 = r130397 - r130403;
double r130405 = r130344 / r130404;
double r130406 = r130373 / r130405;
double r130407 = r130372 * r130406;
double r130408 = 2.568245662391043e+231;
bool r130409 = r130344 <= r130408;
double r130410 = r130351 + r130349;
double r130411 = pow(r130410, r130348);
double r130412 = r130411 - r130351;
double r130413 = cbrt(r130412);
double r130414 = r130413 * r130413;
double r130415 = r130414 / r130344;
double r130416 = cbrt(r130410);
double r130417 = r130416 * r130416;
double r130418 = pow(r130417, r130348);
double r130419 = pow(r130416, r130348);
double r130420 = r130418 * r130419;
double r130421 = r130420 - r130351;
double r130422 = cbrt(r130421);
double r130423 = r130422 * r130348;
double r130424 = r130415 * r130423;
double r130425 = r130347 * r130424;
double r130426 = fma(r130361, r130348, r130373);
double r130427 = fma(r130351, r130344, r130426);
double r130428 = r130427 - r130351;
double r130429 = r130428 / r130349;
double r130430 = r130347 * r130429;
double r130431 = r130409 ? r130425 : r130430;
double r130432 = r130371 ? r130407 : r130431;
double r130433 = r130357 ? r130369 : r130432;
double r130434 = r130346 ? r130355 : r130433;
return r130434;
}




Bits error versus i




Bits error versus n
| Original | 43.1 |
|---|---|
| Target | 42.8 |
| Herbie | 30.0 |
if i < -42606.74875587942Initial program 27.8
Taylor expanded around inf 64.0
Simplified18.8
if -42606.74875587942 < i < 3.332988420430884e-27Initial program 50.7
Taylor expanded around 0 34.2
Simplified34.2
if 3.332988420430884e-27 < i < 9.944860624286458e+141Initial program 38.7
Taylor expanded around inf 37.2
Simplified39.2
rmApplied div-inv39.2
Applied associate-*r*39.2
Taylor expanded around 0 22.8
Simplified22.8
if 9.944860624286458e+141 < i < 2.568245662391043e+231Initial program 32.0
rmApplied div-inv32.0
Applied add-cube-cbrt32.0
Applied times-frac32.0
Simplified32.0
rmApplied add-cube-cbrt32.0
Applied unpow-prod-down31.9
if 2.568245662391043e+231 < i Initial program 29.1
Taylor expanded around 0 36.1
Simplified36.1
Final simplification30.0
herbie shell --seed 2019325 +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))))