100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -6.8977356701701615 \cdot 10^{-9}:\\
\;\;\;\;100 \cdot \left(\frac{{\left(1 + \frac{i}{n}\right)}^{n}}{\frac{i}{n}} - \frac{1}{\frac{i}{n}}\right)\\
\mathbf{elif}\;i \le 3.9028797563160959 \cdot 10^{-7}:\\
\;\;\;\;\left(100 \cdot \frac{\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)}{i}\right) \cdot n\\
\mathbf{else}:\\
\;\;\;\;\left(\left({\left(1 + \frac{i}{n}\right)}^{\left(\frac{n}{2}\right)} + \sqrt{1}\right) \cdot 100\right) \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{\left(\frac{n}{2}\right)} - \sqrt{1}}{\frac{i}{n}}\\
\end{array}double f(double i, double n) {
double r98636 = 100.0;
double r98637 = 1.0;
double r98638 = i;
double r98639 = n;
double r98640 = r98638 / r98639;
double r98641 = r98637 + r98640;
double r98642 = pow(r98641, r98639);
double r98643 = r98642 - r98637;
double r98644 = r98643 / r98640;
double r98645 = r98636 * r98644;
return r98645;
}
double f(double i, double n) {
double r98646 = i;
double r98647 = -6.8977356701701615e-09;
bool r98648 = r98646 <= r98647;
double r98649 = 100.0;
double r98650 = 1.0;
double r98651 = n;
double r98652 = r98646 / r98651;
double r98653 = r98650 + r98652;
double r98654 = pow(r98653, r98651);
double r98655 = r98654 / r98652;
double r98656 = r98650 / r98652;
double r98657 = r98655 - r98656;
double r98658 = r98649 * r98657;
double r98659 = 3.902879756316096e-07;
bool r98660 = r98646 <= r98659;
double r98661 = r98650 * r98646;
double r98662 = 0.5;
double r98663 = 2.0;
double r98664 = pow(r98646, r98663);
double r98665 = r98662 * r98664;
double r98666 = log(r98650);
double r98667 = r98666 * r98651;
double r98668 = r98665 + r98667;
double r98669 = r98661 + r98668;
double r98670 = r98664 * r98666;
double r98671 = r98662 * r98670;
double r98672 = r98669 - r98671;
double r98673 = r98672 / r98646;
double r98674 = r98649 * r98673;
double r98675 = r98674 * r98651;
double r98676 = r98651 / r98663;
double r98677 = pow(r98653, r98676);
double r98678 = sqrt(r98650);
double r98679 = r98677 + r98678;
double r98680 = r98679 * r98649;
double r98681 = r98677 - r98678;
double r98682 = r98681 / r98652;
double r98683 = r98680 * r98682;
double r98684 = r98660 ? r98675 : r98683;
double r98685 = r98648 ? r98658 : r98684;
return r98685;
}




Bits error versus i




Bits error versus n
Results
| Original | 47.8 |
|---|---|
| Target | 47.4 |
| Herbie | 16.9 |
if i < -6.8977356701701615e-09Initial program 29.3
rmApplied div-sub29.3
if -6.8977356701701615e-09 < i < 3.902879756316096e-07Initial program 58.5
Taylor expanded around 0 26.3
rmApplied associate-/r/8.6
Applied associate-*r*8.6
if 3.902879756316096e-07 < i Initial program 32.1
rmApplied *-un-lft-identity32.1
Applied *-un-lft-identity32.1
Applied times-frac32.1
Applied add-sqr-sqrt32.1
Applied sqr-pow32.2
Applied difference-of-squares32.2
Applied times-frac32.2
Applied associate-*r*32.2
Simplified32.2
Final simplification16.9
herbie shell --seed 2020060
(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))))