100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -0.1040807419505014597138625731531647033989:\\
\;\;\;\;100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\\
\mathbf{elif}\;i \le -1.431352546837178178390578970408631011162 \cdot 10^{-255}:\\
\;\;\;\;\left(\sqrt[3]{\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)} \cdot \sqrt[3]{\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)}\right) \cdot \sqrt[3]{\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{elif}\;i \le 3.912989910623956103641462485659015187104 \cdot 10^{-198}:\\
\;\;\;\;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{elif}\;i \le 18.6629372047199559858654538402333855629:\\
\;\;\;\;\left(\sqrt[3]{\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)} \cdot \sqrt[3]{\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)}\right) \cdot \sqrt[3]{\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{elif}\;i \le 5.064717226083425690234124091873168768786 \cdot 10^{144}:\\
\;\;\;\;\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}}\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{\left(1 \cdot i + \left(\log 1 \cdot n + 1\right)\right) - 1}{\frac{i}{n}}\\
\end{array}double f(double i, double n) {
double r104814 = 100.0;
double r104815 = 1.0;
double r104816 = i;
double r104817 = n;
double r104818 = r104816 / r104817;
double r104819 = r104815 + r104818;
double r104820 = pow(r104819, r104817);
double r104821 = r104820 - r104815;
double r104822 = r104821 / r104818;
double r104823 = r104814 * r104822;
return r104823;
}
double f(double i, double n) {
double r104824 = i;
double r104825 = -0.10408074195050146;
bool r104826 = r104824 <= r104825;
double r104827 = 100.0;
double r104828 = 1.0;
double r104829 = n;
double r104830 = r104824 / r104829;
double r104831 = r104828 + r104830;
double r104832 = pow(r104831, r104829);
double r104833 = r104832 - r104828;
double r104834 = r104833 / r104830;
double r104835 = r104827 * r104834;
double r104836 = -1.4313525468371782e-255;
bool r104837 = r104824 <= r104836;
double r104838 = r104827 / r104824;
double r104839 = r104828 * r104824;
double r104840 = 0.5;
double r104841 = 2.0;
double r104842 = pow(r104824, r104841);
double r104843 = r104840 * r104842;
double r104844 = log(r104828);
double r104845 = r104844 * r104829;
double r104846 = r104843 + r104845;
double r104847 = r104839 + r104846;
double r104848 = r104842 * r104844;
double r104849 = r104840 * r104848;
double r104850 = r104847 - r104849;
double r104851 = r104850 * r104829;
double r104852 = r104838 * r104851;
double r104853 = cbrt(r104852);
double r104854 = r104853 * r104853;
double r104855 = r104854 * r104853;
double r104856 = 3.912989910623956e-198;
bool r104857 = r104824 <= r104856;
double r104858 = r104850 / r104824;
double r104859 = r104858 * r104829;
double r104860 = r104827 * r104859;
double r104861 = 18.662937204719956;
bool r104862 = r104824 <= r104861;
double r104863 = 5.064717226083426e+144;
bool r104864 = r104824 <= r104863;
double r104865 = cbrt(r104833);
double r104866 = r104865 * r104865;
double r104867 = r104866 / r104824;
double r104868 = r104827 * r104867;
double r104869 = 1.0;
double r104870 = r104869 / r104829;
double r104871 = r104865 / r104870;
double r104872 = r104868 * r104871;
double r104873 = r104845 + r104869;
double r104874 = r104839 + r104873;
double r104875 = r104874 - r104828;
double r104876 = r104875 / r104830;
double r104877 = r104827 * r104876;
double r104878 = r104864 ? r104872 : r104877;
double r104879 = r104862 ? r104855 : r104878;
double r104880 = r104857 ? r104860 : r104879;
double r104881 = r104837 ? r104855 : r104880;
double r104882 = r104826 ? r104835 : r104881;
return r104882;
}




Bits error versus i




Bits error versus n
Results
| Original | 43.1 |
|---|---|
| Target | 42.7 |
| Herbie | 21.4 |
if i < -0.10408074195050146Initial program 29.8
if -0.10408074195050146 < i < -1.4313525468371782e-255 or 3.912989910623956e-198 < i < 18.662937204719956Initial program 51.0
Taylor expanded around 0 30.6
rmApplied div-inv30.7
Applied *-un-lft-identity30.7
Applied times-frac15.6
Applied associate-*r*15.7
Simplified15.7
rmApplied add-cube-cbrt16.2
Simplified16.2
Simplified16.2
if -1.4313525468371782e-255 < i < 3.912989910623956e-198Initial program 49.3
Taylor expanded around 0 40.8
rmApplied associate-/r/14.4
if 18.662937204719956 < i < 5.064717226083426e+144Initial program 30.0
rmApplied div-inv30.0
Applied add-cube-cbrt30.0
Applied times-frac30.0
Applied associate-*r*30.0
if 5.064717226083426e+144 < i Initial program 30.1
Taylor expanded around 0 36.9
Final simplification21.4
herbie shell --seed 2019235
(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))))