100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;n \le -2.260047491173430560879176932933542305034 \cdot 10^{95}:\\
\;\;\;\;100 \cdot \frac{\left(\mathsf{fma}\left(1, i, \mathsf{fma}\left(0.5, {i}^{2}, \log 1 \cdot n\right)\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)\right) \cdot n}{i}\\
\mathbf{elif}\;n \le -3.040807945417772148751844957499095808404 \cdot 10^{-242}:\\
\;\;\;\;\sqrt{100} \cdot \left(\sqrt{100} \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\right)\\
\mathbf{elif}\;n \le 1.48872624183818144300366844690655908205 \cdot 10^{-106}:\\
\;\;\;\;100 \cdot \frac{\mathsf{fma}\left(1, i, \mathsf{fma}\left(\log 1, n, 1\right)\right) - 1}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(100 \cdot \left(\sqrt[3]{\mathsf{fma}\left(1, i, \mathsf{fma}\left(0.5, {i}^{2}, \log 1 \cdot n\right)\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)} \cdot \sqrt[3]{\mathsf{fma}\left(1, i, \mathsf{fma}\left(0.5, {i}^{2}, \log 1 \cdot n\right)\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)}\right)\right) \cdot \left(\sqrt[3]{n} \cdot \sqrt[3]{n}\right)}{i} \cdot \frac{\sqrt[3]{\mathsf{fma}\left(1, i, \mathsf{fma}\left(0.5, {i}^{2}, \log 1 \cdot n\right)\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)}}{\frac{1}{\sqrt[3]{n}}}\\
\end{array}double f(double i, double n) {
double r103693 = 100.0;
double r103694 = 1.0;
double r103695 = i;
double r103696 = n;
double r103697 = r103695 / r103696;
double r103698 = r103694 + r103697;
double r103699 = pow(r103698, r103696);
double r103700 = r103699 - r103694;
double r103701 = r103700 / r103697;
double r103702 = r103693 * r103701;
return r103702;
}
double f(double i, double n) {
double r103703 = n;
double r103704 = -2.2600474911734306e+95;
bool r103705 = r103703 <= r103704;
double r103706 = 100.0;
double r103707 = 1.0;
double r103708 = i;
double r103709 = 0.5;
double r103710 = 2.0;
double r103711 = pow(r103708, r103710);
double r103712 = log(r103707);
double r103713 = r103712 * r103703;
double r103714 = fma(r103709, r103711, r103713);
double r103715 = fma(r103707, r103708, r103714);
double r103716 = r103711 * r103712;
double r103717 = r103709 * r103716;
double r103718 = r103715 - r103717;
double r103719 = r103718 * r103703;
double r103720 = r103719 / r103708;
double r103721 = r103706 * r103720;
double r103722 = -3.040807945417772e-242;
bool r103723 = r103703 <= r103722;
double r103724 = sqrt(r103706);
double r103725 = r103708 / r103703;
double r103726 = r103707 + r103725;
double r103727 = pow(r103726, r103703);
double r103728 = r103727 - r103707;
double r103729 = r103728 / r103725;
double r103730 = r103724 * r103729;
double r103731 = r103724 * r103730;
double r103732 = 1.4887262418381814e-106;
bool r103733 = r103703 <= r103732;
double r103734 = 1.0;
double r103735 = fma(r103712, r103703, r103734);
double r103736 = fma(r103707, r103708, r103735);
double r103737 = r103736 - r103707;
double r103738 = r103737 / r103725;
double r103739 = r103706 * r103738;
double r103740 = cbrt(r103718);
double r103741 = r103740 * r103740;
double r103742 = r103706 * r103741;
double r103743 = cbrt(r103703);
double r103744 = r103743 * r103743;
double r103745 = r103742 * r103744;
double r103746 = r103745 / r103708;
double r103747 = r103734 / r103743;
double r103748 = r103740 / r103747;
double r103749 = r103746 * r103748;
double r103750 = r103733 ? r103739 : r103749;
double r103751 = r103723 ? r103731 : r103750;
double r103752 = r103705 ? r103721 : r103751;
return r103752;
}




Bits error versus i




Bits error versus n
| Original | 43.0 |
|---|---|
| Target | 43.2 |
| Herbie | 23.5 |
if n < -2.2600474911734306e+95Initial program 49.3
rmApplied div-inv49.3
Applied *-un-lft-identity49.3
Applied times-frac48.9
Applied associate-*r*48.9
Simplified48.8
Taylor expanded around 0 25.9
Simplified25.9
rmApplied div-inv25.9
Applied associate-*l*25.6
Simplified25.4
if -2.2600474911734306e+95 < n < -3.040807945417772e-242Initial program 24.4
rmApplied add-sqr-sqrt24.4
Applied associate-*l*24.4
if -3.040807945417772e-242 < n < 1.4887262418381814e-106Initial program 35.6
Taylor expanded around 0 29.6
Simplified29.6
if 1.4887262418381814e-106 < n Initial program 60.4
rmApplied div-inv60.4
Applied *-un-lft-identity60.4
Applied times-frac60.1
Applied associate-*r*60.1
Simplified60.1
Taylor expanded around 0 18.9
Simplified18.9
rmApplied add-cube-cbrt19.5
Applied *-un-lft-identity19.5
Applied times-frac19.5
Applied add-cube-cbrt19.8
Applied times-frac19.7
Applied associate-*r*18.1
Simplified17.7
Final simplification23.5
herbie shell --seed 2019208 +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))))