100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -42606.74875587941642152145504951477050781:\\
\;\;\;\;100 \cdot \frac{n}{\frac{i}{{\left(\frac{i}{n}\right)}^{n} - 1}}\\
\mathbf{elif}\;i \le 3.332988420430884258276291203877273900307 \cdot 10^{-27}:\\
\;\;\;\;100 \cdot \frac{\mathsf{fma}\left(1, i, \mathsf{fma}\left(0.5, {i}^{2}, \log 1 \cdot n\right)\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)}{\frac{i}{n}}\\
\mathbf{elif}\;i \le 9.944860624286458495633005962801713322847 \cdot 10^{141}:\\
\;\;\;\;\left(100 \cdot n\right) \cdot \frac{1}{\frac{i}{\left(\mathsf{fma}\left(\frac{1}{2}, {\left(\log i\right)}^{2} \cdot {n}^{2}, \mathsf{fma}\left(\frac{1}{2}, {n}^{2} \cdot {\left(\log n\right)}^{2}, \mathsf{fma}\left(\frac{1}{6}, {\left(\log i\right)}^{3} \cdot {n}^{3}, \mathsf{fma}\left(\log i, n, \frac{1}{2} \cdot \left(\log i \cdot \left({n}^{3} \cdot {\left(\log n\right)}^{2}\right)\right)\right)\right)\right)\right) - \log n \cdot \mathsf{fma}\left(n \cdot n, \log i, n\right)\right) - \mathsf{fma}\left(\frac{1}{2}, {\left(\log i\right)}^{2} \cdot \left({n}^{3} \cdot \log n\right), \frac{1}{6} \cdot \left({n}^{3} \cdot {\left(\log n\right)}^{3}\right)\right)}}\\
\mathbf{elif}\;i \le 2.568245662391043108180991997152758915531 \cdot 10^{231}:\\
\;\;\;\;100 \cdot \left(\frac{{\left(1 + \frac{i}{n}\right)}^{\left(\frac{n}{2}\right)} + \sqrt{1}}{i} \cdot \left(\left({\left(1 + \frac{i}{n}\right)}^{\left(\frac{n}{2}\right)} - \sqrt{1}\right) \cdot n\right)\right)\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{\mathsf{fma}\left(1, i, \mathsf{fma}\left(\log 1, n, 1\right)\right) - 1}{\frac{i}{n}}\\
\end{array}double f(double i, double n) {
double r167095 = 100.0;
double r167096 = 1.0;
double r167097 = i;
double r167098 = n;
double r167099 = r167097 / r167098;
double r167100 = r167096 + r167099;
double r167101 = pow(r167100, r167098);
double r167102 = r167101 - r167096;
double r167103 = r167102 / r167099;
double r167104 = r167095 * r167103;
return r167104;
}
double f(double i, double n) {
double r167105 = i;
double r167106 = -42606.74875587942;
bool r167107 = r167105 <= r167106;
double r167108 = 100.0;
double r167109 = n;
double r167110 = r167105 / r167109;
double r167111 = pow(r167110, r167109);
double r167112 = 1.0;
double r167113 = r167111 - r167112;
double r167114 = r167105 / r167113;
double r167115 = r167109 / r167114;
double r167116 = r167108 * r167115;
double r167117 = 3.332988420430884e-27;
bool r167118 = r167105 <= r167117;
double r167119 = 0.5;
double r167120 = 2.0;
double r167121 = pow(r167105, r167120);
double r167122 = log(r167112);
double r167123 = r167122 * r167109;
double r167124 = fma(r167119, r167121, r167123);
double r167125 = fma(r167112, r167105, r167124);
double r167126 = r167121 * r167122;
double r167127 = r167119 * r167126;
double r167128 = r167125 - r167127;
double r167129 = r167128 / r167110;
double r167130 = r167108 * r167129;
double r167131 = 9.944860624286458e+141;
bool r167132 = r167105 <= r167131;
double r167133 = r167108 * r167109;
double r167134 = 1.0;
double r167135 = 0.5;
double r167136 = log(r167105);
double r167137 = pow(r167136, r167120);
double r167138 = pow(r167109, r167120);
double r167139 = r167137 * r167138;
double r167140 = log(r167109);
double r167141 = pow(r167140, r167120);
double r167142 = r167138 * r167141;
double r167143 = 0.16666666666666666;
double r167144 = 3.0;
double r167145 = pow(r167136, r167144);
double r167146 = pow(r167109, r167144);
double r167147 = r167145 * r167146;
double r167148 = r167146 * r167141;
double r167149 = r167136 * r167148;
double r167150 = r167135 * r167149;
double r167151 = fma(r167136, r167109, r167150);
double r167152 = fma(r167143, r167147, r167151);
double r167153 = fma(r167135, r167142, r167152);
double r167154 = fma(r167135, r167139, r167153);
double r167155 = r167109 * r167109;
double r167156 = fma(r167155, r167136, r167109);
double r167157 = r167140 * r167156;
double r167158 = r167154 - r167157;
double r167159 = r167146 * r167140;
double r167160 = r167137 * r167159;
double r167161 = pow(r167140, r167144);
double r167162 = r167146 * r167161;
double r167163 = r167143 * r167162;
double r167164 = fma(r167135, r167160, r167163);
double r167165 = r167158 - r167164;
double r167166 = r167105 / r167165;
double r167167 = r167134 / r167166;
double r167168 = r167133 * r167167;
double r167169 = 2.568245662391043e+231;
bool r167170 = r167105 <= r167169;
double r167171 = r167112 + r167110;
double r167172 = r167109 / r167120;
double r167173 = pow(r167171, r167172);
double r167174 = sqrt(r167112);
double r167175 = r167173 + r167174;
double r167176 = r167175 / r167105;
double r167177 = r167173 - r167174;
double r167178 = r167177 * r167109;
double r167179 = r167176 * r167178;
double r167180 = r167108 * r167179;
double r167181 = fma(r167122, r167109, r167134);
double r167182 = fma(r167112, r167105, r167181);
double r167183 = r167182 - r167112;
double r167184 = r167183 / r167110;
double r167185 = r167108 * r167184;
double r167186 = r167170 ? r167180 : r167185;
double r167187 = r167132 ? r167168 : r167186;
double r167188 = r167118 ? r167130 : r167187;
double r167189 = r167107 ? r167116 : r167188;
return r167189;
}




Bits error versus i




Bits error versus n
| Original | 43.1 |
|---|---|
| Target | 42.8 |
| Herbie | 30.0 |
if i < -42606.74875587942Initial program 27.8
Taylor expanded around inf 64.0
Simplified18.8
if -42606.74875587942 < i < 3.332988420430884e-27Initial program 50.7
Taylor expanded around 0 34.2
Simplified34.2
if 3.332988420430884e-27 < i < 9.944860624286458e+141Initial program 38.7
Taylor expanded around inf 37.2
Simplified39.2
rmApplied div-inv39.2
Applied associate-*r*39.2
Taylor expanded around 0 22.8
Simplified22.8
if 9.944860624286458e+141 < i < 2.568245662391043e+231Initial program 32.0
rmApplied div-inv32.0
Applied add-sqr-sqrt32.0
Applied sqr-pow32.1
Applied difference-of-squares32.0
Applied times-frac32.0
Simplified32.0
if 2.568245662391043e+231 < i Initial program 29.1
Taylor expanded around 0 36.1
Simplified36.1
Final simplification30.0
herbie shell --seed 2019325 +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))))