100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -5.4348495206706917 \cdot 10^{-14}:\\
\;\;\;\;\frac{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}{\frac{i}{n}}\\
\mathbf{elif}\;i \le -3.6505909100430136 \cdot 10^{-289}:\\
\;\;\;\;\frac{100 \cdot \left(\left(\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) \cdot n\right)}{i}\\
\mathbf{elif}\;i \le 1.10371457373729495 \cdot 10^{-38}:\\
\;\;\;\;100 \cdot \left(\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} \cdot n\right)\\
\mathbf{elif}\;i \le 8.04120890918656311 \cdot 10^{241}:\\
\;\;\;\;\frac{\frac{\left({\left(1 + \frac{i}{n}\right)}^{\left(2 \cdot n\right)} - 1 \cdot 1\right) \cdot n}{i} \cdot 100}{{\left(1 + \frac{i}{n}\right)}^{n} + 1}\\
\mathbf{elif}\;i \le 4.24623267635107831 \cdot 10^{289}:\\
\;\;\;\;100 \cdot \frac{\left(1 \cdot i + \left(\log 1 \cdot n + 1\right)\right) - 1}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{\frac{{\left(1 + \frac{i}{n}\right)}^{\left(2 \cdot n\right)} - 1 \cdot 1}{{\left(1 + \frac{i}{n}\right)}^{n} + 1}}{\frac{i}{n}}\\
\end{array}double f(double i, double n) {
double r115762 = 100.0;
double r115763 = 1.0;
double r115764 = i;
double r115765 = n;
double r115766 = r115764 / r115765;
double r115767 = r115763 + r115766;
double r115768 = pow(r115767, r115765);
double r115769 = r115768 - r115763;
double r115770 = r115769 / r115766;
double r115771 = r115762 * r115770;
return r115771;
}
double f(double i, double n) {
double r115772 = i;
double r115773 = -5.434849520670692e-14;
bool r115774 = r115772 <= r115773;
double r115775 = 100.0;
double r115776 = 1.0;
double r115777 = n;
double r115778 = r115772 / r115777;
double r115779 = r115776 + r115778;
double r115780 = pow(r115779, r115777);
double r115781 = r115780 - r115776;
double r115782 = r115775 * r115781;
double r115783 = r115782 / r115778;
double r115784 = -3.6505909100430136e-289;
bool r115785 = r115772 <= r115784;
double r115786 = r115776 * r115772;
double r115787 = 0.5;
double r115788 = 2.0;
double r115789 = pow(r115772, r115788);
double r115790 = r115787 * r115789;
double r115791 = log(r115776);
double r115792 = r115791 * r115777;
double r115793 = r115790 + r115792;
double r115794 = r115786 + r115793;
double r115795 = r115789 * r115791;
double r115796 = r115787 * r115795;
double r115797 = r115794 - r115796;
double r115798 = r115797 * r115777;
double r115799 = r115775 * r115798;
double r115800 = r115799 / r115772;
double r115801 = 1.103714573737295e-38;
bool r115802 = r115772 <= r115801;
double r115803 = r115797 / r115772;
double r115804 = r115803 * r115777;
double r115805 = r115775 * r115804;
double r115806 = 8.041208909186563e+241;
bool r115807 = r115772 <= r115806;
double r115808 = r115788 * r115777;
double r115809 = pow(r115779, r115808);
double r115810 = r115776 * r115776;
double r115811 = r115809 - r115810;
double r115812 = r115811 * r115777;
double r115813 = r115812 / r115772;
double r115814 = r115813 * r115775;
double r115815 = r115780 + r115776;
double r115816 = r115814 / r115815;
double r115817 = 4.246232676351078e+289;
bool r115818 = r115772 <= r115817;
double r115819 = 1.0;
double r115820 = r115792 + r115819;
double r115821 = r115786 + r115820;
double r115822 = r115821 - r115776;
double r115823 = r115822 / r115778;
double r115824 = r115775 * r115823;
double r115825 = r115811 / r115815;
double r115826 = r115825 / r115778;
double r115827 = r115775 * r115826;
double r115828 = r115818 ? r115824 : r115827;
double r115829 = r115807 ? r115816 : r115828;
double r115830 = r115802 ? r115805 : r115829;
double r115831 = r115785 ? r115800 : r115830;
double r115832 = r115774 ? r115783 : r115831;
return r115832;
}




Bits error versus i




Bits error versus n
Results
| Original | 43.1 |
|---|---|
| Target | 43.0 |
| Herbie | 22.8 |
if i < -5.434849520670692e-14Initial program 29.9
rmApplied associate-*r/29.8
if -5.434849520670692e-14 < i < -3.6505909100430136e-289Initial program 51.3
rmApplied div-inv51.3
Applied *-un-lft-identity51.3
Applied times-frac51.0
Simplified51.0
Taylor expanded around 0 15.0
rmApplied associate-*l/14.9
Applied associate-*r/15.0
Simplified15.0
if -3.6505909100430136e-289 < i < 1.103714573737295e-38Initial program 50.3
rmApplied div-inv50.3
Applied *-un-lft-identity50.3
Applied times-frac49.9
Simplified49.9
Taylor expanded around 0 15.9
rmApplied associate-*r*16.6
Simplified16.5
if 1.103714573737295e-38 < i < 8.041208909186563e+241Initial program 37.1
rmApplied div-inv37.1
Applied *-un-lft-identity37.1
Applied times-frac37.1
Simplified37.1
rmApplied flip--37.1
Applied associate-*l/37.1
Applied associate-*r/37.1
Applied associate-*r/37.1
Simplified37.0
if 8.041208909186563e+241 < i < 4.246232676351078e+289Initial program 28.6
Taylor expanded around 0 36.4
if 4.246232676351078e+289 < i Initial program 35.5
rmApplied flip--35.4
Simplified35.4
Final simplification22.8
herbie shell --seed 2020047
(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))))