100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;n \le -2.23087318151625042 \cdot 10^{136}:\\
\;\;\;\;\left(\left(100 \cdot \sqrt{\frac{\mathsf{fma}\left(i, 1, \mathsf{fma}\left(0.5, {i}^{2}, \log 1 \cdot n\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)\right)}{i}}\right) \cdot \sqrt{\frac{\mathsf{fma}\left(i, 1, \mathsf{fma}\left(0.5, {i}^{2}, \log 1 \cdot n\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)\right)}{i}}\right) \cdot n\\
\mathbf{elif}\;n \le -1.09580041647786345 \cdot 10^{86}:\\
\;\;\;\;\frac{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}{\frac{i}{n}}\\
\mathbf{elif}\;n \le -35142169422648208:\\
\;\;\;\;\left(\left(100 \cdot \sqrt{\frac{\mathsf{fma}\left(i, 1, \mathsf{fma}\left(0.5, {i}^{2}, \log 1 \cdot n\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)\right)}{i}}\right) \cdot \sqrt{\frac{\mathsf{fma}\left(i, 1, \mathsf{fma}\left(0.5, {i}^{2}, \log 1 \cdot n\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)\right)}{i}}\right) \cdot n\\
\mathbf{elif}\;n \le -1.2431085101949388 \cdot 10^{-214}:\\
\;\;\;\;100 \cdot \frac{\log \left(e^{{\left(1 + \frac{i}{n}\right)}^{n} - 1}\right)}{\frac{i}{n}}\\
\mathbf{elif}\;n \le 2.0850330521039454 \cdot 10^{-172}:\\
\;\;\;\;100 \cdot \frac{\mathsf{fma}\left(1, i, \mathsf{fma}\left(\log 1, n, 1\right)\right) - 1}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(100 \cdot \sqrt{\frac{\mathsf{fma}\left(i, 1, \mathsf{fma}\left(0.5, {i}^{2}, \log 1 \cdot n\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)\right)}{i}}\right) \cdot \sqrt{\frac{\mathsf{fma}\left(i, 1, \mathsf{fma}\left(0.5, {i}^{2}, \log 1 \cdot n\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)\right)}{i}}\right) \cdot n\\
\end{array}double f(double i, double n) {
double r162783 = 100.0;
double r162784 = 1.0;
double r162785 = i;
double r162786 = n;
double r162787 = r162785 / r162786;
double r162788 = r162784 + r162787;
double r162789 = pow(r162788, r162786);
double r162790 = r162789 - r162784;
double r162791 = r162790 / r162787;
double r162792 = r162783 * r162791;
return r162792;
}
double f(double i, double n) {
double r162793 = n;
double r162794 = -2.2308731815162504e+136;
bool r162795 = r162793 <= r162794;
double r162796 = 100.0;
double r162797 = i;
double r162798 = 1.0;
double r162799 = 0.5;
double r162800 = 2.0;
double r162801 = pow(r162797, r162800);
double r162802 = log(r162798);
double r162803 = r162802 * r162793;
double r162804 = fma(r162799, r162801, r162803);
double r162805 = r162801 * r162802;
double r162806 = r162799 * r162805;
double r162807 = r162804 - r162806;
double r162808 = fma(r162797, r162798, r162807);
double r162809 = r162808 / r162797;
double r162810 = sqrt(r162809);
double r162811 = r162796 * r162810;
double r162812 = r162811 * r162810;
double r162813 = r162812 * r162793;
double r162814 = -1.0958004164778634e+86;
bool r162815 = r162793 <= r162814;
double r162816 = r162797 / r162793;
double r162817 = r162798 + r162816;
double r162818 = pow(r162817, r162793);
double r162819 = r162818 - r162798;
double r162820 = r162796 * r162819;
double r162821 = r162820 / r162816;
double r162822 = -3.514216942264821e+16;
bool r162823 = r162793 <= r162822;
double r162824 = -1.2431085101949388e-214;
bool r162825 = r162793 <= r162824;
double r162826 = exp(r162819);
double r162827 = log(r162826);
double r162828 = r162827 / r162816;
double r162829 = r162796 * r162828;
double r162830 = 2.0850330521039454e-172;
bool r162831 = r162793 <= r162830;
double r162832 = 1.0;
double r162833 = fma(r162802, r162793, r162832);
double r162834 = fma(r162798, r162797, r162833);
double r162835 = r162834 - r162798;
double r162836 = r162835 / r162816;
double r162837 = r162796 * r162836;
double r162838 = r162831 ? r162837 : r162813;
double r162839 = r162825 ? r162829 : r162838;
double r162840 = r162823 ? r162813 : r162839;
double r162841 = r162815 ? r162821 : r162840;
double r162842 = r162795 ? r162813 : r162841;
return r162842;
}




Bits error versus i




Bits error versus n
| Original | 43.1 |
|---|---|
| Target | 42.9 |
| Herbie | 22.2 |
if n < -2.2308731815162504e+136 or -1.0958004164778634e+86 < n < -3.514216942264821e+16 or 2.0850330521039454e-172 < n Initial program 54.1
Taylor expanded around 0 38.7
Simplified38.7
rmApplied associate-/r/22.0
Applied associate-*r*22.0
rmApplied add-sqr-sqrt22.1
Applied associate-*r*22.1
if -2.2308731815162504e+136 < n < -1.0958004164778634e+86Initial program 35.1
rmApplied associate-*r/35.0
if -3.514216942264821e+16 < n < -1.2431085101949388e-214Initial program 19.3
rmApplied add-log-exp19.3
Applied add-log-exp19.4
Applied diff-log19.4
Simplified19.4
if -1.2431085101949388e-214 < n < 2.0850330521039454e-172Initial program 28.7
Taylor expanded around 0 21.5
Simplified21.5
Final simplification22.2
herbie shell --seed 2020034 +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))))