100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;n \le -2.71552055838372837 \cdot 10^{82}:\\
\;\;\;\;100 \cdot \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)\\
\mathbf{elif}\;n \le -3.9974032830534776 \cdot 10^{-251}:\\
\;\;\;\;100 \cdot \frac{{\left({\left(1 + \frac{i}{n}\right)}^{n}\right)}^{3} - {1}^{3}}{\frac{\mathsf{fma}\left(1, {\left(1 + \frac{i}{n}\right)}^{n} + 1, {\left(1 + \frac{i}{n}\right)}^{\left(2 \cdot n\right)}\right) \cdot i}{n}}\\
\mathbf{elif}\;n \le 7.18594828335009282 \cdot 10^{-152}:\\
\;\;\;\;100 \cdot \frac{\mathsf{fma}\left(1, i, \mathsf{fma}\left(\log 1, n, 1\right)\right) - 1}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \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)\\
\end{array}double f(double i, double n) {
double r147125 = 100.0;
double r147126 = 1.0;
double r147127 = i;
double r147128 = n;
double r147129 = r147127 / r147128;
double r147130 = r147126 + r147129;
double r147131 = pow(r147130, r147128);
double r147132 = r147131 - r147126;
double r147133 = r147132 / r147129;
double r147134 = r147125 * r147133;
return r147134;
}
double f(double i, double n) {
double r147135 = n;
double r147136 = -2.7155205583837284e+82;
bool r147137 = r147135 <= r147136;
double r147138 = 100.0;
double r147139 = i;
double r147140 = 1.0;
double r147141 = 0.5;
double r147142 = 2.0;
double r147143 = pow(r147139, r147142);
double r147144 = log(r147140);
double r147145 = r147144 * r147135;
double r147146 = fma(r147141, r147143, r147145);
double r147147 = r147143 * r147144;
double r147148 = r147141 * r147147;
double r147149 = r147146 - r147148;
double r147150 = fma(r147139, r147140, r147149);
double r147151 = r147150 / r147139;
double r147152 = r147151 * r147135;
double r147153 = r147138 * r147152;
double r147154 = -3.9974032830534776e-251;
bool r147155 = r147135 <= r147154;
double r147156 = r147139 / r147135;
double r147157 = r147140 + r147156;
double r147158 = pow(r147157, r147135);
double r147159 = 3.0;
double r147160 = pow(r147158, r147159);
double r147161 = pow(r147140, r147159);
double r147162 = r147160 - r147161;
double r147163 = r147158 + r147140;
double r147164 = r147142 * r147135;
double r147165 = pow(r147157, r147164);
double r147166 = fma(r147140, r147163, r147165);
double r147167 = r147166 * r147139;
double r147168 = r147167 / r147135;
double r147169 = r147162 / r147168;
double r147170 = r147138 * r147169;
double r147171 = 7.185948283350093e-152;
bool r147172 = r147135 <= r147171;
double r147173 = 1.0;
double r147174 = fma(r147144, r147135, r147173);
double r147175 = fma(r147140, r147139, r147174);
double r147176 = r147175 - r147140;
double r147177 = r147176 / r147156;
double r147178 = r147138 * r147177;
double r147179 = r147172 ? r147178 : r147153;
double r147180 = r147155 ? r147170 : r147179;
double r147181 = r147137 ? r147153 : r147180;
return r147181;
}




Bits error versus i




Bits error versus n
| Original | 42.4 |
|---|---|
| Target | 42.3 |
| Herbie | 22.4 |
if n < -2.7155205583837284e+82 or 7.185948283350093e-152 < n Initial program 54.6
Taylor expanded around 0 40.4
Simplified40.4
rmApplied associate-/r/22.3
if -2.7155205583837284e+82 < n < -3.9974032830534776e-251Initial program 22.0
rmApplied flip3--22.0
Applied associate-/l/22.0
Simplified22.0
if -3.9974032830534776e-251 < n < 7.185948283350093e-152Initial program 33.4
Taylor expanded around 0 24.1
Simplified24.1
Final simplification22.4
herbie shell --seed 2020081 +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))))