100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -2.022117346357720003868253810797028791058 \cdot 10^{-5}:\\
\;\;\;\;100 \cdot \frac{{\left({\left(1 + \frac{i}{n}\right)}^{n}\right)}^{3} - {1}^{3}}{\mathsf{fma}\left(1, 1 + {\left(1 + \frac{i}{n}\right)}^{n}, {\left(1 + \frac{i}{n}\right)}^{\left(2 \cdot n\right)}\right) \cdot \frac{i}{n}}\\
\mathbf{elif}\;i \le 187.3391238131879674710944527760148048401:\\
\;\;\;\;100 \cdot \left(\frac{\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)}{i} \cdot n\right)\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{\mathsf{fma}\left(1, i, \mathsf{fma}\left(\log 1, n, 1\right)\right) - 1}{\frac{i}{n}}\\
\end{array}double f(double i, double n) {
double r135824 = 100.0;
double r135825 = 1.0;
double r135826 = i;
double r135827 = n;
double r135828 = r135826 / r135827;
double r135829 = r135825 + r135828;
double r135830 = pow(r135829, r135827);
double r135831 = r135830 - r135825;
double r135832 = r135831 / r135828;
double r135833 = r135824 * r135832;
return r135833;
}
double f(double i, double n) {
double r135834 = i;
double r135835 = -2.02211734635772e-05;
bool r135836 = r135834 <= r135835;
double r135837 = 100.0;
double r135838 = 1.0;
double r135839 = n;
double r135840 = r135834 / r135839;
double r135841 = r135838 + r135840;
double r135842 = pow(r135841, r135839);
double r135843 = 3.0;
double r135844 = pow(r135842, r135843);
double r135845 = pow(r135838, r135843);
double r135846 = r135844 - r135845;
double r135847 = r135838 + r135842;
double r135848 = 2.0;
double r135849 = r135848 * r135839;
double r135850 = pow(r135841, r135849);
double r135851 = fma(r135838, r135847, r135850);
double r135852 = r135851 * r135840;
double r135853 = r135846 / r135852;
double r135854 = r135837 * r135853;
double r135855 = 187.33912381318797;
bool r135856 = r135834 <= r135855;
double r135857 = 0.5;
double r135858 = pow(r135834, r135848);
double r135859 = log(r135838);
double r135860 = r135859 * r135839;
double r135861 = fma(r135857, r135858, r135860);
double r135862 = fma(r135838, r135834, r135861);
double r135863 = r135858 * r135859;
double r135864 = r135857 * r135863;
double r135865 = r135862 - r135864;
double r135866 = r135865 / r135834;
double r135867 = r135866 * r135839;
double r135868 = r135837 * r135867;
double r135869 = 1.0;
double r135870 = fma(r135859, r135839, r135869);
double r135871 = fma(r135838, r135834, r135870);
double r135872 = r135871 - r135838;
double r135873 = r135872 / r135840;
double r135874 = r135837 * r135873;
double r135875 = r135856 ? r135868 : r135874;
double r135876 = r135836 ? r135854 : r135875;
return r135876;
}




Bits error versus i




Bits error versus n
| Original | 42.8 |
|---|---|
| Target | 42.9 |
| Herbie | 22.3 |
if i < -2.02211734635772e-05Initial program 27.2
rmApplied flip3--27.2
Applied associate-/l/27.2
Simplified27.2
if -2.02211734635772e-05 < i < 187.33912381318797Initial program 50.6
Taylor expanded around 0 34.4
Simplified34.4
rmApplied associate-/r/17.0
if 187.33912381318797 < i Initial program 32.4
Taylor expanded around 0 39.8
Simplified39.8
Final simplification22.3
herbie shell --seed 2019305 +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))))