100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -0.1198183818045873705315784718550276011229:\\
\;\;\;\;\frac{100 \cdot \left({\left(\frac{i}{n}\right)}^{n} - 1\right)}{\frac{i}{n}}\\
\mathbf{elif}\;i \le 5.738844998942817632325841259444132447243:\\
\;\;\;\;\left(100 \cdot \frac{\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)}{i}\right) \cdot n\\
\mathbf{elif}\;i \le 3.877114676469803572790117232248422698017 \cdot 10^{110}:\\
\;\;\;\;\frac{100 \cdot \left({\left(\frac{i}{n}\right)}^{n} - 1\right)}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{\mathsf{fma}\left(1, i, \mathsf{fma}\left(\log 1, n, 1\right)\right) - 1}{\frac{i}{n}}\\
\end{array}double f(double i, double n) {
double r104151 = 100.0;
double r104152 = 1.0;
double r104153 = i;
double r104154 = n;
double r104155 = r104153 / r104154;
double r104156 = r104152 + r104155;
double r104157 = pow(r104156, r104154);
double r104158 = r104157 - r104152;
double r104159 = r104158 / r104155;
double r104160 = r104151 * r104159;
return r104160;
}
double f(double i, double n) {
double r104161 = i;
double r104162 = -0.11981838180458737;
bool r104163 = r104161 <= r104162;
double r104164 = 100.0;
double r104165 = n;
double r104166 = r104161 / r104165;
double r104167 = pow(r104166, r104165);
double r104168 = 1.0;
double r104169 = r104167 - r104168;
double r104170 = r104164 * r104169;
double r104171 = r104170 / r104166;
double r104172 = 5.738844998942818;
bool r104173 = r104161 <= r104172;
double r104174 = 0.5;
double r104175 = 2.0;
double r104176 = pow(r104161, r104175);
double r104177 = log(r104168);
double r104178 = r104177 * r104165;
double r104179 = fma(r104174, r104176, r104178);
double r104180 = fma(r104168, r104161, r104179);
double r104181 = r104176 * r104177;
double r104182 = r104174 * r104181;
double r104183 = r104180 - r104182;
double r104184 = r104183 / r104161;
double r104185 = r104164 * r104184;
double r104186 = r104185 * r104165;
double r104187 = 3.8771146764698036e+110;
bool r104188 = r104161 <= r104187;
double r104189 = 1.0;
double r104190 = fma(r104177, r104165, r104189);
double r104191 = fma(r104168, r104161, r104190);
double r104192 = r104191 - r104168;
double r104193 = r104192 / r104166;
double r104194 = r104164 * r104193;
double r104195 = r104188 ? r104171 : r104194;
double r104196 = r104173 ? r104186 : r104195;
double r104197 = r104163 ? r104171 : r104196;
return r104197;
}




Bits error versus i




Bits error versus n
| Original | 43.2 |
|---|---|
| Target | 42.7 |
| Herbie | 19.3 |
if i < -0.11981838180458737 or 5.738844998942818 < i < 3.8771146764698036e+110Initial program 28.6
Taylor expanded around inf 59.3
Simplified20.4
if -0.11981838180458737 < i < 5.738844998942818Initial program 50.9
Taylor expanded around 0 34.6
Simplified34.6
rmApplied associate-/r/16.6
Applied associate-*r*16.6
if 3.8771146764698036e+110 < i Initial program 34.7
Taylor expanded around 0 34.3
Simplified34.3
Final simplification19.3
herbie shell --seed 2019322 +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))))