100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;n \le -2.51457813685989335 \cdot 10^{153}:\\
\;\;\;\;100 \cdot \frac{\mathsf{fma}\left(i, 1, \mathsf{fma}\left(0.5, {i}^{2}, \log 1 \cdot n\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)\right)}{\frac{i}{n}}\\
\mathbf{elif}\;n \le -854986621658212610:\\
\;\;\;\;\left(100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i}\right) \cdot n\\
\mathbf{elif}\;n \le -29.9716390321119768:\\
\;\;\;\;\frac{\mathsf{fma}\left(i, 100, \mathsf{fma}\left(50, {i}^{2}, 100 \cdot \left(\log 1 \cdot n\right)\right) - 50 \cdot \left({i}^{2} \cdot \log 1\right)\right)}{\frac{i}{n}}\\
\mathbf{elif}\;n \le -7.70416426394191 \cdot 10^{-311}:\\
\;\;\;\;100 \cdot \left(\frac{{\left(1 + \frac{i}{n}\right)}^{n}}{\frac{i}{n}} - \frac{1}{\frac{i}{n}}\right)\\
\mathbf{elif}\;n \le 1.86219659931192698 \cdot 10^{-104}:\\
\;\;\;\;\frac{100 \cdot \mathsf{fma}\left(\frac{1}{2} \cdot {\left(\log i\right)}^{2}, {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) - \mathsf{fma}\left(n, \log n, \mathsf{fma}\left(\log i, {n}^{2} \cdot \log n, \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)\right)\right)\right)}{\frac{i}{n}}\\
\mathbf{elif}\;n \le 4.7215330661381895 \cdot 10^{175}:\\
\;\;\;\;100 \cdot \frac{\mathsf{fma}\left(i, 1, \mathsf{fma}\left(0.5, {i}^{2}, \log 1 \cdot n\right) - 0.5 \cdot \left({i}^{2} \cdot \log 1\right)\right)}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;\left(100 \cdot \left({\left(\frac{i}{n}\right)}^{n} - 1\right)\right) \cdot \frac{n}{i}\\
\end{array}double f(double i, double n) {
double r153109 = 100.0;
double r153110 = 1.0;
double r153111 = i;
double r153112 = n;
double r153113 = r153111 / r153112;
double r153114 = r153110 + r153113;
double r153115 = pow(r153114, r153112);
double r153116 = r153115 - r153110;
double r153117 = r153116 / r153113;
double r153118 = r153109 * r153117;
return r153118;
}
double f(double i, double n) {
double r153119 = n;
double r153120 = -2.5145781368598933e+153;
bool r153121 = r153119 <= r153120;
double r153122 = 100.0;
double r153123 = i;
double r153124 = 1.0;
double r153125 = 0.5;
double r153126 = 2.0;
double r153127 = pow(r153123, r153126);
double r153128 = log(r153124);
double r153129 = r153128 * r153119;
double r153130 = fma(r153125, r153127, r153129);
double r153131 = r153127 * r153128;
double r153132 = r153125 * r153131;
double r153133 = r153130 - r153132;
double r153134 = fma(r153123, r153124, r153133);
double r153135 = r153123 / r153119;
double r153136 = r153134 / r153135;
double r153137 = r153122 * r153136;
double r153138 = -8.549866216582126e+17;
bool r153139 = r153119 <= r153138;
double r153140 = r153124 + r153135;
double r153141 = pow(r153140, r153119);
double r153142 = r153141 - r153124;
double r153143 = r153142 / r153123;
double r153144 = r153122 * r153143;
double r153145 = r153144 * r153119;
double r153146 = -29.971639032111977;
bool r153147 = r153119 <= r153146;
double r153148 = 50.0;
double r153149 = r153122 * r153129;
double r153150 = fma(r153148, r153127, r153149);
double r153151 = r153148 * r153131;
double r153152 = r153150 - r153151;
double r153153 = fma(r153123, r153122, r153152);
double r153154 = r153153 / r153135;
double r153155 = -7.7041642639419e-311;
bool r153156 = r153119 <= r153155;
double r153157 = r153141 / r153135;
double r153158 = r153124 / r153135;
double r153159 = r153157 - r153158;
double r153160 = r153122 * r153159;
double r153161 = 1.862196599311927e-104;
bool r153162 = r153119 <= r153161;
double r153163 = 0.5;
double r153164 = log(r153123);
double r153165 = pow(r153164, r153126);
double r153166 = r153163 * r153165;
double r153167 = pow(r153119, r153126);
double r153168 = log(r153119);
double r153169 = pow(r153168, r153126);
double r153170 = r153167 * r153169;
double r153171 = 0.16666666666666666;
double r153172 = 3.0;
double r153173 = pow(r153164, r153172);
double r153174 = pow(r153119, r153172);
double r153175 = r153173 * r153174;
double r153176 = r153174 * r153169;
double r153177 = r153164 * r153176;
double r153178 = r153163 * r153177;
double r153179 = fma(r153164, r153119, r153178);
double r153180 = fma(r153171, r153175, r153179);
double r153181 = fma(r153163, r153170, r153180);
double r153182 = r153167 * r153168;
double r153183 = r153174 * r153168;
double r153184 = r153165 * r153183;
double r153185 = pow(r153168, r153172);
double r153186 = r153174 * r153185;
double r153187 = r153171 * r153186;
double r153188 = fma(r153163, r153184, r153187);
double r153189 = fma(r153164, r153182, r153188);
double r153190 = fma(r153119, r153168, r153189);
double r153191 = r153181 - r153190;
double r153192 = fma(r153166, r153167, r153191);
double r153193 = r153122 * r153192;
double r153194 = r153193 / r153135;
double r153195 = 4.7215330661381895e+175;
bool r153196 = r153119 <= r153195;
double r153197 = pow(r153135, r153119);
double r153198 = r153197 - r153124;
double r153199 = r153122 * r153198;
double r153200 = r153119 / r153123;
double r153201 = r153199 * r153200;
double r153202 = r153196 ? r153137 : r153201;
double r153203 = r153162 ? r153194 : r153202;
double r153204 = r153156 ? r153160 : r153203;
double r153205 = r153147 ? r153154 : r153204;
double r153206 = r153139 ? r153145 : r153205;
double r153207 = r153121 ? r153137 : r153206;
return r153207;
}




Bits error versus i




Bits error versus n
| Original | 42.9 |
|---|---|
| Target | 42.2 |
| Herbie | 29.8 |
if n < -2.5145781368598933e+153 or 1.862196599311927e-104 < n < 4.7215330661381895e+175Initial program 56.5
Taylor expanded around 0 36.6
Simplified36.6
if -2.5145781368598933e+153 < n < -8.549866216582126e+17Initial program 37.9
rmApplied associate-/r/37.7
Applied associate-*r*37.7
if -8.549866216582126e+17 < n < -29.971639032111977Initial program 38.8
rmApplied associate-*r/38.8
Taylor expanded around 0 24.8
Simplified24.8
if -29.971639032111977 < n < -7.7041642639419e-311Initial program 15.7
rmApplied div-sub15.8
if -7.7041642639419e-311 < n < 1.862196599311927e-104Initial program 45.1
rmApplied associate-*r/45.1
Taylor expanded around inf 26.7
Simplified45.6
Taylor expanded around 0 18.1
Simplified18.1
if 4.7215330661381895e+175 < n Initial program 62.3
rmApplied associate-*r/62.3
Taylor expanded around inf 64.0
Simplified44.2
rmApplied div-inv44.2
Simplified44.2
Final simplification29.8
herbie shell --seed 2020035 +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))))