100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -1.3007934666970692 \cdot 10^{+19}:\\
\;\;\;\;\frac{\log \left(e^{\mathsf{fma}\left(100, \left(e^{\mathsf{log1p}\left(\left(\frac{i}{n}\right)\right) \cdot n}\right), -100\right)}\right)}{\frac{i}{n}}\\
\mathbf{elif}\;i \le 9.525407785233792 \cdot 10^{-06}:\\
\;\;\;\;\frac{1}{\left(\frac{\frac{1}{100}}{n} - \frac{i}{n} \cdot \frac{1}{200}\right) + \frac{\mathsf{expm1}\left(\left(\mathsf{log1p}\left(\left(\frac{i}{n} \cdot \frac{1}{200}\right)\right)\right)\right)}{n}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\frac{i}{n}}{\mathsf{fma}\left(50, \left(\left(\log n \cdot n\right) \cdot \left(\log n \cdot n\right)\right), \left(\mathsf{fma}\left(\left(\log i \cdot \left(\left(\left(n \cdot \log i\right) \cdot \left(n \cdot \log i\right)\right) \cdot n\right)\right), \frac{50}{3}, \left(\mathsf{fma}\left(\left(n \cdot \log i\right), 100, \left(50 \cdot \left(\left(\left(\left(\log n \cdot n\right) \cdot \left(\log n \cdot n\right)\right) \cdot n\right) \cdot \log i\right) + 50 \cdot \left(\left(n \cdot \log i\right) \cdot \left(n \cdot \log i\right)\right)\right)\right)\right)\right)\right)\right) - \left(\left(\left(\log n \cdot \left(\left(\left(n \cdot \log i\right) \cdot \left(n \cdot \log i\right)\right) \cdot n\right)\right) \cdot \frac{100}{3} + \mathsf{fma}\left(\frac{50}{3}, \left(\left(\left(\left(\log n \cdot n\right) \cdot \left(\log n \cdot n\right)\right) \cdot n\right) \cdot \log n\right), \left(\mathsf{fma}\left(\frac{50}{3}, \left(\log n \cdot \left(\left(\left(n \cdot \log i\right) \cdot \left(n \cdot \log i\right)\right) \cdot n\right)\right), \left(100 \cdot \left(\log n \cdot n\right)\right)\right)\right)\right)\right) + 100 \cdot \left(\left(\log i \cdot \log n\right) \cdot \left(n \cdot n\right)\right)\right)}}\\
\end{array}double f(double i, double n) {
double r4110102 = 100.0;
double r4110103 = 1.0;
double r4110104 = i;
double r4110105 = n;
double r4110106 = r4110104 / r4110105;
double r4110107 = r4110103 + r4110106;
double r4110108 = pow(r4110107, r4110105);
double r4110109 = r4110108 - r4110103;
double r4110110 = r4110109 / r4110106;
double r4110111 = r4110102 * r4110110;
return r4110111;
}
double f(double i, double n) {
double r4110112 = i;
double r4110113 = -1.3007934666970692e+19;
bool r4110114 = r4110112 <= r4110113;
double r4110115 = 100.0;
double r4110116 = n;
double r4110117 = r4110112 / r4110116;
double r4110118 = log1p(r4110117);
double r4110119 = r4110118 * r4110116;
double r4110120 = exp(r4110119);
double r4110121 = -100.0;
double r4110122 = fma(r4110115, r4110120, r4110121);
double r4110123 = exp(r4110122);
double r4110124 = log(r4110123);
double r4110125 = r4110124 / r4110117;
double r4110126 = 9.525407785233792e-06;
bool r4110127 = r4110112 <= r4110126;
double r4110128 = 1.0;
double r4110129 = 0.01;
double r4110130 = r4110129 / r4110116;
double r4110131 = 0.005;
double r4110132 = r4110117 * r4110131;
double r4110133 = r4110130 - r4110132;
double r4110134 = log1p(r4110132);
double r4110135 = expm1(r4110134);
double r4110136 = r4110135 / r4110116;
double r4110137 = r4110133 + r4110136;
double r4110138 = r4110128 / r4110137;
double r4110139 = 50.0;
double r4110140 = log(r4110116);
double r4110141 = r4110140 * r4110116;
double r4110142 = r4110141 * r4110141;
double r4110143 = log(r4110112);
double r4110144 = r4110116 * r4110143;
double r4110145 = r4110144 * r4110144;
double r4110146 = r4110145 * r4110116;
double r4110147 = r4110143 * r4110146;
double r4110148 = 16.666666666666668;
double r4110149 = r4110142 * r4110116;
double r4110150 = r4110149 * r4110143;
double r4110151 = r4110139 * r4110150;
double r4110152 = r4110139 * r4110145;
double r4110153 = r4110151 + r4110152;
double r4110154 = fma(r4110144, r4110115, r4110153);
double r4110155 = fma(r4110147, r4110148, r4110154);
double r4110156 = fma(r4110139, r4110142, r4110155);
double r4110157 = r4110140 * r4110146;
double r4110158 = 33.333333333333336;
double r4110159 = r4110157 * r4110158;
double r4110160 = r4110149 * r4110140;
double r4110161 = r4110115 * r4110141;
double r4110162 = fma(r4110148, r4110157, r4110161);
double r4110163 = fma(r4110148, r4110160, r4110162);
double r4110164 = r4110159 + r4110163;
double r4110165 = r4110143 * r4110140;
double r4110166 = r4110116 * r4110116;
double r4110167 = r4110165 * r4110166;
double r4110168 = r4110115 * r4110167;
double r4110169 = r4110164 + r4110168;
double r4110170 = r4110156 - r4110169;
double r4110171 = r4110117 / r4110170;
double r4110172 = r4110128 / r4110171;
double r4110173 = r4110127 ? r4110138 : r4110172;
double r4110174 = r4110114 ? r4110125 : r4110173;
return r4110174;
}




Bits error versus i




Bits error versus n
| Original | 42.2 |
|---|---|
| Target | 41.8 |
| Herbie | 12.5 |
if i < -1.3007934666970692e+19Initial program 26.5
Simplified26.5
rmApplied add-exp-log26.5
Applied pow-exp26.5
Simplified4.9
rmApplied add-log-exp4.9
if -1.3007934666970692e+19 < i < 9.525407785233792e-06Initial program 49.6
Simplified49.6
rmApplied add-exp-log49.6
Applied pow-exp49.6
Simplified47.7
rmApplied *-un-lft-identity47.7
Applied associate-/l*47.7
Taylor expanded around 0 14.5
Simplified13.1
rmApplied expm1-log1p-u13.1
if 9.525407785233792e-06 < i Initial program 32.0
Simplified31.9
rmApplied add-exp-log50.0
Applied pow-exp50.0
Simplified48.6
rmApplied *-un-lft-identity48.6
Applied associate-/l*48.6
Taylor expanded around 0 20.7
Simplified20.7
Final simplification12.5
herbie shell --seed 2019130 +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))))