100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -2072.084458567275305540533736348152160645:\\
\;\;\;\;\frac{{\left(\frac{1}{n} \cdot i\right)}^{n} - 1}{\frac{i}{n}} \cdot 100\\
\mathbf{elif}\;i \le 3.107272117925894111483480369189253739367 \cdot 10^{-249}:\\
\;\;\;\;\frac{1}{\frac{\frac{i}{i \cdot \left(i \cdot 0.5 + 1\right) - \left(0.5 \cdot \left(i \cdot i\right) - n\right) \cdot \log 1}}{100}} \cdot n\\
\mathbf{elif}\;i \le 5.594879277814152504998655712764588088248 \cdot 10^{-6}:\\
\;\;\;\;\sqrt[3]{\frac{n \cdot \left(i \cdot \left(i \cdot 0.5 + 1\right) - \left(0.5 \cdot \left(i \cdot i\right) - n\right) \cdot \log 1\right)}{\frac{i}{100}}} \cdot \left(\sqrt[3]{\frac{n \cdot \left(i \cdot \left(i \cdot 0.5 + 1\right) - \left(0.5 \cdot \left(i \cdot i\right) - n\right) \cdot \log 1\right)}{\frac{i}{100}}} \cdot \sqrt[3]{\frac{n \cdot \left(i \cdot \left(i \cdot 0.5 + 1\right) - \left(0.5 \cdot \left(i \cdot i\right) - n\right) \cdot \log 1\right)}{\frac{i}{100}}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\left({\left(\frac{i}{n} + 1\right)}^{\left(n \cdot 2\right)} - 1 \cdot 1\right) \cdot 100}{{\left(\frac{i}{n} + 1\right)}^{n} + 1}}{i} \cdot n\\
\end{array}double f(double i, double n) {
double r113843 = 100.0;
double r113844 = 1.0;
double r113845 = i;
double r113846 = n;
double r113847 = r113845 / r113846;
double r113848 = r113844 + r113847;
double r113849 = pow(r113848, r113846);
double r113850 = r113849 - r113844;
double r113851 = r113850 / r113847;
double r113852 = r113843 * r113851;
return r113852;
}
double f(double i, double n) {
double r113853 = i;
double r113854 = -2072.0844585672753;
bool r113855 = r113853 <= r113854;
double r113856 = 1.0;
double r113857 = n;
double r113858 = r113856 / r113857;
double r113859 = r113858 * r113853;
double r113860 = pow(r113859, r113857);
double r113861 = 1.0;
double r113862 = r113860 - r113861;
double r113863 = r113853 / r113857;
double r113864 = r113862 / r113863;
double r113865 = 100.0;
double r113866 = r113864 * r113865;
double r113867 = 3.107272117925894e-249;
bool r113868 = r113853 <= r113867;
double r113869 = 0.5;
double r113870 = r113853 * r113869;
double r113871 = r113870 + r113861;
double r113872 = r113853 * r113871;
double r113873 = r113853 * r113853;
double r113874 = r113869 * r113873;
double r113875 = r113874 - r113857;
double r113876 = log(r113861);
double r113877 = r113875 * r113876;
double r113878 = r113872 - r113877;
double r113879 = r113853 / r113878;
double r113880 = r113879 / r113865;
double r113881 = r113856 / r113880;
double r113882 = r113881 * r113857;
double r113883 = 5.5948792778141525e-06;
bool r113884 = r113853 <= r113883;
double r113885 = r113857 * r113878;
double r113886 = r113853 / r113865;
double r113887 = r113885 / r113886;
double r113888 = cbrt(r113887);
double r113889 = r113888 * r113888;
double r113890 = r113888 * r113889;
double r113891 = r113863 + r113861;
double r113892 = 2.0;
double r113893 = r113857 * r113892;
double r113894 = pow(r113891, r113893);
double r113895 = r113861 * r113861;
double r113896 = r113894 - r113895;
double r113897 = r113896 * r113865;
double r113898 = pow(r113891, r113857);
double r113899 = r113898 + r113861;
double r113900 = r113897 / r113899;
double r113901 = r113900 / r113853;
double r113902 = r113901 * r113857;
double r113903 = r113884 ? r113890 : r113902;
double r113904 = r113868 ? r113882 : r113903;
double r113905 = r113855 ? r113866 : r113904;
return r113905;
}




Bits error versus i




Bits error versus n
Results
| Original | 43.3 |
|---|---|
| Target | 43.1 |
| Herbie | 19.0 |
if i < -2072.0844585672753Initial program 27.9
rmApplied associate-/r/28.5
Applied associate-*r*28.5
Simplified28.4
Taylor expanded around inf 64.0
Simplified19.4
if -2072.0844585672753 < i < 3.107272117925894e-249Initial program 51.5
rmApplied associate-/r/51.1
Applied associate-*r*51.1
Simplified51.1
Taylor expanded around 0 16.2
Simplified16.2
rmApplied clear-num16.2
Simplified16.1
if 3.107272117925894e-249 < i < 5.5948792778141525e-06Initial program 50.4
rmApplied associate-/r/50.2
Applied associate-*r*50.2
Simplified50.2
Taylor expanded around 0 17.6
Simplified17.6
rmApplied add-cube-cbrt18.4
Simplified15.4
Simplified15.5
if 5.5948792778141525e-06 < i Initial program 32.7
rmApplied associate-/r/32.7
Applied associate-*r*32.7
Simplified32.7
rmApplied flip--32.7
Applied associate-*l/32.7
Simplified32.7
Final simplification19.0
herbie shell --seed 2019196
(FPCore (i n)
:name "Compound Interest"
:herbie-target
(* 100.0 (/ (- (exp (* n (if (== (+ 1.0 (/ i n)) 1.0) (/ i n) (/ (* (/ i n) (log (+ 1.0 (/ i n)))) (- (+ (/ i n) 1.0) 1.0))))) 1.0) (/ i n)))
(* 100.0 (/ (- (pow (+ 1.0 (/ i n)) n) 1.0) (/ i n))))