100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;n \le -6.470021336482934 \cdot 10^{+94}:\\
\;\;\;\;\left(n + n \cdot \left(\frac{1}{2} \cdot i + \frac{1}{6} \cdot \left(i \cdot i\right)\right)\right) \cdot 100\\
\mathbf{elif}\;n \le -6.429664273656172 \cdot 10^{+68}:\\
\;\;\;\;n \cdot \left(\frac{{\left(\frac{i}{n} + 1\right)}^{n} - 1}{i} \cdot 100\right)\\
\mathbf{elif}\;n \le -0.574841385015252:\\
\;\;\;\;\left(n + n \cdot \left(\frac{1}{2} \cdot i + \frac{1}{6} \cdot \left(i \cdot i\right)\right)\right) \cdot 100\\
\mathbf{elif}\;n \le 1.2083195710773826 \cdot 10^{-138}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;\left(n + n \cdot \left(\frac{1}{2} \cdot i + \frac{1}{6} \cdot \left(i \cdot i\right)\right)\right) \cdot 100\\
\end{array}double f(double i, double n) {
double r5069820 = 100.0;
double r5069821 = 1.0;
double r5069822 = i;
double r5069823 = n;
double r5069824 = r5069822 / r5069823;
double r5069825 = r5069821 + r5069824;
double r5069826 = pow(r5069825, r5069823);
double r5069827 = r5069826 - r5069821;
double r5069828 = r5069827 / r5069824;
double r5069829 = r5069820 * r5069828;
return r5069829;
}
double f(double i, double n) {
double r5069830 = n;
double r5069831 = -6.470021336482934e+94;
bool r5069832 = r5069830 <= r5069831;
double r5069833 = 0.5;
double r5069834 = i;
double r5069835 = r5069833 * r5069834;
double r5069836 = 0.16666666666666666;
double r5069837 = r5069834 * r5069834;
double r5069838 = r5069836 * r5069837;
double r5069839 = r5069835 + r5069838;
double r5069840 = r5069830 * r5069839;
double r5069841 = r5069830 + r5069840;
double r5069842 = 100.0;
double r5069843 = r5069841 * r5069842;
double r5069844 = -6.429664273656172e+68;
bool r5069845 = r5069830 <= r5069844;
double r5069846 = r5069834 / r5069830;
double r5069847 = 1.0;
double r5069848 = r5069846 + r5069847;
double r5069849 = pow(r5069848, r5069830);
double r5069850 = r5069849 - r5069847;
double r5069851 = r5069850 / r5069834;
double r5069852 = r5069851 * r5069842;
double r5069853 = r5069830 * r5069852;
double r5069854 = -0.574841385015252;
bool r5069855 = r5069830 <= r5069854;
double r5069856 = 1.2083195710773826e-138;
bool r5069857 = r5069830 <= r5069856;
double r5069858 = 0.0;
double r5069859 = r5069857 ? r5069858 : r5069843;
double r5069860 = r5069855 ? r5069843 : r5069859;
double r5069861 = r5069845 ? r5069853 : r5069860;
double r5069862 = r5069832 ? r5069843 : r5069861;
return r5069862;
}




Bits error versus i




Bits error versus n
Results
| Original | 42.1 |
|---|---|
| Target | 41.8 |
| Herbie | 21.0 |
if n < -6.470021336482934e+94 or -6.429664273656172e+68 < n < -0.574841385015252 or 1.2083195710773826e-138 < n Initial program 52.4
Taylor expanded around 0 37.5
Simplified37.5
rmApplied associate-/r/21.9
Simplified21.9
Taylor expanded around 0 22.0
Simplified21.9
if -6.470021336482934e+94 < n < -6.429664273656172e+68Initial program 33.9
rmApplied associate-/r/33.8
Applied associate-*r*33.7
if -0.574841385015252 < n < 1.2083195710773826e-138Initial program 24.4
Taylor expanded around 0 18.5
Final simplification21.0
herbie shell --seed 2019162
(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))))