100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;n \le -1.4608487543202562 \cdot 10^{+112}:\\
\;\;\;\;100 \cdot n + \left(\frac{50}{3} \cdot \left(\left(i \cdot i\right) \cdot n\right) + \left(i \cdot n\right) \cdot 50\right)\\
\mathbf{elif}\;n \le -0.5086740071675135:\\
\;\;\;\;\frac{100}{i} \cdot \left(\frac{{\left(\frac{i}{n} + 1\right)}^{n}}{\frac{1}{n}} - n\right)\\
\mathbf{elif}\;n \le 6.641285833915873 \cdot 10^{-252}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;100 \cdot n + \left(\frac{50}{3} \cdot \left(\left(i \cdot i\right) \cdot n\right) + \left(i \cdot n\right) \cdot 50\right)\\
\end{array}double f(double i, double n) {
double r2466171 = 100.0;
double r2466172 = 1.0;
double r2466173 = i;
double r2466174 = n;
double r2466175 = r2466173 / r2466174;
double r2466176 = r2466172 + r2466175;
double r2466177 = pow(r2466176, r2466174);
double r2466178 = r2466177 - r2466172;
double r2466179 = r2466178 / r2466175;
double r2466180 = r2466171 * r2466179;
return r2466180;
}
double f(double i, double n) {
double r2466181 = n;
double r2466182 = -1.4608487543202562e+112;
bool r2466183 = r2466181 <= r2466182;
double r2466184 = 100.0;
double r2466185 = r2466184 * r2466181;
double r2466186 = 16.666666666666668;
double r2466187 = i;
double r2466188 = r2466187 * r2466187;
double r2466189 = r2466188 * r2466181;
double r2466190 = r2466186 * r2466189;
double r2466191 = r2466187 * r2466181;
double r2466192 = 50.0;
double r2466193 = r2466191 * r2466192;
double r2466194 = r2466190 + r2466193;
double r2466195 = r2466185 + r2466194;
double r2466196 = -0.5086740071675135;
bool r2466197 = r2466181 <= r2466196;
double r2466198 = r2466184 / r2466187;
double r2466199 = r2466187 / r2466181;
double r2466200 = 1.0;
double r2466201 = r2466199 + r2466200;
double r2466202 = pow(r2466201, r2466181);
double r2466203 = r2466200 / r2466181;
double r2466204 = r2466202 / r2466203;
double r2466205 = r2466204 - r2466181;
double r2466206 = r2466198 * r2466205;
double r2466207 = 6.641285833915873e-252;
bool r2466208 = r2466181 <= r2466207;
double r2466209 = 0.0;
double r2466210 = r2466208 ? r2466209 : r2466195;
double r2466211 = r2466197 ? r2466206 : r2466210;
double r2466212 = r2466183 ? r2466195 : r2466211;
return r2466212;
}




Bits error versus i




Bits error versus n
Results
| Original | 42.3 |
|---|---|
| Target | 42.2 |
| Herbie | 22.7 |
if n < -1.4608487543202562e+112 or 6.641285833915873e-252 < n Initial program 54.3
rmApplied div-inv54.3
Applied *-un-lft-identity54.3
Applied times-frac54.6
Applied associate-*r*54.6
Simplified54.6
Taylor expanded around 0 27.4
Simplified27.4
Taylor expanded around inf 23.1
Simplified23.1
if -1.4608487543202562e+112 < n < -0.5086740071675135Initial program 35.5
rmApplied div-inv35.5
Applied *-un-lft-identity35.5
Applied times-frac35.4
Applied associate-*r*35.5
Simplified35.4
rmApplied div-sub35.4
Simplified35.3
if -0.5086740071675135 < n < 6.641285833915873e-252Initial program 18.3
rmApplied div-inv18.3
Applied *-un-lft-identity18.3
Applied times-frac18.5
Applied associate-*r*18.7
Simplified18.7
Taylor expanded around 0 15.7
Final simplification22.7
herbie shell --seed 2019151
(FPCore (i n)
:name "Compound Interest"
: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))))