100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -2.2920532433751285 \cdot 10^{-92}:\\
\;\;\;\;\frac{\sqrt[3]{\mathsf{fma}\left(100, \left(e^{\mathsf{log1p}\left(\left(\frac{i}{n}\right)\right) \cdot n}\right), -100\right) \cdot \mathsf{fma}\left(100, \left(e^{\mathsf{log1p}\left(\left(\frac{i}{n}\right)\right) \cdot n}\right), -100\right)}}{i} \cdot \left(\sqrt[3]{\mathsf{fma}\left(100, \left(e^{\mathsf{log1p}\left(\left(\frac{i}{n}\right)\right) \cdot n}\right), -100\right)} \cdot n\right)\\
\mathbf{elif}\;i \le -6.547047229389803 \cdot 10^{-148}:\\
\;\;\;\;\frac{\mathsf{fma}\left(i, 100, \left(\mathsf{fma}\left(\frac{50}{3}, \left(i \cdot \left(i \cdot i\right)\right), \left(50 \cdot \left(i \cdot i\right)\right)\right)\right)\right)}{\frac{i}{n}}\\
\mathbf{elif}\;i \le -9.429451325520378 \cdot 10^{-161}:\\
\;\;\;\;\frac{\log \left(e^{\mathsf{fma}\left(100, \left({\left(\frac{i}{n} + 1\right)}^{n}\right), -100\right)}\right)}{\frac{i}{n}}\\
\mathbf{elif}\;i \le 2.448607663119347:\\
\;\;\;\;\frac{\mathsf{fma}\left(i, 100, \left(\mathsf{fma}\left(\frac{50}{3}, \left(i \cdot \left(i \cdot i\right)\right), \left(50 \cdot \left(i \cdot i\right)\right)\right)\right)\right)}{\frac{i}{n}}\\
\mathbf{elif}\;i \le 2.7000146131065657 \cdot 10^{+237}:\\
\;\;\;\;\frac{\left(\mathsf{fma}\left(\frac{50}{3}, \left(\left(n \cdot \left(n \cdot n\right)\right) \cdot \left(\left(\log i \cdot \log i\right) \cdot \log i\right)\right), \left(\mathsf{fma}\left(100, \left(n \cdot \log i\right), \left(\mathsf{fma}\left(\frac{100}{3}, \left(\left(\left(n \cdot \left(n \cdot n\right)\right) \cdot \log i\right) \cdot \left(\log n \cdot \log n\right)\right), \left(\mathsf{fma}\left(\frac{50}{3}, \left(\left(\left(n \cdot \left(n \cdot n\right)\right) \cdot \log i\right) \cdot \left(\log n \cdot \log n\right)\right), \left(\left(\left(n \cdot n\right) \cdot 50\right) \cdot \left(\log i \cdot \log i\right)\right)\right)\right)\right)\right)\right)\right)\right) - \mathsf{fma}\left(\frac{100}{3}, \left(\left(n \cdot \left(n \cdot n\right)\right) \cdot \left(\left(\log i \cdot \log i\right) \cdot \log n\right)\right), \left(\left(\left(\left(n \cdot n\right) \cdot 50\right) \cdot \left(\log n \cdot \log i\right) + \left(\left(n \cdot n\right) \cdot 50\right) \cdot \left(\log n \cdot \log i\right)\right) + \mathsf{fma}\left(\frac{50}{3}, \left(\left(\log n \cdot \left(\log n \cdot \log n\right)\right) \cdot \left(n \cdot \left(n \cdot n\right)\right)\right), \left(\mathsf{fma}\left(\frac{50}{3}, \left(\left(n \cdot \left(n \cdot n\right)\right) \cdot \left(\left(\log i \cdot \log i\right) \cdot \log n\right)\right), \left(\left(\log n \cdot n\right) \cdot 100\right)\right)\right)\right)\right)\right)\right) + \left(\left(n \cdot n\right) \cdot 50\right) \cdot \left(\log n \cdot \log n\right)}{\frac{i}{n}}\\
\mathbf{elif}\;i \le 1.7504058567965248 \cdot 10^{+288}:\\
\;\;\;\;\frac{\log \left(e^{\mathsf{fma}\left(100, \left({\left(\frac{i}{n} + 1\right)}^{n}\right), -100\right)}\right)}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\mathsf{fma}\left(\frac{50}{3}, \left(\left(n \cdot \left(n \cdot n\right)\right) \cdot \left(\left(\log i \cdot \log i\right) \cdot \log i\right)\right), \left(\mathsf{fma}\left(100, \left(n \cdot \log i\right), \left(\mathsf{fma}\left(\frac{100}{3}, \left(\left(\left(n \cdot \left(n \cdot n\right)\right) \cdot \log i\right) \cdot \left(\log n \cdot \log n\right)\right), \left(\mathsf{fma}\left(\frac{50}{3}, \left(\left(\left(n \cdot \left(n \cdot n\right)\right) \cdot \log i\right) \cdot \left(\log n \cdot \log n\right)\right), \left(\left(\left(n \cdot n\right) \cdot 50\right) \cdot \left(\log i \cdot \log i\right)\right)\right)\right)\right)\right)\right)\right)\right) - \mathsf{fma}\left(\frac{100}{3}, \left(\left(n \cdot \left(n \cdot n\right)\right) \cdot \left(\left(\log i \cdot \log i\right) \cdot \log n\right)\right), \left(\left(\left(\left(n \cdot n\right) \cdot 50\right) \cdot \left(\log n \cdot \log i\right) + \left(\left(n \cdot n\right) \cdot 50\right) \cdot \left(\log n \cdot \log i\right)\right) + \mathsf{fma}\left(\frac{50}{3}, \left(\left(\log n \cdot \left(\log n \cdot \log n\right)\right) \cdot \left(n \cdot \left(n \cdot n\right)\right)\right), \left(\mathsf{fma}\left(\frac{50}{3}, \left(\left(n \cdot \left(n \cdot n\right)\right) \cdot \left(\left(\log i \cdot \log i\right) \cdot \log n\right)\right), \left(\left(\log n \cdot n\right) \cdot 100\right)\right)\right)\right)\right)\right)\right) + \left(\left(n \cdot n\right) \cdot 50\right) \cdot \left(\log n \cdot \log n\right)}{\frac{i}{n}}\\
\end{array}double f(double i, double n) {
double r2550010 = 100.0;
double r2550011 = 1.0;
double r2550012 = i;
double r2550013 = n;
double r2550014 = r2550012 / r2550013;
double r2550015 = r2550011 + r2550014;
double r2550016 = pow(r2550015, r2550013);
double r2550017 = r2550016 - r2550011;
double r2550018 = r2550017 / r2550014;
double r2550019 = r2550010 * r2550018;
return r2550019;
}
double f(double i, double n) {
double r2550020 = i;
double r2550021 = -2.2920532433751285e-92;
bool r2550022 = r2550020 <= r2550021;
double r2550023 = 100.0;
double r2550024 = n;
double r2550025 = r2550020 / r2550024;
double r2550026 = log1p(r2550025);
double r2550027 = r2550026 * r2550024;
double r2550028 = exp(r2550027);
double r2550029 = -100.0;
double r2550030 = fma(r2550023, r2550028, r2550029);
double r2550031 = r2550030 * r2550030;
double r2550032 = cbrt(r2550031);
double r2550033 = r2550032 / r2550020;
double r2550034 = cbrt(r2550030);
double r2550035 = r2550034 * r2550024;
double r2550036 = r2550033 * r2550035;
double r2550037 = -6.547047229389803e-148;
bool r2550038 = r2550020 <= r2550037;
double r2550039 = 16.666666666666668;
double r2550040 = r2550020 * r2550020;
double r2550041 = r2550020 * r2550040;
double r2550042 = 50.0;
double r2550043 = r2550042 * r2550040;
double r2550044 = fma(r2550039, r2550041, r2550043);
double r2550045 = fma(r2550020, r2550023, r2550044);
double r2550046 = r2550045 / r2550025;
double r2550047 = -9.429451325520378e-161;
bool r2550048 = r2550020 <= r2550047;
double r2550049 = 1.0;
double r2550050 = r2550025 + r2550049;
double r2550051 = pow(r2550050, r2550024);
double r2550052 = fma(r2550023, r2550051, r2550029);
double r2550053 = exp(r2550052);
double r2550054 = log(r2550053);
double r2550055 = r2550054 / r2550025;
double r2550056 = 2.448607663119347;
bool r2550057 = r2550020 <= r2550056;
double r2550058 = 2.7000146131065657e+237;
bool r2550059 = r2550020 <= r2550058;
double r2550060 = r2550024 * r2550024;
double r2550061 = r2550024 * r2550060;
double r2550062 = log(r2550020);
double r2550063 = r2550062 * r2550062;
double r2550064 = r2550063 * r2550062;
double r2550065 = r2550061 * r2550064;
double r2550066 = r2550024 * r2550062;
double r2550067 = 33.333333333333336;
double r2550068 = r2550061 * r2550062;
double r2550069 = log(r2550024);
double r2550070 = r2550069 * r2550069;
double r2550071 = r2550068 * r2550070;
double r2550072 = r2550060 * r2550042;
double r2550073 = r2550072 * r2550063;
double r2550074 = fma(r2550039, r2550071, r2550073);
double r2550075 = fma(r2550067, r2550071, r2550074);
double r2550076 = fma(r2550023, r2550066, r2550075);
double r2550077 = fma(r2550039, r2550065, r2550076);
double r2550078 = r2550063 * r2550069;
double r2550079 = r2550061 * r2550078;
double r2550080 = r2550069 * r2550062;
double r2550081 = r2550072 * r2550080;
double r2550082 = r2550081 + r2550081;
double r2550083 = r2550069 * r2550070;
double r2550084 = r2550083 * r2550061;
double r2550085 = r2550069 * r2550024;
double r2550086 = r2550085 * r2550023;
double r2550087 = fma(r2550039, r2550079, r2550086);
double r2550088 = fma(r2550039, r2550084, r2550087);
double r2550089 = r2550082 + r2550088;
double r2550090 = fma(r2550067, r2550079, r2550089);
double r2550091 = r2550077 - r2550090;
double r2550092 = r2550072 * r2550070;
double r2550093 = r2550091 + r2550092;
double r2550094 = r2550093 / r2550025;
double r2550095 = 1.7504058567965248e+288;
bool r2550096 = r2550020 <= r2550095;
double r2550097 = r2550096 ? r2550055 : r2550094;
double r2550098 = r2550059 ? r2550094 : r2550097;
double r2550099 = r2550057 ? r2550046 : r2550098;
double r2550100 = r2550048 ? r2550055 : r2550099;
double r2550101 = r2550038 ? r2550046 : r2550100;
double r2550102 = r2550022 ? r2550036 : r2550101;
return r2550102;
}




Bits error versus i




Bits error versus n
| Original | 42.1 |
|---|---|
| Target | 42.2 |
| Herbie | 27.4 |
if i < -2.2920532433751285e-92Initial program 33.6
Simplified33.5
rmApplied add-exp-log33.5
Simplified16.4
rmApplied add-cbrt-cube16.4
rmApplied div-inv16.4
Applied cbrt-prod16.4
Applied times-frac17.1
Simplified17.0
if -2.2920532433751285e-92 < i < -6.547047229389803e-148 or -9.429451325520378e-161 < i < 2.448607663119347Initial program 49.7
Simplified49.7
Taylor expanded around 0 34.5
Simplified34.5
if -6.547047229389803e-148 < i < -9.429451325520378e-161 or 2.7000146131065657e+237 < i < 1.7504058567965248e+288Initial program 35.4
Simplified35.3
rmApplied add-log-exp35.5
if 2.448607663119347 < i < 2.7000146131065657e+237 or 1.7504058567965248e+288 < i Initial program 31.0
Simplified30.9
rmApplied add-exp-log30.9
Simplified47.7
Taylor expanded around 0 18.5
Simplified18.5
Final simplification27.4
herbie shell --seed 2019128 +o rules:numerics
(FPCore (i n)
:name "Compound Interest"
: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))))