100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -5.4348495206706917 \cdot 10^{-14}:\\
\;\;\;\;\frac{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}{\frac{i}{n}}\\
\mathbf{elif}\;i \le 1.10371457373729495 \cdot 10^{-38}:\\
\;\;\;\;100 \cdot \frac{\left(\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)\right) \cdot n}{i}\\
\mathbf{elif}\;i \le 8.555628525961589 \cdot 10^{241}:\\
\;\;\;\;\frac{\frac{{\left(1 + \frac{i}{n}\right)}^{\left(2 \cdot n\right)} - 1 \cdot 1}{{\left(1 + \frac{i}{n}\right)}^{n} + 1} \cdot n}{i} \cdot 100\\
\mathbf{elif}\;i \le 3.67423122849791526 \cdot 10^{289}:\\
\;\;\;\;100 \cdot \frac{\left(1 \cdot i + \left(\log 1 \cdot n + 1\right)\right) - 1}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;\frac{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}{\frac{i}{n}}\\
\end{array}double f(double i, double n) {
double r154050 = 100.0;
double r154051 = 1.0;
double r154052 = i;
double r154053 = n;
double r154054 = r154052 / r154053;
double r154055 = r154051 + r154054;
double r154056 = pow(r154055, r154053);
double r154057 = r154056 - r154051;
double r154058 = r154057 / r154054;
double r154059 = r154050 * r154058;
return r154059;
}
double f(double i, double n) {
double r154060 = i;
double r154061 = -5.434849520670692e-14;
bool r154062 = r154060 <= r154061;
double r154063 = 100.0;
double r154064 = 1.0;
double r154065 = n;
double r154066 = r154060 / r154065;
double r154067 = r154064 + r154066;
double r154068 = pow(r154067, r154065);
double r154069 = r154068 - r154064;
double r154070 = r154063 * r154069;
double r154071 = r154070 / r154066;
double r154072 = 1.103714573737295e-38;
bool r154073 = r154060 <= r154072;
double r154074 = r154064 * r154060;
double r154075 = 0.5;
double r154076 = 2.0;
double r154077 = pow(r154060, r154076);
double r154078 = r154075 * r154077;
double r154079 = log(r154064);
double r154080 = r154079 * r154065;
double r154081 = r154078 + r154080;
double r154082 = r154074 + r154081;
double r154083 = r154077 * r154079;
double r154084 = r154075 * r154083;
double r154085 = r154082 - r154084;
double r154086 = r154085 * r154065;
double r154087 = r154086 / r154060;
double r154088 = r154063 * r154087;
double r154089 = 8.555628525961589e+241;
bool r154090 = r154060 <= r154089;
double r154091 = r154076 * r154065;
double r154092 = pow(r154067, r154091);
double r154093 = r154064 * r154064;
double r154094 = r154092 - r154093;
double r154095 = r154068 + r154064;
double r154096 = r154094 / r154095;
double r154097 = r154096 * r154065;
double r154098 = r154097 / r154060;
double r154099 = r154098 * r154063;
double r154100 = 3.6742312284979153e+289;
bool r154101 = r154060 <= r154100;
double r154102 = 1.0;
double r154103 = r154080 + r154102;
double r154104 = r154074 + r154103;
double r154105 = r154104 - r154064;
double r154106 = r154105 / r154066;
double r154107 = r154063 * r154106;
double r154108 = r154101 ? r154107 : r154071;
double r154109 = r154090 ? r154099 : r154108;
double r154110 = r154073 ? r154088 : r154109;
double r154111 = r154062 ? r154071 : r154110;
return r154111;
}




Bits error versus i




Bits error versus n
Results
| Original | 43.1 |
|---|---|
| Target | 43.0 |
| Herbie | 22.5 |
if i < -5.434849520670692e-14 or 3.6742312284979153e+289 < i Initial program 30.1
rmApplied associate-*r/30.1
if -5.434849520670692e-14 < i < 1.103714573737295e-38Initial program 50.8
rmApplied div-inv50.8
Applied add-sqr-sqrt50.8
Applied add-sqr-sqrt50.8
Applied difference-of-squares50.8
Applied times-frac50.5
Simplified50.5
rmApplied *-un-lft-identity50.5
Applied associate-*l*50.5
Simplified50.4
Taylor expanded around 0 15.3
if 1.103714573737295e-38 < i < 8.555628525961589e+241Initial program 37.1
rmApplied div-inv37.1
Applied add-sqr-sqrt37.1
Applied add-sqr-sqrt37.1
Applied difference-of-squares37.1
Applied times-frac37.1
Simplified37.1
rmApplied *-un-lft-identity37.1
Applied associate-*l*37.1
Simplified37.0
rmApplied flip--37.0
Simplified37.0
if 8.555628525961589e+241 < i < 3.6742312284979153e+289Initial program 28.6
Taylor expanded around 0 36.4
Final simplification22.5
herbie shell --seed 2020047
(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))))