100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -1.9035517225708853 \cdot 10^{-05}:\\
\;\;\;\;\frac{1}{i} \cdot \left(\mathsf{fma}\left(\left(e^{\mathsf{log1p}\left(\left(\frac{i}{n}\right)\right) \cdot n}\right), 100, -100\right) \cdot n\right)\\
\mathbf{elif}\;i \le 4.6215886817230635 \cdot 10^{-236}:\\
\;\;\;\;\frac{\mathsf{fma}\left(i, 100, \left(\left(i \cdot i\right) \cdot \left(50 + i \cdot \frac{50}{3}\right)\right)\right)}{\frac{i}{n}}\\
\mathbf{elif}\;i \le 5.047641306012117 \cdot 10^{-225}:\\
\;\;\;\;\frac{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + -100}{\frac{i}{n}}\\
\mathbf{elif}\;i \le 0.007511268653787123:\\
\;\;\;\;\frac{\mathsf{fma}\left(i, 100, \left(\left(i \cdot i\right) \cdot \left(50 + i \cdot \frac{50}{3}\right)\right)\right)}{\frac{i}{n}}\\
\mathbf{elif}\;i \le 1.710926129998514 \cdot 10^{+244}:\\
\;\;\;\;\frac{\left(\left(\left(n \cdot \log n\right) \cdot \left(n \cdot \log n\right)\right) \cdot 50 - \left(\left(\frac{100}{3} \cdot \left(\left(\left(n \cdot \log n\right) \cdot \left(n \cdot n\right)\right) \cdot \left(\log i \cdot \log i\right)\right) + \left(\left(\log n \cdot \log i\right) \cdot \left(n \cdot n\right)\right) \cdot 100\right) + \mathsf{fma}\left(\frac{50}{3}, \left(\log n \cdot \left(\left(\left(n \cdot \log n\right) \cdot \left(n \cdot \log n\right)\right) \cdot n\right)\right), \left(\mathsf{fma}\left(\frac{50}{3}, \left(\left(\left(n \cdot \log n\right) \cdot \left(n \cdot n\right)\right) \cdot \left(\log i \cdot \log i\right)\right), \left(100 \cdot \left(n \cdot \log n\right)\right)\right)\right)\right)\right)\right) + \mathsf{fma}\left(\frac{50}{3}, \left(\log i \cdot \left(n \cdot \left(\left(\log i \cdot n\right) \cdot \left(\log i \cdot n\right)\right)\right)\right), \left(\mathsf{fma}\left(\left(\log i \cdot n\right), 100, \left(\mathsf{fma}\left(\frac{100}{3}, \left(\left(\left(\left(n \cdot \log n\right) \cdot \left(n \cdot \log n\right)\right) \cdot n\right) \cdot \log i\right), \left(\mathsf{fma}\left(\left(\left(\left(\left(n \cdot \log n\right) \cdot \left(n \cdot \log n\right)\right) \cdot n\right) \cdot \log i\right), \frac{50}{3}, \left(\left(\left(\log i \cdot n\right) \cdot \left(\log i \cdot n\right)\right) \cdot 50\right)\right)\right)\right)\right)\right)\right)\right)}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;\frac{100 \cdot {\left(1 + \frac{i}{n}\right)}^{n} + -100}{\frac{i}{n}}\\
\end{array}double f(double i, double n) {
double r4495132 = 100.0;
double r4495133 = 1.0;
double r4495134 = i;
double r4495135 = n;
double r4495136 = r4495134 / r4495135;
double r4495137 = r4495133 + r4495136;
double r4495138 = pow(r4495137, r4495135);
double r4495139 = r4495138 - r4495133;
double r4495140 = r4495139 / r4495136;
double r4495141 = r4495132 * r4495140;
return r4495141;
}
double f(double i, double n) {
double r4495142 = i;
double r4495143 = -1.9035517225708853e-05;
bool r4495144 = r4495142 <= r4495143;
double r4495145 = 1.0;
double r4495146 = r4495145 / r4495142;
double r4495147 = n;
double r4495148 = r4495142 / r4495147;
double r4495149 = log1p(r4495148);
double r4495150 = r4495149 * r4495147;
double r4495151 = exp(r4495150);
double r4495152 = 100.0;
double r4495153 = -100.0;
double r4495154 = fma(r4495151, r4495152, r4495153);
double r4495155 = r4495154 * r4495147;
double r4495156 = r4495146 * r4495155;
double r4495157 = 4.6215886817230635e-236;
bool r4495158 = r4495142 <= r4495157;
double r4495159 = r4495142 * r4495142;
double r4495160 = 50.0;
double r4495161 = 16.666666666666668;
double r4495162 = r4495142 * r4495161;
double r4495163 = r4495160 + r4495162;
double r4495164 = r4495159 * r4495163;
double r4495165 = fma(r4495142, r4495152, r4495164);
double r4495166 = r4495165 / r4495148;
double r4495167 = 5.047641306012117e-225;
bool r4495168 = r4495142 <= r4495167;
double r4495169 = r4495145 + r4495148;
double r4495170 = pow(r4495169, r4495147);
double r4495171 = r4495152 * r4495170;
double r4495172 = r4495171 + r4495153;
double r4495173 = r4495172 / r4495148;
double r4495174 = 0.007511268653787123;
bool r4495175 = r4495142 <= r4495174;
double r4495176 = 1.710926129998514e+244;
bool r4495177 = r4495142 <= r4495176;
double r4495178 = log(r4495147);
double r4495179 = r4495147 * r4495178;
double r4495180 = r4495179 * r4495179;
double r4495181 = r4495180 * r4495160;
double r4495182 = 33.333333333333336;
double r4495183 = r4495147 * r4495147;
double r4495184 = r4495179 * r4495183;
double r4495185 = log(r4495142);
double r4495186 = r4495185 * r4495185;
double r4495187 = r4495184 * r4495186;
double r4495188 = r4495182 * r4495187;
double r4495189 = r4495178 * r4495185;
double r4495190 = r4495189 * r4495183;
double r4495191 = r4495190 * r4495152;
double r4495192 = r4495188 + r4495191;
double r4495193 = r4495180 * r4495147;
double r4495194 = r4495178 * r4495193;
double r4495195 = r4495152 * r4495179;
double r4495196 = fma(r4495161, r4495187, r4495195);
double r4495197 = fma(r4495161, r4495194, r4495196);
double r4495198 = r4495192 + r4495197;
double r4495199 = r4495181 - r4495198;
double r4495200 = r4495185 * r4495147;
double r4495201 = r4495200 * r4495200;
double r4495202 = r4495147 * r4495201;
double r4495203 = r4495185 * r4495202;
double r4495204 = r4495193 * r4495185;
double r4495205 = r4495201 * r4495160;
double r4495206 = fma(r4495204, r4495161, r4495205);
double r4495207 = fma(r4495182, r4495204, r4495206);
double r4495208 = fma(r4495200, r4495152, r4495207);
double r4495209 = fma(r4495161, r4495203, r4495208);
double r4495210 = r4495199 + r4495209;
double r4495211 = r4495210 / r4495148;
double r4495212 = r4495177 ? r4495211 : r4495173;
double r4495213 = r4495175 ? r4495166 : r4495212;
double r4495214 = r4495168 ? r4495173 : r4495213;
double r4495215 = r4495158 ? r4495166 : r4495214;
double r4495216 = r4495144 ? r4495156 : r4495215;
return r4495216;
}




Bits error versus i




Bits error versus n
| Original | 43.0 |
|---|---|
| Target | 42.2 |
| Herbie | 25.2 |
if i < -1.9035517225708853e-05Initial program 29.3
Simplified29.2
rmApplied pow-to-exp29.2
Simplified5.8
rmApplied div-inv5.8
Applied *-un-lft-identity5.8
Applied times-frac6.9
Simplified6.8
if -1.9035517225708853e-05 < i < 4.6215886817230635e-236 or 5.047641306012117e-225 < i < 0.007511268653787123Initial program 50.3
Simplified50.3
Taylor expanded around 0 32.8
Simplified32.8
if 4.6215886817230635e-236 < i < 5.047641306012117e-225 or 1.710926129998514e+244 < i Initial program 36.9
Simplified36.8
rmApplied fma-udef36.8
if 0.007511268653787123 < i < 1.710926129998514e+244Initial program 33.8
Simplified33.8
rmApplied pow-to-exp48.0
Simplified46.8
Taylor expanded around 0 16.3
Simplified16.3
Final simplification25.2
herbie shell --seed 2019132 +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))))