100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -0.8489635077384908301567634225648362189531:\\
\;\;\;\;\frac{100 \cdot \left({\left(\frac{i}{n}\right)}^{n} - 1\right)}{\frac{i}{n}}\\
\mathbf{elif}\;i \le 0.5476118163719528864064045592385809868574:\\
\;\;\;\;\frac{100}{i} \cdot \left(\left(\mathsf{fma}\left(1, i, \mathsf{fma}\left(0.5, {i}^{2}, \log 1 \cdot n\right)\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)\right) \cdot n\right)\\
\mathbf{else}:\\
\;\;\;\;\left(100 \cdot \frac{\sqrt[3]{{\left(1 + \frac{i}{n}\right)}^{n} - 1} \cdot \sqrt[3]{{\left(1 + \frac{i}{n}\right)}^{n} - 1}}{i}\right) \cdot \frac{\sqrt[3]{{\left(1 + \frac{i}{n}\right)}^{n} - 1}}{\frac{1}{n}}\\
\end{array}double f(double i, double n) {
double r167296 = 100.0;
double r167297 = 1.0;
double r167298 = i;
double r167299 = n;
double r167300 = r167298 / r167299;
double r167301 = r167297 + r167300;
double r167302 = pow(r167301, r167299);
double r167303 = r167302 - r167297;
double r167304 = r167303 / r167300;
double r167305 = r167296 * r167304;
return r167305;
}
double f(double i, double n) {
double r167306 = i;
double r167307 = -0.8489635077384908;
bool r167308 = r167306 <= r167307;
double r167309 = 100.0;
double r167310 = n;
double r167311 = r167306 / r167310;
double r167312 = pow(r167311, r167310);
double r167313 = 1.0;
double r167314 = r167312 - r167313;
double r167315 = r167309 * r167314;
double r167316 = r167315 / r167311;
double r167317 = 0.5476118163719529;
bool r167318 = r167306 <= r167317;
double r167319 = r167309 / r167306;
double r167320 = 0.5;
double r167321 = 2.0;
double r167322 = pow(r167306, r167321);
double r167323 = log(r167313);
double r167324 = r167323 * r167310;
double r167325 = fma(r167320, r167322, r167324);
double r167326 = fma(r167313, r167306, r167325);
double r167327 = r167322 * r167323;
double r167328 = r167320 * r167327;
double r167329 = r167326 - r167328;
double r167330 = r167329 * r167310;
double r167331 = r167319 * r167330;
double r167332 = r167313 + r167311;
double r167333 = pow(r167332, r167310);
double r167334 = r167333 - r167313;
double r167335 = cbrt(r167334);
double r167336 = r167335 * r167335;
double r167337 = r167336 / r167306;
double r167338 = r167309 * r167337;
double r167339 = 1.0;
double r167340 = r167339 / r167310;
double r167341 = r167335 / r167340;
double r167342 = r167338 * r167341;
double r167343 = r167318 ? r167331 : r167342;
double r167344 = r167308 ? r167316 : r167343;
return r167344;
}




Bits error versus i




Bits error versus n
| Original | 43.0 |
|---|---|
| Target | 43.5 |
| Herbie | 18.8 |
if i < -0.8489635077384908Initial program 27.4
Taylor expanded around inf 64.0
Simplified18.1
if -0.8489635077384908 < i < 0.5476118163719529Initial program 50.8
Taylor expanded around 0 34.2
Simplified34.2
rmApplied div-inv34.3
Applied *-un-lft-identity34.3
Applied times-frac15.8
Simplified15.8
rmApplied associate-*r*16.2
Simplified16.1
if 0.5476118163719529 < i Initial program 32.4
rmApplied div-inv32.4
Applied add-cube-cbrt32.4
Applied times-frac32.4
Applied associate-*r*32.4
Final simplification18.8
herbie shell --seed 2019323 +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))))