100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -0.09568466101685804692245085334434406831861:\\
\;\;\;\;\frac{100 \cdot \left({\left(\frac{i}{n}\right)}^{n} - 1\right)}{\frac{i}{n}}\\
\mathbf{elif}\;i \le 4.636828096634822172894426601649853756376 \cdot 10^{-231}:\\
\;\;\;\;\left(\left(\sqrt[3]{\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)} \cdot \sqrt[3]{\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)}\right) \cdot \frac{100}{i}\right) \cdot \frac{\sqrt[3]{\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{1}{n}}\\
\mathbf{elif}\;i \le 2.421886781167336491233076084341835921918 \cdot 10^{-182}:\\
\;\;\;\;\frac{100}{i} \cdot \sqrt[3]{{\left(\left(\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)\right) \cdot n\right)}^{3}}\\
\mathbf{elif}\;i \le 6.433403710498657594142250154269082661313 \cdot 10^{46}:\\
\;\;\;\;100 \cdot \left(\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)}{i} \cdot n\right)\\
\mathbf{elif}\;i \le 1.353418716849568981322833055613312096611 \cdot 10^{183}:\\
\;\;\;\;100 \cdot \frac{n}{\frac{i}{{\left(\frac{i}{n}\right)}^{n} - 1}}\\
\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 r122023 = 100.0;
double r122024 = 1.0;
double r122025 = i;
double r122026 = n;
double r122027 = r122025 / r122026;
double r122028 = r122024 + r122027;
double r122029 = pow(r122028, r122026);
double r122030 = r122029 - r122024;
double r122031 = r122030 / r122027;
double r122032 = r122023 * r122031;
return r122032;
}
double f(double i, double n) {
double r122033 = i;
double r122034 = -0.09568466101685805;
bool r122035 = r122033 <= r122034;
double r122036 = 100.0;
double r122037 = n;
double r122038 = r122033 / r122037;
double r122039 = pow(r122038, r122037);
double r122040 = 1.0;
double r122041 = r122039 - r122040;
double r122042 = r122036 * r122041;
double r122043 = r122042 / r122038;
double r122044 = 4.636828096634822e-231;
bool r122045 = r122033 <= r122044;
double r122046 = 0.5;
double r122047 = 2.0;
double r122048 = pow(r122033, r122047);
double r122049 = log(r122040);
double r122050 = r122049 * r122037;
double r122051 = fma(r122046, r122048, r122050);
double r122052 = fma(r122040, r122033, r122051);
double r122053 = r122048 * r122049;
double r122054 = r122046 * r122053;
double r122055 = r122052 - r122054;
double r122056 = cbrt(r122055);
double r122057 = r122056 * r122056;
double r122058 = r122036 / r122033;
double r122059 = r122057 * r122058;
double r122060 = 1.0;
double r122061 = r122060 / r122037;
double r122062 = r122056 / r122061;
double r122063 = r122059 * r122062;
double r122064 = 2.4218867811673365e-182;
bool r122065 = r122033 <= r122064;
double r122066 = r122055 * r122037;
double r122067 = 3.0;
double r122068 = pow(r122066, r122067);
double r122069 = cbrt(r122068);
double r122070 = r122058 * r122069;
double r122071 = 6.433403710498658e+46;
bool r122072 = r122033 <= r122071;
double r122073 = r122055 / r122033;
double r122074 = r122073 * r122037;
double r122075 = r122036 * r122074;
double r122076 = 1.353418716849569e+183;
bool r122077 = r122033 <= r122076;
double r122078 = r122033 / r122041;
double r122079 = r122037 / r122078;
double r122080 = r122036 * r122079;
double r122081 = fma(r122049, r122037, r122060);
double r122082 = fma(r122040, r122033, r122081);
double r122083 = r122082 - r122040;
double r122084 = r122083 / r122038;
double r122085 = r122036 * r122084;
double r122086 = r122077 ? r122080 : r122085;
double r122087 = r122072 ? r122075 : r122086;
double r122088 = r122065 ? r122070 : r122087;
double r122089 = r122045 ? r122063 : r122088;
double r122090 = r122035 ? r122043 : r122089;
return r122090;
}




Bits error versus i




Bits error versus n
| Original | 42.6 |
|---|---|
| Target | 42.1 |
| Herbie | 21.2 |
if i < -0.09568466101685805Initial program 28.6
Taylor expanded around inf 64.0
Simplified18.7
if -0.09568466101685805 < i < 4.636828096634822e-231Initial program 49.2
rmApplied div-inv49.2
Applied *-un-lft-identity49.2
Applied times-frac48.8
Applied associate-*r*48.9
Simplified48.9
Taylor expanded around 0 17.2
Simplified17.2
rmApplied *-un-lft-identity17.2
Applied add-sqr-sqrt17.2
Applied times-frac17.2
Applied add-cube-cbrt17.8
Applied times-frac17.8
Applied associate-*r*18.6
Simplified18.6
if 4.636828096634822e-231 < i < 2.4218867811673365e-182Initial program 48.3
rmApplied div-inv48.3
Applied *-un-lft-identity48.3
Applied times-frac47.8
Applied associate-*r*47.8
Simplified47.8
Taylor expanded around 0 16.9
Simplified16.9
rmApplied add-cbrt-cube39.9
Applied add-cbrt-cube39.9
Applied cbrt-undiv39.9
Applied add-cbrt-cube48.3
Applied cbrt-undiv48.3
Simplified24.7
if 2.4218867811673365e-182 < i < 6.433403710498658e+46Initial program 50.3
rmApplied div-inv50.3
Applied *-un-lft-identity50.3
Applied times-frac50.2
Applied associate-*r*50.2
Simplified50.2
Taylor expanded around 0 19.3
Simplified19.3
rmApplied div-inv19.3
Applied associate-*l*19.2
Simplified21.5
if 6.433403710498658e+46 < i < 1.353418716849569e+183Initial program 32.0
Taylor expanded around inf 29.2
Simplified32.0
if 1.353418716849569e+183 < i Initial program 33.1
Taylor expanded around 0 32.9
Simplified32.9
Final simplification21.2
herbie shell --seed 2019326 +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))))