100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;n \le -2.8503749344901687 \cdot 10^{+128}:\\
\;\;\;\;\mathsf{fma}\left(e^{\mathsf{log1p}\left(\frac{i}{n}\right) \cdot n}, 100, -100\right) \cdot \frac{n}{i}\\
\mathbf{elif}\;n \le -6.741071980134238 \cdot 10^{+48}:\\
\;\;\;\;\frac{1}{i} \cdot \left(n \cdot \mathsf{fma}\left({\left(\frac{i}{n} + 1\right)}^{n}, 100, -100\right)\right)\\
\mathbf{elif}\;n \le -2.81251599798957 \cdot 10^{+26}:\\
\;\;\;\;\frac{\mathsf{fma}\left(50, i \cdot i, \left(100 + \left(i \cdot i\right) \cdot \frac{50}{3}\right) \cdot i\right)}{\frac{i}{n}}\\
\mathbf{elif}\;n \le -3.9175258711905035 \cdot 10^{-19}:\\
\;\;\;\;\frac{\frac{\sqrt[3]{\mathsf{fma}\left(e^{\mathsf{log1p}\left(\frac{i}{n}\right) \cdot n + \left(n + n\right) \cdot \mathsf{log1p}\left(\frac{i}{n}\right)}, 1000000, -1000000\right)}}{\sqrt[3]{\mathsf{fma}\left(e^{\mathsf{log1p}\left(\frac{i}{n}\right) \cdot n}, 10000 \cdot e^{\mathsf{log1p}\left(\frac{i}{n}\right) \cdot n}, 10000 \cdot e^{\mathsf{log1p}\left(\frac{i}{n}\right) \cdot n} + 10000\right)}}}{\frac{\sqrt[3]{i}}{\sqrt[3]{n}}} \cdot \frac{\frac{\sqrt[3]{\mathsf{fma}\left(e^{\mathsf{log1p}\left(\frac{i}{n}\right) \cdot n + \left(n + n\right) \cdot \mathsf{log1p}\left(\frac{i}{n}\right)}, 1000000, -1000000\right)} \cdot \sqrt[3]{\mathsf{fma}\left(e^{\mathsf{log1p}\left(\frac{i}{n}\right) \cdot n + \left(n + n\right) \cdot \mathsf{log1p}\left(\frac{i}{n}\right)}, 1000000, -1000000\right)}}{\sqrt[3]{\mathsf{fma}\left(e^{\mathsf{log1p}\left(\frac{i}{n}\right) \cdot n}, 10000 \cdot e^{\mathsf{log1p}\left(\frac{i}{n}\right) \cdot n}, 10000 \cdot e^{\mathsf{log1p}\left(\frac{i}{n}\right) \cdot n} + 10000\right)} \cdot \sqrt[3]{\mathsf{fma}\left(e^{\mathsf{log1p}\left(\frac{i}{n}\right) \cdot n}, 10000 \cdot e^{\mathsf{log1p}\left(\frac{i}{n}\right) \cdot n}, 10000 \cdot e^{\mathsf{log1p}\left(\frac{i}{n}\right) \cdot n} + 10000\right)}}}{\frac{\sqrt[3]{i} \cdot \sqrt[3]{i}}{\sqrt[3]{n} \cdot \sqrt[3]{n}}}\\
\mathbf{elif}\;n \le 1.8317810149458703 \cdot 10^{-135}:\\
\;\;\;\;0\\
\mathbf{elif}\;n \le 2.3783092808523403 \cdot 10^{+147}:\\
\;\;\;\;\frac{\mathsf{fma}\left(50, i \cdot i, \left(100 + \left(i \cdot i\right) \cdot \frac{50}{3}\right) \cdot i\right)}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(e^{\mathsf{log1p}\left(\frac{i}{n}\right) \cdot n + \left(n + n\right) \cdot \mathsf{log1p}\left(\frac{i}{n}\right)}, 1000000, -1000000\right)}{\mathsf{fma}\left(e^{\mathsf{log1p}\left(\frac{i}{n}\right) \cdot n}, 10000, 10000 \cdot e^{\mathsf{log1p}\left(\frac{i}{n}\right) \cdot n} + 10000\right)}}{\frac{i}{n}}\\
\end{array}double f(double i, double n) {
double r7002275 = 100.0;
double r7002276 = 1.0;
double r7002277 = i;
double r7002278 = n;
double r7002279 = r7002277 / r7002278;
double r7002280 = r7002276 + r7002279;
double r7002281 = pow(r7002280, r7002278);
double r7002282 = r7002281 - r7002276;
double r7002283 = r7002282 / r7002279;
double r7002284 = r7002275 * r7002283;
return r7002284;
}
double f(double i, double n) {
double r7002285 = n;
double r7002286 = -2.8503749344901687e+128;
bool r7002287 = r7002285 <= r7002286;
double r7002288 = i;
double r7002289 = r7002288 / r7002285;
double r7002290 = log1p(r7002289);
double r7002291 = r7002290 * r7002285;
double r7002292 = exp(r7002291);
double r7002293 = 100.0;
double r7002294 = -100.0;
double r7002295 = fma(r7002292, r7002293, r7002294);
double r7002296 = r7002285 / r7002288;
double r7002297 = r7002295 * r7002296;
double r7002298 = -6.741071980134238e+48;
bool r7002299 = r7002285 <= r7002298;
double r7002300 = 1.0;
double r7002301 = r7002300 / r7002288;
double r7002302 = r7002289 + r7002300;
double r7002303 = pow(r7002302, r7002285);
double r7002304 = fma(r7002303, r7002293, r7002294);
double r7002305 = r7002285 * r7002304;
double r7002306 = r7002301 * r7002305;
double r7002307 = -2.81251599798957e+26;
bool r7002308 = r7002285 <= r7002307;
double r7002309 = 50.0;
double r7002310 = r7002288 * r7002288;
double r7002311 = 16.666666666666668;
double r7002312 = r7002310 * r7002311;
double r7002313 = r7002293 + r7002312;
double r7002314 = r7002313 * r7002288;
double r7002315 = fma(r7002309, r7002310, r7002314);
double r7002316 = r7002315 / r7002289;
double r7002317 = -3.9175258711905035e-19;
bool r7002318 = r7002285 <= r7002317;
double r7002319 = r7002285 + r7002285;
double r7002320 = r7002319 * r7002290;
double r7002321 = r7002291 + r7002320;
double r7002322 = exp(r7002321);
double r7002323 = 1000000.0;
double r7002324 = -1000000.0;
double r7002325 = fma(r7002322, r7002323, r7002324);
double r7002326 = cbrt(r7002325);
double r7002327 = 10000.0;
double r7002328 = r7002327 * r7002292;
double r7002329 = r7002328 + r7002327;
double r7002330 = fma(r7002292, r7002328, r7002329);
double r7002331 = cbrt(r7002330);
double r7002332 = r7002326 / r7002331;
double r7002333 = cbrt(r7002288);
double r7002334 = cbrt(r7002285);
double r7002335 = r7002333 / r7002334;
double r7002336 = r7002332 / r7002335;
double r7002337 = r7002326 * r7002326;
double r7002338 = r7002331 * r7002331;
double r7002339 = r7002337 / r7002338;
double r7002340 = r7002333 * r7002333;
double r7002341 = r7002334 * r7002334;
double r7002342 = r7002340 / r7002341;
double r7002343 = r7002339 / r7002342;
double r7002344 = r7002336 * r7002343;
double r7002345 = 1.8317810149458703e-135;
bool r7002346 = r7002285 <= r7002345;
double r7002347 = 0.0;
double r7002348 = 2.3783092808523403e+147;
bool r7002349 = r7002285 <= r7002348;
double r7002350 = fma(r7002292, r7002327, r7002329);
double r7002351 = r7002325 / r7002350;
double r7002352 = r7002351 / r7002289;
double r7002353 = r7002349 ? r7002316 : r7002352;
double r7002354 = r7002346 ? r7002347 : r7002353;
double r7002355 = r7002318 ? r7002344 : r7002354;
double r7002356 = r7002308 ? r7002316 : r7002355;
double r7002357 = r7002299 ? r7002306 : r7002356;
double r7002358 = r7002287 ? r7002297 : r7002357;
return r7002358;
}




Bits error versus i




Bits error versus n
| Original | 42.5 |
|---|---|
| Target | 41.8 |
| Herbie | 29.4 |
if n < -2.8503749344901687e+128Initial program 50.8
Simplified50.8
rmApplied pow-to-exp55.7
Simplified41.2
rmApplied div-inv41.3
Simplified41.3
if -2.8503749344901687e+128 < n < -6.741071980134238e+48Initial program 38.8
Simplified38.8
rmApplied div-inv38.8
Applied *-un-lft-identity38.8
Applied times-frac38.7
Simplified38.6
if -6.741071980134238e+48 < n < -2.81251599798957e+26 or 1.8317810149458703e-135 < n < 2.3783092808523403e+147Initial program 55.4
Simplified55.4
Taylor expanded around 0 25.0
Simplified25.0
if -2.81251599798957e+26 < n < -3.9175258711905035e-19Initial program 25.2
Simplified25.1
rmApplied pow-to-exp30.2
Simplified29.2
rmApplied fma-udef29.3
rmApplied flip3-+29.3
Simplified29.0
Simplified29.0
rmApplied add-cube-cbrt29.2
Applied add-cube-cbrt29.3
Applied times-frac29.3
Applied add-cube-cbrt29.3
Applied add-cube-cbrt29.3
Applied times-frac29.3
Applied times-frac29.4
if -3.9175258711905035e-19 < n < 1.8317810149458703e-135Initial program 25.5
Simplified25.5
Taylor expanded around 0 18.1
if 2.3783092808523403e+147 < n Initial program 60.2
Simplified60.2
rmApplied pow-to-exp60.2
Simplified42.4
rmApplied fma-udef42.4
rmApplied flip3-+42.4
Simplified42.4
Simplified42.4
Taylor expanded around inf 43.0
Final simplification29.4
herbie shell --seed 2019143 +o rules:numerics
(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))))