100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;n \le -1.221351164035121487084940040764531680711 \cdot 10^{167}:\\
\;\;\;\;n \cdot \frac{100 \cdot \left(\mathsf{fma}\left(1, i, \mathsf{fma}\left(0.5, i \cdot i, \log 1 \cdot n\right)\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)\right)}{i}\\
\mathbf{elif}\;n \le -2.480881740905884775675974535607866708188 \cdot 10^{155}:\\
\;\;\;\;100 \cdot \frac{n}{\frac{i}{{\left(\frac{i}{n}\right)}^{n} - 1}}\\
\mathbf{elif}\;n \le -2.725703542154751437414591467328010381395 \cdot 10^{65}:\\
\;\;\;\;n \cdot \frac{100 \cdot \left(\mathsf{fma}\left(1, i, \mathsf{fma}\left(0.5, i \cdot i, \log 1 \cdot n\right)\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)\right)}{i}\\
\mathbf{elif}\;n \le 2.651124307599290160581024077772320494899 \cdot 10^{-310}:\\
\;\;\;\;\frac{\sqrt[3]{{\left(1 + \frac{i}{n}\right)}^{n} \cdot 100 + \left(-1\right) \cdot 100} \cdot \sqrt[3]{{\left(1 + \frac{i}{n}\right)}^{n} \cdot 100 + \left(-1\right) \cdot 100}}{\frac{\frac{i}{n}}{\sqrt[3]{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}}}\\
\mathbf{elif}\;n \le 1.803619210409391642244204445393223551086 \cdot 10^{-92}:\\
\;\;\;\;\mathsf{fma}\left(50, \mathsf{fma}\left(\frac{{n}^{3}}{i}, {\left(\log n\right)}^{2}, \frac{{\left(\log i\right)}^{2} \cdot {n}^{3}}{i}\right), \mathsf{fma}\left(16.66666666666666429819088079966604709625, \frac{{\left(\log i\right)}^{3} \cdot {n}^{4}}{i}, \mathsf{fma}\left(100, \frac{\log i \cdot {n}^{2}}{i}, 50 \cdot \frac{\log i \cdot \left({n}^{4} \cdot {\left(\log n\right)}^{2}\right)}{i}\right)\right)\right) - \mathsf{fma}\left(\frac{{n}^{4} \cdot {\left(\log n\right)}^{3}}{i}, 16.66666666666666429819088079966604709625, \mathsf{fma}\left(100, \mathsf{fma}\left(\frac{\log i}{i}, {n}^{3} \cdot \log n, \frac{{n}^{2} \cdot \log n}{i}\right), 50 \cdot \frac{{\left(\log i\right)}^{2} \cdot \left({n}^{4} \cdot \log n\right)}{i}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;n \cdot \frac{100 \cdot \left(\mathsf{fma}\left(1, i, \mathsf{fma}\left(0.5, i \cdot i, \log 1 \cdot n\right)\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)\right)}{i}\\
\end{array}double f(double i, double n) {
double r117243 = 100.0;
double r117244 = 1.0;
double r117245 = i;
double r117246 = n;
double r117247 = r117245 / r117246;
double r117248 = r117244 + r117247;
double r117249 = pow(r117248, r117246);
double r117250 = r117249 - r117244;
double r117251 = r117250 / r117247;
double r117252 = r117243 * r117251;
return r117252;
}
double f(double i, double n) {
double r117253 = n;
double r117254 = -1.2213511640351215e+167;
bool r117255 = r117253 <= r117254;
double r117256 = 100.0;
double r117257 = 1.0;
double r117258 = i;
double r117259 = 0.5;
double r117260 = r117258 * r117258;
double r117261 = log(r117257);
double r117262 = r117261 * r117253;
double r117263 = fma(r117259, r117260, r117262);
double r117264 = fma(r117257, r117258, r117263);
double r117265 = 2.0;
double r117266 = pow(r117258, r117265);
double r117267 = r117266 * r117261;
double r117268 = r117259 * r117267;
double r117269 = r117264 - r117268;
double r117270 = r117256 * r117269;
double r117271 = r117270 / r117258;
double r117272 = r117253 * r117271;
double r117273 = -2.480881740905885e+155;
bool r117274 = r117253 <= r117273;
double r117275 = r117258 / r117253;
double r117276 = pow(r117275, r117253);
double r117277 = r117276 - r117257;
double r117278 = r117258 / r117277;
double r117279 = r117253 / r117278;
double r117280 = r117256 * r117279;
double r117281 = -2.7257035421547514e+65;
bool r117282 = r117253 <= r117281;
double r117283 = 2.6511243075993e-310;
bool r117284 = r117253 <= r117283;
double r117285 = r117257 + r117275;
double r117286 = pow(r117285, r117253);
double r117287 = r117286 * r117256;
double r117288 = -r117257;
double r117289 = r117288 * r117256;
double r117290 = r117287 + r117289;
double r117291 = cbrt(r117290);
double r117292 = r117291 * r117291;
double r117293 = r117286 - r117257;
double r117294 = r117256 * r117293;
double r117295 = cbrt(r117294);
double r117296 = r117275 / r117295;
double r117297 = r117292 / r117296;
double r117298 = 1.8036192104093916e-92;
bool r117299 = r117253 <= r117298;
double r117300 = 50.0;
double r117301 = 3.0;
double r117302 = pow(r117253, r117301);
double r117303 = r117302 / r117258;
double r117304 = log(r117253);
double r117305 = pow(r117304, r117265);
double r117306 = log(r117258);
double r117307 = pow(r117306, r117265);
double r117308 = r117307 * r117302;
double r117309 = r117308 / r117258;
double r117310 = fma(r117303, r117305, r117309);
double r117311 = 16.666666666666664;
double r117312 = pow(r117306, r117301);
double r117313 = 4.0;
double r117314 = pow(r117253, r117313);
double r117315 = r117312 * r117314;
double r117316 = r117315 / r117258;
double r117317 = pow(r117253, r117265);
double r117318 = r117306 * r117317;
double r117319 = r117318 / r117258;
double r117320 = r117314 * r117305;
double r117321 = r117306 * r117320;
double r117322 = r117321 / r117258;
double r117323 = r117300 * r117322;
double r117324 = fma(r117256, r117319, r117323);
double r117325 = fma(r117311, r117316, r117324);
double r117326 = fma(r117300, r117310, r117325);
double r117327 = pow(r117304, r117301);
double r117328 = r117314 * r117327;
double r117329 = r117328 / r117258;
double r117330 = r117306 / r117258;
double r117331 = r117302 * r117304;
double r117332 = r117317 * r117304;
double r117333 = r117332 / r117258;
double r117334 = fma(r117330, r117331, r117333);
double r117335 = r117314 * r117304;
double r117336 = r117307 * r117335;
double r117337 = r117336 / r117258;
double r117338 = r117300 * r117337;
double r117339 = fma(r117256, r117334, r117338);
double r117340 = fma(r117329, r117311, r117339);
double r117341 = r117326 - r117340;
double r117342 = r117299 ? r117341 : r117272;
double r117343 = r117284 ? r117297 : r117342;
double r117344 = r117282 ? r117272 : r117343;
double r117345 = r117274 ? r117280 : r117344;
double r117346 = r117255 ? r117272 : r117345;
return r117346;
}




Bits error versus i




Bits error versus n
| Original | 43.0 |
|---|---|
| Target | 42.6 |
| Herbie | 21.2 |
if n < -1.2213511640351215e+167 or -2.480881740905885e+155 < n < -2.7257035421547514e+65 or 1.8036192104093916e-92 < n Initial program 55.1
rmApplied associate-*r/55.1
rmApplied sub-neg55.1
Applied distribute-lft-in55.1
Simplified55.1
Simplified55.1
rmApplied *-un-lft-identity55.1
Applied *-un-lft-identity55.1
Applied times-frac55.1
Applied *-un-lft-identity55.1
Applied times-frac55.1
Simplified55.1
Simplified54.7
Taylor expanded around 0 20.6
Simplified20.6
if -1.2213511640351215e+167 < n < -2.480881740905885e+155Initial program 41.5
Taylor expanded around inf 64.0
Simplified42.0
if -2.7257035421547514e+65 < n < 2.6511243075993e-310Initial program 19.8
rmApplied associate-*r/19.7
rmApplied sub-neg19.7
Applied distribute-lft-in19.7
Simplified19.7
Simplified19.7
rmApplied add-cube-cbrt19.9
Applied associate-/l*19.9
Simplified19.9
if 2.6511243075993e-310 < n < 1.8036192104093916e-92Initial program 45.7
rmApplied associate-*r/45.7
rmApplied sub-neg45.7
Applied distribute-lft-in45.7
Simplified45.7
Simplified45.7
rmApplied *-un-lft-identity45.7
Applied *-un-lft-identity45.7
Applied times-frac45.7
Applied *-un-lft-identity45.7
Applied times-frac45.7
Simplified45.7
Simplified45.7
Taylor expanded around 0 24.2
Simplified24.3
Final simplification21.2
herbie shell --seed 2019347 +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))))