100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -1.39612767473641797:\\
\;\;\;\;100 \cdot \frac{\frac{{\left(1 + \frac{i}{n}\right)}^{\left(2 \cdot n\right)} - 1 \cdot 1}{{\left(1 + \frac{i}{n}\right)}^{n} + 1}}{\frac{i}{n}}\\
\mathbf{elif}\;i \le -1.4029318248824242 \cdot 10^{-247}:\\
\;\;\;\;\frac{100}{i} \cdot \frac{1}{\frac{\frac{1}{n}}{\left(1 \cdot i + \left(0.5 \cdot {i}^{2} + \log 1 \cdot n\right)\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)}}\\
\mathbf{elif}\;i \le 6.7609796441213635 \cdot 10^{-279}:\\
\;\;\;\;100 \cdot \left(\frac{\left(1 \cdot i + \left(0.5 \cdot {i}^{2} + \log 1 \cdot n\right)\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)}{i} \cdot n\right)\\
\mathbf{elif}\;i \le 2.3133805028339562 \cdot 10^{-220}:\\
\;\;\;\;\frac{100}{i} \cdot \left(\frac{1}{\sqrt[3]{\frac{1}{n}} \cdot \sqrt[3]{\frac{1}{n}}} \cdot \frac{\left(1 \cdot i + \left(0.5 \cdot {i}^{2} + \log 1 \cdot n\right)\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)}{\sqrt[3]{\frac{1}{n}}}\right)\\
\mathbf{elif}\;i \le 4.6153207705272044 \cdot 10^{-7}:\\
\;\;\;\;100 \cdot \left(\frac{\left(1 \cdot i + \left(0.5 \cdot {i}^{2} + \log 1 \cdot n\right)\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)}{i} \cdot n\right)\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{\frac{{\left(1 + \frac{i}{n}\right)}^{\left(2 \cdot n\right)} - 1 \cdot 1}{{\left(1 + \frac{i}{n}\right)}^{n} + 1}}{\frac{i}{n}}\\
\end{array}double f(double i, double n) {
double r110254 = 100.0;
double r110255 = 1.0;
double r110256 = i;
double r110257 = n;
double r110258 = r110256 / r110257;
double r110259 = r110255 + r110258;
double r110260 = pow(r110259, r110257);
double r110261 = r110260 - r110255;
double r110262 = r110261 / r110258;
double r110263 = r110254 * r110262;
return r110263;
}
double f(double i, double n) {
double r110264 = i;
double r110265 = -1.396127674736418;
bool r110266 = r110264 <= r110265;
double r110267 = 100.0;
double r110268 = 1.0;
double r110269 = n;
double r110270 = r110264 / r110269;
double r110271 = r110268 + r110270;
double r110272 = 2.0;
double r110273 = r110272 * r110269;
double r110274 = pow(r110271, r110273);
double r110275 = r110268 * r110268;
double r110276 = r110274 - r110275;
double r110277 = pow(r110271, r110269);
double r110278 = r110277 + r110268;
double r110279 = r110276 / r110278;
double r110280 = r110279 / r110270;
double r110281 = r110267 * r110280;
double r110282 = -1.4029318248824242e-247;
bool r110283 = r110264 <= r110282;
double r110284 = r110267 / r110264;
double r110285 = 1.0;
double r110286 = r110285 / r110269;
double r110287 = r110268 * r110264;
double r110288 = 0.5;
double r110289 = pow(r110264, r110272);
double r110290 = r110288 * r110289;
double r110291 = log(r110268);
double r110292 = r110291 * r110269;
double r110293 = r110290 + r110292;
double r110294 = r110287 + r110293;
double r110295 = r110289 * r110291;
double r110296 = r110288 * r110295;
double r110297 = r110294 - r110296;
double r110298 = r110286 / r110297;
double r110299 = r110285 / r110298;
double r110300 = r110284 * r110299;
double r110301 = 6.7609796441213635e-279;
bool r110302 = r110264 <= r110301;
double r110303 = r110297 / r110264;
double r110304 = r110303 * r110269;
double r110305 = r110267 * r110304;
double r110306 = 2.3133805028339562e-220;
bool r110307 = r110264 <= r110306;
double r110308 = cbrt(r110286);
double r110309 = r110308 * r110308;
double r110310 = r110285 / r110309;
double r110311 = r110297 / r110308;
double r110312 = r110310 * r110311;
double r110313 = r110284 * r110312;
double r110314 = 4.6153207705272044e-07;
bool r110315 = r110264 <= r110314;
double r110316 = r110315 ? r110305 : r110281;
double r110317 = r110307 ? r110313 : r110316;
double r110318 = r110302 ? r110305 : r110317;
double r110319 = r110283 ? r110300 : r110318;
double r110320 = r110266 ? r110281 : r110319;
return r110320;
}




Bits error versus i




Bits error versus n
Results
| Original | 43.2 |
|---|---|
| Target | 42.8 |
| Herbie | 21.0 |
if i < -1.396127674736418 or 4.6153207705272044e-07 < i Initial program 30.2
rmApplied flip--30.2
Simplified30.1
if -1.396127674736418 < i < -1.4029318248824242e-247Initial program 51.3
rmApplied div-inv51.3
Applied *-un-lft-identity51.3
Applied times-frac51.0
Applied associate-*r*51.0
Simplified51.0
Taylor expanded around 0 15.3
rmApplied clear-num15.0
if -1.4029318248824242e-247 < i < 6.7609796441213635e-279 or 2.3133805028339562e-220 < i < 4.6153207705272044e-07Initial program 51.3
rmApplied div-inv51.3
Applied *-un-lft-identity51.3
Applied times-frac51.0
Applied associate-*r*51.2
Simplified51.2
Taylor expanded around 0 15.8
rmApplied div-inv15.8
Applied associate-*l*15.2
Simplified15.7
if 6.7609796441213635e-279 < i < 2.3133805028339562e-220Initial program 48.3
rmApplied div-inv48.3
Applied *-un-lft-identity48.3
Applied times-frac47.7
Applied associate-*r*47.7
Simplified47.7
Taylor expanded around 0 16.7
rmApplied add-cube-cbrt17.3
Applied *-un-lft-identity17.3
Applied times-frac17.3
Final simplification21.0
herbie shell --seed 2020046
(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))))