100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -3.076493361831821548083157134309908748576 \cdot 10^{-11}:\\
\;\;\;\;100 \cdot \frac{{\left({\left(\frac{i}{n} + 1\right)}^{n}\right)}^{3} - {1}^{3}}{\frac{i}{n} \cdot \left({\left(\frac{i}{n} + 1\right)}^{n} \cdot {\left(\frac{i}{n} + 1\right)}^{n} + \left(1 \cdot 1 + 1 \cdot {\left(\frac{i}{n} + 1\right)}^{n}\right)\right)}\\
\mathbf{elif}\;i \le 4.681047647742425900350258684689085185658 \cdot 10^{-271}:\\
\;\;\;\;100 \cdot \left(n \cdot \frac{\mathsf{fma}\left(n, \log 1, i \cdot \mathsf{fma}\left(i, 0.5, 1\right)\right) - \left(\left(i \cdot i\right) \cdot 0.5\right) \cdot \log 1}{i}\right)\\
\mathbf{elif}\;i \le 11.91186691865260804945592099102213978767:\\
\;\;\;\;\frac{100}{i} \cdot \left(n \cdot \left(\mathsf{fma}\left(n, \log 1, i \cdot \left(i \cdot 0.5 + 1\right)\right) - \left(\left(i \cdot i\right) \cdot 0.5\right) \cdot \log 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{{\left(\frac{i}{n} + 1\right)}^{n} - 1}{i}}{\frac{1}{n}} \cdot 100\\
\end{array}double f(double i, double n) {
double r5886038 = 100.0;
double r5886039 = 1.0;
double r5886040 = i;
double r5886041 = n;
double r5886042 = r5886040 / r5886041;
double r5886043 = r5886039 + r5886042;
double r5886044 = pow(r5886043, r5886041);
double r5886045 = r5886044 - r5886039;
double r5886046 = r5886045 / r5886042;
double r5886047 = r5886038 * r5886046;
return r5886047;
}
double f(double i, double n) {
double r5886048 = i;
double r5886049 = -3.0764933618318215e-11;
bool r5886050 = r5886048 <= r5886049;
double r5886051 = 100.0;
double r5886052 = n;
double r5886053 = r5886048 / r5886052;
double r5886054 = 1.0;
double r5886055 = r5886053 + r5886054;
double r5886056 = pow(r5886055, r5886052);
double r5886057 = 3.0;
double r5886058 = pow(r5886056, r5886057);
double r5886059 = pow(r5886054, r5886057);
double r5886060 = r5886058 - r5886059;
double r5886061 = r5886056 * r5886056;
double r5886062 = r5886054 * r5886054;
double r5886063 = r5886054 * r5886056;
double r5886064 = r5886062 + r5886063;
double r5886065 = r5886061 + r5886064;
double r5886066 = r5886053 * r5886065;
double r5886067 = r5886060 / r5886066;
double r5886068 = r5886051 * r5886067;
double r5886069 = 4.681047647742426e-271;
bool r5886070 = r5886048 <= r5886069;
double r5886071 = log(r5886054);
double r5886072 = 0.5;
double r5886073 = fma(r5886048, r5886072, r5886054);
double r5886074 = r5886048 * r5886073;
double r5886075 = fma(r5886052, r5886071, r5886074);
double r5886076 = r5886048 * r5886048;
double r5886077 = r5886076 * r5886072;
double r5886078 = r5886077 * r5886071;
double r5886079 = r5886075 - r5886078;
double r5886080 = r5886079 / r5886048;
double r5886081 = r5886052 * r5886080;
double r5886082 = r5886051 * r5886081;
double r5886083 = 11.911866918652608;
bool r5886084 = r5886048 <= r5886083;
double r5886085 = r5886051 / r5886048;
double r5886086 = r5886048 * r5886072;
double r5886087 = r5886086 + r5886054;
double r5886088 = r5886048 * r5886087;
double r5886089 = fma(r5886052, r5886071, r5886088);
double r5886090 = r5886089 - r5886078;
double r5886091 = r5886052 * r5886090;
double r5886092 = r5886085 * r5886091;
double r5886093 = r5886056 - r5886054;
double r5886094 = r5886093 / r5886048;
double r5886095 = 1.0;
double r5886096 = r5886095 / r5886052;
double r5886097 = r5886094 / r5886096;
double r5886098 = r5886097 * r5886051;
double r5886099 = r5886084 ? r5886092 : r5886098;
double r5886100 = r5886070 ? r5886082 : r5886099;
double r5886101 = r5886050 ? r5886068 : r5886100;
return r5886101;
}




Bits error versus i




Bits error versus n
| Original | 42.8 |
|---|---|
| Target | 42.7 |
| Herbie | 21.4 |
if i < -3.0764933618318215e-11Initial program 28.6
rmApplied flip3--28.6
Applied associate-/l/28.6
if -3.0764933618318215e-11 < i < 4.681047647742426e-271Initial program 50.5
Taylor expanded around 0 35.0
Simplified35.0
rmApplied div-inv35.0
Applied *-un-lft-identity35.0
Applied times-frac15.8
Simplified15.8
rmApplied associate-*r*16.4
Simplified16.3
if 4.681047647742426e-271 < i < 11.911866918652608Initial program 51.0
Taylor expanded around 0 32.8
Simplified32.8
rmApplied div-inv32.8
Applied *-un-lft-identity32.8
Applied times-frac16.7
Simplified16.7
rmApplied associate-*r*16.8
Simplified16.7
if 11.911866918652608 < i Initial program 31.3
rmApplied div-inv31.3
Applied associate-/r*31.3
Final simplification21.4
herbie shell --seed 2019179 +o rules:numerics
(FPCore (i n)
:name "Compound Interest"
:herbie-target
(* 100.0 (/ (- (exp (* n (if (== (+ 1.0 (/ i n)) 1.0) (/ i n) (/ (* (/ i n) (log (+ 1.0 (/ i n)))) (- (+ (/ i n) 1.0) 1.0))))) 1.0) (/ i n)))
(* 100.0 (/ (- (pow (+ 1.0 (/ i n)) n) 1.0) (/ i n))))