Falkner and Boettcher, Appendix A

Percentage Accurate: 91.0% → 99.7%
Time: 11.9s
Alternatives: 16
Speedup: 1.1×

Specification

?
\[\begin{array}{l} \\ \frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \end{array} \]
(FPCore (a k m)
 :precision binary64
 (/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))
double code(double a, double k, double m) {
	return (a * pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
}
real(8) function code(a, k, m)
    real(8), intent (in) :: a
    real(8), intent (in) :: k
    real(8), intent (in) :: m
    code = (a * (k ** m)) / ((1.0d0 + (10.0d0 * k)) + (k * k))
end function
public static double code(double a, double k, double m) {
	return (a * Math.pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
}
def code(a, k, m):
	return (a * math.pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k))
function code(a, k, m)
	return Float64(Float64(a * (k ^ m)) / Float64(Float64(1.0 + Float64(10.0 * k)) + Float64(k * k)))
end
function tmp = code(a, k, m)
	tmp = (a * (k ^ m)) / ((1.0 + (10.0 * k)) + (k * k));
end
code[a_, k_, m_] := N[(N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 + N[(10.0 * k), $MachinePrecision]), $MachinePrecision] + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 16 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 91.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \end{array} \]
(FPCore (a k m)
 :precision binary64
 (/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))
double code(double a, double k, double m) {
	return (a * pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
}
real(8) function code(a, k, m)
    real(8), intent (in) :: a
    real(8), intent (in) :: k
    real(8), intent (in) :: m
    code = (a * (k ** m)) / ((1.0d0 + (10.0d0 * k)) + (k * k))
end function
public static double code(double a, double k, double m) {
	return (a * Math.pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
}
def code(a, k, m):
	return (a * math.pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k))
function code(a, k, m)
	return Float64(Float64(a * (k ^ m)) / Float64(Float64(1.0 + Float64(10.0 * k)) + Float64(k * k)))
end
function tmp = code(a, k, m)
	tmp = (a * (k ^ m)) / ((1.0 + (10.0 * k)) + (k * k));
end
code[a_, k_, m_] := N[(N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 + N[(10.0 * k), $MachinePrecision]), $MachinePrecision] + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k}
\end{array}

Alternative 1: 99.7% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := a \cdot {k}^{m}\\ \mathbf{if}\;k \leq 6.4 \cdot 10^{-27}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(k, \frac{k}{t\_0} + \frac{10}{t\_0}, \frac{1}{t\_0}\right)}\\ \end{array} \end{array} \]
(FPCore (a k m)
 :precision binary64
 (let* ((t_0 (* a (pow k m))))
   (if (<= k 6.4e-27)
     t_0
     (/ 1.0 (fma k (+ (/ k t_0) (/ 10.0 t_0)) (/ 1.0 t_0))))))
double code(double a, double k, double m) {
	double t_0 = a * pow(k, m);
	double tmp;
	if (k <= 6.4e-27) {
		tmp = t_0;
	} else {
		tmp = 1.0 / fma(k, ((k / t_0) + (10.0 / t_0)), (1.0 / t_0));
	}
	return tmp;
}
function code(a, k, m)
	t_0 = Float64(a * (k ^ m))
	tmp = 0.0
	if (k <= 6.4e-27)
		tmp = t_0;
	else
		tmp = Float64(1.0 / fma(k, Float64(Float64(k / t_0) + Float64(10.0 / t_0)), Float64(1.0 / t_0)));
	end
	return tmp
end
code[a_, k_, m_] := Block[{t$95$0 = N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[k, 6.4e-27], t$95$0, N[(1.0 / N[(k * N[(N[(k / t$95$0), $MachinePrecision] + N[(10.0 / t$95$0), $MachinePrecision]), $MachinePrecision] + N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := a \cdot {k}^{m}\\
\mathbf{if}\;k \leq 6.4 \cdot 10^{-27}:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(k, \frac{k}{t\_0} + \frac{10}{t\_0}, \frac{1}{t\_0}\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if k < 6.39999999999999982e-27

    1. Initial program 95.9%

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Add Preprocessing
    3. Taylor expanded in k around 0

      \[\leadsto \color{blue}{a \cdot {k}^{m}} \]
    4. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \color{blue}{a \cdot {k}^{m}} \]
      2. lower-pow.f64100.0

        \[\leadsto a \cdot \color{blue}{{k}^{m}} \]
    5. Applied rewrites100.0%

      \[\leadsto \color{blue}{a \cdot {k}^{m}} \]

    if 6.39999999999999982e-27 < k

    1. Initial program 82.3%

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k}} \]
      2. clear-numN/A

        \[\leadsto \color{blue}{\frac{1}{\frac{\left(1 + 10 \cdot k\right) + k \cdot k}{a \cdot {k}^{m}}}} \]
      3. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{1}{\frac{\left(1 + 10 \cdot k\right) + k \cdot k}{a \cdot {k}^{m}}}} \]
      4. lower-/.f6482.4

        \[\leadsto \frac{1}{\color{blue}{\frac{\left(1 + 10 \cdot k\right) + k \cdot k}{a \cdot {k}^{m}}}} \]
      5. lift-+.f64N/A

        \[\leadsto \frac{1}{\frac{\color{blue}{\left(1 + 10 \cdot k\right) + k \cdot k}}{a \cdot {k}^{m}}} \]
      6. lift-+.f64N/A

        \[\leadsto \frac{1}{\frac{\color{blue}{\left(1 + 10 \cdot k\right)} + k \cdot k}{a \cdot {k}^{m}}} \]
      7. associate-+l+N/A

        \[\leadsto \frac{1}{\frac{\color{blue}{1 + \left(10 \cdot k + k \cdot k\right)}}{a \cdot {k}^{m}}} \]
      8. +-commutativeN/A

        \[\leadsto \frac{1}{\frac{\color{blue}{\left(10 \cdot k + k \cdot k\right) + 1}}{a \cdot {k}^{m}}} \]
      9. lift-*.f64N/A

        \[\leadsto \frac{1}{\frac{\left(\color{blue}{10 \cdot k} + k \cdot k\right) + 1}{a \cdot {k}^{m}}} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{1}{\frac{\left(10 \cdot k + \color{blue}{k \cdot k}\right) + 1}{a \cdot {k}^{m}}} \]
      11. distribute-rgt-outN/A

        \[\leadsto \frac{1}{\frac{\color{blue}{k \cdot \left(10 + k\right)} + 1}{a \cdot {k}^{m}}} \]
      12. lower-fma.f64N/A

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

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

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

      \[\leadsto \frac{1}{\color{blue}{k \cdot \left(10 \cdot \frac{1}{a \cdot {k}^{m}} + \frac{k}{a \cdot {k}^{m}}\right) + \frac{1}{a \cdot {k}^{m}}}} \]
    6. Step-by-step derivation
      1. lower-fma.f64N/A

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

        \[\leadsto \frac{1}{\mathsf{fma}\left(k, \color{blue}{\frac{k}{a \cdot {k}^{m}} + 10 \cdot \frac{1}{a \cdot {k}^{m}}}, \frac{1}{a \cdot {k}^{m}}\right)} \]
      3. lower-+.f64N/A

        \[\leadsto \frac{1}{\mathsf{fma}\left(k, \color{blue}{\frac{k}{a \cdot {k}^{m}} + 10 \cdot \frac{1}{a \cdot {k}^{m}}}, \frac{1}{a \cdot {k}^{m}}\right)} \]
      4. lower-/.f64N/A

        \[\leadsto \frac{1}{\mathsf{fma}\left(k, \color{blue}{\frac{k}{a \cdot {k}^{m}}} + 10 \cdot \frac{1}{a \cdot {k}^{m}}, \frac{1}{a \cdot {k}^{m}}\right)} \]
      5. lower-*.f64N/A

        \[\leadsto \frac{1}{\mathsf{fma}\left(k, \frac{k}{\color{blue}{a \cdot {k}^{m}}} + 10 \cdot \frac{1}{a \cdot {k}^{m}}, \frac{1}{a \cdot {k}^{m}}\right)} \]
      6. lower-pow.f64N/A

        \[\leadsto \frac{1}{\mathsf{fma}\left(k, \frac{k}{a \cdot \color{blue}{{k}^{m}}} + 10 \cdot \frac{1}{a \cdot {k}^{m}}, \frac{1}{a \cdot {k}^{m}}\right)} \]
      7. associate-*r/N/A

        \[\leadsto \frac{1}{\mathsf{fma}\left(k, \frac{k}{a \cdot {k}^{m}} + \color{blue}{\frac{10 \cdot 1}{a \cdot {k}^{m}}}, \frac{1}{a \cdot {k}^{m}}\right)} \]
      8. metadata-evalN/A

        \[\leadsto \frac{1}{\mathsf{fma}\left(k, \frac{k}{a \cdot {k}^{m}} + \frac{\color{blue}{10}}{a \cdot {k}^{m}}, \frac{1}{a \cdot {k}^{m}}\right)} \]
      9. lower-/.f64N/A

        \[\leadsto \frac{1}{\mathsf{fma}\left(k, \frac{k}{a \cdot {k}^{m}} + \color{blue}{\frac{10}{a \cdot {k}^{m}}}, \frac{1}{a \cdot {k}^{m}}\right)} \]
      10. lower-*.f64N/A

        \[\leadsto \frac{1}{\mathsf{fma}\left(k, \frac{k}{a \cdot {k}^{m}} + \frac{10}{\color{blue}{a \cdot {k}^{m}}}, \frac{1}{a \cdot {k}^{m}}\right)} \]
      11. lower-pow.f64N/A

        \[\leadsto \frac{1}{\mathsf{fma}\left(k, \frac{k}{a \cdot {k}^{m}} + \frac{10}{a \cdot \color{blue}{{k}^{m}}}, \frac{1}{a \cdot {k}^{m}}\right)} \]
      12. lower-/.f64N/A

        \[\leadsto \frac{1}{\mathsf{fma}\left(k, \frac{k}{a \cdot {k}^{m}} + \frac{10}{a \cdot {k}^{m}}, \color{blue}{\frac{1}{a \cdot {k}^{m}}}\right)} \]
      13. lower-*.f64N/A

        \[\leadsto \frac{1}{\mathsf{fma}\left(k, \frac{k}{a \cdot {k}^{m}} + \frac{10}{a \cdot {k}^{m}}, \frac{1}{\color{blue}{a \cdot {k}^{m}}}\right)} \]
      14. lower-pow.f6499.3

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

      \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left(k, \frac{k}{a \cdot {k}^{m}} + \frac{10}{a \cdot {k}^{m}}, \frac{1}{a \cdot {k}^{m}}\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 2: 38.0% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{a \cdot {k}^{m}}{k \cdot k + \left(1 + k \cdot 10\right)}\\ \mathbf{if}\;t\_0 \leq 4 \cdot 10^{-283}:\\ \;\;\;\;\frac{a}{k \cdot \left(k + 10\right)}\\ \mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+287}:\\ \;\;\;\;\frac{a}{\mathsf{fma}\left(k, 10, 1\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{k \cdot k}\\ \end{array} \end{array} \]
(FPCore (a k m)
 :precision binary64
 (let* ((t_0 (/ (* a (pow k m)) (+ (* k k) (+ 1.0 (* k 10.0))))))
   (if (<= t_0 4e-283)
     (/ a (* k (+ k 10.0)))
     (if (<= t_0 4e+287) (/ a (fma k 10.0 1.0)) (/ a (* k k))))))
double code(double a, double k, double m) {
	double t_0 = (a * pow(k, m)) / ((k * k) + (1.0 + (k * 10.0)));
	double tmp;
	if (t_0 <= 4e-283) {
		tmp = a / (k * (k + 10.0));
	} else if (t_0 <= 4e+287) {
		tmp = a / fma(k, 10.0, 1.0);
	} else {
		tmp = a / (k * k);
	}
	return tmp;
}
function code(a, k, m)
	t_0 = Float64(Float64(a * (k ^ m)) / Float64(Float64(k * k) + Float64(1.0 + Float64(k * 10.0))))
	tmp = 0.0
	if (t_0 <= 4e-283)
		tmp = Float64(a / Float64(k * Float64(k + 10.0)));
	elseif (t_0 <= 4e+287)
		tmp = Float64(a / fma(k, 10.0, 1.0));
	else
		tmp = Float64(a / Float64(k * k));
	end
	return tmp
end
code[a_, k_, m_] := Block[{t$95$0 = N[(N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision] / N[(N[(k * k), $MachinePrecision] + N[(1.0 + N[(k * 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 4e-283], N[(a / N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 4e+287], N[(a / N[(k * 10.0 + 1.0), $MachinePrecision]), $MachinePrecision], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{a \cdot {k}^{m}}{k \cdot k + \left(1 + k \cdot 10\right)}\\
\mathbf{if}\;t\_0 \leq 4 \cdot 10^{-283}:\\
\;\;\;\;\frac{a}{k \cdot \left(k + 10\right)}\\

\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+287}:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(k, 10, 1\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{a}{k \cdot k}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) < 3.99999999999999979e-283

    1. Initial program 97.3%

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Add Preprocessing
    3. Taylor expanded in m around 0

      \[\leadsto \color{blue}{\frac{a}{1 + \left(10 \cdot k + {k}^{2}\right)}} \]
    4. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{a}{1 + \left(10 \cdot k + {k}^{2}\right)}} \]
      2. unpow2N/A

        \[\leadsto \frac{a}{1 + \left(10 \cdot k + \color{blue}{k \cdot k}\right)} \]
      3. distribute-rgt-inN/A

        \[\leadsto \frac{a}{1 + \color{blue}{k \cdot \left(10 + k\right)}} \]
      4. +-commutativeN/A

        \[\leadsto \frac{a}{\color{blue}{k \cdot \left(10 + k\right) + 1}} \]
      5. metadata-evalN/A

        \[\leadsto \frac{a}{k \cdot \left(\color{blue}{10 \cdot 1} + k\right) + 1} \]
      6. lft-mult-inverseN/A

        \[\leadsto \frac{a}{k \cdot \left(10 \cdot \color{blue}{\left(\frac{1}{k} \cdot k\right)} + k\right) + 1} \]
      7. associate-*l*N/A

        \[\leadsto \frac{a}{k \cdot \left(\color{blue}{\left(10 \cdot \frac{1}{k}\right) \cdot k} + k\right) + 1} \]
      8. *-lft-identityN/A

        \[\leadsto \frac{a}{k \cdot \left(\left(10 \cdot \frac{1}{k}\right) \cdot k + \color{blue}{1 \cdot k}\right) + 1} \]
      9. distribute-rgt-inN/A

        \[\leadsto \frac{a}{k \cdot \color{blue}{\left(k \cdot \left(10 \cdot \frac{1}{k} + 1\right)\right)} + 1} \]
      10. +-commutativeN/A

        \[\leadsto \frac{a}{k \cdot \left(k \cdot \color{blue}{\left(1 + 10 \cdot \frac{1}{k}\right)}\right) + 1} \]
      11. *-commutativeN/A

        \[\leadsto \frac{a}{k \cdot \color{blue}{\left(\left(1 + 10 \cdot \frac{1}{k}\right) \cdot k\right)} + 1} \]
      12. lower-fma.f64N/A

        \[\leadsto \frac{a}{\color{blue}{\mathsf{fma}\left(k, \left(1 + 10 \cdot \frac{1}{k}\right) \cdot k, 1\right)}} \]
      13. *-commutativeN/A

        \[\leadsto \frac{a}{\mathsf{fma}\left(k, \color{blue}{k \cdot \left(1 + 10 \cdot \frac{1}{k}\right)}, 1\right)} \]
      14. +-commutativeN/A

        \[\leadsto \frac{a}{\mathsf{fma}\left(k, k \cdot \color{blue}{\left(10 \cdot \frac{1}{k} + 1\right)}, 1\right)} \]
      15. distribute-rgt-inN/A

        \[\leadsto \frac{a}{\mathsf{fma}\left(k, \color{blue}{\left(10 \cdot \frac{1}{k}\right) \cdot k + 1 \cdot k}, 1\right)} \]
      16. associate-*l*N/A

        \[\leadsto \frac{a}{\mathsf{fma}\left(k, \color{blue}{10 \cdot \left(\frac{1}{k} \cdot k\right)} + 1 \cdot k, 1\right)} \]
      17. lft-mult-inverseN/A

        \[\leadsto \frac{a}{\mathsf{fma}\left(k, 10 \cdot \color{blue}{1} + 1 \cdot k, 1\right)} \]
      18. metadata-evalN/A

        \[\leadsto \frac{a}{\mathsf{fma}\left(k, \color{blue}{10} + 1 \cdot k, 1\right)} \]
      19. *-lft-identityN/A

        \[\leadsto \frac{a}{\mathsf{fma}\left(k, 10 + \color{blue}{k}, 1\right)} \]
      20. lower-+.f6447.6

        \[\leadsto \frac{a}{\mathsf{fma}\left(k, \color{blue}{10 + k}, 1\right)} \]
    5. Applied rewrites47.6%

      \[\leadsto \color{blue}{\frac{a}{\mathsf{fma}\left(k, 10 + k, 1\right)}} \]
    6. Taylor expanded in k around inf

      \[\leadsto \frac{a}{{k}^{2} \cdot \color{blue}{\left(1 + 10 \cdot \frac{1}{k}\right)}} \]
    7. Step-by-step derivation
      1. Applied rewrites36.8%

        \[\leadsto \frac{a}{k \cdot \color{blue}{\left(k + 10\right)}} \]

      if 3.99999999999999979e-283 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) < 4.0000000000000003e287

      1. Initial program 99.8%

        \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
      2. Add Preprocessing
      3. Taylor expanded in m around 0

        \[\leadsto \color{blue}{\frac{a}{1 + \left(10 \cdot k + {k}^{2}\right)}} \]
      4. Step-by-step derivation
        1. lower-/.f64N/A

          \[\leadsto \color{blue}{\frac{a}{1 + \left(10 \cdot k + {k}^{2}\right)}} \]
        2. unpow2N/A

          \[\leadsto \frac{a}{1 + \left(10 \cdot k + \color{blue}{k \cdot k}\right)} \]
        3. distribute-rgt-inN/A

          \[\leadsto \frac{a}{1 + \color{blue}{k \cdot \left(10 + k\right)}} \]
        4. +-commutativeN/A

          \[\leadsto \frac{a}{\color{blue}{k \cdot \left(10 + k\right) + 1}} \]
        5. metadata-evalN/A

          \[\leadsto \frac{a}{k \cdot \left(\color{blue}{10 \cdot 1} + k\right) + 1} \]
        6. lft-mult-inverseN/A

          \[\leadsto \frac{a}{k \cdot \left(10 \cdot \color{blue}{\left(\frac{1}{k} \cdot k\right)} + k\right) + 1} \]
        7. associate-*l*N/A

          \[\leadsto \frac{a}{k \cdot \left(\color{blue}{\left(10 \cdot \frac{1}{k}\right) \cdot k} + k\right) + 1} \]
        8. *-lft-identityN/A

          \[\leadsto \frac{a}{k \cdot \left(\left(10 \cdot \frac{1}{k}\right) \cdot k + \color{blue}{1 \cdot k}\right) + 1} \]
        9. distribute-rgt-inN/A

          \[\leadsto \frac{a}{k \cdot \color{blue}{\left(k \cdot \left(10 \cdot \frac{1}{k} + 1\right)\right)} + 1} \]
        10. +-commutativeN/A

          \[\leadsto \frac{a}{k \cdot \left(k \cdot \color{blue}{\left(1 + 10 \cdot \frac{1}{k}\right)}\right) + 1} \]
        11. *-commutativeN/A

          \[\leadsto \frac{a}{k \cdot \color{blue}{\left(\left(1 + 10 \cdot \frac{1}{k}\right) \cdot k\right)} + 1} \]
        12. lower-fma.f64N/A

          \[\leadsto \frac{a}{\color{blue}{\mathsf{fma}\left(k, \left(1 + 10 \cdot \frac{1}{k}\right) \cdot k, 1\right)}} \]
        13. *-commutativeN/A

          \[\leadsto \frac{a}{\mathsf{fma}\left(k, \color{blue}{k \cdot \left(1 + 10 \cdot \frac{1}{k}\right)}, 1\right)} \]
        14. +-commutativeN/A

          \[\leadsto \frac{a}{\mathsf{fma}\left(k, k \cdot \color{blue}{\left(10 \cdot \frac{1}{k} + 1\right)}, 1\right)} \]
        15. distribute-rgt-inN/A

          \[\leadsto \frac{a}{\mathsf{fma}\left(k, \color{blue}{\left(10 \cdot \frac{1}{k}\right) \cdot k + 1 \cdot k}, 1\right)} \]
        16. associate-*l*N/A

          \[\leadsto \frac{a}{\mathsf{fma}\left(k, \color{blue}{10 \cdot \left(\frac{1}{k} \cdot k\right)} + 1 \cdot k, 1\right)} \]
        17. lft-mult-inverseN/A

          \[\leadsto \frac{a}{\mathsf{fma}\left(k, 10 \cdot \color{blue}{1} + 1 \cdot k, 1\right)} \]
        18. metadata-evalN/A

          \[\leadsto \frac{a}{\mathsf{fma}\left(k, \color{blue}{10} + 1 \cdot k, 1\right)} \]
        19. *-lft-identityN/A

          \[\leadsto \frac{a}{\mathsf{fma}\left(k, 10 + \color{blue}{k}, 1\right)} \]
        20. lower-+.f6497.0

          \[\leadsto \frac{a}{\mathsf{fma}\left(k, \color{blue}{10 + k}, 1\right)} \]
      5. Applied rewrites97.0%

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

        \[\leadsto \frac{a}{\mathsf{fma}\left(k, 10, 1\right)} \]
      7. Step-by-step derivation
        1. Applied rewrites71.0%

          \[\leadsto \frac{a}{\mathsf{fma}\left(k, 10, 1\right)} \]

        if 4.0000000000000003e287 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k)))

        1. Initial program 62.8%

          \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
        2. Add Preprocessing
        3. Taylor expanded in m around 0

          \[\leadsto \color{blue}{\frac{a}{1 + \left(10 \cdot k + {k}^{2}\right)}} \]
        4. Step-by-step derivation
          1. lower-/.f64N/A

            \[\leadsto \color{blue}{\frac{a}{1 + \left(10 \cdot k + {k}^{2}\right)}} \]
          2. unpow2N/A

            \[\leadsto \frac{a}{1 + \left(10 \cdot k + \color{blue}{k \cdot k}\right)} \]
          3. distribute-rgt-inN/A

            \[\leadsto \frac{a}{1 + \color{blue}{k \cdot \left(10 + k\right)}} \]
          4. +-commutativeN/A

            \[\leadsto \frac{a}{\color{blue}{k \cdot \left(10 + k\right) + 1}} \]
          5. metadata-evalN/A

            \[\leadsto \frac{a}{k \cdot \left(\color{blue}{10 \cdot 1} + k\right) + 1} \]
          6. lft-mult-inverseN/A

            \[\leadsto \frac{a}{k \cdot \left(10 \cdot \color{blue}{\left(\frac{1}{k} \cdot k\right)} + k\right) + 1} \]
          7. associate-*l*N/A

            \[\leadsto \frac{a}{k \cdot \left(\color{blue}{\left(10 \cdot \frac{1}{k}\right) \cdot k} + k\right) + 1} \]
          8. *-lft-identityN/A

            \[\leadsto \frac{a}{k \cdot \left(\left(10 \cdot \frac{1}{k}\right) \cdot k + \color{blue}{1 \cdot k}\right) + 1} \]
          9. distribute-rgt-inN/A

            \[\leadsto \frac{a}{k \cdot \color{blue}{\left(k \cdot \left(10 \cdot \frac{1}{k} + 1\right)\right)} + 1} \]
          10. +-commutativeN/A

            \[\leadsto \frac{a}{k \cdot \left(k \cdot \color{blue}{\left(1 + 10 \cdot \frac{1}{k}\right)}\right) + 1} \]
          11. *-commutativeN/A

            \[\leadsto \frac{a}{k \cdot \color{blue}{\left(\left(1 + 10 \cdot \frac{1}{k}\right) \cdot k\right)} + 1} \]
          12. lower-fma.f64N/A

            \[\leadsto \frac{a}{\color{blue}{\mathsf{fma}\left(k, \left(1 + 10 \cdot \frac{1}{k}\right) \cdot k, 1\right)}} \]
          13. *-commutativeN/A

            \[\leadsto \frac{a}{\mathsf{fma}\left(k, \color{blue}{k \cdot \left(1 + 10 \cdot \frac{1}{k}\right)}, 1\right)} \]
          14. +-commutativeN/A

            \[\leadsto \frac{a}{\mathsf{fma}\left(k, k \cdot \color{blue}{\left(10 \cdot \frac{1}{k} + 1\right)}, 1\right)} \]
          15. distribute-rgt-inN/A

            \[\leadsto \frac{a}{\mathsf{fma}\left(k, \color{blue}{\left(10 \cdot \frac{1}{k}\right) \cdot k + 1 \cdot k}, 1\right)} \]
          16. associate-*l*N/A

            \[\leadsto \frac{a}{\mathsf{fma}\left(k, \color{blue}{10 \cdot \left(\frac{1}{k} \cdot k\right)} + 1 \cdot k, 1\right)} \]
          17. lft-mult-inverseN/A

            \[\leadsto \frac{a}{\mathsf{fma}\left(k, 10 \cdot \color{blue}{1} + 1 \cdot k, 1\right)} \]
          18. metadata-evalN/A

            \[\leadsto \frac{a}{\mathsf{fma}\left(k, \color{blue}{10} + 1 \cdot k, 1\right)} \]
          19. *-lft-identityN/A

            \[\leadsto \frac{a}{\mathsf{fma}\left(k, 10 + \color{blue}{k}, 1\right)} \]
          20. lower-+.f644.1

            \[\leadsto \frac{a}{\mathsf{fma}\left(k, \color{blue}{10 + k}, 1\right)} \]
        5. Applied rewrites4.1%

          \[\leadsto \color{blue}{\frac{a}{\mathsf{fma}\left(k, 10 + k, 1\right)}} \]
        6. Taylor expanded in k around inf

          \[\leadsto \frac{a}{{k}^{\color{blue}{2}}} \]
        7. Step-by-step derivation
          1. Applied rewrites23.2%

            \[\leadsto \frac{a}{k \cdot \color{blue}{k}} \]
        8. Recombined 3 regimes into one program.
        9. Final simplification38.0%

          \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{a \cdot {k}^{m}}{k \cdot k + \left(1 + k \cdot 10\right)} \leq 4 \cdot 10^{-283}:\\ \;\;\;\;\frac{a}{k \cdot \left(k + 10\right)}\\ \mathbf{elif}\;\frac{a \cdot {k}^{m}}{k \cdot k + \left(1 + k \cdot 10\right)} \leq 4 \cdot 10^{+287}:\\ \;\;\;\;\frac{a}{\mathsf{fma}\left(k, 10, 1\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{k \cdot k}\\ \end{array} \]
        10. Add Preprocessing

        Reproduce

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