100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;n \le -1.00297232240918336 \cdot 10^{174}:\\
\;\;\;\;\left(100 \cdot \frac{\mathsf{fma}\left(1, i, \mathsf{fma}\left(0.5, i \cdot i, \log 1 \cdot n\right)\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)}{i}\right) \cdot n\\
\mathbf{elif}\;n \le -4.03699116408299863 \cdot 10^{85}:\\
\;\;\;\;\frac{100 \cdot \left(\left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right) \cdot n\right)}{i}\\
\mathbf{elif}\;n \le -3.31747608845659503 \cdot 10^{63}:\\
\;\;\;\;\left(100 \cdot \frac{\mathsf{fma}\left(1, i, \mathsf{fma}\left(0.5, i \cdot i, \log 1 \cdot n\right)\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)}{i}\right) \cdot n\\
\mathbf{elif}\;n \le -1.0912719332224593 \cdot 10^{26}:\\
\;\;\;\;\frac{100 \cdot \left({\left(1 + \frac{i}{n}\right)}^{n} - 1\right)}{\frac{i}{n}}\\
\mathbf{elif}\;n \le -934893.903368213796:\\
\;\;\;\;\left(100 \cdot \frac{\mathsf{fma}\left(1, i, \mathsf{fma}\left(0.5, i \cdot i, \log 1 \cdot n\right)\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)}{i}\right) \cdot n\\
\mathbf{elif}\;n \le 1.4472641457797862 \cdot 10^{-291}:\\
\;\;\;\;100 \cdot \left(\frac{{\left(1 + \frac{i}{n}\right)}^{n}}{\frac{i}{n}} - \frac{1}{\frac{i}{n}}\right)\\
\mathbf{elif}\;n \le 6.25395219693272548 \cdot 10^{-155}:\\
\;\;\;\;100 \cdot \frac{\mathsf{fma}\left(1, i, \mathsf{fma}\left(\log 1, n, 1\right)\right) - 1}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;\left(100 \cdot \frac{\mathsf{fma}\left(1, i, \mathsf{fma}\left(0.5, i \cdot i, \log 1 \cdot n\right)\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)}{i}\right) \cdot n\\
\end{array}double f(double i, double n) {
double r171170 = 100.0;
double r171171 = 1.0;
double r171172 = i;
double r171173 = n;
double r171174 = r171172 / r171173;
double r171175 = r171171 + r171174;
double r171176 = pow(r171175, r171173);
double r171177 = r171176 - r171171;
double r171178 = r171177 / r171174;
double r171179 = r171170 * r171178;
return r171179;
}
double f(double i, double n) {
double r171180 = n;
double r171181 = -1.0029723224091834e+174;
bool r171182 = r171180 <= r171181;
double r171183 = 100.0;
double r171184 = 1.0;
double r171185 = i;
double r171186 = 0.5;
double r171187 = r171185 * r171185;
double r171188 = log(r171184);
double r171189 = r171188 * r171180;
double r171190 = fma(r171186, r171187, r171189);
double r171191 = fma(r171184, r171185, r171190);
double r171192 = 2.0;
double r171193 = pow(r171185, r171192);
double r171194 = r171193 * r171188;
double r171195 = r171186 * r171194;
double r171196 = r171191 - r171195;
double r171197 = r171196 / r171185;
double r171198 = r171183 * r171197;
double r171199 = r171198 * r171180;
double r171200 = -4.0369911640829986e+85;
bool r171201 = r171180 <= r171200;
double r171202 = r171185 / r171180;
double r171203 = r171184 + r171202;
double r171204 = pow(r171203, r171180);
double r171205 = r171204 - r171184;
double r171206 = r171205 * r171180;
double r171207 = r171183 * r171206;
double r171208 = r171207 / r171185;
double r171209 = -3.317476088456595e+63;
bool r171210 = r171180 <= r171209;
double r171211 = -1.0912719332224593e+26;
bool r171212 = r171180 <= r171211;
double r171213 = r171183 * r171205;
double r171214 = r171213 / r171202;
double r171215 = -934893.9033682138;
bool r171216 = r171180 <= r171215;
double r171217 = 1.4472641457797862e-291;
bool r171218 = r171180 <= r171217;
double r171219 = r171204 / r171202;
double r171220 = r171184 / r171202;
double r171221 = r171219 - r171220;
double r171222 = r171183 * r171221;
double r171223 = 6.2539521969327255e-155;
bool r171224 = r171180 <= r171223;
double r171225 = 1.0;
double r171226 = fma(r171188, r171180, r171225);
double r171227 = fma(r171184, r171185, r171226);
double r171228 = r171227 - r171184;
double r171229 = r171228 / r171202;
double r171230 = r171183 * r171229;
double r171231 = r171224 ? r171230 : r171199;
double r171232 = r171218 ? r171222 : r171231;
double r171233 = r171216 ? r171199 : r171232;
double r171234 = r171212 ? r171214 : r171233;
double r171235 = r171210 ? r171199 : r171234;
double r171236 = r171201 ? r171208 : r171235;
double r171237 = r171182 ? r171199 : r171236;
return r171237;
}




Bits error versus i




Bits error versus n
| Original | 43.1 |
|---|---|
| Target | 43.0 |
| Herbie | 23.6 |
if n < -1.0029723224091834e+174 or -4.0369911640829986e+85 < n < -3.317476088456595e+63 or -1.0912719332224593e+26 < n < -934893.9033682138 or 6.2539521969327255e-155 < n Initial program 56.2
rmApplied associate-/r/55.9
Taylor expanded around 0 21.3
Simplified21.3
rmApplied associate-*r*21.3
if -1.0029723224091834e+174 < n < -4.0369911640829986e+85Initial program 40.6
rmApplied associate-/r/40.3
rmApplied associate-*l/40.2
Applied associate-*r/40.2
if -3.317476088456595e+63 < n < -1.0912719332224593e+26Initial program 30.6
rmApplied associate-*r/30.5
if -934893.9033682138 < n < 1.4472641457797862e-291Initial program 18.0
rmApplied div-sub18.0
if 1.4472641457797862e-291 < n < 6.2539521969327255e-155Initial program 43.0
Taylor expanded around 0 32.4
Simplified32.4
Final simplification23.6
herbie shell --seed 2020047 +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))))