Average Error: 4.7 → 1.7
Time: 6.1s
Precision: binary64
\[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
\[\begin{array}{l} t_0 := a \cdot {k}^{m}\\ \mathbf{if}\;m \leq 1.0596384614903166 \cdot 10^{+26}:\\ \;\;\;\;\frac{t_0}{\mathsf{fma}\left(k, k + 10, 1\right)}\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot \left(\mathsf{fma}\left(k \cdot k, 99, 1\right) - k \cdot 10\right)\\ \end{array} \]
\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k}
\begin{array}{l}
t_0 := a \cdot {k}^{m}\\
\mathbf{if}\;m \leq 1.0596384614903166 \cdot 10^{+26}:\\
\;\;\;\;\frac{t_0}{\mathsf{fma}\left(k, k + 10, 1\right)}\\

\mathbf{else}:\\
\;\;\;\;t_0 \cdot \left(\mathsf{fma}\left(k \cdot k, 99, 1\right) - k \cdot 10\right)\\


\end{array}
(FPCore (a k m)
 :precision binary64
 (/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))
(FPCore (a k m)
 :precision binary64
 (let* ((t_0 (* a (pow k m))))
   (if (<= m 1.0596384614903166e+26)
     (/ t_0 (fma k (+ k 10.0) 1.0))
     (* t_0 (- (fma (* k k) 99.0 1.0) (* k 10.0))))))
double code(double a, double k, double m) {
	return (a * pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
}
double code(double a, double k, double m) {
	double t_0 = a * pow(k, m);
	double tmp;
	if (m <= 1.0596384614903166e+26) {
		tmp = t_0 / fma(k, (k + 10.0), 1.0);
	} else {
		tmp = t_0 * (fma((k * k), 99.0, 1.0) - (k * 10.0));
	}
	return tmp;
}

Error

Bits error versus a

Bits error versus k

Bits error versus m

Derivation

  1. Split input into 2 regimes
  2. if m < 1.059638461490317e26

    1. Initial program 2.4

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Simplified2.4

      \[\leadsto \color{blue}{\frac{a \cdot {k}^{m}}{\mathsf{fma}\left(k, k + 10, 1\right)}} \]

    if 1.059638461490317e26 < m

    1. Initial program 9.9

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Simplified9.9

      \[\leadsto \color{blue}{\frac{a \cdot {k}^{m}}{\mathsf{fma}\left(k, k + 10, 1\right)}} \]
    3. Taylor expanded in k around 0 46.6

      \[\leadsto \color{blue}{\left(99 \cdot \left({k}^{2} \cdot \left(a \cdot e^{\log k \cdot m}\right)\right) + a \cdot e^{\log k \cdot m}\right) - 10 \cdot \left(k \cdot \left(e^{\log k \cdot m} \cdot a\right)\right)} \]
    4. Simplified0.1

      \[\leadsto \color{blue}{\left(a \cdot {k}^{m}\right) \cdot \left(\mathsf{fma}\left(k \cdot k, 99, 1\right) - k \cdot 10\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;m \leq 1.0596384614903166 \cdot 10^{+26}:\\ \;\;\;\;\frac{a \cdot {k}^{m}}{\mathsf{fma}\left(k, k + 10, 1\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(a \cdot {k}^{m}\right) \cdot \left(\mathsf{fma}\left(k \cdot k, 99, 1\right) - k \cdot 10\right)\\ \end{array} \]

Reproduce

herbie shell --seed 2022088 
(FPCore (a k m)
  :name "Falkner and Boettcher, Appendix A"
  :precision binary64
  (/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))