100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -0.318831405035280346:\\
\;\;\;\;\sqrt{100} \cdot \left(\sqrt{100} \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\right)\\
\mathbf{elif}\;i \le 0.0030890666332557444:\\
\;\;\;\;100 \cdot \left(\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} \cdot n\right)\\
\mathbf{else}:\\
\;\;\;\;\left(100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i}\right) \cdot n\\
\end{array}double f(double i, double n) {
double r134281 = 100.0;
double r134282 = 1.0;
double r134283 = i;
double r134284 = n;
double r134285 = r134283 / r134284;
double r134286 = r134282 + r134285;
double r134287 = pow(r134286, r134284);
double r134288 = r134287 - r134282;
double r134289 = r134288 / r134285;
double r134290 = r134281 * r134289;
return r134290;
}
double f(double i, double n) {
double r134291 = i;
double r134292 = -0.31883140503528035;
bool r134293 = r134291 <= r134292;
double r134294 = 100.0;
double r134295 = sqrt(r134294);
double r134296 = 1.0;
double r134297 = n;
double r134298 = r134291 / r134297;
double r134299 = r134296 + r134298;
double r134300 = pow(r134299, r134297);
double r134301 = r134300 - r134296;
double r134302 = r134301 / r134298;
double r134303 = r134295 * r134302;
double r134304 = r134295 * r134303;
double r134305 = 0.0030890666332557444;
bool r134306 = r134291 <= r134305;
double r134307 = 0.5;
double r134308 = 2.0;
double r134309 = pow(r134291, r134308);
double r134310 = log(r134296);
double r134311 = r134310 * r134297;
double r134312 = fma(r134307, r134309, r134311);
double r134313 = r134309 * r134310;
double r134314 = r134307 * r134313;
double r134315 = r134312 - r134314;
double r134316 = fma(r134291, r134296, r134315);
double r134317 = r134316 / r134291;
double r134318 = r134317 * r134297;
double r134319 = r134294 * r134318;
double r134320 = r134301 / r134291;
double r134321 = r134294 * r134320;
double r134322 = r134321 * r134297;
double r134323 = r134306 ? r134319 : r134322;
double r134324 = r134293 ? r134304 : r134323;
return r134324;
}




Bits error versus i




Bits error versus n
| Original | 42.7 |
|---|---|
| Target | 42.6 |
| Herbie | 21.3 |
if i < -0.31883140503528035Initial program 28.1
rmApplied add-sqr-sqrt28.1
Applied associate-*l*28.2
if -0.31883140503528035 < i < 0.0030890666332557444Initial program 50.8
Taylor expanded around 0 34.3
Simplified34.3
rmApplied associate-/r/17.1
if 0.0030890666332557444 < i Initial program 29.6
rmApplied associate-/r/29.6
Applied associate-*r*29.6
Final simplification21.3
herbie shell --seed 2020020 +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))))