100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -1.070226988062184:\\
\;\;\;\;\frac{1}{\frac{i}{\left(100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)\right) \cdot n}}\\
\mathbf{elif}\;i \le 1.1172319783923582 \cdot 10^{-10}:\\
\;\;\;\;\frac{\left(100 \cdot \left(\left(1 \cdot i + \left(0.5 \cdot {i}^{2} + \log 1 \cdot n\right)\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)\right)\right) \cdot n}{i}\\
\mathbf{else}:\\
\;\;\;\;\frac{{\left(1 + \frac{i}{n}\right)}^{n} \cdot 100 + \left(-1\right) \cdot 100}{\frac{i}{n}}\\
\end{array}double f(double i, double n) {
double r145091 = 100.0;
double r145092 = 1.0;
double r145093 = i;
double r145094 = n;
double r145095 = r145093 / r145094;
double r145096 = r145092 + r145095;
double r145097 = pow(r145096, r145094);
double r145098 = r145097 - r145092;
double r145099 = r145098 / r145095;
double r145100 = r145091 * r145099;
return r145100;
}
double f(double i, double n) {
double r145101 = i;
double r145102 = -1.070226988062184;
bool r145103 = r145101 <= r145102;
double r145104 = 1.0;
double r145105 = 100.0;
double r145106 = 1.0;
double r145107 = n;
double r145108 = r145101 / r145107;
double r145109 = r145106 + r145108;
double r145110 = pow(r145109, r145107);
double r145111 = r145110 - r145106;
double r145112 = r145105 * r145111;
double r145113 = r145112 * r145107;
double r145114 = r145101 / r145113;
double r145115 = r145104 / r145114;
double r145116 = 1.1172319783923582e-10;
bool r145117 = r145101 <= r145116;
double r145118 = r145106 * r145101;
double r145119 = 0.5;
double r145120 = 2.0;
double r145121 = pow(r145101, r145120);
double r145122 = r145119 * r145121;
double r145123 = log(r145106);
double r145124 = r145123 * r145107;
double r145125 = r145122 + r145124;
double r145126 = r145118 + r145125;
double r145127 = r145121 * r145123;
double r145128 = r145119 * r145127;
double r145129 = r145126 - r145128;
double r145130 = r145105 * r145129;
double r145131 = r145130 * r145107;
double r145132 = r145131 / r145101;
double r145133 = r145110 * r145105;
double r145134 = -r145106;
double r145135 = r145134 * r145105;
double r145136 = r145133 + r145135;
double r145137 = r145136 / r145108;
double r145138 = r145117 ? r145132 : r145137;
double r145139 = r145103 ? r145115 : r145138;
return r145139;
}




Bits error versus i




Bits error versus n
Results
| Original | 43.1 |
|---|---|
| Target | 42.4 |
| Herbie | 21.0 |
if i < -1.070226988062184Initial program 28.5
rmApplied associate-*r/28.5
rmApplied sub-neg28.5
Applied distribute-lft-in28.5
Simplified28.5
Simplified28.5
rmApplied *-un-lft-identity28.5
Applied *-un-lft-identity28.5
Applied times-frac28.5
Applied *-un-lft-identity28.5
Applied times-frac28.5
Simplified28.5
Simplified29.0
rmApplied clear-num28.6
if -1.070226988062184 < i < 1.1172319783923582e-10Initial program 51.0
rmApplied associate-*r/51.0
rmApplied sub-neg51.0
Applied distribute-lft-in51.0
Simplified51.0
Simplified51.0
rmApplied *-un-lft-identity51.0
Applied *-un-lft-identity51.0
Applied times-frac51.0
Applied *-un-lft-identity51.0
Applied times-frac51.0
Simplified51.0
Simplified50.6
Taylor expanded around 0 15.5
if 1.1172319783923582e-10 < i Initial program 32.9
rmApplied associate-*r/32.8
rmApplied sub-neg32.8
Applied distribute-lft-in32.9
Simplified32.9
Simplified32.9
Final simplification21.0
herbie shell --seed 2020043
(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))))