100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -2.56140166535216897 \cdot 10^{135}:\\
\;\;\;\;\frac{100 \cdot \frac{\log \left(e^{\mathsf{fma}\left(-1, 1, {\left(1 + \frac{i}{n}\right)}^{\left(2 \cdot n\right)}\right)}\right)}{{\left(1 + \frac{i}{n}\right)}^{n} + 1}}{\frac{i}{n}}\\
\mathbf{elif}\;i \le -1.3992561866449662 \cdot 10^{-10}:\\
\;\;\;\;\frac{100 \cdot \left({\left(\frac{i}{n}\right)}^{n} - 1\right)}{\frac{i}{n}}\\
\mathbf{elif}\;i \le 2.51591290926460688 \cdot 10^{-160}:\\
\;\;\;\;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)}{\frac{i}{n}}\\
\mathbf{elif}\;i \le 6.02622510223326963 \cdot 10^{-125}:\\
\;\;\;\;\frac{\frac{100 \cdot \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}}{\frac{1}{n}}\\
\mathbf{elif}\;i \le 8532543483832934860000:\\
\;\;\;\;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)}{\frac{i}{n}}\\
\mathbf{elif}\;i \le 7.39555913873958208 \cdot 10^{219}:\\
\;\;\;\;\frac{\frac{100 \cdot \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}}{\frac{1}{n}}\\
\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 r228221 = 100.0;
double r228222 = 1.0;
double r228223 = i;
double r228224 = n;
double r228225 = r228223 / r228224;
double r228226 = r228222 + r228225;
double r228227 = pow(r228226, r228224);
double r228228 = r228227 - r228222;
double r228229 = r228228 / r228225;
double r228230 = r228221 * r228229;
return r228230;
}
double f(double i, double n) {
double r228231 = i;
double r228232 = -2.561401665352169e+135;
bool r228233 = r228231 <= r228232;
double r228234 = 100.0;
double r228235 = 1.0;
double r228236 = -r228235;
double r228237 = n;
double r228238 = r228231 / r228237;
double r228239 = r228235 + r228238;
double r228240 = 2.0;
double r228241 = r228240 * r228237;
double r228242 = pow(r228239, r228241);
double r228243 = fma(r228236, r228235, r228242);
double r228244 = exp(r228243);
double r228245 = log(r228244);
double r228246 = pow(r228239, r228237);
double r228247 = r228246 + r228235;
double r228248 = r228245 / r228247;
double r228249 = r228234 * r228248;
double r228250 = r228249 / r228238;
double r228251 = -1.3992561866449662e-10;
bool r228252 = r228231 <= r228251;
double r228253 = pow(r228238, r228237);
double r228254 = r228253 - r228235;
double r228255 = r228234 * r228254;
double r228256 = r228255 / r228238;
double r228257 = 2.515912909264607e-160;
bool r228258 = r228231 <= r228257;
double r228259 = 0.5;
double r228260 = pow(r228231, r228240);
double r228261 = log(r228235);
double r228262 = r228261 * r228237;
double r228263 = fma(r228259, r228260, r228262);
double r228264 = r228260 * r228261;
double r228265 = r228259 * r228264;
double r228266 = r228263 - r228265;
double r228267 = fma(r228231, r228235, r228266);
double r228268 = r228267 / r228238;
double r228269 = r228234 * r228268;
double r228270 = 6.02622510223327e-125;
bool r228271 = r228231 <= r228270;
double r228272 = r228243 / r228247;
double r228273 = r228234 * r228272;
double r228274 = r228273 / r228231;
double r228275 = 1.0;
double r228276 = r228275 / r228237;
double r228277 = r228274 / r228276;
double r228278 = 8.532543483832935e+21;
bool r228279 = r228231 <= r228278;
double r228280 = 7.395559138739582e+219;
bool r228281 = r228231 <= r228280;
double r228282 = fma(r228261, r228237, r228275);
double r228283 = fma(r228235, r228231, r228282);
double r228284 = r228283 - r228235;
double r228285 = r228284 / r228238;
double r228286 = r228234 * r228285;
double r228287 = r228281 ? r228277 : r228286;
double r228288 = r228279 ? r228269 : r228287;
double r228289 = r228271 ? r228277 : r228288;
double r228290 = r228258 ? r228269 : r228289;
double r228291 = r228252 ? r228256 : r228290;
double r228292 = r228233 ? r228250 : r228291;
return r228292;
}




Bits error versus i




Bits error versus n
| Original | 42.7 |
|---|---|
| Target | 42.6 |
| Herbie | 31.4 |
if i < -2.561401665352169e+135Initial program 15.4
rmApplied associate-*r/15.4
rmApplied flip--15.4
Simplified15.4
rmApplied add-log-exp15.4
if -2.561401665352169e+135 < i < -1.3992561866449662e-10Initial program 41.3
rmApplied associate-*r/41.3
Taylor expanded around inf 64.0
Simplified27.6
if -1.3992561866449662e-10 < i < 2.515912909264607e-160 or 6.02622510223327e-125 < i < 8.532543483832935e+21Initial program 49.9
Taylor expanded around 0 33.7
Simplified33.7
if 2.515912909264607e-160 < i < 6.02622510223327e-125 or 8.532543483832935e+21 < i < 7.395559138739582e+219Initial program 38.2
rmApplied associate-*r/38.1
rmApplied flip--38.1
Simplified38.1
rmApplied div-inv38.1
Applied associate-/r*38.0
if 7.395559138739582e+219 < i Initial program 30.6
Taylor expanded around 0 34.7
Simplified34.7
Final simplification31.4
herbie shell --seed 2020056 +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))))