100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;n \le -8.25471062341413314 \cdot 10^{133}:\\
\;\;\;\;1 \cdot \left(\left(\frac{\mathsf{fma}\left(i, 1, \mathsf{fma}\left(0.5, {i}^{2}, \log 1 \cdot n\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)\right)}{i} \cdot n\right) \cdot 100\right)\\
\mathbf{elif}\;n \le -1.06647918148280056 \cdot 10^{98}:\\
\;\;\;\;\frac{\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot 100}{\frac{1}{n}}\\
\mathbf{elif}\;n \le -273763342797823150000:\\
\;\;\;\;1 \cdot \left(\left(\frac{\mathsf{fma}\left(i, 1, \mathsf{fma}\left(0.5, {i}^{2}, \log 1 \cdot n\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)\right)}{i} \cdot n\right) \cdot 100\right)\\
\mathbf{elif}\;n \le -1052610260.2415111:\\
\;\;\;\;\frac{\frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i} \cdot 100}{\frac{1}{n}}\\
\mathbf{elif}\;n \le -1.4720208733212128:\\
\;\;\;\;1 \cdot \frac{\left(\mathsf{fma}\left(i, 1, \mathsf{fma}\left(0.5, {i}^{2}, \log 1 \cdot n\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)\right) \cdot n\right) \cdot 100}{i}\\
\mathbf{elif}\;n \le 6.9315088713900162 \cdot 10^{-118}:\\
\;\;\;\;\mathsf{fma}\left(100, \log 1 \cdot {n}^{2}, \mathsf{fma}\left(50, \frac{{\left(\log 1\right)}^{2} \cdot {n}^{3}}{i}, 100 \cdot \frac{\log 1 \cdot {n}^{2}}{i}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;1 \cdot \left(\left(\frac{\mathsf{fma}\left(i, 1, \mathsf{fma}\left(0.5, {i}^{2}, \log 1 \cdot n\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)\right)}{i} \cdot n\right) \cdot 100\right)\\
\end{array}double code(double i, double n) {
return (100.0 * ((pow((1.0 + (i / n)), n) - 1.0) / (i / n)));
}
double code(double i, double n) {
double temp;
if ((n <= -8.254710623414133e+133)) {
temp = (1.0 * (((fma(i, 1.0, (fma(0.5, pow(i, 2.0), (log(1.0) * n)) - (0.5 * (pow(i, 2.0) * log(1.0))))) / i) * n) * 100.0));
} else {
double temp_1;
if ((n <= -1.0664791814828006e+98)) {
temp_1 = ((((pow((1.0 + (i / n)), n) - 1.0) / i) * 100.0) / (1.0 / n));
} else {
double temp_2;
if ((n <= -2.7376334279782315e+20)) {
temp_2 = (1.0 * (((fma(i, 1.0, (fma(0.5, pow(i, 2.0), (log(1.0) * n)) - (0.5 * (pow(i, 2.0) * log(1.0))))) / i) * n) * 100.0));
} else {
double temp_3;
if ((n <= -1052610260.2415111)) {
temp_3 = ((((pow((1.0 + (i / n)), n) - 1.0) / i) * 100.0) / (1.0 / n));
} else {
double temp_4;
if ((n <= -1.4720208733212128)) {
temp_4 = (1.0 * (((fma(i, 1.0, (fma(0.5, pow(i, 2.0), (log(1.0) * n)) - (0.5 * (pow(i, 2.0) * log(1.0))))) * n) * 100.0) / i));
} else {
double temp_5;
if ((n <= 6.931508871390016e-118)) {
temp_5 = fma(100.0, (log(1.0) * pow(n, 2.0)), fma(50.0, ((pow(log(1.0), 2.0) * pow(n, 3.0)) / i), (100.0 * ((log(1.0) * pow(n, 2.0)) / i))));
} else {
temp_5 = (1.0 * (((fma(i, 1.0, (fma(0.5, pow(i, 2.0), (log(1.0) * n)) - (0.5 * (pow(i, 2.0) * log(1.0))))) / i) * n) * 100.0));
}
temp_4 = temp_5;
}
temp_3 = temp_4;
}
temp_2 = temp_3;
}
temp_1 = temp_2;
}
temp = temp_1;
}
return temp;
}




Bits error versus i




Bits error versus n
Results
| Original | 42.9 |
|---|---|
| Target | 42.8 |
| Herbie | 21.7 |
if n < -8.254710623414133e+133 or -1.0664791814828006e+98 < n < -2.7376334279782315e+20 or 6.931508871390016e-118 < n Initial program 54.1
rmApplied div-inv54.1
Applied associate-/r*53.8
Taylor expanded around 0 21.7
Simplified21.7
rmApplied *-un-lft-identity21.7
Applied associate-*l*21.7
Simplified21.6
if -8.254710623414133e+133 < n < -1.0664791814828006e+98 or -2.7376334279782315e+20 < n < -1052610260.2415111Initial program 40.1
rmApplied div-inv40.1
Applied associate-/r*39.9
rmApplied associate-*r/39.9
Simplified39.9
if -1052610260.2415111 < n < -1.4720208733212128Initial program 28.1
rmApplied div-inv28.1
Applied associate-/r*28.1
Taylor expanded around 0 35.1
Simplified35.1
rmApplied *-un-lft-identity35.1
Applied associate-*l*35.1
Simplified35.0
rmApplied associate-*l/35.0
Applied associate-*l/35.1
if -1.4720208733212128 < n < 6.931508871390016e-118Initial program 25.6
rmApplied div-inv25.6
Applied associate-/r*26.1
Taylor expanded around 0 19.1
Simplified19.1
Final simplification21.7
herbie shell --seed 2020058 +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))))