double f(double i, double n) {
double r50319678 = 100.0;
double r50319679 = 1.0;
double r50319680 = i;
double r50319681 = n;
double r50319682 = r50319680 / r50319681;
double r50319683 = r50319679 + r50319682;
double r50319684 = pow(r50319683, r50319681);
double r50319685 = r50319684 - r50319679;
double r50319686 = r50319685 / r50319682;
double r50319687 = r50319678 * r50319686;
return r50319687;
}
double f(double i, double n) {
double r50319688 = i;
double r50319689 = -1.0226829360061689;
bool r50319690 = r50319688 <= r50319689;
double r50319691 = n;
double r50319692 = r50319691 / r50319688;
double r50319693 = 1.0;
double r50319694 = r50319693 / r50319692;
double r50319695 = pow(r50319694, r50319691);
double r50319696 = r50319695 - r50319693;
double r50319697 = r50319692 * r50319696;
double r50319698 = 100.0;
double r50319699 = r50319697 * r50319698;
double r50319700 = 0.7031677524180419;
bool r50319701 = r50319688 <= r50319700;
double r50319702 = 0.16666666666666666;
double r50319703 = r50319688 * r50319702;
double r50319704 = 0.5;
double r50319705 = r50319703 + r50319704;
double r50319706 = r50319688 * r50319705;
double r50319707 = r50319688 * r50319706;
double r50319708 = r50319688 + r50319707;
double r50319709 = r50319691 * r50319708;
double r50319710 = r50319693 / r50319688;
double r50319711 = r50319710 * r50319698;
double r50319712 = r50319709 * r50319711;
double r50319713 = 0.0;
double r50319714 = r50319701 ? r50319712 : r50319713;
double r50319715 = r50319690 ? r50319699 : r50319714;
return r50319715;
}
100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -1.0226829360061689:\\
\;\;\;\;\left(\frac{n}{i} \cdot \left({\left(\frac{1}{\frac{n}{i}}\right)}^{n} - 1\right)\right) \cdot 100\\
\mathbf{elif}\;i \le 0.7031677524180419:\\
\;\;\;\;\left(n \cdot \left(i + i \cdot \left(i \cdot \left(i \cdot \frac{1}{6} + \frac{1}{2}\right)\right)\right)\right) \cdot \left(\frac{1}{i} \cdot 100\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}



Bits error versus i




Bits error versus n
| Original | 42.6 |
|---|---|
| Target | 41.9 |
| Herbie | 18.4 |
if i < -1.0226829360061689Initial program 29.5
Taylor expanded around inf 62.9
Simplified19.6
if -1.0226829360061689 < i < 0.7031677524180419Initial program 49.8
Taylor expanded around 0 32.3
Simplified32.3
rmApplied div-inv32.4
Applied *-un-lft-identity32.4
Applied times-frac15.2
Applied associate-*r*15.6
Simplified15.6
if 0.7031677524180419 < i Initial program 31.2
Taylor expanded around 0 29.5
Final simplification18.4
herbie shell --seed 2019101
(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))))