100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -2.2920532433751285 \cdot 10^{-92}:\\
\;\;\;\;\mathsf{fma}\left(100, \left(e^{\mathsf{log1p}\left(\left(\frac{i}{n}\right)\right) \cdot n}\right), -100\right) \cdot \frac{n}{i}\\
\mathbf{elif}\;i \le -6.547047229389803 \cdot 10^{-148}:\\
\;\;\;\;\frac{i \cdot \mathsf{fma}\left(i, \left(\mathsf{fma}\left(i, \frac{50}{3}, 50\right)\right), 100\right)}{\frac{i}{n}}\\
\mathbf{elif}\;i \le -9.429451325520378 \cdot 10^{-161}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(100, \left({\left(\frac{i}{n} + 1\right)}^{n}\right), -100\right)}{\sqrt[3]{\frac{i}{n}} \cdot \sqrt[3]{\frac{i}{n}}}}{\sqrt[3]{\frac{i}{n}}}\\
\mathbf{elif}\;i \le 2.448607663119347:\\
\;\;\;\;\frac{i \cdot \mathsf{fma}\left(i, \left(\mathsf{fma}\left(i, \frac{50}{3}, 50\right)\right), 100\right)}{\frac{i}{n}}\\
\mathbf{elif}\;i \le 2.7000146131065657 \cdot 10^{+237}:\\
\;\;\;\;\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(\left(n \cdot \left(\left(\log i \cdot n\right) \cdot \left(\log i \cdot n\right)\right)\right) \cdot \log i\right), \left(\mathsf{fma}\left(100, \left(\log i \cdot n\right), \left(50 \cdot \left(\log i \cdot \left(n \cdot \left(\left(\log n \cdot n\right) \cdot \left(\log n \cdot n\right)\right)\right)\right) + \left(\left(\log i \cdot n\right) \cdot \left(\log i \cdot n\right)\right) \cdot 50\right)\right)\right)\right)\right)\right) - \left(\left(\mathsf{fma}\left(\left(\left(\log i \cdot \log i\right) \cdot \left(\left(\log n \cdot n\right) \cdot \left(n \cdot n\right)\right)\right), \frac{100}{3}, \left(\left(\log i \cdot 50\right) \cdot \left(\left(n \cdot n\right) \cdot \log n\right)\right)\right) + \left(\log i \cdot 50\right) \cdot \left(\left(n \cdot n\right) \cdot \log n\right)\right) + \mathsf{fma}\left(\frac{50}{3}, \left(\log n \cdot \left(n \cdot \left(\left(\log n \cdot n\right) \cdot \left(\log n \cdot n\right)\right)\right)\right), \left(\mathsf{fma}\left(\left(\left(\log i \cdot \log i\right) \cdot \left(\left(\log n \cdot n\right) \cdot \left(n \cdot n\right)\right)\right), \frac{50}{3}, \left(100 \cdot \left(\log n \cdot n\right)\right)\right)\right)\right)\right)}{\frac{i}{n}}\\
\mathbf{elif}\;i \le 1.7504058567965248 \cdot 10^{+288}:\\
\;\;\;\;\frac{\log \left(e^{\mathsf{fma}\left(100, \left({\left(\frac{i}{n} + 1\right)}^{n}\right), -100\right)}\right)}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;\frac{n}{i} \cdot \left(\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(\left(n \cdot \left(\left(\log i \cdot n\right) \cdot \left(\log i \cdot n\right)\right)\right) \cdot \log i\right), \left(\mathsf{fma}\left(100, \left(\log i \cdot n\right), \left(50 \cdot \left(\log i \cdot \left(n \cdot \left(\left(\log n \cdot n\right) \cdot \left(\log n \cdot n\right)\right)\right)\right) + \left(\left(\log i \cdot n\right) \cdot \left(\log i \cdot n\right)\right) \cdot 50\right)\right)\right)\right)\right)\right) - \left(\left(\mathsf{fma}\left(\left(\left(\log i \cdot \log i\right) \cdot \left(\left(\log n \cdot n\right) \cdot \left(n \cdot n\right)\right)\right), \frac{100}{3}, \left(\left(\log i \cdot 50\right) \cdot \left(\left(n \cdot n\right) \cdot \log n\right)\right)\right) + \left(\log i \cdot 50\right) \cdot \left(\left(n \cdot n\right) \cdot \log n\right)\right) + \mathsf{fma}\left(\frac{50}{3}, \left(\log n \cdot \left(n \cdot \left(\left(\log n \cdot n\right) \cdot \left(\log n \cdot n\right)\right)\right)\right), \left(\mathsf{fma}\left(\left(\left(\log i \cdot \log i\right) \cdot \left(\left(\log n \cdot n\right) \cdot \left(n \cdot n\right)\right)\right), \frac{50}{3}, \left(100 \cdot \left(\log n \cdot n\right)\right)\right)\right)\right)\right)\right)\\
\end{array}double f(double i, double n) {
double r33435252 = 100.0;
double r33435253 = 1.0;
double r33435254 = i;
double r33435255 = n;
double r33435256 = r33435254 / r33435255;
double r33435257 = r33435253 + r33435256;
double r33435258 = pow(r33435257, r33435255);
double r33435259 = r33435258 - r33435253;
double r33435260 = r33435259 / r33435256;
double r33435261 = r33435252 * r33435260;
return r33435261;
}
double f(double i, double n) {
double r33435262 = i;
double r33435263 = -2.2920532433751285e-92;
bool r33435264 = r33435262 <= r33435263;
double r33435265 = 100.0;
double r33435266 = n;
double r33435267 = r33435262 / r33435266;
double r33435268 = log1p(r33435267);
double r33435269 = r33435268 * r33435266;
double r33435270 = exp(r33435269);
double r33435271 = -100.0;
double r33435272 = fma(r33435265, r33435270, r33435271);
double r33435273 = r33435266 / r33435262;
double r33435274 = r33435272 * r33435273;
double r33435275 = -6.547047229389803e-148;
bool r33435276 = r33435262 <= r33435275;
double r33435277 = 16.666666666666668;
double r33435278 = 50.0;
double r33435279 = fma(r33435262, r33435277, r33435278);
double r33435280 = fma(r33435262, r33435279, r33435265);
double r33435281 = r33435262 * r33435280;
double r33435282 = r33435281 / r33435267;
double r33435283 = -9.429451325520378e-161;
bool r33435284 = r33435262 <= r33435283;
double r33435285 = 1.0;
double r33435286 = r33435267 + r33435285;
double r33435287 = pow(r33435286, r33435266);
double r33435288 = fma(r33435265, r33435287, r33435271);
double r33435289 = cbrt(r33435267);
double r33435290 = r33435289 * r33435289;
double r33435291 = r33435288 / r33435290;
double r33435292 = r33435291 / r33435289;
double r33435293 = 2.448607663119347;
bool r33435294 = r33435262 <= r33435293;
double r33435295 = 2.7000146131065657e+237;
bool r33435296 = r33435262 <= r33435295;
double r33435297 = log(r33435266);
double r33435298 = r33435297 * r33435266;
double r33435299 = r33435298 * r33435298;
double r33435300 = log(r33435262);
double r33435301 = r33435300 * r33435266;
double r33435302 = r33435301 * r33435301;
double r33435303 = r33435266 * r33435302;
double r33435304 = r33435303 * r33435300;
double r33435305 = r33435266 * r33435299;
double r33435306 = r33435300 * r33435305;
double r33435307 = r33435278 * r33435306;
double r33435308 = r33435302 * r33435278;
double r33435309 = r33435307 + r33435308;
double r33435310 = fma(r33435265, r33435301, r33435309);
double r33435311 = fma(r33435277, r33435304, r33435310);
double r33435312 = fma(r33435278, r33435299, r33435311);
double r33435313 = r33435300 * r33435300;
double r33435314 = r33435266 * r33435266;
double r33435315 = r33435298 * r33435314;
double r33435316 = r33435313 * r33435315;
double r33435317 = 33.333333333333336;
double r33435318 = r33435300 * r33435278;
double r33435319 = r33435314 * r33435297;
double r33435320 = r33435318 * r33435319;
double r33435321 = fma(r33435316, r33435317, r33435320);
double r33435322 = r33435321 + r33435320;
double r33435323 = r33435297 * r33435305;
double r33435324 = r33435265 * r33435298;
double r33435325 = fma(r33435316, r33435277, r33435324);
double r33435326 = fma(r33435277, r33435323, r33435325);
double r33435327 = r33435322 + r33435326;
double r33435328 = r33435312 - r33435327;
double r33435329 = r33435328 / r33435267;
double r33435330 = 1.7504058567965248e+288;
bool r33435331 = r33435262 <= r33435330;
double r33435332 = exp(r33435288);
double r33435333 = log(r33435332);
double r33435334 = r33435333 / r33435267;
double r33435335 = r33435273 * r33435328;
double r33435336 = r33435331 ? r33435334 : r33435335;
double r33435337 = r33435296 ? r33435329 : r33435336;
double r33435338 = r33435294 ? r33435282 : r33435337;
double r33435339 = r33435284 ? r33435292 : r33435338;
double r33435340 = r33435276 ? r33435282 : r33435339;
double r33435341 = r33435264 ? r33435274 : r33435340;
return r33435341;
}




Bits error versus i




Bits error versus n
| Original | 42.1 |
|---|---|
| Target | 42.2 |
| Herbie | 27.4 |
if i < -2.2920532433751285e-92Initial program 33.6
Simplified33.5
rmApplied add-exp-log33.5
Applied pow-exp33.5
Simplified16.4
rmApplied div-inv16.5
Simplified16.9
if -2.2920532433751285e-92 < i < -6.547047229389803e-148 or -9.429451325520378e-161 < i < 2.448607663119347Initial program 49.7
Simplified49.7
Taylor expanded around 0 34.5
Simplified34.5
if -6.547047229389803e-148 < i < -9.429451325520378e-161Initial program 47.7
Simplified47.7
rmApplied add-cube-cbrt47.7
Applied associate-/r*47.7
if 2.448607663119347 < i < 2.7000146131065657e+237Initial program 30.9
Simplified30.8
rmApplied add-exp-log46.3
Applied pow-exp46.3
Simplified45.7
Taylor expanded around 0 16.6
Simplified16.6
if 2.7000146131065657e+237 < i < 1.7504058567965248e+288Initial program 29.0
Simplified28.9
rmApplied add-log-exp29.2
if 1.7504058567965248e+288 < i Initial program 31.7
Simplified31.7
rmApplied add-exp-log62.2
Applied pow-exp62.2
Simplified62.2
rmApplied div-inv62.2
Simplified62.2
Taylor expanded around 0 31.5
Simplified31.5
Final simplification27.4
herbie shell --seed 2019128 +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))))