100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -5.163360055787723405136702348322010579229 \cdot 10^{-11}:\\
\;\;\;\;\frac{{\left(\frac{1}{n} \cdot i\right)}^{n} \cdot 100 - 100}{i} \cdot n\\
\mathbf{elif}\;i \le 6.305809243265488292923253978118289242438 \cdot 10^{-10}:\\
\;\;\;\;n \cdot \left(100 \cdot \left(0.5 \cdot i + \left(\mathsf{fma}\left(\frac{\log 1}{i}, n, 1\right) - \log 1 \cdot \left(0.5 \cdot i\right)\right)\right)\right)\\
\mathbf{elif}\;i \le 2.565130334196551364557031790272495063197 \cdot 10^{190}:\\
\;\;\;\;\frac{{\left(\frac{1}{n} \cdot i\right)}^{n} \cdot 100 - 100}{i} \cdot n\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(1, i, \mathsf{fma}\left(\log 1, n, 1\right)\right) - 1}{\frac{i}{n}} \cdot 100\\
\end{array}double f(double i, double n) {
double r6005782 = 100.0;
double r6005783 = 1.0;
double r6005784 = i;
double r6005785 = n;
double r6005786 = r6005784 / r6005785;
double r6005787 = r6005783 + r6005786;
double r6005788 = pow(r6005787, r6005785);
double r6005789 = r6005788 - r6005783;
double r6005790 = r6005789 / r6005786;
double r6005791 = r6005782 * r6005790;
return r6005791;
}
double f(double i, double n) {
double r6005792 = i;
double r6005793 = -5.1633600557877234e-11;
bool r6005794 = r6005792 <= r6005793;
double r6005795 = 1.0;
double r6005796 = n;
double r6005797 = r6005795 / r6005796;
double r6005798 = r6005797 * r6005792;
double r6005799 = pow(r6005798, r6005796);
double r6005800 = 100.0;
double r6005801 = r6005799 * r6005800;
double r6005802 = r6005801 - r6005800;
double r6005803 = r6005802 / r6005792;
double r6005804 = r6005803 * r6005796;
double r6005805 = 6.305809243265488e-10;
bool r6005806 = r6005792 <= r6005805;
double r6005807 = 0.5;
double r6005808 = r6005807 * r6005792;
double r6005809 = 1.0;
double r6005810 = log(r6005809);
double r6005811 = r6005810 / r6005792;
double r6005812 = fma(r6005811, r6005796, r6005809);
double r6005813 = r6005810 * r6005808;
double r6005814 = r6005812 - r6005813;
double r6005815 = r6005808 + r6005814;
double r6005816 = r6005800 * r6005815;
double r6005817 = r6005796 * r6005816;
double r6005818 = 2.5651303341965514e+190;
bool r6005819 = r6005792 <= r6005818;
double r6005820 = fma(r6005810, r6005796, r6005795);
double r6005821 = fma(r6005809, r6005792, r6005820);
double r6005822 = r6005821 - r6005809;
double r6005823 = r6005792 / r6005796;
double r6005824 = r6005822 / r6005823;
double r6005825 = r6005824 * r6005800;
double r6005826 = r6005819 ? r6005804 : r6005825;
double r6005827 = r6005806 ? r6005817 : r6005826;
double r6005828 = r6005794 ? r6005804 : r6005827;
return r6005828;
}




Bits error versus i




Bits error versus n
| Original | 42.8 |
|---|---|
| Target | 42.7 |
| Herbie | 19.7 |
if i < -5.1633600557877234e-11 or 6.305809243265488e-10 < i < 2.5651303341965514e+190Initial program 29.3
rmApplied associate-/r/29.8
Applied associate-*r*29.8
Taylor expanded around inf 55.4
Simplified23.4
if -5.1633600557877234e-11 < i < 6.305809243265488e-10Initial program 50.7
rmApplied associate-/r/50.4
Applied associate-*r*50.4
Taylor expanded around 0 16.3
Simplified16.3
Taylor expanded around 0 16.3
Simplified16.3
if 2.5651303341965514e+190 < i Initial program 33.1
Taylor expanded around 0 33.3
Simplified33.3
Final simplification19.7
herbie shell --seed 2019200 +o rules:numerics
(FPCore (i n)
:name "Compound Interest"
:herbie-target
(* 100.0 (/ (- (exp (* n (if (== (+ 1.0 (/ i n)) 1.0) (/ i n) (/ (* (/ i n) (log (+ 1.0 (/ i n)))) (- (+ (/ i n) 1.0) 1.0))))) 1.0) (/ i n)))
(* 100.0 (/ (- (pow (+ 1.0 (/ i n)) n) 1.0) (/ i n))))