100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -0.008529206764181104793998144941724603995681 \lor \neg \left(i \le 4.039962480132392563803023222135379910469\right):\\
\;\;\;\;100 \cdot \frac{\frac{{\left(\frac{i}{n} + 1\right)}^{\left(n \cdot 2\right)} - 1 \cdot 1}{1 + {\left(\frac{i}{n} + 1\right)}^{n}}}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \left(\frac{\log 1 \cdot \left(n - \left(i \cdot 0.5\right) \cdot i\right) + i \cdot \left(i \cdot 0.5 + 1\right)}{i} \cdot n\right)\\
\end{array}double f(double i, double n) {
double r390618 = 100.0;
double r390619 = 1.0;
double r390620 = i;
double r390621 = n;
double r390622 = r390620 / r390621;
double r390623 = r390619 + r390622;
double r390624 = pow(r390623, r390621);
double r390625 = r390624 - r390619;
double r390626 = r390625 / r390622;
double r390627 = r390618 * r390626;
return r390627;
}
double f(double i, double n) {
double r390628 = i;
double r390629 = -0.008529206764181105;
bool r390630 = r390628 <= r390629;
double r390631 = 4.039962480132393;
bool r390632 = r390628 <= r390631;
double r390633 = !r390632;
bool r390634 = r390630 || r390633;
double r390635 = 100.0;
double r390636 = n;
double r390637 = r390628 / r390636;
double r390638 = 1.0;
double r390639 = r390637 + r390638;
double r390640 = 2.0;
double r390641 = r390636 * r390640;
double r390642 = pow(r390639, r390641);
double r390643 = r390638 * r390638;
double r390644 = r390642 - r390643;
double r390645 = pow(r390639, r390636);
double r390646 = r390638 + r390645;
double r390647 = r390644 / r390646;
double r390648 = r390647 / r390637;
double r390649 = r390635 * r390648;
double r390650 = log(r390638);
double r390651 = 0.5;
double r390652 = r390628 * r390651;
double r390653 = r390652 * r390628;
double r390654 = r390636 - r390653;
double r390655 = r390650 * r390654;
double r390656 = r390652 + r390638;
double r390657 = r390628 * r390656;
double r390658 = r390655 + r390657;
double r390659 = r390658 / r390628;
double r390660 = r390659 * r390636;
double r390661 = r390635 * r390660;
double r390662 = r390634 ? r390649 : r390661;
return r390662;
}




Bits error versus i




Bits error versus n
Results
| Original | 43.1 |
|---|---|
| Target | 42.9 |
| Herbie | 21.5 |
if i < -0.008529206764181105 or 4.039962480132393 < i Initial program 30.1
rmApplied flip--30.1
Simplified30.0
Simplified30.0
if -0.008529206764181105 < i < 4.039962480132393Initial program 50.8
Taylor expanded around 0 33.6
Simplified33.6
rmApplied associate-/r/16.4
Simplified16.4
Final simplification21.5
herbie shell --seed 2019174
(FPCore (i n)
:name "Compound Interest"
:herbie-target
(* 100.0 (/ (- (exp (* n (if (== (+ 1.0 (/ i n)) 1.0) (/ i n) (/ (* (/ i n) (log (+ 1.0 (/ i n)))) (- (+ (/ i n) 1.0) 1.0))))) 1.0) (/ i n)))
(* 100.0 (/ (- (pow (+ 1.0 (/ i n)) n) 1.0) (/ i n))))