100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -1.62626015699271742 \cdot 10^{-16}:\\
\;\;\;\;\frac{100}{i} \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} \cdot n - 1 \cdot n\right)\\
\mathbf{elif}\;i \le 622281.331476159976:\\
\;\;\;\;\frac{100 \cdot \left(\sqrt[3]{\left(1 \cdot i + \left(0.5 \cdot {i}^{2} + \log 1 \cdot n\right)\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)} \cdot \sqrt[3]{\left(1 \cdot i + \left(0.5 \cdot {i}^{2} + \log 1 \cdot n\right)\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)}\right)}{i} \cdot \frac{1 \cdot \sqrt[3]{\left(1 \cdot i + \left(0.5 \cdot {i}^{2} + \log 1 \cdot n\right)\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)}}{\frac{\sqrt{1}}{n}}\\
\mathbf{else}:\\
\;\;\;\;\frac{100}{i} \cdot \frac{\frac{{\left(1 + \frac{i}{n}\right)}^{\left(2 \cdot n\right)} + \left(-1 \cdot 1\right)}{{\left(1 + \frac{i}{n}\right)}^{n} + 1}}{\frac{1}{n}}\\
\end{array}double f(double i, double n) {
double r126663 = 100.0;
double r126664 = 1.0;
double r126665 = i;
double r126666 = n;
double r126667 = r126665 / r126666;
double r126668 = r126664 + r126667;
double r126669 = pow(r126668, r126666);
double r126670 = r126669 - r126664;
double r126671 = r126670 / r126667;
double r126672 = r126663 * r126671;
return r126672;
}
double f(double i, double n) {
double r126673 = i;
double r126674 = -1.6262601569927174e-16;
bool r126675 = r126673 <= r126674;
double r126676 = 100.0;
double r126677 = r126676 / r126673;
double r126678 = 1.0;
double r126679 = n;
double r126680 = r126673 / r126679;
double r126681 = r126678 + r126680;
double r126682 = pow(r126681, r126679);
double r126683 = r126682 * r126679;
double r126684 = r126678 * r126679;
double r126685 = r126683 - r126684;
double r126686 = r126677 * r126685;
double r126687 = 622281.33147616;
bool r126688 = r126673 <= r126687;
double r126689 = r126678 * r126673;
double r126690 = 0.5;
double r126691 = 2.0;
double r126692 = pow(r126673, r126691);
double r126693 = r126690 * r126692;
double r126694 = log(r126678);
double r126695 = r126694 * r126679;
double r126696 = r126693 + r126695;
double r126697 = r126689 + r126696;
double r126698 = r126692 * r126694;
double r126699 = r126690 * r126698;
double r126700 = r126697 - r126699;
double r126701 = cbrt(r126700);
double r126702 = r126701 * r126701;
double r126703 = r126676 * r126702;
double r126704 = r126703 / r126673;
double r126705 = 1.0;
double r126706 = r126705 * r126701;
double r126707 = sqrt(r126705);
double r126708 = r126707 / r126679;
double r126709 = r126706 / r126708;
double r126710 = r126704 * r126709;
double r126711 = r126691 * r126679;
double r126712 = pow(r126681, r126711);
double r126713 = r126678 * r126678;
double r126714 = -r126713;
double r126715 = r126712 + r126714;
double r126716 = r126682 + r126678;
double r126717 = r126715 / r126716;
double r126718 = r126705 / r126679;
double r126719 = r126717 / r126718;
double r126720 = r126677 * r126719;
double r126721 = r126688 ? r126710 : r126720;
double r126722 = r126675 ? r126686 : r126721;
return r126722;
}




Bits error versus i




Bits error versus n
Results
| Original | 41.3 |
|---|---|
| Target | 41.0 |
| Herbie | 24.2 |
if i < -1.6262601569927174e-16Initial program 29.7
rmApplied div-inv29.7
Applied *-un-lft-identity29.7
Applied times-frac30.3
Applied associate-*r*30.4
Simplified30.3
rmApplied div-sub30.3
Simplified31.0
Simplified30.3
if -1.6262601569927174e-16 < i < 622281.33147616Initial program 48.5
rmApplied div-inv48.5
Applied *-un-lft-identity48.5
Applied times-frac48.2
Applied associate-*r*48.3
Simplified48.3
Taylor expanded around 0 18.5
rmApplied *-un-lft-identity18.5
Applied add-sqr-sqrt18.5
Applied times-frac18.5
Applied add-cube-cbrt19.1
Applied times-frac19.1
Applied associate-*r*19.8
Simplified19.5
rmApplied *-un-lft-identity19.5
if 622281.33147616 < i Initial program 32.4
rmApplied div-inv32.5
Applied *-un-lft-identity32.5
Applied times-frac32.4
Applied associate-*r*32.4
Simplified32.4
rmApplied flip--32.5
Simplified32.5
Final simplification24.2
herbie shell --seed 2020021
(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))))