100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;n \le -1.8734143464281 \cdot 10^{-311}:\\
\;\;\;\;\mathsf{fma}\left(e^{\left(\left(\mathsf{log1p}\left(\frac{i}{n}\right)\right)\right) \cdot n}, 100, -100\right) \cdot \frac{1}{\frac{i}{n}}\\
\mathbf{elif}\;n \le 1.512315662452518 \cdot 10^{-93}:\\
\;\;\;\;\frac{\mathsf{fma}\left(50 \cdot \left(n \cdot n\right), \log n \cdot \log n, \mathsf{fma}\left(\left(n \cdot \left(n \cdot n\right)\right) \cdot \frac{50}{3}, \left(\log i \cdot \log i\right) \cdot \log i, \mathsf{fma}\left(n \cdot \log i, 100, \mathsf{fma}\left(\frac{100}{3}, \left(\left(n \cdot \left(n \cdot n\right)\right) \cdot \log i\right) \cdot \left(\log n \cdot \log n\right), \mathsf{fma}\left(\frac{50}{3}, \left(\left(n \cdot \left(n \cdot n\right)\right) \cdot \log i\right) \cdot \left(\log n \cdot \log n\right), \left(50 \cdot \left(n \cdot n\right)\right) \cdot \left(\log i \cdot \log i\right)\right)\right)\right)\right)\right) - \mathsf{fma}\left(\frac{100}{3} \cdot \left(n \cdot \left(n \cdot n\right)\right), \left(\log i \cdot \log i\right) \cdot \log n, \log n \cdot \left(n \cdot 100\right) + \left(\left(\left(n \cdot \left(n \cdot n\right)\right) \cdot \frac{50}{3}\right) \cdot \left(\left(\log i \cdot \log i\right) \cdot \log n + \log n \cdot \left(\log n \cdot \log n\right)\right) + \left(\left(\log n \cdot \log i\right) \cdot \left(n \cdot n\right)\right) \cdot 100\right)\right)}{\frac{i}{n}}\\
\mathbf{elif}\;n \le 1.7502911309066923 \cdot 10^{+267}:\\
\;\;\;\;\frac{\mathsf{fma}\left(100, i, \left(i \cdot i\right) \cdot \left(50 + i \cdot \frac{50}{3}\right)\right)}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(e^{\left(\left(\mathsf{log1p}\left(\frac{i}{n}\right) \cdot n\right)\right)}, 100, -100\right)}{\frac{i}{n}}\\
\end{array}double f(double i, double n) {
double r5543147 = 100.0;
double r5543148 = 1.0;
double r5543149 = i;
double r5543150 = n;
double r5543151 = r5543149 / r5543150;
double r5543152 = r5543148 + r5543151;
double r5543153 = pow(r5543152, r5543150);
double r5543154 = r5543153 - r5543148;
double r5543155 = r5543154 / r5543151;
double r5543156 = r5543147 * r5543155;
return r5543156;
}
double f(double i, double n) {
double r5543157 = n;
double r5543158 = -1.8734143464281e-311;
bool r5543159 = r5543157 <= r5543158;
double r5543160 = i;
double r5543161 = r5543160 / r5543157;
double r5543162 = log1p(r5543161);
double r5543163 = /* ERROR: no posit support in C */;
double r5543164 = /* ERROR: no posit support in C */;
double r5543165 = r5543164 * r5543157;
double r5543166 = exp(r5543165);
double r5543167 = 100.0;
double r5543168 = -100.0;
double r5543169 = fma(r5543166, r5543167, r5543168);
double r5543170 = 1.0;
double r5543171 = r5543170 / r5543161;
double r5543172 = r5543169 * r5543171;
double r5543173 = 1.512315662452518e-93;
bool r5543174 = r5543157 <= r5543173;
double r5543175 = 50.0;
double r5543176 = r5543157 * r5543157;
double r5543177 = r5543175 * r5543176;
double r5543178 = log(r5543157);
double r5543179 = r5543178 * r5543178;
double r5543180 = r5543157 * r5543176;
double r5543181 = 16.666666666666668;
double r5543182 = r5543180 * r5543181;
double r5543183 = log(r5543160);
double r5543184 = r5543183 * r5543183;
double r5543185 = r5543184 * r5543183;
double r5543186 = r5543157 * r5543183;
double r5543187 = 33.333333333333336;
double r5543188 = r5543180 * r5543183;
double r5543189 = r5543188 * r5543179;
double r5543190 = r5543177 * r5543184;
double r5543191 = fma(r5543181, r5543189, r5543190);
double r5543192 = fma(r5543187, r5543189, r5543191);
double r5543193 = fma(r5543186, r5543167, r5543192);
double r5543194 = fma(r5543182, r5543185, r5543193);
double r5543195 = fma(r5543177, r5543179, r5543194);
double r5543196 = r5543187 * r5543180;
double r5543197 = r5543184 * r5543178;
double r5543198 = r5543157 * r5543167;
double r5543199 = r5543178 * r5543198;
double r5543200 = r5543178 * r5543179;
double r5543201 = r5543197 + r5543200;
double r5543202 = r5543182 * r5543201;
double r5543203 = r5543178 * r5543183;
double r5543204 = r5543203 * r5543176;
double r5543205 = r5543204 * r5543167;
double r5543206 = r5543202 + r5543205;
double r5543207 = r5543199 + r5543206;
double r5543208 = fma(r5543196, r5543197, r5543207);
double r5543209 = r5543195 - r5543208;
double r5543210 = r5543209 / r5543161;
double r5543211 = 1.7502911309066923e+267;
bool r5543212 = r5543157 <= r5543211;
double r5543213 = r5543160 * r5543160;
double r5543214 = r5543160 * r5543181;
double r5543215 = r5543175 + r5543214;
double r5543216 = r5543213 * r5543215;
double r5543217 = fma(r5543167, r5543160, r5543216);
double r5543218 = r5543217 / r5543161;
double r5543219 = r5543162 * r5543157;
double r5543220 = /* ERROR: no posit support in C */;
double r5543221 = /* ERROR: no posit support in C */;
double r5543222 = exp(r5543221);
double r5543223 = fma(r5543222, r5543167, r5543168);
double r5543224 = r5543223 / r5543161;
double r5543225 = r5543212 ? r5543218 : r5543224;
double r5543226 = r5543174 ? r5543210 : r5543225;
double r5543227 = r5543159 ? r5543172 : r5543226;
return r5543227;
}




Bits error versus i




Bits error versus n
| Original | 42.8 |
|---|---|
| Target | 42.1 |
| Herbie | 27.7 |
if n < -1.8734143464281e-311Initial program 33.0
Simplified33.0
rmApplied pow-to-exp37.3
Simplified31.7
rmApplied div-inv31.8
rmApplied insert-posit1628.6
if -1.8734143464281e-311 < n < 1.512315662452518e-93Initial program 45.3
Simplified45.3
rmApplied pow-to-exp45.3
Simplified45.3
Taylor expanded around 0 18.9
Simplified18.9
if 1.512315662452518e-93 < n < 1.7502911309066923e+267Initial program 59.0
Simplified59.0
Taylor expanded around 0 29.4
Simplified29.4
if 1.7502911309066923e+267 < n Initial program 58.3
Simplified58.3
rmApplied pow-to-exp58.3
Simplified37.1
rmApplied insert-posit1638.3
Final simplification27.7
herbie shell --seed 2019144 +o rules:numerics
(FPCore (i n)
:name "Compound Interest"
: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))))