100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;n \le -6.30319521589689999 \cdot 10^{84}:\\
\;\;\;\;\frac{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}{\frac{i}{n}}\\
\mathbf{elif}\;n \le -5.65874252440070165 \cdot 10^{63}:\\
\;\;\;\;100 \cdot \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)}{\frac{i}{n}}\\
\mathbf{elif}\;n \le -1.02888823886774177 \cdot 10^{26}:\\
\;\;\;\;\frac{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}{\frac{i}{n}}\\
\mathbf{elif}\;n \le -934893.903368213796:\\
\;\;\;\;100 \cdot \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)}{\frac{i}{n}}\\
\mathbf{elif}\;n \le 1.4472641457797862 \cdot 10^{-291}:\\
\;\;\;\;100 \cdot \left(\frac{{\left(1 + \frac{i}{n}\right)}^{n}}{\frac{i}{n}} - \frac{1}{\frac{i}{n}}\right)\\
\mathbf{elif}\;n \le 5.5209725096373698 \cdot 10^{-155}:\\
\;\;\;\;100 \cdot \frac{\mathsf{fma}\left(1, i, \mathsf{fma}\left(\log 1, n, 1\right)\right) - 1}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \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)}{\frac{i}{n}}\\
\end{array}double f(double i, double n) {
double r112999 = 100.0;
double r113000 = 1.0;
double r113001 = i;
double r113002 = n;
double r113003 = r113001 / r113002;
double r113004 = r113000 + r113003;
double r113005 = pow(r113004, r113002);
double r113006 = r113005 - r113000;
double r113007 = r113006 / r113003;
double r113008 = r112999 * r113007;
return r113008;
}
double f(double i, double n) {
double r113009 = n;
double r113010 = -6.3031952158969e+84;
bool r113011 = r113009 <= r113010;
double r113012 = 100.0;
double r113013 = 1.0;
double r113014 = i;
double r113015 = r113014 / r113009;
double r113016 = r113013 + r113015;
double r113017 = pow(r113016, r113009);
double r113018 = r113017 - r113013;
double r113019 = r113012 * r113018;
double r113020 = r113019 / r113015;
double r113021 = -5.658742524400702e+63;
bool r113022 = r113009 <= r113021;
double r113023 = 0.5;
double r113024 = 2.0;
double r113025 = pow(r113014, r113024);
double r113026 = log(r113013);
double r113027 = r113026 * r113009;
double r113028 = fma(r113023, r113025, r113027);
double r113029 = fma(r113013, r113014, r113028);
double r113030 = r113025 * r113026;
double r113031 = r113023 * r113030;
double r113032 = r113029 - r113031;
double r113033 = r113032 / r113015;
double r113034 = r113012 * r113033;
double r113035 = -1.0288882388677418e+26;
bool r113036 = r113009 <= r113035;
double r113037 = -934893.9033682138;
bool r113038 = r113009 <= r113037;
double r113039 = 1.4472641457797862e-291;
bool r113040 = r113009 <= r113039;
double r113041 = r113017 / r113015;
double r113042 = r113013 / r113015;
double r113043 = r113041 - r113042;
double r113044 = r113012 * r113043;
double r113045 = 5.52097250963737e-155;
bool r113046 = r113009 <= r113045;
double r113047 = 1.0;
double r113048 = fma(r113026, r113009, r113047);
double r113049 = fma(r113013, r113014, r113048);
double r113050 = r113049 - r113013;
double r113051 = r113050 / r113015;
double r113052 = r113012 * r113051;
double r113053 = r113046 ? r113052 : r113034;
double r113054 = r113040 ? r113044 : r113053;
double r113055 = r113038 ? r113034 : r113054;
double r113056 = r113036 ? r113020 : r113055;
double r113057 = r113022 ? r113034 : r113056;
double r113058 = r113011 ? r113020 : r113057;
return r113058;
}




Bits error versus i




Bits error versus n
| Original | 43.1 |
|---|---|
| Target | 43.0 |
| Herbie | 32.9 |
if n < -6.3031952158969e+84 or -5.658742524400702e+63 < n < -1.0288882388677418e+26Initial program 45.6
rmApplied associate-*r/45.6
if -6.3031952158969e+84 < n < -5.658742524400702e+63 or -1.0288882388677418e+26 < n < -934893.9033682138 or 5.52097250963737e-155 < n Initial program 57.0
Taylor expanded around 0 34.0
Simplified34.0
if -934893.9033682138 < n < 1.4472641457797862e-291Initial program 18.0
rmApplied div-sub18.0
if 1.4472641457797862e-291 < n < 5.52097250963737e-155Initial program 43.0
Taylor expanded around 0 32.4
Simplified32.4
Final simplification32.9
herbie shell --seed 2020047 +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))))