100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -8.64473136240284 \cdot 10^{-06}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(e^{n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)}, 100, -100\right)}{i}}{\frac{1}{n}}\\
\mathbf{elif}\;i \le -1.3724256626812409 \cdot 10^{-191}:\\
\;\;\;\;\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{elif}\;i \le -2.4975427968587587 \cdot 10^{-298}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(e^{n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)}, 100, -100\right)}{i}}{\frac{1}{n}}\\
\mathbf{elif}\;i \le 1.4951161488388485:\\
\;\;\;\;\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{elif}\;i \le 6.023686335920959 \cdot 10^{+212}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\left(n \cdot n\right) \cdot 50, \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(\left(n \cdot n\right) \cdot 50\right) \cdot \left(\log i \cdot \log i\right)\right)\right)\right)\right)\right) - \mathsf{fma}\left(\left(n \cdot \left(n \cdot n\right)\right) \cdot \frac{100}{3}, \left(\log i \cdot \log i\right) \cdot \log n, \log n \cdot \left(100 \cdot n\right) + \left(\left(\left(\log n \cdot \log n\right) \cdot \log n + \left(\log i \cdot \log i\right) \cdot \log n\right) \cdot \left(\left(n \cdot \left(n \cdot n\right)\right) \cdot \frac{50}{3}\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}\;i \le 2.4667133503465437 \cdot 10^{+265}:\\
\;\;\;\;\frac{1}{i} \cdot \left(\mathsf{fma}\left(e^{n \cdot \left(\left(\mathsf{log1p}\left(\frac{i}{n}\right)\right)\right)}, 100, -100\right) \cdot n\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\left(n \cdot n\right) \cdot 50, \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(\left(n \cdot n\right) \cdot 50\right) \cdot \left(\log i \cdot \log i\right)\right)\right)\right)\right)\right) - \mathsf{fma}\left(\left(n \cdot \left(n \cdot n\right)\right) \cdot \frac{100}{3}, \left(\log i \cdot \log i\right) \cdot \log n, \log n \cdot \left(100 \cdot n\right) + \left(\left(\left(\log n \cdot \log n\right) \cdot \log n + \left(\log i \cdot \log i\right) \cdot \log n\right) \cdot \left(\left(n \cdot \left(n \cdot n\right)\right) \cdot \frac{50}{3}\right) + \left(\left(\log n \cdot \log i\right) \cdot \left(n \cdot n\right)\right) \cdot 100\right)\right)}{\frac{i}{n}}\\
\end{array}double f(double i, double n) {
double r4599082 = 100.0;
double r4599083 = 1.0;
double r4599084 = i;
double r4599085 = n;
double r4599086 = r4599084 / r4599085;
double r4599087 = r4599083 + r4599086;
double r4599088 = pow(r4599087, r4599085);
double r4599089 = r4599088 - r4599083;
double r4599090 = r4599089 / r4599086;
double r4599091 = r4599082 * r4599090;
return r4599091;
}
double f(double i, double n) {
double r4599092 = i;
double r4599093 = -8.64473136240284e-06;
bool r4599094 = r4599092 <= r4599093;
double r4599095 = n;
double r4599096 = r4599092 / r4599095;
double r4599097 = log1p(r4599096);
double r4599098 = r4599095 * r4599097;
double r4599099 = exp(r4599098);
double r4599100 = 100.0;
double r4599101 = -100.0;
double r4599102 = fma(r4599099, r4599100, r4599101);
double r4599103 = r4599102 / r4599092;
double r4599104 = 1.0;
double r4599105 = r4599104 / r4599095;
double r4599106 = r4599103 / r4599105;
double r4599107 = -1.3724256626812409e-191;
bool r4599108 = r4599092 <= r4599107;
double r4599109 = r4599092 * r4599092;
double r4599110 = 50.0;
double r4599111 = 16.666666666666668;
double r4599112 = r4599092 * r4599111;
double r4599113 = r4599110 + r4599112;
double r4599114 = r4599109 * r4599113;
double r4599115 = fma(r4599100, r4599092, r4599114);
double r4599116 = r4599115 / r4599096;
double r4599117 = -2.4975427968587587e-298;
bool r4599118 = r4599092 <= r4599117;
double r4599119 = 1.4951161488388485;
bool r4599120 = r4599092 <= r4599119;
double r4599121 = 6.023686335920959e+212;
bool r4599122 = r4599092 <= r4599121;
double r4599123 = r4599095 * r4599095;
double r4599124 = r4599123 * r4599110;
double r4599125 = log(r4599095);
double r4599126 = r4599125 * r4599125;
double r4599127 = r4599095 * r4599123;
double r4599128 = r4599127 * r4599111;
double r4599129 = log(r4599092);
double r4599130 = r4599129 * r4599129;
double r4599131 = r4599130 * r4599129;
double r4599132 = r4599095 * r4599129;
double r4599133 = 33.333333333333336;
double r4599134 = r4599127 * r4599129;
double r4599135 = r4599134 * r4599126;
double r4599136 = r4599124 * r4599130;
double r4599137 = fma(r4599111, r4599135, r4599136);
double r4599138 = fma(r4599133, r4599135, r4599137);
double r4599139 = fma(r4599132, r4599100, r4599138);
double r4599140 = fma(r4599128, r4599131, r4599139);
double r4599141 = fma(r4599124, r4599126, r4599140);
double r4599142 = r4599127 * r4599133;
double r4599143 = r4599130 * r4599125;
double r4599144 = r4599100 * r4599095;
double r4599145 = r4599125 * r4599144;
double r4599146 = r4599126 * r4599125;
double r4599147 = r4599146 + r4599143;
double r4599148 = r4599147 * r4599128;
double r4599149 = r4599125 * r4599129;
double r4599150 = r4599149 * r4599123;
double r4599151 = r4599150 * r4599100;
double r4599152 = r4599148 + r4599151;
double r4599153 = r4599145 + r4599152;
double r4599154 = fma(r4599142, r4599143, r4599153);
double r4599155 = r4599141 - r4599154;
double r4599156 = r4599155 / r4599096;
double r4599157 = 2.4667133503465437e+265;
bool r4599158 = r4599092 <= r4599157;
double r4599159 = r4599104 / r4599092;
double r4599160 = /* ERROR: no posit support in C */;
double r4599161 = /* ERROR: no posit support in C */;
double r4599162 = r4599095 * r4599161;
double r4599163 = exp(r4599162);
double r4599164 = fma(r4599163, r4599100, r4599101);
double r4599165 = r4599164 * r4599095;
double r4599166 = r4599159 * r4599165;
double r4599167 = r4599158 ? r4599166 : r4599156;
double r4599168 = r4599122 ? r4599156 : r4599167;
double r4599169 = r4599120 ? r4599116 : r4599168;
double r4599170 = r4599118 ? r4599106 : r4599169;
double r4599171 = r4599108 ? r4599116 : r4599170;
double r4599172 = r4599094 ? r4599106 : r4599171;
return r4599172;
}




Bits error versus i




Bits error versus n
| Original | 42.4 |
|---|---|
| Target | 42.2 |
| Herbie | 26.6 |
if i < -8.64473136240284e-06 or -1.3724256626812409e-191 < i < -2.4975427968587587e-298Initial program 35.1
Simplified35.1
rmApplied add-exp-log35.1
Simplified19.8
rmApplied div-inv19.9
Applied associate-/r*20.2
if -8.64473136240284e-06 < i < -1.3724256626812409e-191 or -2.4975427968587587e-298 < i < 1.4951161488388485Initial program 50.3
Simplified50.3
Taylor expanded around 0 32.3
Simplified32.3
if 1.4951161488388485 < i < 6.023686335920959e+212 or 2.4667133503465437e+265 < i Initial program 32.5
Simplified32.5
rmApplied add-exp-log32.5
Simplified48.9
Taylor expanded around 0 19.0
Simplified19.1
if 6.023686335920959e+212 < i < 2.4667133503465437e+265Initial program 32.5
Simplified32.4
rmApplied add-exp-log32.4
Simplified57.8
rmApplied insert-posit1632.7
rmApplied div-inv32.7
Simplified32.6
rmApplied div-inv32.7
Applied associate-*r*32.7
Final simplification26.6
herbie shell --seed 2019142 +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))))