100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -0.8489635077384908301567634225648362189531:\\
\;\;\;\;100 \cdot \frac{{\left(\frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\\
\mathbf{elif}\;i \le 0.5476118163719528864064045592385809868574:\\
\;\;\;\;\frac{100}{i} \cdot \left(\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) \cdot n\right)\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \left(\frac{1}{i} \cdot \left(\left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right) \cdot n\right)\right)\\
\end{array}double f(double i, double n) {
double r268886 = 100.0;
double r268887 = 1.0;
double r268888 = i;
double r268889 = n;
double r268890 = r268888 / r268889;
double r268891 = r268887 + r268890;
double r268892 = pow(r268891, r268889);
double r268893 = r268892 - r268887;
double r268894 = r268893 / r268890;
double r268895 = r268886 * r268894;
return r268895;
}
double f(double i, double n) {
double r268896 = i;
double r268897 = -0.8489635077384908;
bool r268898 = r268896 <= r268897;
double r268899 = 100.0;
double r268900 = n;
double r268901 = r268896 / r268900;
double r268902 = pow(r268901, r268900);
double r268903 = 1.0;
double r268904 = r268902 - r268903;
double r268905 = r268904 / r268901;
double r268906 = r268899 * r268905;
double r268907 = 0.5476118163719529;
bool r268908 = r268896 <= r268907;
double r268909 = r268899 / r268896;
double r268910 = r268903 * r268896;
double r268911 = 0.5;
double r268912 = 2.0;
double r268913 = pow(r268896, r268912);
double r268914 = r268911 * r268913;
double r268915 = log(r268903);
double r268916 = r268915 * r268900;
double r268917 = r268914 + r268916;
double r268918 = r268910 + r268917;
double r268919 = r268913 * r268915;
double r268920 = r268911 * r268919;
double r268921 = r268918 - r268920;
double r268922 = r268921 * r268900;
double r268923 = r268909 * r268922;
double r268924 = 1.0;
double r268925 = r268924 / r268896;
double r268926 = r268903 + r268901;
double r268927 = pow(r268926, r268900);
double r268928 = r268927 - r268903;
double r268929 = r268928 * r268900;
double r268930 = r268925 * r268929;
double r268931 = r268899 * r268930;
double r268932 = r268908 ? r268923 : r268931;
double r268933 = r268898 ? r268906 : r268932;
return r268933;
}




Bits error versus i




Bits error versus n
Results
| Original | 43.0 |
|---|---|
| Target | 43.5 |
| Herbie | 18.8 |
if i < -0.8489635077384908Initial program 27.4
Taylor expanded around inf 64.0
Simplified18.2
if -0.8489635077384908 < i < 0.5476118163719529Initial program 50.8
Taylor expanded around 0 34.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 *-un-lft-identity32.4
Applied times-frac32.4
Simplified32.4
Final simplification18.8
herbie shell --seed 2019323
(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))))