100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -0.4112290909641321823286830294819083064795:\\
\;\;\;\;100 \cdot \frac{{\left(\frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\\
\mathbf{elif}\;i \le 116.7795525870314179428532952442765235901:\\
\;\;\;\;\frac{100}{\frac{i}{\left(i \cdot \left(1 + 0.5 \cdot i\right) + \log 1 \cdot \left(n - 0.5 \cdot {i}^{2}\right)\right) \cdot n}}\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{n \cdot \left({\left(\frac{i}{n}\right)}^{n} - 1\right)}{i}\\
\end{array}double f(double i, double n) {
double r126359 = 100.0;
double r126360 = 1.0;
double r126361 = i;
double r126362 = n;
double r126363 = r126361 / r126362;
double r126364 = r126360 + r126363;
double r126365 = pow(r126364, r126362);
double r126366 = r126365 - r126360;
double r126367 = r126366 / r126363;
double r126368 = r126359 * r126367;
return r126368;
}
double f(double i, double n) {
double r126369 = i;
double r126370 = -0.4112290909641322;
bool r126371 = r126369 <= r126370;
double r126372 = 100.0;
double r126373 = n;
double r126374 = r126369 / r126373;
double r126375 = pow(r126374, r126373);
double r126376 = 1.0;
double r126377 = r126375 - r126376;
double r126378 = r126377 / r126374;
double r126379 = r126372 * r126378;
double r126380 = 116.77955258703142;
bool r126381 = r126369 <= r126380;
double r126382 = 0.5;
double r126383 = r126382 * r126369;
double r126384 = r126376 + r126383;
double r126385 = r126369 * r126384;
double r126386 = log(r126376);
double r126387 = 2.0;
double r126388 = pow(r126369, r126387);
double r126389 = r126382 * r126388;
double r126390 = r126373 - r126389;
double r126391 = r126386 * r126390;
double r126392 = r126385 + r126391;
double r126393 = r126392 * r126373;
double r126394 = r126369 / r126393;
double r126395 = r126372 / r126394;
double r126396 = r126373 * r126377;
double r126397 = r126396 / r126369;
double r126398 = r126372 * r126397;
double r126399 = r126381 ? r126395 : r126398;
double r126400 = r126371 ? r126379 : r126399;
return r126400;
}




Bits error versus i




Bits error versus n
Results
| Original | 43.0 |
|---|---|
| Target | 42.6 |
| Herbie | 18.5 |
if i < -0.4112290909641322Initial program 27.5
Taylor expanded around inf 64.0
Simplified17.6
if -0.4112290909641322 < i < 116.77955258703142Initial program 50.8
rmApplied associate-*r/50.8
rmApplied sub-neg50.8
Applied distribute-lft-in50.8
rmApplied distribute-lft-out50.8
Applied associate-/l*50.8
Simplified50.5
Taylor expanded around 0 16.3
Simplified16.3
if 116.77955258703142 < i Initial program 31.3
Taylor expanded around inf 29.2
Simplified31.3
Final simplification18.5
herbie shell --seed 2019347
(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))))