100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -1.237131456279114563109935683102053260005 \cdot 10^{-18} \lor \neg \left(i \le 3222196569.804427623748779296875\right):\\
\;\;\;\;100 \cdot \frac{\mathsf{fma}\left({\left(\sqrt[3]{1 + \frac{i}{n}} \cdot \sqrt[3]{1 + \frac{i}{n}}\right)}^{n}, {\left(\sqrt[3]{\frac{i}{n}}\right)}^{n}, -1\right)}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;\frac{100 \cdot \left(\left(\mathsf{fma}\left(1, i, \mathsf{fma}\left(0.5, i \cdot i, \log 1 \cdot n\right)\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)\right) \cdot n\right)}{i}\\
\end{array}double f(double i, double n) {
double r121956 = 100.0;
double r121957 = 1.0;
double r121958 = i;
double r121959 = n;
double r121960 = r121958 / r121959;
double r121961 = r121957 + r121960;
double r121962 = pow(r121961, r121959);
double r121963 = r121962 - r121957;
double r121964 = r121963 / r121960;
double r121965 = r121956 * r121964;
return r121965;
}
double f(double i, double n) {
double r121966 = i;
double r121967 = -1.2371314562791146e-18;
bool r121968 = r121966 <= r121967;
double r121969 = 3222196569.8044276;
bool r121970 = r121966 <= r121969;
double r121971 = !r121970;
bool r121972 = r121968 || r121971;
double r121973 = 100.0;
double r121974 = 1.0;
double r121975 = n;
double r121976 = r121966 / r121975;
double r121977 = r121974 + r121976;
double r121978 = cbrt(r121977);
double r121979 = r121978 * r121978;
double r121980 = pow(r121979, r121975);
double r121981 = cbrt(r121976);
double r121982 = pow(r121981, r121975);
double r121983 = -r121974;
double r121984 = fma(r121980, r121982, r121983);
double r121985 = r121984 / r121976;
double r121986 = r121973 * r121985;
double r121987 = 0.5;
double r121988 = r121966 * r121966;
double r121989 = log(r121974);
double r121990 = r121989 * r121975;
double r121991 = fma(r121987, r121988, r121990);
double r121992 = fma(r121974, r121966, r121991);
double r121993 = 2.0;
double r121994 = pow(r121966, r121993);
double r121995 = r121994 * r121989;
double r121996 = r121987 * r121995;
double r121997 = r121992 - r121996;
double r121998 = r121997 * r121975;
double r121999 = r121973 * r121998;
double r122000 = r121999 / r121966;
double r122001 = r121972 ? r121986 : r122000;
return r122001;
}




Bits error versus i




Bits error versus n
| Original | 43.0 |
|---|---|
| Target | 42.7 |
| Herbie | 19.4 |
if i < -1.2371314562791146e-18 or 3222196569.8044276 < i Initial program 30.3
rmApplied add-cube-cbrt30.5
Applied unpow-prod-down30.5
Applied fma-neg30.5
Taylor expanded around inf 59.7
Simplified25.0
if -1.2371314562791146e-18 < i < 3222196569.8044276Initial program 50.8
rmApplied associate-/r/50.4
Taylor expanded around 0 16.9
Simplified16.9
rmApplied associate-*l/15.7
Applied associate-*r/15.9
Final simplification19.4
herbie shell --seed 2019212 +o rules:numerics
(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))))