100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;n \le -5.45421367555386284 \cdot 10^{117}:\\
\;\;\;\;100 \cdot \left(\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)}{i} \cdot n\right)\\
\mathbf{elif}\;n \le -8.94632381714276356 \cdot 10^{69}:\\
\;\;\;\;\frac{100}{i} \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{1}{n}}\\
\mathbf{elif}\;n \le -50247890715477128:\\
\;\;\;\;100 \cdot \left(\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)}{i} \cdot n\right)\\
\mathbf{elif}\;n \le -5.80539647643117144 \cdot 10^{-192}:\\
\;\;\;\;100 \cdot \frac{\mathsf{fma}\left({\left(\sqrt[3]{1 + \frac{i}{n}} \cdot \sqrt[3]{1 + \frac{i}{n}}\right)}^{n}, {\left(\sqrt[3]{1 + \frac{i}{n}}\right)}^{n}, -1\right)}{\frac{i}{n}}\\
\mathbf{elif}\;n \le 2.12821304689236942 \cdot 10^{-175}:\\
\;\;\;\;100 \cdot \frac{\mathsf{fma}\left(1, i, \mathsf{fma}\left(\log 1, n, 1\right)\right) - 1}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \left(\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)}{i} \cdot n\right)\\
\end{array}double f(double i, double n) {
double r111310 = 100.0;
double r111311 = 1.0;
double r111312 = i;
double r111313 = n;
double r111314 = r111312 / r111313;
double r111315 = r111311 + r111314;
double r111316 = pow(r111315, r111313);
double r111317 = r111316 - r111311;
double r111318 = r111317 / r111314;
double r111319 = r111310 * r111318;
return r111319;
}
double f(double i, double n) {
double r111320 = n;
double r111321 = -5.454213675553863e+117;
bool r111322 = r111320 <= r111321;
double r111323 = 100.0;
double r111324 = 1.0;
double r111325 = i;
double r111326 = 0.5;
double r111327 = 2.0;
double r111328 = pow(r111325, r111327);
double r111329 = log(r111324);
double r111330 = r111329 * r111320;
double r111331 = fma(r111326, r111328, r111330);
double r111332 = fma(r111324, r111325, r111331);
double r111333 = r111328 * r111329;
double r111334 = r111326 * r111333;
double r111335 = r111332 - r111334;
double r111336 = r111335 / r111325;
double r111337 = r111336 * r111320;
double r111338 = r111323 * r111337;
double r111339 = -8.946323817142764e+69;
bool r111340 = r111320 <= r111339;
double r111341 = r111323 / r111325;
double r111342 = r111325 / r111320;
double r111343 = r111324 + r111342;
double r111344 = pow(r111343, r111320);
double r111345 = r111344 - r111324;
double r111346 = 1.0;
double r111347 = r111346 / r111320;
double r111348 = r111345 / r111347;
double r111349 = r111341 * r111348;
double r111350 = -5.024789071547713e+16;
bool r111351 = r111320 <= r111350;
double r111352 = -5.8053964764311714e-192;
bool r111353 = r111320 <= r111352;
double r111354 = cbrt(r111343);
double r111355 = r111354 * r111354;
double r111356 = pow(r111355, r111320);
double r111357 = pow(r111354, r111320);
double r111358 = -r111324;
double r111359 = fma(r111356, r111357, r111358);
double r111360 = r111359 / r111342;
double r111361 = r111323 * r111360;
double r111362 = 2.1282130468923694e-175;
bool r111363 = r111320 <= r111362;
double r111364 = fma(r111329, r111320, r111346);
double r111365 = fma(r111324, r111325, r111364);
double r111366 = r111365 - r111324;
double r111367 = r111366 / r111342;
double r111368 = r111323 * r111367;
double r111369 = r111363 ? r111368 : r111338;
double r111370 = r111353 ? r111361 : r111369;
double r111371 = r111351 ? r111338 : r111370;
double r111372 = r111340 ? r111349 : r111371;
double r111373 = r111322 ? r111338 : r111372;
return r111373;
}




Bits error versus i




Bits error versus n
| Original | 42.9 |
|---|---|
| Target | 43.3 |
| Herbie | 23.4 |
if n < -5.454213675553863e+117 or -8.946323817142764e+69 < n < -5.024789071547713e+16 or 2.1282130468923694e-175 < n Initial program 53.5
Taylor expanded around 0 40.2
Simplified40.2
rmApplied associate-/r/23.2
if -5.454213675553863e+117 < n < -8.946323817142764e+69Initial program 38.0
rmApplied div-inv38.0
Applied *-un-lft-identity38.0
Applied times-frac37.8
Applied associate-*r*37.8
Simplified37.8
if -5.024789071547713e+16 < n < -5.8053964764311714e-192Initial program 20.8
rmApplied add-cube-cbrt20.8
Applied unpow-prod-down20.8
Applied fma-neg20.8
if -5.8053964764311714e-192 < n < 2.1282130468923694e-175Initial program 26.9
Taylor expanded around 0 22.3
Simplified22.3
Final simplification23.4
herbie shell --seed 2019199 +o rules:numerics
(FPCore (i n)
:name "Compound Interest"
:herbie-target
(* 100.0 (/ (- (exp (* n (if (== (+ 1.0 (/ i n)) 1.0) (/ i n) (/ (* (/ i n) (log (+ 1.0 (/ i n)))) (- (+ (/ i n) 1.0) 1.0))))) 1.0) (/ i n)))
(* 100.0 (/ (- (pow (+ 1.0 (/ i n)) n) 1.0) (/ i n))))