100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -1.310331411391640804347629725946168576314 \cdot 10^{-11}:\\
\;\;\;\;\frac{100 \cdot \left({\left(\frac{i}{n}\right)}^{n} - 1\right)}{\frac{i}{n}}\\
\mathbf{elif}\;i \le 1.280488904274837516756893343241770257007 \cdot 10^{-213}:\\
\;\;\;\;100 \cdot \left(\left(\sqrt[3]{\frac{1}{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)} \cdot \sqrt[3]{\frac{1}{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)}\right) \cdot \sqrt[3]{\frac{1}{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)}\right)\\
\mathbf{elif}\;i \le 1.07855901895175032609094606924337049933 \cdot 10^{-163}:\\
\;\;\;\;100 \cdot \left(\frac{1}{i} \cdot \sqrt[3]{{\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)}^{3}}\right)\\
\mathbf{elif}\;i \le 0.454201659190358431050782428428647108376:\\
\;\;\;\;100 \cdot \left(\frac{\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)}{i} \cdot n\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{100 \cdot \left({\left(\frac{i}{n}\right)}^{n} - 1\right)}{\frac{i}{n}}\\
\end{array}double f(double i, double n) {
double r141855 = 100.0;
double r141856 = 1.0;
double r141857 = i;
double r141858 = n;
double r141859 = r141857 / r141858;
double r141860 = r141856 + r141859;
double r141861 = pow(r141860, r141858);
double r141862 = r141861 - r141856;
double r141863 = r141862 / r141859;
double r141864 = r141855 * r141863;
return r141864;
}
double f(double i, double n) {
double r141865 = i;
double r141866 = -1.3103314113916408e-11;
bool r141867 = r141865 <= r141866;
double r141868 = 100.0;
double r141869 = n;
double r141870 = r141865 / r141869;
double r141871 = pow(r141870, r141869);
double r141872 = 1.0;
double r141873 = r141871 - r141872;
double r141874 = r141868 * r141873;
double r141875 = r141874 / r141870;
double r141876 = 1.2804889042748375e-213;
bool r141877 = r141865 <= r141876;
double r141878 = 1.0;
double r141879 = r141878 / r141865;
double r141880 = r141872 * r141865;
double r141881 = 0.5;
double r141882 = 2.0;
double r141883 = pow(r141865, r141882);
double r141884 = r141881 * r141883;
double r141885 = log(r141872);
double r141886 = r141885 * r141869;
double r141887 = r141884 + r141886;
double r141888 = r141880 + r141887;
double r141889 = r141883 * r141885;
double r141890 = r141881 * r141889;
double r141891 = r141888 - r141890;
double r141892 = r141891 * r141869;
double r141893 = r141879 * r141892;
double r141894 = cbrt(r141893);
double r141895 = r141894 * r141894;
double r141896 = r141895 * r141894;
double r141897 = r141868 * r141896;
double r141898 = 1.0785590189517503e-163;
bool r141899 = r141865 <= r141898;
double r141900 = 3.0;
double r141901 = pow(r141892, r141900);
double r141902 = cbrt(r141901);
double r141903 = r141879 * r141902;
double r141904 = r141868 * r141903;
double r141905 = 0.45420165919035843;
bool r141906 = r141865 <= r141905;
double r141907 = r141891 / r141865;
double r141908 = r141907 * r141869;
double r141909 = r141868 * r141908;
double r141910 = r141906 ? r141909 : r141875;
double r141911 = r141899 ? r141904 : r141910;
double r141912 = r141877 ? r141897 : r141911;
double r141913 = r141867 ? r141875 : r141912;
return r141913;
}




Bits error versus i




Bits error versus n
Results
| Original | 42.4 |
|---|---|
| Target | 42.3 |
| Herbie | 20.1 |
if i < -1.3103314113916408e-11 or 0.45420165919035843 < i Initial program 29.9
rmApplied associate-*r/29.8
Taylor expanded around inf 51.5
Simplified23.9
if -1.3103314113916408e-11 < i < 1.2804889042748375e-213Initial program 49.8
rmApplied div-inv49.8
Applied *-un-lft-identity49.8
Applied times-frac49.5
Simplified49.5
Taylor expanded around 0 15.7
rmApplied add-cube-cbrt16.3
if 1.2804889042748375e-213 < i < 1.0785590189517503e-163Initial program 49.0
rmApplied div-inv49.0
Applied *-un-lft-identity49.0
Applied times-frac48.6
Simplified48.6
Taylor expanded around 0 15.7
rmApplied add-cbrt-cube39.2
Applied add-cbrt-cube49.0
Applied cbrt-unprod49.0
Simplified27.1
if 1.0785590189517503e-163 < i < 0.45420165919035843Initial program 51.7
rmApplied div-inv51.7
Applied *-un-lft-identity51.7
Applied times-frac51.6
Simplified51.6
Taylor expanded around 0 15.1
rmApplied associate-*r*18.2
Simplified18.1
Final simplification20.1
herbie shell --seed 2019294
(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))))