100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;n \le -8.046837769241036 \cdot 10^{81}:\\
\;\;\;\;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)}{\frac{i}{n}}\\
\mathbf{elif}\;n \le -4.5306115068498307 \cdot 10^{56}:\\
\;\;\;\;\frac{100}{i} \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{1}{n}}\\
\mathbf{elif}\;n \le -15831.5864445897478:\\
\;\;\;\;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)}{\frac{i}{n}}\\
\mathbf{elif}\;n \le 8.1979849820500912 \cdot 10^{-194}:\\
\;\;\;\;\left(100 \cdot \frac{\sqrt[3]{{\left(1 + \frac{i}{n}\right)}^{n} - 1} \cdot \sqrt[3]{{\left(1 + \frac{i}{n}\right)}^{n} - 1}}{i}\right) \cdot \frac{\sqrt[3]{\log \left(e^{{\left(1 + \frac{i}{n}\right)}^{n} - 1}\right)}}{\frac{1}{n}}\\
\mathbf{else}:\\
\;\;\;\;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)}{\frac{i}{n}}\\
\end{array}double f(double i, double n) {
double r144739 = 100.0;
double r144740 = 1.0;
double r144741 = i;
double r144742 = n;
double r144743 = r144741 / r144742;
double r144744 = r144740 + r144743;
double r144745 = pow(r144744, r144742);
double r144746 = r144745 - r144740;
double r144747 = r144746 / r144743;
double r144748 = r144739 * r144747;
return r144748;
}
double f(double i, double n) {
double r144749 = n;
double r144750 = -8.046837769241036e+81;
bool r144751 = r144749 <= r144750;
double r144752 = 100.0;
double r144753 = 1.0;
double r144754 = i;
double r144755 = r144753 * r144754;
double r144756 = 0.5;
double r144757 = 2.0;
double r144758 = pow(r144754, r144757);
double r144759 = r144756 * r144758;
double r144760 = log(r144753);
double r144761 = r144760 * r144749;
double r144762 = r144759 + r144761;
double r144763 = r144755 + r144762;
double r144764 = r144758 * r144760;
double r144765 = r144756 * r144764;
double r144766 = r144763 - r144765;
double r144767 = r144754 / r144749;
double r144768 = r144766 / r144767;
double r144769 = r144752 * r144768;
double r144770 = -4.530611506849831e+56;
bool r144771 = r144749 <= r144770;
double r144772 = r144752 / r144754;
double r144773 = r144753 + r144767;
double r144774 = pow(r144773, r144749);
double r144775 = r144774 - r144753;
double r144776 = 1.0;
double r144777 = r144776 / r144749;
double r144778 = r144775 / r144777;
double r144779 = r144772 * r144778;
double r144780 = -15831.586444589748;
bool r144781 = r144749 <= r144780;
double r144782 = 8.197984982050091e-194;
bool r144783 = r144749 <= r144782;
double r144784 = cbrt(r144775);
double r144785 = r144784 * r144784;
double r144786 = r144785 / r144754;
double r144787 = r144752 * r144786;
double r144788 = exp(r144775);
double r144789 = log(r144788);
double r144790 = cbrt(r144789);
double r144791 = r144790 / r144777;
double r144792 = r144787 * r144791;
double r144793 = r144783 ? r144792 : r144769;
double r144794 = r144781 ? r144769 : r144793;
double r144795 = r144771 ? r144779 : r144794;
double r144796 = r144751 ? r144769 : r144795;
return r144796;
}




Bits error versus i




Bits error versus n
Results
| Original | 43.1 |
|---|---|
| Target | 43.0 |
| Herbie | 34.1 |
if n < -8.046837769241036e+81 or -4.530611506849831e+56 < n < -15831.586444589748 or 8.197984982050091e-194 < n Initial program 53.1
Taylor expanded around 0 39.4
if -8.046837769241036e+81 < n < -4.530611506849831e+56Initial program 33.4
rmApplied div-inv33.5
Applied *-un-lft-identity33.5
Applied times-frac33.3
Applied associate-*r*33.3
Simplified33.2
if -15831.586444589748 < n < 8.197984982050091e-194Initial program 21.8
rmApplied div-inv21.8
Applied add-cube-cbrt21.8
Applied times-frac22.3
Applied associate-*r*22.4
rmApplied add-log-exp22.4
Applied add-log-exp22.4
Applied diff-log22.4
Simplified22.4
Final simplification34.1
herbie shell --seed 2020083
(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))))