100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -9.441810589112862 \cdot 10^{-06}:\\
\;\;\;\;\frac{1}{\frac{\frac{i}{n}}{\mathsf{fma}\left(100, \left(e^{\mathsf{log1p}\left(\left(\frac{i}{n}\right)\right) \cdot n}\right), -100\right)}}\\
\mathbf{elif}\;i \le 0.004614392422049968:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\left(\frac{i}{n}\right), \left(\frac{\frac{1}{200}}{n} - \frac{1}{200}\right), \left(\frac{1}{\frac{n}{\frac{1}{100}}}\right)\right)}\\
\mathbf{elif}\;i \le 3.108127690004362 \cdot 10^{+258}:\\
\;\;\;\;\frac{\mathsf{fma}\left(50, \left(\left(\log n \cdot n\right) \cdot \left(\log n \cdot n\right)\right), \left(\mathsf{fma}\left(\frac{50}{3}, \left(\log i \cdot \left(\left(\left(n \cdot \log i\right) \cdot \left(n \cdot \log i\right)\right) \cdot n\right)\right), \left(\mathsf{fma}\left(100, \left(n \cdot \log i\right), \left(\left(\log i \cdot \left(\left(\left(\log n \cdot n\right) \cdot \left(\log n \cdot n\right)\right) \cdot n\right)\right) \cdot 50 + 50 \cdot \left(\left(n \cdot \log i\right) \cdot \left(n \cdot \log i\right)\right)\right)\right)\right)\right)\right)\right) - \left(\left(\left(\log n \cdot \left(n \cdot n\right)\right) \cdot \left(\log i \cdot 50\right) + \mathsf{fma}\left(\left(\left(\log i \cdot \log i\right) \cdot \left(\left(n \cdot n\right) \cdot \left(\log n \cdot n\right)\right)\right), \frac{100}{3}, \left(\left(\log n \cdot \left(n \cdot n\right)\right) \cdot \left(\log i \cdot 50\right)\right)\right)\right) + \mathsf{fma}\left(\frac{50}{3}, \left(\log n \cdot \left(\left(\left(\log n \cdot n\right) \cdot \left(\log n \cdot n\right)\right) \cdot n\right)\right), \left(\mathsf{fma}\left(\left(\left(\log i \cdot \log i\right) \cdot \left(\left(n \cdot n\right) \cdot \left(\log n \cdot n\right)\right)\right), \frac{50}{3}, \left(\left(\log n \cdot n\right) \cdot 100\right)\right)\right)\right)\right)}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-100 + 100 \cdot {\left(1 + \frac{i}{n}\right)}^{n}}{\frac{i}{n}}\\
\end{array}double f(double i, double n) {
double r25561271 = 100.0;
double r25561272 = 1.0;
double r25561273 = i;
double r25561274 = n;
double r25561275 = r25561273 / r25561274;
double r25561276 = r25561272 + r25561275;
double r25561277 = pow(r25561276, r25561274);
double r25561278 = r25561277 - r25561272;
double r25561279 = r25561278 / r25561275;
double r25561280 = r25561271 * r25561279;
return r25561280;
}
double f(double i, double n) {
double r25561281 = i;
double r25561282 = -9.441810589112862e-06;
bool r25561283 = r25561281 <= r25561282;
double r25561284 = 1.0;
double r25561285 = n;
double r25561286 = r25561281 / r25561285;
double r25561287 = 100.0;
double r25561288 = log1p(r25561286);
double r25561289 = r25561288 * r25561285;
double r25561290 = exp(r25561289);
double r25561291 = -100.0;
double r25561292 = fma(r25561287, r25561290, r25561291);
double r25561293 = r25561286 / r25561292;
double r25561294 = r25561284 / r25561293;
double r25561295 = 0.004614392422049968;
bool r25561296 = r25561281 <= r25561295;
double r25561297 = 0.005;
double r25561298 = r25561297 / r25561285;
double r25561299 = r25561298 - r25561297;
double r25561300 = 0.01;
double r25561301 = r25561285 / r25561300;
double r25561302 = r25561284 / r25561301;
double r25561303 = fma(r25561286, r25561299, r25561302);
double r25561304 = r25561284 / r25561303;
double r25561305 = 3.108127690004362e+258;
bool r25561306 = r25561281 <= r25561305;
double r25561307 = 50.0;
double r25561308 = log(r25561285);
double r25561309 = r25561308 * r25561285;
double r25561310 = r25561309 * r25561309;
double r25561311 = 16.666666666666668;
double r25561312 = log(r25561281);
double r25561313 = r25561285 * r25561312;
double r25561314 = r25561313 * r25561313;
double r25561315 = r25561314 * r25561285;
double r25561316 = r25561312 * r25561315;
double r25561317 = r25561310 * r25561285;
double r25561318 = r25561312 * r25561317;
double r25561319 = r25561318 * r25561307;
double r25561320 = r25561307 * r25561314;
double r25561321 = r25561319 + r25561320;
double r25561322 = fma(r25561287, r25561313, r25561321);
double r25561323 = fma(r25561311, r25561316, r25561322);
double r25561324 = fma(r25561307, r25561310, r25561323);
double r25561325 = r25561285 * r25561285;
double r25561326 = r25561308 * r25561325;
double r25561327 = r25561312 * r25561307;
double r25561328 = r25561326 * r25561327;
double r25561329 = r25561312 * r25561312;
double r25561330 = r25561325 * r25561309;
double r25561331 = r25561329 * r25561330;
double r25561332 = 33.333333333333336;
double r25561333 = fma(r25561331, r25561332, r25561328);
double r25561334 = r25561328 + r25561333;
double r25561335 = r25561308 * r25561317;
double r25561336 = r25561309 * r25561287;
double r25561337 = fma(r25561331, r25561311, r25561336);
double r25561338 = fma(r25561311, r25561335, r25561337);
double r25561339 = r25561334 + r25561338;
double r25561340 = r25561324 - r25561339;
double r25561341 = r25561340 / r25561286;
double r25561342 = r25561284 + r25561286;
double r25561343 = pow(r25561342, r25561285);
double r25561344 = r25561287 * r25561343;
double r25561345 = r25561291 + r25561344;
double r25561346 = r25561345 / r25561286;
double r25561347 = r25561306 ? r25561341 : r25561346;
double r25561348 = r25561296 ? r25561304 : r25561347;
double r25561349 = r25561283 ? r25561294 : r25561348;
return r25561349;
}




Bits error versus i




Bits error versus n
| Original | 42.6 |
|---|---|
| Target | 42.4 |
| Herbie | 12.1 |
if i < -9.441810589112862e-06Initial program 28.7
Simplified28.7
rmApplied add-exp-log28.7
Applied pow-exp28.7
Simplified6.2
rmApplied clear-num6.2
if -9.441810589112862e-06 < i < 0.004614392422049968Initial program 50.0
Simplified50.0
rmApplied add-exp-log50.0
Applied pow-exp50.0
Simplified49.3
rmApplied clear-num49.3
Taylor expanded around 0 13.7
Simplified12.5
rmApplied clear-num12.5
if 0.004614392422049968 < i < 3.108127690004362e+258Initial program 33.1
Simplified33.1
rmApplied add-exp-log49.4
Applied pow-exp49.4
Simplified48.3
Taylor expanded around 0 18.1
Simplified18.1
if 3.108127690004362e+258 < i Initial program 28.2
Simplified28.2
rmApplied fma-udef28.2
Final simplification12.1
herbie shell --seed 2019120 +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))))