100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;n \le -4.152610626697651 \cdot 10^{+69}:\\
\;\;\;\;\frac{\frac{1}{2} \cdot i + \left(\left(i \cdot i\right) \cdot \frac{1}{6} + 1\right)}{\frac{1}{n}} \cdot 100\\
\mathbf{elif}\;n \le -3.1597532325517974 \cdot 10^{-85}:\\
\;\;\;\;100 \cdot \frac{\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i}}{\frac{1}{n}}\\
\mathbf{elif}\;n \le 2.3277881727215845 \cdot 10^{-107}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;\left(n \cdot \frac{\frac{1}{6} \cdot \left(\left(i \cdot i\right) \cdot i\right) + \left(\left(i \cdot i\right) \cdot \frac{1}{2} + i\right)}{i}\right) \cdot 100\\
\end{array}double f(double i, double n) {
double r5179323 = 100.0;
double r5179324 = 1.0;
double r5179325 = i;
double r5179326 = n;
double r5179327 = r5179325 / r5179326;
double r5179328 = r5179324 + r5179327;
double r5179329 = pow(r5179328, r5179326);
double r5179330 = r5179329 - r5179324;
double r5179331 = r5179330 / r5179327;
double r5179332 = r5179323 * r5179331;
return r5179332;
}
double f(double i, double n) {
double r5179333 = n;
double r5179334 = -4.152610626697651e+69;
bool r5179335 = r5179333 <= r5179334;
double r5179336 = 0.5;
double r5179337 = i;
double r5179338 = r5179336 * r5179337;
double r5179339 = r5179337 * r5179337;
double r5179340 = 0.16666666666666666;
double r5179341 = r5179339 * r5179340;
double r5179342 = 1.0;
double r5179343 = r5179341 + r5179342;
double r5179344 = r5179338 + r5179343;
double r5179345 = r5179342 / r5179333;
double r5179346 = r5179344 / r5179345;
double r5179347 = 100.0;
double r5179348 = r5179346 * r5179347;
double r5179349 = -3.1597532325517974e-85;
bool r5179350 = r5179333 <= r5179349;
double r5179351 = r5179337 / r5179333;
double r5179352 = r5179342 + r5179351;
double r5179353 = pow(r5179352, r5179333);
double r5179354 = r5179353 - r5179342;
double r5179355 = r5179354 / r5179337;
double r5179356 = r5179355 / r5179345;
double r5179357 = r5179347 * r5179356;
double r5179358 = 2.3277881727215845e-107;
bool r5179359 = r5179333 <= r5179358;
double r5179360 = 0.0;
double r5179361 = r5179339 * r5179337;
double r5179362 = r5179340 * r5179361;
double r5179363 = r5179339 * r5179336;
double r5179364 = r5179363 + r5179337;
double r5179365 = r5179362 + r5179364;
double r5179366 = r5179365 / r5179337;
double r5179367 = r5179333 * r5179366;
double r5179368 = r5179367 * r5179347;
double r5179369 = r5179359 ? r5179360 : r5179368;
double r5179370 = r5179350 ? r5179357 : r5179369;
double r5179371 = r5179335 ? r5179348 : r5179370;
return r5179371;
}




Bits error versus i




Bits error versus n
Results
| Original | 43.1 |
|---|---|
| Target | 42.7 |
| Herbie | 21.6 |
if n < -4.152610626697651e+69Initial program 47.7
rmApplied div-inv47.8
Applied associate-/r*47.4
Taylor expanded around 0 25.8
Simplified25.8
Taylor expanded around 0 25.6
Simplified25.6
if -4.152610626697651e+69 < n < -3.1597532325517974e-85Initial program 27.7
rmApplied div-inv27.7
Applied associate-/r*27.9
if -3.1597532325517974e-85 < n < 2.3277881727215845e-107Initial program 28.6
Taylor expanded around 0 20.8
if 2.3277881727215845e-107 < n Initial program 59.2
rmApplied div-inv59.2
Applied associate-/r*60.0
Taylor expanded around 0 16.8
Simplified16.8
rmApplied div-inv16.8
Simplified16.7
Final simplification21.6
herbie shell --seed 2019149
(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))))