100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -0.0723466983079063958:\\
\;\;\;\;100 \cdot \frac{\frac{{\left(1 + \frac{i}{n}\right)}^{\left(2 \cdot n\right)} + \left(-1 \cdot 1\right)}{{\left(1 + \frac{i}{n}\right)}^{n} + 1}}{\frac{i}{n}}\\
\mathbf{elif}\;i \le 52622542467923034000:\\
\;\;\;\;\left(100 \cdot \frac{\mathsf{fma}\left(i, 1, \mathsf{fma}\left(0.5, {i}^{2}, \log 1 \cdot n\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)\right)}{i}\right) \cdot n\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \left(\left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right) \cdot \frac{n}{i}\right)\\
\end{array}double f(double i, double n) {
double r143340 = 100.0;
double r143341 = 1.0;
double r143342 = i;
double r143343 = n;
double r143344 = r143342 / r143343;
double r143345 = r143341 + r143344;
double r143346 = pow(r143345, r143343);
double r143347 = r143346 - r143341;
double r143348 = r143347 / r143344;
double r143349 = r143340 * r143348;
return r143349;
}
double f(double i, double n) {
double r143350 = i;
double r143351 = -0.0723466983079064;
bool r143352 = r143350 <= r143351;
double r143353 = 100.0;
double r143354 = 1.0;
double r143355 = n;
double r143356 = r143350 / r143355;
double r143357 = r143354 + r143356;
double r143358 = 2.0;
double r143359 = r143358 * r143355;
double r143360 = pow(r143357, r143359);
double r143361 = r143354 * r143354;
double r143362 = -r143361;
double r143363 = r143360 + r143362;
double r143364 = pow(r143357, r143355);
double r143365 = r143364 + r143354;
double r143366 = r143363 / r143365;
double r143367 = r143366 / r143356;
double r143368 = r143353 * r143367;
double r143369 = 5.2622542467923034e+19;
bool r143370 = r143350 <= r143369;
double r143371 = 0.5;
double r143372 = pow(r143350, r143358);
double r143373 = log(r143354);
double r143374 = r143373 * r143355;
double r143375 = fma(r143371, r143372, r143374);
double r143376 = r143372 * r143373;
double r143377 = r143371 * r143376;
double r143378 = r143375 - r143377;
double r143379 = fma(r143350, r143354, r143378);
double r143380 = r143379 / r143350;
double r143381 = r143353 * r143380;
double r143382 = r143381 * r143355;
double r143383 = r143364 - r143354;
double r143384 = r143355 / r143350;
double r143385 = r143383 * r143384;
double r143386 = r143353 * r143385;
double r143387 = r143370 ? r143382 : r143386;
double r143388 = r143352 ? r143368 : r143387;
return r143388;
}




Bits error versus i




Bits error versus n
| Original | 47.6 |
|---|---|
| Target | 47.8 |
| Herbie | 16.6 |
if i < -0.0723466983079064Initial program 27.5
rmApplied flip--27.5
Simplified27.5
if -0.0723466983079064 < i < 5.2622542467923034e+19Initial program 58.0
Taylor expanded around 0 26.8
Simplified26.8
rmApplied associate-/r/10.0
Applied associate-*r*10.0
if 5.2622542467923034e+19 < i Initial program 30.4
rmApplied div-inv30.4
Simplified30.4
Final simplification16.6
herbie shell --seed 2020064 +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))))