100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -1.237131456279114563109935683102053260005 \cdot 10^{-18}:\\
\;\;\;\;\frac{100 \cdot {\left(\frac{1}{n} \cdot i\right)}^{n} - 100}{i} \cdot n\\
\mathbf{elif}\;i \le 3222196569.804427623748779296875:\\
\;\;\;\;\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}:\\
\;\;\;\;100 \cdot \frac{\frac{n \cdot \left({\left(\frac{i}{n}\right)}^{\left(2 \cdot n\right)} - 1\right)}{{\left(\frac{i}{n}\right)}^{n} + 1}}{i}\\
\end{array}double f(double i, double n) {
double r362694 = 100.0;
double r362695 = 1.0;
double r362696 = i;
double r362697 = n;
double r362698 = r362696 / r362697;
double r362699 = r362695 + r362698;
double r362700 = pow(r362699, r362697);
double r362701 = r362700 - r362695;
double r362702 = r362701 / r362698;
double r362703 = r362694 * r362702;
return r362703;
}
double f(double i, double n) {
double r362704 = i;
double r362705 = -1.2371314562791146e-18;
bool r362706 = r362704 <= r362705;
double r362707 = 100.0;
double r362708 = 1.0;
double r362709 = n;
double r362710 = r362708 / r362709;
double r362711 = r362710 * r362704;
double r362712 = pow(r362711, r362709);
double r362713 = r362707 * r362712;
double r362714 = r362713 - r362707;
double r362715 = r362714 / r362704;
double r362716 = r362715 * r362709;
double r362717 = 3222196569.8044276;
bool r362718 = r362704 <= r362717;
double r362719 = 1.0;
double r362720 = r362719 * r362704;
double r362721 = 0.5;
double r362722 = 2.0;
double r362723 = pow(r362704, r362722);
double r362724 = r362721 * r362723;
double r362725 = log(r362719);
double r362726 = r362725 * r362709;
double r362727 = r362724 + r362726;
double r362728 = r362720 + r362727;
double r362729 = r362723 * r362725;
double r362730 = r362721 * r362729;
double r362731 = r362728 - r362730;
double r362732 = r362731 / r362704;
double r362733 = r362707 * r362732;
double r362734 = r362733 * r362709;
double r362735 = r362704 / r362709;
double r362736 = r362722 * r362709;
double r362737 = pow(r362735, r362736);
double r362738 = r362737 - r362719;
double r362739 = r362709 * r362738;
double r362740 = pow(r362735, r362709);
double r362741 = r362740 + r362719;
double r362742 = r362739 / r362741;
double r362743 = r362742 / r362704;
double r362744 = r362707 * r362743;
double r362745 = r362718 ? r362734 : r362744;
double r362746 = r362706 ? r362716 : r362745;
return r362746;
}




Bits error versus i




Bits error versus n
Results
| Original | 43.0 |
|---|---|
| Target | 42.7 |
| Herbie | 20.1 |
if i < -1.2371314562791146e-18Initial program 29.3
rmApplied associate-/r/29.9
Applied associate-*r*29.9
Taylor expanded around inf 64.0
Simplified21.6
if -1.2371314562791146e-18 < i < 3222196569.8044276Initial program 50.8
rmApplied associate-/r/50.4
Applied associate-*r*50.4
Taylor expanded around 0 16.9
if 3222196569.8044276 < i Initial program 32.3
rmApplied flip--32.3
Applied associate-/l/32.3
Taylor expanded around inf 28.4
Simplified32.2
Final simplification20.1
herbie shell --seed 2019212
(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))))