100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;n \le -5.170598455267974816273456052167524301145 \cdot 10^{128}:\\
\;\;\;\;\left(100 \cdot \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.17451235129368526597014478538898566314 \cdot 10^{115}:\\
\;\;\;\;100 \cdot \left(\frac{{\left(1 + \frac{i}{n}\right)}^{n}}{\frac{i}{n}} - \frac{1}{\frac{i}{n}}\right)\\
\mathbf{elif}\;n \le -103630197189143872:\\
\;\;\;\;\left(100 \cdot \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 5.964212362723236143156593386256578372635 \cdot 10^{-309}:\\
\;\;\;\;\left(100 \cdot \frac{\frac{\mathsf{fma}\left(-1, 1, {\left(1 + \frac{i}{n}\right)}^{\left(2 \cdot n\right)}\right)}{{\left(1 + \frac{i}{n}\right)}^{n} + 1}}{i}\right) \cdot n\\
\mathbf{elif}\;n \le 5.061964505964020145803022024124640179055 \cdot 10^{-200}:\\
\;\;\;\;\frac{100 \cdot e^{\left(\log \left(\frac{1}{n}\right) - \log \left(\frac{1}{i}\right)\right) \cdot n} - 100}{i} \cdot n\\
\mathbf{else}:\\
\;\;\;\;\left(100 \cdot \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 r131154 = 100.0;
double r131155 = 1.0;
double r131156 = i;
double r131157 = n;
double r131158 = r131156 / r131157;
double r131159 = r131155 + r131158;
double r131160 = pow(r131159, r131157);
double r131161 = r131160 - r131155;
double r131162 = r131161 / r131158;
double r131163 = r131154 * r131162;
return r131163;
}
double f(double i, double n) {
double r131164 = n;
double r131165 = -5.170598455267975e+128;
bool r131166 = r131164 <= r131165;
double r131167 = 100.0;
double r131168 = i;
double r131169 = 1.0;
double r131170 = 0.5;
double r131171 = 2.0;
double r131172 = pow(r131168, r131171);
double r131173 = log(r131169);
double r131174 = r131173 * r131164;
double r131175 = fma(r131170, r131172, r131174);
double r131176 = r131172 * r131173;
double r131177 = r131170 * r131176;
double r131178 = r131175 - r131177;
double r131179 = fma(r131168, r131169, r131178);
double r131180 = r131179 / r131168;
double r131181 = r131167 * r131180;
double r131182 = r131181 * r131164;
double r131183 = -1.1745123512936853e+115;
bool r131184 = r131164 <= r131183;
double r131185 = r131168 / r131164;
double r131186 = r131169 + r131185;
double r131187 = pow(r131186, r131164);
double r131188 = r131187 / r131185;
double r131189 = r131169 / r131185;
double r131190 = r131188 - r131189;
double r131191 = r131167 * r131190;
double r131192 = -1.0363019718914387e+17;
bool r131193 = r131164 <= r131192;
double r131194 = 5.964212362723236e-309;
bool r131195 = r131164 <= r131194;
double r131196 = -r131169;
double r131197 = r131171 * r131164;
double r131198 = pow(r131186, r131197);
double r131199 = fma(r131196, r131169, r131198);
double r131200 = r131187 + r131169;
double r131201 = r131199 / r131200;
double r131202 = r131201 / r131168;
double r131203 = r131167 * r131202;
double r131204 = r131203 * r131164;
double r131205 = 5.06196450596402e-200;
bool r131206 = r131164 <= r131205;
double r131207 = 1.0;
double r131208 = r131207 / r131164;
double r131209 = log(r131208);
double r131210 = r131207 / r131168;
double r131211 = log(r131210);
double r131212 = r131209 - r131211;
double r131213 = r131212 * r131164;
double r131214 = exp(r131213);
double r131215 = r131167 * r131214;
double r131216 = r131215 - r131167;
double r131217 = r131216 / r131168;
double r131218 = r131217 * r131164;
double r131219 = r131206 ? r131218 : r131182;
double r131220 = r131195 ? r131204 : r131219;
double r131221 = r131193 ? r131182 : r131220;
double r131222 = r131184 ? r131191 : r131221;
double r131223 = r131166 ? r131182 : r131222;
return r131223;
}




Bits error versus i




Bits error versus n
| Original | 43.0 |
|---|---|
| Target | 42.5 |
| Herbie | 21.5 |
if n < -5.170598455267975e+128 or -1.1745123512936853e+115 < n < -1.0363019718914387e+17 or 5.06196450596402e-200 < n Initial program 52.7
rmApplied associate-/r/52.3
Applied associate-*r*52.4
Taylor expanded around 0 23.3
Simplified23.3
if -5.170598455267975e+128 < n < -1.1745123512936853e+115Initial program 39.6
rmApplied div-sub39.7
if -1.0363019718914387e+17 < n < 5.964212362723236e-309Initial program 17.0
rmApplied associate-/r/17.6
Applied associate-*r*17.6
rmApplied flip--17.6
Simplified17.6
if 5.964212362723236e-309 < n < 5.06196450596402e-200Initial program 38.7
rmApplied associate-/r/38.7
Applied associate-*r*38.7
Taylor expanded around inf 14.6
Final simplification21.5
herbie shell --seed 2019354 +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))))