100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -0.8489635077384908301567634225648362189531:\\
\;\;\;\;\frac{100 \cdot \left({\left(\frac{i}{n}\right)}^{n} - 1\right)}{\frac{i}{n}}\\
\mathbf{elif}\;i \le 0.5476118163719528864064045592385809868574:\\
\;\;\;\;\frac{100}{i} \cdot \left(\left(\mathsf{fma}\left(1, i, \mathsf{fma}\left(0.5, {i}^{2}, \log 1 \cdot n\right)\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)\right) \cdot n\right)\\
\mathbf{else}:\\
\;\;\;\;\left(100 \cdot \frac{\sqrt[3]{{\left(1 + \frac{i}{n}\right)}^{n} - 1} \cdot \sqrt[3]{{\left(1 + \frac{i}{n}\right)}^{n} - 1}}{i}\right) \cdot \frac{\sqrt[3]{{\left(1 + \frac{i}{n}\right)}^{n} - 1}}{\frac{1}{n}}\\
\end{array}double f(double i, double n) {
double r111944 = 100.0;
double r111945 = 1.0;
double r111946 = i;
double r111947 = n;
double r111948 = r111946 / r111947;
double r111949 = r111945 + r111948;
double r111950 = pow(r111949, r111947);
double r111951 = r111950 - r111945;
double r111952 = r111951 / r111948;
double r111953 = r111944 * r111952;
return r111953;
}
double f(double i, double n) {
double r111954 = i;
double r111955 = -0.8489635077384908;
bool r111956 = r111954 <= r111955;
double r111957 = 100.0;
double r111958 = n;
double r111959 = r111954 / r111958;
double r111960 = pow(r111959, r111958);
double r111961 = 1.0;
double r111962 = r111960 - r111961;
double r111963 = r111957 * r111962;
double r111964 = r111963 / r111959;
double r111965 = 0.5476118163719529;
bool r111966 = r111954 <= r111965;
double r111967 = r111957 / r111954;
double r111968 = 0.5;
double r111969 = 2.0;
double r111970 = pow(r111954, r111969);
double r111971 = log(r111961);
double r111972 = r111971 * r111958;
double r111973 = fma(r111968, r111970, r111972);
double r111974 = fma(r111961, r111954, r111973);
double r111975 = r111970 * r111971;
double r111976 = r111968 * r111975;
double r111977 = r111974 - r111976;
double r111978 = r111977 * r111958;
double r111979 = r111967 * r111978;
double r111980 = r111961 + r111959;
double r111981 = pow(r111980, r111958);
double r111982 = r111981 - r111961;
double r111983 = cbrt(r111982);
double r111984 = r111983 * r111983;
double r111985 = r111984 / r111954;
double r111986 = r111957 * r111985;
double r111987 = 1.0;
double r111988 = r111987 / r111958;
double r111989 = r111983 / r111988;
double r111990 = r111986 * r111989;
double r111991 = r111966 ? r111979 : r111990;
double r111992 = r111956 ? r111964 : r111991;
return r111992;
}




Bits error versus i




Bits error versus n
| Original | 43.0 |
|---|---|
| Target | 43.5 |
| Herbie | 18.8 |
if i < -0.8489635077384908Initial program 27.4
Taylor expanded around inf 64.0
Simplified18.1
if -0.8489635077384908 < i < 0.5476118163719529Initial program 50.8
Taylor expanded around 0 34.2
Simplified34.2
rmApplied div-inv34.3
Applied *-un-lft-identity34.3
Applied times-frac15.8
Simplified15.8
rmApplied associate-*r*16.2
Simplified16.1
if 0.5476118163719529 < i Initial program 32.4
rmApplied div-inv32.4
Applied add-cube-cbrt32.4
Applied times-frac32.4
Applied associate-*r*32.4
Final simplification18.8
herbie shell --seed 2019323 +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))))