100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;n \le -4.6511036455496 \cdot 10^{+137}:\\
\;\;\;\;\frac{1}{i} \cdot \left(\mathsf{fma}\left(100, e^{n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)}, -100\right) \cdot n\right)\\
\mathbf{elif}\;n \le 1.9360594076256 \cdot 10^{-310}:\\
\;\;\;\;n \cdot \frac{\mathsf{fma}\left({\left(1 + \frac{i}{n}\right)}^{n}, 100, -100\right)}{i}\\
\mathbf{elif}\;n \le 1.547355740653275 \cdot 10^{-211}:\\
\;\;\;\;\frac{\left(\left(\mathsf{fma}\left(50, \left(n \cdot \log n\right) \cdot \left(n \cdot \log n\right), \mathsf{fma}\left(\frac{50}{3}, \log i \cdot \left(\left(\left(\log i \cdot n\right) \cdot \left(\log i \cdot n\right)\right) \cdot n\right), \mathsf{fma}\left(\log i \cdot n, 100, 50 \cdot \left(\log i \cdot \left(\left(\left(n \cdot \log n\right) \cdot \left(n \cdot \log n\right)\right) \cdot n\right)\right) + \left(\left(\log i \cdot n\right) \cdot \left(\log i \cdot n\right)\right) \cdot 50\right)\right)\right) - \left(\log n \cdot \left(\left(\left(\log i \cdot n\right) \cdot \left(\log i \cdot n\right)\right) \cdot n\right)\right) \cdot \frac{100}{3}\right) - \left(\left(\left(n \cdot n\right) \cdot \log n\right) \cdot \log i\right) \cdot 100\right) - \mathsf{fma}\left(\frac{50}{3}, \left(\left(\left(n \cdot \log n\right) \cdot \left(n \cdot \log n\right)\right) \cdot n\right) \cdot \log n, \mathsf{fma}\left(100, n \cdot \log n, \frac{50}{3} \cdot \left(\log n \cdot \left(\left(\left(\log i \cdot n\right) \cdot \left(\log i \cdot n\right)\right) \cdot n\right)\right)\right)\right)}{\frac{i}{n}}\\
\mathbf{elif}\;n \le 3.2388182495466635 \cdot 10^{-96}:\\
\;\;\;\;\frac{\mathsf{fma}\left(100, i, \left(50 + \frac{50}{3} \cdot i\right) \cdot \left(i \cdot i\right)\right)}{\frac{i}{n}}\\
\mathbf{elif}\;n \le 4.809293212884638 \cdot 10^{-44}:\\
\;\;\;\;\frac{\left(\left(\mathsf{fma}\left(50, \left(n \cdot \log n\right) \cdot \left(n \cdot \log n\right), \mathsf{fma}\left(\frac{50}{3}, \log i \cdot \left(\left(\left(\log i \cdot n\right) \cdot \left(\log i \cdot n\right)\right) \cdot n\right), \mathsf{fma}\left(\log i \cdot n, 100, 50 \cdot \left(\log i \cdot \left(\left(\left(n \cdot \log n\right) \cdot \left(n \cdot \log n\right)\right) \cdot n\right)\right) + \left(\left(\log i \cdot n\right) \cdot \left(\log i \cdot n\right)\right) \cdot 50\right)\right)\right) - \left(\log n \cdot \left(\left(\left(\log i \cdot n\right) \cdot \left(\log i \cdot n\right)\right) \cdot n\right)\right) \cdot \frac{100}{3}\right) - \left(\left(\left(n \cdot n\right) \cdot \log n\right) \cdot \log i\right) \cdot 100\right) - \mathsf{fma}\left(\frac{50}{3}, \left(\left(\left(n \cdot \log n\right) \cdot \left(n \cdot \log n\right)\right) \cdot n\right) \cdot \log n, \mathsf{fma}\left(100, n \cdot \log n, \frac{50}{3} \cdot \left(\log n \cdot \left(\left(\left(\log i \cdot n\right) \cdot \left(\log i \cdot n\right)\right) \cdot n\right)\right)\right)\right)}{\frac{i}{n}}\\
\mathbf{elif}\;n \le 7.855089357782943 \cdot 10^{+198}:\\
\;\;\;\;\frac{\mathsf{fma}\left(100, i, \left(50 + \frac{50}{3} \cdot i\right) \cdot \left(i \cdot i\right)\right)}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(e^{\left(\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)\right)}, 100, -100\right)}{\frac{i}{n}}\\
\end{array}double f(double i, double n) {
double r4319196 = 100.0;
double r4319197 = 1.0;
double r4319198 = i;
double r4319199 = n;
double r4319200 = r4319198 / r4319199;
double r4319201 = r4319197 + r4319200;
double r4319202 = pow(r4319201, r4319199);
double r4319203 = r4319202 - r4319197;
double r4319204 = r4319203 / r4319200;
double r4319205 = r4319196 * r4319204;
return r4319205;
}
double f(double i, double n) {
double r4319206 = n;
double r4319207 = -4.6511036455496e+137;
bool r4319208 = r4319206 <= r4319207;
double r4319209 = 1.0;
double r4319210 = i;
double r4319211 = r4319209 / r4319210;
double r4319212 = 100.0;
double r4319213 = r4319210 / r4319206;
double r4319214 = log1p(r4319213);
double r4319215 = r4319206 * r4319214;
double r4319216 = exp(r4319215);
double r4319217 = -100.0;
double r4319218 = fma(r4319212, r4319216, r4319217);
double r4319219 = r4319218 * r4319206;
double r4319220 = r4319211 * r4319219;
double r4319221 = 1.9360594076256e-310;
bool r4319222 = r4319206 <= r4319221;
double r4319223 = r4319209 + r4319213;
double r4319224 = pow(r4319223, r4319206);
double r4319225 = fma(r4319224, r4319212, r4319217);
double r4319226 = r4319225 / r4319210;
double r4319227 = r4319206 * r4319226;
double r4319228 = 1.547355740653275e-211;
bool r4319229 = r4319206 <= r4319228;
double r4319230 = 50.0;
double r4319231 = log(r4319206);
double r4319232 = r4319206 * r4319231;
double r4319233 = r4319232 * r4319232;
double r4319234 = 16.666666666666668;
double r4319235 = log(r4319210);
double r4319236 = r4319235 * r4319206;
double r4319237 = r4319236 * r4319236;
double r4319238 = r4319237 * r4319206;
double r4319239 = r4319235 * r4319238;
double r4319240 = r4319233 * r4319206;
double r4319241 = r4319235 * r4319240;
double r4319242 = r4319230 * r4319241;
double r4319243 = r4319237 * r4319230;
double r4319244 = r4319242 + r4319243;
double r4319245 = fma(r4319236, r4319212, r4319244);
double r4319246 = fma(r4319234, r4319239, r4319245);
double r4319247 = fma(r4319230, r4319233, r4319246);
double r4319248 = r4319231 * r4319238;
double r4319249 = 33.333333333333336;
double r4319250 = r4319248 * r4319249;
double r4319251 = r4319247 - r4319250;
double r4319252 = r4319206 * r4319206;
double r4319253 = r4319252 * r4319231;
double r4319254 = r4319253 * r4319235;
double r4319255 = r4319254 * r4319212;
double r4319256 = r4319251 - r4319255;
double r4319257 = r4319240 * r4319231;
double r4319258 = r4319234 * r4319248;
double r4319259 = fma(r4319212, r4319232, r4319258);
double r4319260 = fma(r4319234, r4319257, r4319259);
double r4319261 = r4319256 - r4319260;
double r4319262 = r4319261 / r4319213;
double r4319263 = 3.2388182495466635e-96;
bool r4319264 = r4319206 <= r4319263;
double r4319265 = r4319234 * r4319210;
double r4319266 = r4319230 + r4319265;
double r4319267 = r4319210 * r4319210;
double r4319268 = r4319266 * r4319267;
double r4319269 = fma(r4319212, r4319210, r4319268);
double r4319270 = r4319269 / r4319213;
double r4319271 = 4.809293212884638e-44;
bool r4319272 = r4319206 <= r4319271;
double r4319273 = 7.855089357782943e+198;
bool r4319274 = r4319206 <= r4319273;
double r4319275 = /* ERROR: no posit support in C */;
double r4319276 = /* ERROR: no posit support in C */;
double r4319277 = exp(r4319276);
double r4319278 = fma(r4319277, r4319212, r4319217);
double r4319279 = r4319278 / r4319213;
double r4319280 = r4319274 ? r4319270 : r4319279;
double r4319281 = r4319272 ? r4319262 : r4319280;
double r4319282 = r4319264 ? r4319270 : r4319281;
double r4319283 = r4319229 ? r4319262 : r4319282;
double r4319284 = r4319222 ? r4319227 : r4319283;
double r4319285 = r4319208 ? r4319220 : r4319284;
return r4319285;
}




Bits error versus i




Bits error versus n
| Original | 42.3 |
|---|---|
| Target | 42.2 |
| Herbie | 29.4 |
if n < -4.6511036455496e+137Initial program 50.9
Simplified50.9
rmApplied add-exp-log50.9
Simplified42.6
rmApplied fma-udef42.7
rmApplied div-inv42.7
Applied *-un-lft-identity42.7
Applied times-frac42.5
Simplified42.5
if -4.6511036455496e+137 < n < 1.9360594076256e-310Initial program 23.7
Simplified23.7
rmApplied associate-/r/23.8
if 1.9360594076256e-310 < n < 1.547355740653275e-211 or 3.2388182495466635e-96 < n < 4.809293212884638e-44Initial program 47.3
Simplified47.3
rmApplied add-exp-log47.3
Simplified47.3
rmApplied fma-udef47.3
Taylor expanded around 0 21.0
Simplified21.0
if 1.547355740653275e-211 < n < 3.2388182495466635e-96 or 4.809293212884638e-44 < n < 7.855089357782943e+198Initial program 55.9
Simplified55.9
Taylor expanded around 0 28.4
Simplified28.4
if 7.855089357782943e+198 < n Initial program 59.7
Simplified59.7
rmApplied add-exp-log59.7
Simplified41.8
rmApplied insert-posit1642.4
Final simplification29.4
herbie shell --seed 2019151 +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))))