100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;n \le -0.8249084896539374:\\
\;\;\;\;100 \cdot \frac{\mathsf{expm1}\left(i\right)}{\frac{i}{n}}\\
\mathbf{elif}\;n \le -2.7004764031193593 \cdot 10^{-129}:\\
\;\;\;\;\frac{\sqrt[3]{\left(\left(\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{i}{n}\right) \cdot n\right) \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\frac{i}{n}\right) \cdot n\right)\right) \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\frac{i}{n}\right) \cdot n\right)\right) \cdot 1000000}}{\frac{i}{n}}\\
\mathbf{elif}\;n \le -1.1007636657452675 \cdot 10^{-234}:\\
\;\;\;\;\frac{100 \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\frac{i}{n}\right) \cdot n\right)}{\frac{i}{n}}\\
\mathbf{elif}\;n \le 5.476973539989824 \cdot 10^{-182}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{1}{\frac{\frac{i}{n}}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{i}{n}\right) \cdot n\right)}}\\
\end{array}double f(double i, double n) {
double r4535355 = 100.0;
double r4535356 = 1.0;
double r4535357 = i;
double r4535358 = n;
double r4535359 = r4535357 / r4535358;
double r4535360 = r4535356 + r4535359;
double r4535361 = pow(r4535360, r4535358);
double r4535362 = r4535361 - r4535356;
double r4535363 = r4535362 / r4535359;
double r4535364 = r4535355 * r4535363;
return r4535364;
}
double f(double i, double n) {
double r4535365 = n;
double r4535366 = -0.8249084896539374;
bool r4535367 = r4535365 <= r4535366;
double r4535368 = 100.0;
double r4535369 = i;
double r4535370 = expm1(r4535369);
double r4535371 = r4535369 / r4535365;
double r4535372 = r4535370 / r4535371;
double r4535373 = r4535368 * r4535372;
double r4535374 = -2.7004764031193593e-129;
bool r4535375 = r4535365 <= r4535374;
double r4535376 = log1p(r4535371);
double r4535377 = r4535376 * r4535365;
double r4535378 = expm1(r4535377);
double r4535379 = r4535378 * r4535378;
double r4535380 = r4535379 * r4535378;
double r4535381 = 1000000.0;
double r4535382 = r4535380 * r4535381;
double r4535383 = cbrt(r4535382);
double r4535384 = r4535383 / r4535371;
double r4535385 = -1.1007636657452675e-234;
bool r4535386 = r4535365 <= r4535385;
double r4535387 = r4535368 * r4535378;
double r4535388 = r4535387 / r4535371;
double r4535389 = 5.476973539989824e-182;
bool r4535390 = r4535365 <= r4535389;
double r4535391 = 0.0;
double r4535392 = 1.0;
double r4535393 = r4535371 / r4535378;
double r4535394 = r4535392 / r4535393;
double r4535395 = r4535368 * r4535394;
double r4535396 = r4535390 ? r4535391 : r4535395;
double r4535397 = r4535386 ? r4535388 : r4535396;
double r4535398 = r4535375 ? r4535384 : r4535397;
double r4535399 = r4535367 ? r4535373 : r4535398;
return r4535399;
}




Bits error versus i




Bits error versus n
Results
| Original | 42.5 |
|---|---|
| Target | 42.6 |
| Herbie | 18.1 |
if n < -0.8249084896539374Initial program 45.2
rmApplied add-exp-log52.9
Applied pow-exp52.9
Applied expm1-def52.9
Taylor expanded around 0 24.9
if -0.8249084896539374 < n < -2.7004764031193593e-129Initial program 18.4
rmApplied add-exp-log18.4
Applied pow-exp18.4
Applied expm1-def1.8
rmApplied log1p-expm1-u1.8
Simplified31.9
rmApplied associate-*r/31.8
rmApplied add-cbrt-cube9.2
Applied add-cbrt-cube9.2
Applied cbrt-unprod9.2
Simplified9.2
if -2.7004764031193593e-129 < n < -1.1007636657452675e-234Initial program 14.4
rmApplied add-exp-log14.4
Applied pow-exp14.4
Applied expm1-def3.3
rmApplied log1p-expm1-u3.3
Simplified16.0
rmApplied associate-*r/15.9
if -1.1007636657452675e-234 < n < 5.476973539989824e-182Initial program 28.9
rmApplied add-exp-log28.9
Applied pow-exp28.9
Applied expm1-def21.3
rmApplied log1p-expm1-u21.3
Simplified16.4
Taylor expanded around 0 14.0
if 5.476973539989824e-182 < n Initial program 57.6
rmApplied add-exp-log57.6
Applied pow-exp57.6
Applied expm1-def51.3
rmApplied log1p-expm1-u51.3
Simplified16.4
rmApplied clear-num16.6
Final simplification18.1
herbie shell --seed 2019168 +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))))