100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -0.01274350772906004958251457992446376010776:\\
\;\;\;\;100 \cdot \left(\frac{{\left(\frac{i}{n} + 1\right)}^{n}}{\frac{i}{n}} - \frac{1}{\frac{i}{n}}\right)\\
\mathbf{elif}\;i \le 8.942303972784239462012963121098640220187 \cdot 10^{-300}:\\
\;\;\;\;\frac{\left(\left(\left(-\log 1\right) \cdot \left(\left(i \cdot i\right) \cdot 0.5\right) + \mathsf{fma}\left(\log 1, n, \mathsf{fma}\left(1, i, \left(i \cdot i\right) \cdot 0.5\right)\right)\right) \cdot n\right) \cdot 100}{i}\\
\mathbf{elif}\;i \le 1.150450650179924164542989794445145639508 \cdot 10^{-111}:\\
\;\;\;\;\left(100 \cdot \frac{\mathsf{fma}\left(n, \log 1, \mathsf{fma}\left(i \cdot i, 0.5, 1 \cdot i\right)\right) - \left(\left(i \cdot i\right) \cdot \log 1\right) \cdot 0.5}{i}\right) \cdot n\\
\mathbf{elif}\;i \le 4586135949800822790097416960868352:\\
\;\;\;\;\frac{\left(\left(\left(-\log 1\right) \cdot \left(\left(i \cdot i\right) \cdot 0.5\right) + \mathsf{fma}\left(\log 1, n, \mathsf{fma}\left(1, i, \left(i \cdot i\right) \cdot 0.5\right)\right)\right) \cdot n\right) \cdot 100}{i}\\
\mathbf{else}:\\
\;\;\;\;\frac{100}{i} \cdot \frac{{\left(\frac{i}{n} + 1\right)}^{n} - 1}{\frac{1}{n}}\\
\end{array}double f(double i, double n) {
double r5385312 = 100.0;
double r5385313 = 1.0;
double r5385314 = i;
double r5385315 = n;
double r5385316 = r5385314 / r5385315;
double r5385317 = r5385313 + r5385316;
double r5385318 = pow(r5385317, r5385315);
double r5385319 = r5385318 - r5385313;
double r5385320 = r5385319 / r5385316;
double r5385321 = r5385312 * r5385320;
return r5385321;
}
double f(double i, double n) {
double r5385322 = i;
double r5385323 = -0.01274350772906005;
bool r5385324 = r5385322 <= r5385323;
double r5385325 = 100.0;
double r5385326 = n;
double r5385327 = r5385322 / r5385326;
double r5385328 = 1.0;
double r5385329 = r5385327 + r5385328;
double r5385330 = pow(r5385329, r5385326);
double r5385331 = r5385330 / r5385327;
double r5385332 = r5385328 / r5385327;
double r5385333 = r5385331 - r5385332;
double r5385334 = r5385325 * r5385333;
double r5385335 = 8.94230397278424e-300;
bool r5385336 = r5385322 <= r5385335;
double r5385337 = log(r5385328);
double r5385338 = -r5385337;
double r5385339 = r5385322 * r5385322;
double r5385340 = 0.5;
double r5385341 = r5385339 * r5385340;
double r5385342 = r5385338 * r5385341;
double r5385343 = fma(r5385328, r5385322, r5385341);
double r5385344 = fma(r5385337, r5385326, r5385343);
double r5385345 = r5385342 + r5385344;
double r5385346 = r5385345 * r5385326;
double r5385347 = r5385346 * r5385325;
double r5385348 = r5385347 / r5385322;
double r5385349 = 1.1504506501799242e-111;
bool r5385350 = r5385322 <= r5385349;
double r5385351 = r5385328 * r5385322;
double r5385352 = fma(r5385339, r5385340, r5385351);
double r5385353 = fma(r5385326, r5385337, r5385352);
double r5385354 = r5385339 * r5385337;
double r5385355 = r5385354 * r5385340;
double r5385356 = r5385353 - r5385355;
double r5385357 = r5385356 / r5385322;
double r5385358 = r5385325 * r5385357;
double r5385359 = r5385358 * r5385326;
double r5385360 = 4.586135949800823e+33;
bool r5385361 = r5385322 <= r5385360;
double r5385362 = r5385325 / r5385322;
double r5385363 = r5385330 - r5385328;
double r5385364 = 1.0;
double r5385365 = r5385364 / r5385326;
double r5385366 = r5385363 / r5385365;
double r5385367 = r5385362 * r5385366;
double r5385368 = r5385361 ? r5385348 : r5385367;
double r5385369 = r5385350 ? r5385359 : r5385368;
double r5385370 = r5385336 ? r5385348 : r5385369;
double r5385371 = r5385324 ? r5385334 : r5385370;
return r5385371;
}




Bits error versus i




Bits error versus n
| Original | 43.0 |
|---|---|
| Target | 42.8 |
| Herbie | 21.1 |
if i < -0.01274350772906005Initial program 28.2
rmApplied div-sub28.3
if -0.01274350772906005 < i < 8.94230397278424e-300 or 1.1504506501799242e-111 < i < 4.586135949800823e+33Initial program 50.8
Taylor expanded around 0 32.6
Simplified32.6
rmApplied associate-/r/18.5
Applied associate-*r*18.5
rmApplied div-inv18.7
rmApplied associate-*r/18.5
Applied associate-*r/18.6
Applied associate-*l/17.0
Simplified16.9
if 8.94230397278424e-300 < i < 1.1504506501799242e-111Initial program 49.8
Taylor expanded around 0 36.9
Simplified36.9
rmApplied associate-/r/15.9
Applied associate-*r*15.9
if 4.586135949800823e+33 < i Initial program 31.3
rmApplied div-inv31.3
Applied *-un-lft-identity31.3
Applied times-frac31.3
Applied associate-*r*31.3
Simplified31.3
Final simplification21.1
herbie shell --seed 2019172 +o rules:numerics
(FPCore (i n)
:name "Compound Interest"
:herbie-target
(* 100.0 (/ (- (exp (* n (if (== (+ 1.0 (/ i n)) 1.0) (/ i n) (/ (* (/ i n) (log (+ 1.0 (/ i n)))) (- (+ (/ i n) 1.0) 1.0))))) 1.0) (/ i n)))
(* 100.0 (/ (- (pow (+ 1.0 (/ i n)) n) 1.0) (/ i n))))