Falkner and Boettcher, Appendix A

Percentage Accurate: 90.0% → 98.9%
Time: 8.3s
Alternatives: 13
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));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(a, k, m)
use fmin_fmax_functions
    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 13 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: 90.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));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(a, k, m)
use fmin_fmax_functions
    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: 98.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {k}^{m} \cdot a\\ \mathbf{if}\;k \leq 1.85 \cdot 10^{-11}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{t\_0}{k}}{k}\\ \end{array} \end{array} \]
(FPCore (a k m)
 :precision binary64
 (let* ((t_0 (* (pow k m) a))) (if (<= k 1.85e-11) t_0 (/ (/ t_0 k) k))))
double code(double a, double k, double m) {
	double t_0 = pow(k, m) * a;
	double tmp;
	if (k <= 1.85e-11) {
		tmp = t_0;
	} else {
		tmp = (t_0 / k) / k;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(a, k, m)
use fmin_fmax_functions
    real(8), intent (in) :: a
    real(8), intent (in) :: k
    real(8), intent (in) :: m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (k ** m) * a
    if (k <= 1.85d-11) then
        tmp = t_0
    else
        tmp = (t_0 / k) / k
    end if
    code = tmp
end function
public static double code(double a, double k, double m) {
	double t_0 = Math.pow(k, m) * a;
	double tmp;
	if (k <= 1.85e-11) {
		tmp = t_0;
	} else {
		tmp = (t_0 / k) / k;
	}
	return tmp;
}
def code(a, k, m):
	t_0 = math.pow(k, m) * a
	tmp = 0
	if k <= 1.85e-11:
		tmp = t_0
	else:
		tmp = (t_0 / k) / k
	return tmp
function code(a, k, m)
	t_0 = Float64((k ^ m) * a)
	tmp = 0.0
	if (k <= 1.85e-11)
		tmp = t_0;
	else
		tmp = Float64(Float64(t_0 / k) / k);
	end
	return tmp
end
function tmp_2 = code(a, k, m)
	t_0 = (k ^ m) * a;
	tmp = 0.0;
	if (k <= 1.85e-11)
		tmp = t_0;
	else
		tmp = (t_0 / k) / k;
	end
	tmp_2 = tmp;
end
code[a_, k_, m_] := Block[{t$95$0 = N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision]}, If[LessEqual[k, 1.85e-11], t$95$0, N[(N[(t$95$0 / k), $MachinePrecision] / k), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{t\_0}{k}}{k}\\


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

    1. Initial program 93.5%

      \[\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. Applied rewrites100.0%

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

      if 1.8500000000000001e-11 < k

      1. Initial program 83.2%

        \[\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 \frac{a \cdot {k}^{m}}{\color{blue}{\left(1 + 10 \cdot k\right) + k \cdot k}} \]
        2. flip-+N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{a \cdot {k}^{m}}{\color{blue}{{k}^{2}}} \]
      6. Step-by-step derivation
        1. Applied rewrites81.3%

          \[\leadsto \frac{a \cdot {k}^{m}}{\color{blue}{k \cdot k}} \]
        2. Taylor expanded in k around inf

          \[\leadsto \color{blue}{\frac{a \cdot e^{-1 \cdot \left(m \cdot \log \left(\frac{1}{k}\right)\right)}}{{k}^{2}}} \]
        3. Step-by-step derivation
          1. Applied rewrites88.0%

            \[\leadsto \color{blue}{{\left({k}^{\left(-m\right)}\right)}^{-1} \cdot \frac{\frac{a}{k}}{k}} \]
          2. Step-by-step derivation
            1. Applied rewrites97.9%

              \[\leadsto \frac{\frac{{k}^{m} \cdot a}{k}}{\color{blue}{k}} \]
          3. Recombined 2 regimes into one program.
          4. Add Preprocessing

          Alternative 2: 97.6% accurate, 0.5× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \leq \infty:\\ \;\;\;\;\frac{{k}^{m}}{\mathsf{fma}\left(k, 10 + k, 1\right)} \cdot a\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(99, k, -10\right), k, 1\right) \cdot a\\ \end{array} \end{array} \]
          (FPCore (a k m)
           :precision binary64
           (if (<= (/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))) INFINITY)
             (* (/ (pow k m) (fma k (+ 10.0 k) 1.0)) a)
             (* (fma (fma 99.0 k -10.0) k 1.0) a)))
          double code(double a, double k, double m) {
          	double tmp;
          	if (((a * pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k))) <= ((double) INFINITY)) {
          		tmp = (pow(k, m) / fma(k, (10.0 + k), 1.0)) * a;
          	} else {
          		tmp = fma(fma(99.0, k, -10.0), k, 1.0) * a;
          	}
          	return tmp;
          }
          
          function code(a, k, m)
          	tmp = 0.0
          	if (Float64(Float64(a * (k ^ m)) / Float64(Float64(1.0 + Float64(10.0 * k)) + Float64(k * k))) <= Inf)
          		tmp = Float64(Float64((k ^ m) / fma(k, Float64(10.0 + k), 1.0)) * a);
          	else
          		tmp = Float64(fma(fma(99.0, k, -10.0), k, 1.0) * a);
          	end
          	return tmp
          end
          
          code[a_, k_, m_] := If[LessEqual[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], Infinity], N[(N[(N[Power[k, m], $MachinePrecision] / N[(k * N[(10.0 + k), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision], N[(N[(N[(99.0 * k + -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision] * a), $MachinePrecision]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \leq \infty:\\
          \;\;\;\;\frac{{k}^{m}}{\mathsf{fma}\left(k, 10 + k, 1\right)} \cdot a\\
          
          \mathbf{else}:\\
          \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(99, k, -10\right), k, 1\right) \cdot a\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 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))) < +inf.0

            1. Initial program 97.9%

              \[\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. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            if +inf.0 < (/.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 0.0%

              \[\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. Applied rewrites1.6%

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

                \[\leadsto a + \color{blue}{k \cdot \left(-1 \cdot \left(k \cdot \left(a + -100 \cdot a\right)\right) - 10 \cdot a\right)} \]
              3. Step-by-step derivation
                1. Applied rewrites70.4%

                  \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(99 \cdot a, k, -10 \cdot a\right), \color{blue}{k}, a\right) \]
                2. Taylor expanded in a around 0

                  \[\leadsto a \cdot \left(1 + \color{blue}{k \cdot \left(99 \cdot k - 10\right)}\right) \]
                3. Step-by-step derivation
                  1. Applied rewrites100.0%

                    \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(99, k, -10\right), k, 1\right) \cdot a \]
                4. Recombined 2 regimes into one program.
                5. Add Preprocessing

                Alternative 3: 97.0% accurate, 1.0× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq -5.1 \cdot 10^{-8}:\\ \;\;\;\;\frac{a \cdot {k}^{m}}{k \cdot k}\\ \mathbf{elif}\;m \leq 0.022:\\ \;\;\;\;\frac{a}{\mathsf{fma}\left(k - -10, k, 1\right)}\\ \mathbf{else}:\\ \;\;\;\;{k}^{m} \cdot a\\ \end{array} \end{array} \]
                (FPCore (a k m)
                 :precision binary64
                 (if (<= m -5.1e-8)
                   (/ (* a (pow k m)) (* k k))
                   (if (<= m 0.022) (/ a (fma (- k -10.0) k 1.0)) (* (pow k m) a))))
                double code(double a, double k, double m) {
                	double tmp;
                	if (m <= -5.1e-8) {
                		tmp = (a * pow(k, m)) / (k * k);
                	} else if (m <= 0.022) {
                		tmp = a / fma((k - -10.0), k, 1.0);
                	} else {
                		tmp = pow(k, m) * a;
                	}
                	return tmp;
                }
                
                function code(a, k, m)
                	tmp = 0.0
                	if (m <= -5.1e-8)
                		tmp = Float64(Float64(a * (k ^ m)) / Float64(k * k));
                	elseif (m <= 0.022)
                		tmp = Float64(a / fma(Float64(k - -10.0), k, 1.0));
                	else
                		tmp = Float64((k ^ m) * a);
                	end
                	return tmp
                end
                
                code[a_, k_, m_] := If[LessEqual[m, -5.1e-8], N[(N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision] / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 0.022], N[(a / N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision]]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                \mathbf{if}\;m \leq -5.1 \cdot 10^{-8}:\\
                \;\;\;\;\frac{a \cdot {k}^{m}}{k \cdot k}\\
                
                \mathbf{elif}\;m \leq 0.022:\\
                \;\;\;\;\frac{a}{\mathsf{fma}\left(k - -10, k, 1\right)}\\
                
                \mathbf{else}:\\
                \;\;\;\;{k}^{m} \cdot a\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 3 regimes
                2. if m < -5.10000000000000001e-8

                  1. Initial program 99.9%

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

                    \[\leadsto \frac{a \cdot {k}^{m}}{\color{blue}{{k}^{2}}} \]
                  4. Step-by-step derivation
                    1. Applied rewrites99.9%

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

                    if -5.10000000000000001e-8 < m < 0.021999999999999999

                    1. Initial program 94.4%

                      \[\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. Applied rewrites93.5%

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

                      if 0.021999999999999999 < m

                      1. Initial program 74.4%

                        \[\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. Applied rewrites100.0%

                          \[\leadsto \color{blue}{{k}^{m} \cdot a} \]
                      5. Recombined 3 regimes into one program.
                      6. Add Preprocessing

                      Alternative 4: 96.3% accurate, 1.1× speedup?

                      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq -4.2 \cdot 10^{+17} \lor \neg \left(m \leq 0.022\right):\\ \;\;\;\;{k}^{m} \cdot a\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{\mathsf{fma}\left(k - -10, k, 1\right)}\\ \end{array} \end{array} \]
                      (FPCore (a k m)
                       :precision binary64
                       (if (or (<= m -4.2e+17) (not (<= m 0.022)))
                         (* (pow k m) a)
                         (/ a (fma (- k -10.0) k 1.0))))
                      double code(double a, double k, double m) {
                      	double tmp;
                      	if ((m <= -4.2e+17) || !(m <= 0.022)) {
                      		tmp = pow(k, m) * a;
                      	} else {
                      		tmp = a / fma((k - -10.0), k, 1.0);
                      	}
                      	return tmp;
                      }
                      
                      function code(a, k, m)
                      	tmp = 0.0
                      	if ((m <= -4.2e+17) || !(m <= 0.022))
                      		tmp = Float64((k ^ m) * a);
                      	else
                      		tmp = Float64(a / fma(Float64(k - -10.0), k, 1.0));
                      	end
                      	return tmp
                      end
                      
                      code[a_, k_, m_] := If[Or[LessEqual[m, -4.2e+17], N[Not[LessEqual[m, 0.022]], $MachinePrecision]], N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision], N[(a / N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision]]
                      
                      \begin{array}{l}
                      
                      \\
                      \begin{array}{l}
                      \mathbf{if}\;m \leq -4.2 \cdot 10^{+17} \lor \neg \left(m \leq 0.022\right):\\
                      \;\;\;\;{k}^{m} \cdot a\\
                      
                      \mathbf{else}:\\
                      \;\;\;\;\frac{a}{\mathsf{fma}\left(k - -10, k, 1\right)}\\
                      
                      
                      \end{array}
                      \end{array}
                      
                      Derivation
                      1. Split input into 2 regimes
                      2. if m < -4.2e17 or 0.021999999999999999 < m

                        1. Initial program 86.7%

                          \[\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. Applied rewrites100.0%

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

                          if -4.2e17 < m < 0.021999999999999999

                          1. Initial program 94.5%

                            \[\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. Applied rewrites93.7%

                              \[\leadsto \color{blue}{\frac{a}{\mathsf{fma}\left(k - -10, k, 1\right)}} \]
                          5. Recombined 2 regimes into one program.
                          6. Final simplification97.8%

                            \[\leadsto \begin{array}{l} \mathbf{if}\;m \leq -4.2 \cdot 10^{+17} \lor \neg \left(m \leq 0.022\right):\\ \;\;\;\;{k}^{m} \cdot a\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{\mathsf{fma}\left(k - -10, k, 1\right)}\\ \end{array} \]
                          7. Add Preprocessing

                          Alternative 5: 71.0% accurate, 2.3× speedup?

                          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq -4.2 \cdot 10^{+17}:\\ \;\;\;\;\frac{a - \frac{\mathsf{fma}\left(-99, \frac{a}{k}, 10 \cdot a\right)}{k}}{k \cdot k}\\ \mathbf{elif}\;m \leq 0.82:\\ \;\;\;\;\frac{a}{\mathsf{fma}\left(k - -10, k, 1\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(a \cdot k\right) \cdot k\right) \cdot 99\\ \end{array} \end{array} \]
                          (FPCore (a k m)
                           :precision binary64
                           (if (<= m -4.2e+17)
                             (/ (- a (/ (fma -99.0 (/ a k) (* 10.0 a)) k)) (* k k))
                             (if (<= m 0.82) (/ a (fma (- k -10.0) k 1.0)) (* (* (* a k) k) 99.0))))
                          double code(double a, double k, double m) {
                          	double tmp;
                          	if (m <= -4.2e+17) {
                          		tmp = (a - (fma(-99.0, (a / k), (10.0 * a)) / k)) / (k * k);
                          	} else if (m <= 0.82) {
                          		tmp = a / fma((k - -10.0), k, 1.0);
                          	} else {
                          		tmp = ((a * k) * k) * 99.0;
                          	}
                          	return tmp;
                          }
                          
                          function code(a, k, m)
                          	tmp = 0.0
                          	if (m <= -4.2e+17)
                          		tmp = Float64(Float64(a - Float64(fma(-99.0, Float64(a / k), Float64(10.0 * a)) / k)) / Float64(k * k));
                          	elseif (m <= 0.82)
                          		tmp = Float64(a / fma(Float64(k - -10.0), k, 1.0));
                          	else
                          		tmp = Float64(Float64(Float64(a * k) * k) * 99.0);
                          	end
                          	return tmp
                          end
                          
                          code[a_, k_, m_] := If[LessEqual[m, -4.2e+17], N[(N[(a - N[(N[(-99.0 * N[(a / k), $MachinePrecision] + N[(10.0 * a), $MachinePrecision]), $MachinePrecision] / k), $MachinePrecision]), $MachinePrecision] / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 0.82], N[(a / N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(a * k), $MachinePrecision] * k), $MachinePrecision] * 99.0), $MachinePrecision]]]
                          
                          \begin{array}{l}
                          
                          \\
                          \begin{array}{l}
                          \mathbf{if}\;m \leq -4.2 \cdot 10^{+17}:\\
                          \;\;\;\;\frac{a - \frac{\mathsf{fma}\left(-99, \frac{a}{k}, 10 \cdot a\right)}{k}}{k \cdot k}\\
                          
                          \mathbf{elif}\;m \leq 0.82:\\
                          \;\;\;\;\frac{a}{\mathsf{fma}\left(k - -10, k, 1\right)}\\
                          
                          \mathbf{else}:\\
                          \;\;\;\;\left(\left(a \cdot k\right) \cdot k\right) \cdot 99\\
                          
                          
                          \end{array}
                          \end{array}
                          
                          Derivation
                          1. Split input into 3 regimes
                          2. if m < -4.2e17

                            1. Initial program 100.0%

                              \[\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. Applied rewrites30.4%

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

                                \[\leadsto a \]
                              3. Step-by-step derivation
                                1. Applied rewrites3.9%

                                  \[\leadsto a \]
                                2. Taylor expanded in k around inf

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

                                    \[\leadsto \frac{a - \frac{\mathsf{fma}\left(-99, \frac{a}{k}, 10 \cdot a\right)}{k}}{\color{blue}{k \cdot k}} \]

                                  if -4.2e17 < m < 0.819999999999999951

                                  1. Initial program 94.5%

                                    \[\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. Applied rewrites93.7%

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

                                    if 0.819999999999999951 < m

                                    1. Initial program 74.4%

                                      \[\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. Applied rewrites3.1%

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

                                        \[\leadsto a + \color{blue}{k \cdot \left(-1 \cdot \left(k \cdot \left(a + -100 \cdot a\right)\right) - 10 \cdot a\right)} \]
                                      3. Step-by-step derivation
                                        1. Applied rewrites27.7%

                                          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(99 \cdot a, k, -10 \cdot a\right), \color{blue}{k}, a\right) \]
                                        2. Taylor expanded in k around inf

                                          \[\leadsto 99 \cdot \left(a \cdot \color{blue}{{k}^{2}}\right) \]
                                        3. Step-by-step derivation
                                          1. Applied rewrites49.5%

                                            \[\leadsto \left(\left(a \cdot k\right) \cdot k\right) \cdot 99 \]
                                        4. Recombined 3 regimes into one program.
                                        5. Add Preprocessing

                                        Alternative 6: 69.1% accurate, 3.9× speedup?

                                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq -4.2 \cdot 10^{+17}:\\ \;\;\;\;\frac{\frac{1}{k}}{k} \cdot a\\ \mathbf{elif}\;m \leq 0.82:\\ \;\;\;\;\frac{a}{\mathsf{fma}\left(k - -10, k, 1\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(a \cdot k\right) \cdot k\right) \cdot 99\\ \end{array} \end{array} \]
                                        (FPCore (a k m)
                                         :precision binary64
                                         (if (<= m -4.2e+17)
                                           (* (/ (/ 1.0 k) k) a)
                                           (if (<= m 0.82) (/ a (fma (- k -10.0) k 1.0)) (* (* (* a k) k) 99.0))))
                                        double code(double a, double k, double m) {
                                        	double tmp;
                                        	if (m <= -4.2e+17) {
                                        		tmp = ((1.0 / k) / k) * a;
                                        	} else if (m <= 0.82) {
                                        		tmp = a / fma((k - -10.0), k, 1.0);
                                        	} else {
                                        		tmp = ((a * k) * k) * 99.0;
                                        	}
                                        	return tmp;
                                        }
                                        
                                        function code(a, k, m)
                                        	tmp = 0.0
                                        	if (m <= -4.2e+17)
                                        		tmp = Float64(Float64(Float64(1.0 / k) / k) * a);
                                        	elseif (m <= 0.82)
                                        		tmp = Float64(a / fma(Float64(k - -10.0), k, 1.0));
                                        	else
                                        		tmp = Float64(Float64(Float64(a * k) * k) * 99.0);
                                        	end
                                        	return tmp
                                        end
                                        
                                        code[a_, k_, m_] := If[LessEqual[m, -4.2e+17], N[(N[(N[(1.0 / k), $MachinePrecision] / k), $MachinePrecision] * a), $MachinePrecision], If[LessEqual[m, 0.82], N[(a / N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(a * k), $MachinePrecision] * k), $MachinePrecision] * 99.0), $MachinePrecision]]]
                                        
                                        \begin{array}{l}
                                        
                                        \\
                                        \begin{array}{l}
                                        \mathbf{if}\;m \leq -4.2 \cdot 10^{+17}:\\
                                        \;\;\;\;\frac{\frac{1}{k}}{k} \cdot a\\
                                        
                                        \mathbf{elif}\;m \leq 0.82:\\
                                        \;\;\;\;\frac{a}{\mathsf{fma}\left(k - -10, k, 1\right)}\\
                                        
                                        \mathbf{else}:\\
                                        \;\;\;\;\left(\left(a \cdot k\right) \cdot k\right) \cdot 99\\
                                        
                                        
                                        \end{array}
                                        \end{array}
                                        
                                        Derivation
                                        1. Split input into 3 regimes
                                        2. if m < -4.2e17

                                          1. Initial program 100.0%

                                            \[\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. Applied rewrites30.4%

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

                                              \[\leadsto \frac{a + -10 \cdot \frac{a}{k}}{\color{blue}{{k}^{2}}} \]
                                            3. Step-by-step derivation
                                              1. Applied rewrites36.4%

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

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

                                                  \[\leadsto \frac{\frac{1 - \frac{10}{k}}{k}}{k} \cdot a \]
                                                2. Taylor expanded in k around inf

                                                  \[\leadsto \frac{1}{{k}^{2}} \cdot a \]
                                                3. Step-by-step derivation
                                                  1. Applied rewrites58.1%

                                                    \[\leadsto \frac{\frac{1}{k}}{k} \cdot a \]

                                                  if -4.2e17 < m < 0.819999999999999951

                                                  1. Initial program 94.5%

                                                    \[\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. Applied rewrites93.7%

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

                                                    if 0.819999999999999951 < m

                                                    1. Initial program 74.4%

                                                      \[\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. Applied rewrites3.1%

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

                                                        \[\leadsto a + \color{blue}{k \cdot \left(-1 \cdot \left(k \cdot \left(a + -100 \cdot a\right)\right) - 10 \cdot a\right)} \]
                                                      3. Step-by-step derivation
                                                        1. Applied rewrites27.7%

                                                          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(99 \cdot a, k, -10 \cdot a\right), \color{blue}{k}, a\right) \]
                                                        2. Taylor expanded in k around inf

                                                          \[\leadsto 99 \cdot \left(a \cdot \color{blue}{{k}^{2}}\right) \]
                                                        3. Step-by-step derivation
                                                          1. Applied rewrites49.5%

                                                            \[\leadsto \left(\left(a \cdot k\right) \cdot k\right) \cdot 99 \]
                                                        4. Recombined 3 regimes into one program.
                                                        5. Add Preprocessing

                                                        Alternative 7: 69.5% accurate, 4.1× speedup?

                                                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq -6 \cdot 10^{-6}:\\ \;\;\;\;\frac{a}{k \cdot k}\\ \mathbf{elif}\;m \leq 0.82:\\ \;\;\;\;\frac{a}{\mathsf{fma}\left(k - -10, k, 1\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(a \cdot k\right) \cdot k\right) \cdot 99\\ \end{array} \end{array} \]
                                                        (FPCore (a k m)
                                                         :precision binary64
                                                         (if (<= m -6e-6)
                                                           (/ a (* k k))
                                                           (if (<= m 0.82) (/ a (fma (- k -10.0) k 1.0)) (* (* (* a k) k) 99.0))))
                                                        double code(double a, double k, double m) {
                                                        	double tmp;
                                                        	if (m <= -6e-6) {
                                                        		tmp = a / (k * k);
                                                        	} else if (m <= 0.82) {
                                                        		tmp = a / fma((k - -10.0), k, 1.0);
                                                        	} else {
                                                        		tmp = ((a * k) * k) * 99.0;
                                                        	}
                                                        	return tmp;
                                                        }
                                                        
                                                        function code(a, k, m)
                                                        	tmp = 0.0
                                                        	if (m <= -6e-6)
                                                        		tmp = Float64(a / Float64(k * k));
                                                        	elseif (m <= 0.82)
                                                        		tmp = Float64(a / fma(Float64(k - -10.0), k, 1.0));
                                                        	else
                                                        		tmp = Float64(Float64(Float64(a * k) * k) * 99.0);
                                                        	end
                                                        	return tmp
                                                        end
                                                        
                                                        code[a_, k_, m_] := If[LessEqual[m, -6e-6], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 0.82], N[(a / N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(a * k), $MachinePrecision] * k), $MachinePrecision] * 99.0), $MachinePrecision]]]
                                                        
                                                        \begin{array}{l}
                                                        
                                                        \\
                                                        \begin{array}{l}
                                                        \mathbf{if}\;m \leq -6 \cdot 10^{-6}:\\
                                                        \;\;\;\;\frac{a}{k \cdot k}\\
                                                        
                                                        \mathbf{elif}\;m \leq 0.82:\\
                                                        \;\;\;\;\frac{a}{\mathsf{fma}\left(k - -10, k, 1\right)}\\
                                                        
                                                        \mathbf{else}:\\
                                                        \;\;\;\;\left(\left(a \cdot k\right) \cdot k\right) \cdot 99\\
                                                        
                                                        
                                                        \end{array}
                                                        \end{array}
                                                        
                                                        Derivation
                                                        1. Split input into 3 regimes
                                                        2. if m < -6.0000000000000002e-6

                                                          1. Initial program 99.9%

                                                            \[\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. Applied rewrites33.6%

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

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

                                                                \[\leadsto \frac{a}{\color{blue}{k \cdot k}} \]

                                                              if -6.0000000000000002e-6 < m < 0.819999999999999951

                                                              1. Initial program 94.4%

                                                                \[\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. Applied rewrites93.5%

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

                                                                if 0.819999999999999951 < m

                                                                1. Initial program 74.4%

                                                                  \[\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. Applied rewrites3.1%

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

                                                                    \[\leadsto a + \color{blue}{k \cdot \left(-1 \cdot \left(k \cdot \left(a + -100 \cdot a\right)\right) - 10 \cdot a\right)} \]
                                                                  3. Step-by-step derivation
                                                                    1. Applied rewrites27.7%

                                                                      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(99 \cdot a, k, -10 \cdot a\right), \color{blue}{k}, a\right) \]
                                                                    2. Taylor expanded in k around inf

                                                                      \[\leadsto 99 \cdot \left(a \cdot \color{blue}{{k}^{2}}\right) \]
                                                                    3. Step-by-step derivation
                                                                      1. Applied rewrites49.5%

                                                                        \[\leadsto \left(\left(a \cdot k\right) \cdot k\right) \cdot 99 \]
                                                                    4. Recombined 3 regimes into one program.
                                                                    5. Add Preprocessing

                                                                    Alternative 8: 68.7% accurate, 4.5× speedup?

                                                                    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq -6 \cdot 10^{-6}:\\ \;\;\;\;\frac{a}{k \cdot k}\\ \mathbf{elif}\;m \leq 0.82:\\ \;\;\;\;\frac{a}{\mathsf{fma}\left(k, k, 1\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(a \cdot k\right) \cdot k\right) \cdot 99\\ \end{array} \end{array} \]
                                                                    (FPCore (a k m)
                                                                     :precision binary64
                                                                     (if (<= m -6e-6)
                                                                       (/ a (* k k))
                                                                       (if (<= m 0.82) (/ a (fma k k 1.0)) (* (* (* a k) k) 99.0))))
                                                                    double code(double a, double k, double m) {
                                                                    	double tmp;
                                                                    	if (m <= -6e-6) {
                                                                    		tmp = a / (k * k);
                                                                    	} else if (m <= 0.82) {
                                                                    		tmp = a / fma(k, k, 1.0);
                                                                    	} else {
                                                                    		tmp = ((a * k) * k) * 99.0;
                                                                    	}
                                                                    	return tmp;
                                                                    }
                                                                    
                                                                    function code(a, k, m)
                                                                    	tmp = 0.0
                                                                    	if (m <= -6e-6)
                                                                    		tmp = Float64(a / Float64(k * k));
                                                                    	elseif (m <= 0.82)
                                                                    		tmp = Float64(a / fma(k, k, 1.0));
                                                                    	else
                                                                    		tmp = Float64(Float64(Float64(a * k) * k) * 99.0);
                                                                    	end
                                                                    	return tmp
                                                                    end
                                                                    
                                                                    code[a_, k_, m_] := If[LessEqual[m, -6e-6], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 0.82], N[(a / N[(k * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(a * k), $MachinePrecision] * k), $MachinePrecision] * 99.0), $MachinePrecision]]]
                                                                    
                                                                    \begin{array}{l}
                                                                    
                                                                    \\
                                                                    \begin{array}{l}
                                                                    \mathbf{if}\;m \leq -6 \cdot 10^{-6}:\\
                                                                    \;\;\;\;\frac{a}{k \cdot k}\\
                                                                    
                                                                    \mathbf{elif}\;m \leq 0.82:\\
                                                                    \;\;\;\;\frac{a}{\mathsf{fma}\left(k, k, 1\right)}\\
                                                                    
                                                                    \mathbf{else}:\\
                                                                    \;\;\;\;\left(\left(a \cdot k\right) \cdot k\right) \cdot 99\\
                                                                    
                                                                    
                                                                    \end{array}
                                                                    \end{array}
                                                                    
                                                                    Derivation
                                                                    1. Split input into 3 regimes
                                                                    2. if m < -6.0000000000000002e-6

                                                                      1. Initial program 99.9%

                                                                        \[\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. Applied rewrites33.6%

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

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

                                                                            \[\leadsto \frac{a}{\color{blue}{k \cdot k}} \]

                                                                          if -6.0000000000000002e-6 < m < 0.819999999999999951

                                                                          1. Initial program 94.4%

                                                                            \[\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. Applied rewrites93.5%

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

                                                                              \[\leadsto \frac{a}{\mathsf{fma}\left(k, k, 1\right)} \]
                                                                            3. Step-by-step derivation
                                                                              1. Applied rewrites91.2%

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

                                                                              if 0.819999999999999951 < m

                                                                              1. Initial program 74.4%

                                                                                \[\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. Applied rewrites3.1%

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

                                                                                  \[\leadsto a + \color{blue}{k \cdot \left(-1 \cdot \left(k \cdot \left(a + -100 \cdot a\right)\right) - 10 \cdot a\right)} \]
                                                                                3. Step-by-step derivation
                                                                                  1. Applied rewrites27.7%

                                                                                    \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(99 \cdot a, k, -10 \cdot a\right), \color{blue}{k}, a\right) \]
                                                                                  2. Taylor expanded in k around inf

                                                                                    \[\leadsto 99 \cdot \left(a \cdot \color{blue}{{k}^{2}}\right) \]
                                                                                  3. Step-by-step derivation
                                                                                    1. Applied rewrites49.5%

                                                                                      \[\leadsto \left(\left(a \cdot k\right) \cdot k\right) \cdot 99 \]
                                                                                  4. Recombined 3 regimes into one program.
                                                                                  5. Add Preprocessing

                                                                                  Alternative 9: 55.2% accurate, 4.5× speedup?

                                                                                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq 3.2 \cdot 10^{-234}:\\ \;\;\;\;\frac{a}{k \cdot k}\\ \mathbf{elif}\;m \leq 0.82:\\ \;\;\;\;\frac{a}{\mathsf{fma}\left(10, k, 1\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(a \cdot k\right) \cdot k\right) \cdot 99\\ \end{array} \end{array} \]
                                                                                  (FPCore (a k m)
                                                                                   :precision binary64
                                                                                   (if (<= m 3.2e-234)
                                                                                     (/ a (* k k))
                                                                                     (if (<= m 0.82) (/ a (fma 10.0 k 1.0)) (* (* (* a k) k) 99.0))))
                                                                                  double code(double a, double k, double m) {
                                                                                  	double tmp;
                                                                                  	if (m <= 3.2e-234) {
                                                                                  		tmp = a / (k * k);
                                                                                  	} else if (m <= 0.82) {
                                                                                  		tmp = a / fma(10.0, k, 1.0);
                                                                                  	} else {
                                                                                  		tmp = ((a * k) * k) * 99.0;
                                                                                  	}
                                                                                  	return tmp;
                                                                                  }
                                                                                  
                                                                                  function code(a, k, m)
                                                                                  	tmp = 0.0
                                                                                  	if (m <= 3.2e-234)
                                                                                  		tmp = Float64(a / Float64(k * k));
                                                                                  	elseif (m <= 0.82)
                                                                                  		tmp = Float64(a / fma(10.0, k, 1.0));
                                                                                  	else
                                                                                  		tmp = Float64(Float64(Float64(a * k) * k) * 99.0);
                                                                                  	end
                                                                                  	return tmp
                                                                                  end
                                                                                  
                                                                                  code[a_, k_, m_] := If[LessEqual[m, 3.2e-234], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 0.82], N[(a / N[(10.0 * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(a * k), $MachinePrecision] * k), $MachinePrecision] * 99.0), $MachinePrecision]]]
                                                                                  
                                                                                  \begin{array}{l}
                                                                                  
                                                                                  \\
                                                                                  \begin{array}{l}
                                                                                  \mathbf{if}\;m \leq 3.2 \cdot 10^{-234}:\\
                                                                                  \;\;\;\;\frac{a}{k \cdot k}\\
                                                                                  
                                                                                  \mathbf{elif}\;m \leq 0.82:\\
                                                                                  \;\;\;\;\frac{a}{\mathsf{fma}\left(10, k, 1\right)}\\
                                                                                  
                                                                                  \mathbf{else}:\\
                                                                                  \;\;\;\;\left(\left(a \cdot k\right) \cdot k\right) \cdot 99\\
                                                                                  
                                                                                  
                                                                                  \end{array}
                                                                                  \end{array}
                                                                                  
                                                                                  Derivation
                                                                                  1. Split input into 3 regimes
                                                                                  2. if m < 3.1999999999999999e-234

                                                                                    1. Initial program 96.5%

                                                                                      \[\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. Applied rewrites56.5%

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

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

                                                                                          \[\leadsto \frac{a}{\color{blue}{k \cdot k}} \]

                                                                                        if 3.1999999999999999e-234 < m < 0.819999999999999951

                                                                                        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. Applied rewrites98.5%

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

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

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

                                                                                            if 0.819999999999999951 < m

                                                                                            1. Initial program 74.4%

                                                                                              \[\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. Applied rewrites3.1%

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

                                                                                                \[\leadsto a + \color{blue}{k \cdot \left(-1 \cdot \left(k \cdot \left(a + -100 \cdot a\right)\right) - 10 \cdot a\right)} \]
                                                                                              3. Step-by-step derivation
                                                                                                1. Applied rewrites27.7%

                                                                                                  \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(99 \cdot a, k, -10 \cdot a\right), \color{blue}{k}, a\right) \]
                                                                                                2. Taylor expanded in k around inf

                                                                                                  \[\leadsto 99 \cdot \left(a \cdot \color{blue}{{k}^{2}}\right) \]
                                                                                                3. Step-by-step derivation
                                                                                                  1. Applied rewrites49.5%

                                                                                                    \[\leadsto \left(\left(a \cdot k\right) \cdot k\right) \cdot 99 \]
                                                                                                4. Recombined 3 regimes into one program.
                                                                                                5. Add Preprocessing

                                                                                                Alternative 10: 53.6% accurate, 4.8× speedup?

                                                                                                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq 1.4 \cdot 10^{-188}:\\ \;\;\;\;\frac{a}{k \cdot k}\\ \mathbf{elif}\;m \leq 0.32:\\ \;\;\;\;a\\ \mathbf{else}:\\ \;\;\;\;\left(\left(a \cdot k\right) \cdot k\right) \cdot 99\\ \end{array} \end{array} \]
                                                                                                (FPCore (a k m)
                                                                                                 :precision binary64
                                                                                                 (if (<= m 1.4e-188) (/ a (* k k)) (if (<= m 0.32) a (* (* (* a k) k) 99.0))))
                                                                                                double code(double a, double k, double m) {
                                                                                                	double tmp;
                                                                                                	if (m <= 1.4e-188) {
                                                                                                		tmp = a / (k * k);
                                                                                                	} else if (m <= 0.32) {
                                                                                                		tmp = a;
                                                                                                	} else {
                                                                                                		tmp = ((a * k) * k) * 99.0;
                                                                                                	}
                                                                                                	return tmp;
                                                                                                }
                                                                                                
                                                                                                module fmin_fmax_functions
                                                                                                    implicit none
                                                                                                    private
                                                                                                    public fmax
                                                                                                    public fmin
                                                                                                
                                                                                                    interface fmax
                                                                                                        module procedure fmax88
                                                                                                        module procedure fmax44
                                                                                                        module procedure fmax84
                                                                                                        module procedure fmax48
                                                                                                    end interface
                                                                                                    interface fmin
                                                                                                        module procedure fmin88
                                                                                                        module procedure fmin44
                                                                                                        module procedure fmin84
                                                                                                        module procedure fmin48
                                                                                                    end interface
                                                                                                contains
                                                                                                    real(8) function fmax88(x, y) result (res)
                                                                                                        real(8), intent (in) :: x
                                                                                                        real(8), intent (in) :: y
                                                                                                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                                                                    end function
                                                                                                    real(4) function fmax44(x, y) result (res)
                                                                                                        real(4), intent (in) :: x
                                                                                                        real(4), intent (in) :: y
                                                                                                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                                                                    end function
                                                                                                    real(8) function fmax84(x, y) result(res)
                                                                                                        real(8), intent (in) :: x
                                                                                                        real(4), intent (in) :: y
                                                                                                        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                                                                                    end function
                                                                                                    real(8) function fmax48(x, y) result(res)
                                                                                                        real(4), intent (in) :: x
                                                                                                        real(8), intent (in) :: y
                                                                                                        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                                                                                    end function
                                                                                                    real(8) function fmin88(x, y) result (res)
                                                                                                        real(8), intent (in) :: x
                                                                                                        real(8), intent (in) :: y
                                                                                                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                                                                    end function
                                                                                                    real(4) function fmin44(x, y) result (res)
                                                                                                        real(4), intent (in) :: x
                                                                                                        real(4), intent (in) :: y
                                                                                                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                                                                    end function
                                                                                                    real(8) function fmin84(x, y) result(res)
                                                                                                        real(8), intent (in) :: x
                                                                                                        real(4), intent (in) :: y
                                                                                                        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                                                                                    end function
                                                                                                    real(8) function fmin48(x, y) result(res)
                                                                                                        real(4), intent (in) :: x
                                                                                                        real(8), intent (in) :: y
                                                                                                        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                                                                                    end function
                                                                                                end module
                                                                                                
                                                                                                real(8) function code(a, k, m)
                                                                                                use fmin_fmax_functions
                                                                                                    real(8), intent (in) :: a
                                                                                                    real(8), intent (in) :: k
                                                                                                    real(8), intent (in) :: m
                                                                                                    real(8) :: tmp
                                                                                                    if (m <= 1.4d-188) then
                                                                                                        tmp = a / (k * k)
                                                                                                    else if (m <= 0.32d0) then
                                                                                                        tmp = a
                                                                                                    else
                                                                                                        tmp = ((a * k) * k) * 99.0d0
                                                                                                    end if
                                                                                                    code = tmp
                                                                                                end function
                                                                                                
                                                                                                public static double code(double a, double k, double m) {
                                                                                                	double tmp;
                                                                                                	if (m <= 1.4e-188) {
                                                                                                		tmp = a / (k * k);
                                                                                                	} else if (m <= 0.32) {
                                                                                                		tmp = a;
                                                                                                	} else {
                                                                                                		tmp = ((a * k) * k) * 99.0;
                                                                                                	}
                                                                                                	return tmp;
                                                                                                }
                                                                                                
                                                                                                def code(a, k, m):
                                                                                                	tmp = 0
                                                                                                	if m <= 1.4e-188:
                                                                                                		tmp = a / (k * k)
                                                                                                	elif m <= 0.32:
                                                                                                		tmp = a
                                                                                                	else:
                                                                                                		tmp = ((a * k) * k) * 99.0
                                                                                                	return tmp
                                                                                                
                                                                                                function code(a, k, m)
                                                                                                	tmp = 0.0
                                                                                                	if (m <= 1.4e-188)
                                                                                                		tmp = Float64(a / Float64(k * k));
                                                                                                	elseif (m <= 0.32)
                                                                                                		tmp = a;
                                                                                                	else
                                                                                                		tmp = Float64(Float64(Float64(a * k) * k) * 99.0);
                                                                                                	end
                                                                                                	return tmp
                                                                                                end
                                                                                                
                                                                                                function tmp_2 = code(a, k, m)
                                                                                                	tmp = 0.0;
                                                                                                	if (m <= 1.4e-188)
                                                                                                		tmp = a / (k * k);
                                                                                                	elseif (m <= 0.32)
                                                                                                		tmp = a;
                                                                                                	else
                                                                                                		tmp = ((a * k) * k) * 99.0;
                                                                                                	end
                                                                                                	tmp_2 = tmp;
                                                                                                end
                                                                                                
                                                                                                code[a_, k_, m_] := If[LessEqual[m, 1.4e-188], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 0.32], a, N[(N[(N[(a * k), $MachinePrecision] * k), $MachinePrecision] * 99.0), $MachinePrecision]]]
                                                                                                
                                                                                                \begin{array}{l}
                                                                                                
                                                                                                \\
                                                                                                \begin{array}{l}
                                                                                                \mathbf{if}\;m \leq 1.4 \cdot 10^{-188}:\\
                                                                                                \;\;\;\;\frac{a}{k \cdot k}\\
                                                                                                
                                                                                                \mathbf{elif}\;m \leq 0.32:\\
                                                                                                \;\;\;\;a\\
                                                                                                
                                                                                                \mathbf{else}:\\
                                                                                                \;\;\;\;\left(\left(a \cdot k\right) \cdot k\right) \cdot 99\\
                                                                                                
                                                                                                
                                                                                                \end{array}
                                                                                                \end{array}
                                                                                                
                                                                                                Derivation
                                                                                                1. Split input into 3 regimes
                                                                                                2. if m < 1.4000000000000001e-188

                                                                                                  1. Initial program 96.7%

                                                                                                    \[\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. Applied rewrites58.8%

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

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

                                                                                                        \[\leadsto \frac{a}{\color{blue}{k \cdot k}} \]

                                                                                                      if 1.4000000000000001e-188 < m < 0.320000000000000007

                                                                                                      1. Initial program 99.9%

                                                                                                        \[\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. Applied rewrites98.1%

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

                                                                                                          \[\leadsto a \]
                                                                                                        3. Step-by-step derivation
                                                                                                          1. Applied rewrites61.6%

                                                                                                            \[\leadsto a \]

                                                                                                          if 0.320000000000000007 < m

                                                                                                          1. Initial program 74.4%

                                                                                                            \[\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. Applied rewrites3.1%

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

                                                                                                              \[\leadsto a + \color{blue}{k \cdot \left(-1 \cdot \left(k \cdot \left(a + -100 \cdot a\right)\right) - 10 \cdot a\right)} \]
                                                                                                            3. Step-by-step derivation
                                                                                                              1. Applied rewrites27.7%

                                                                                                                \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(99 \cdot a, k, -10 \cdot a\right), \color{blue}{k}, a\right) \]
                                                                                                              2. Taylor expanded in k around inf

                                                                                                                \[\leadsto 99 \cdot \left(a \cdot \color{blue}{{k}^{2}}\right) \]
                                                                                                              3. Step-by-step derivation
                                                                                                                1. Applied rewrites49.5%

                                                                                                                  \[\leadsto \left(\left(a \cdot k\right) \cdot k\right) \cdot 99 \]
                                                                                                              4. Recombined 3 regimes into one program.
                                                                                                              5. Add Preprocessing

                                                                                                              Alternative 11: 35.7% accurate, 6.1× speedup?

                                                                                                              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq 0.32:\\ \;\;\;\;a\\ \mathbf{else}:\\ \;\;\;\;\left(\left(a \cdot k\right) \cdot k\right) \cdot 99\\ \end{array} \end{array} \]
                                                                                                              (FPCore (a k m) :precision binary64 (if (<= m 0.32) a (* (* (* a k) k) 99.0)))
                                                                                                              double code(double a, double k, double m) {
                                                                                                              	double tmp;
                                                                                                              	if (m <= 0.32) {
                                                                                                              		tmp = a;
                                                                                                              	} else {
                                                                                                              		tmp = ((a * k) * k) * 99.0;
                                                                                                              	}
                                                                                                              	return tmp;
                                                                                                              }
                                                                                                              
                                                                                                              module fmin_fmax_functions
                                                                                                                  implicit none
                                                                                                                  private
                                                                                                                  public fmax
                                                                                                                  public fmin
                                                                                                              
                                                                                                                  interface fmax
                                                                                                                      module procedure fmax88
                                                                                                                      module procedure fmax44
                                                                                                                      module procedure fmax84
                                                                                                                      module procedure fmax48
                                                                                                                  end interface
                                                                                                                  interface fmin
                                                                                                                      module procedure fmin88
                                                                                                                      module procedure fmin44
                                                                                                                      module procedure fmin84
                                                                                                                      module procedure fmin48
                                                                                                                  end interface
                                                                                                              contains
                                                                                                                  real(8) function fmax88(x, y) result (res)
                                                                                                                      real(8), intent (in) :: x
                                                                                                                      real(8), intent (in) :: y
                                                                                                                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                                                                                  end function
                                                                                                                  real(4) function fmax44(x, y) result (res)
                                                                                                                      real(4), intent (in) :: x
                                                                                                                      real(4), intent (in) :: y
                                                                                                                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                                                                                  end function
                                                                                                                  real(8) function fmax84(x, y) result(res)
                                                                                                                      real(8), intent (in) :: x
                                                                                                                      real(4), intent (in) :: y
                                                                                                                      res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                                                                                                  end function
                                                                                                                  real(8) function fmax48(x, y) result(res)
                                                                                                                      real(4), intent (in) :: x
                                                                                                                      real(8), intent (in) :: y
                                                                                                                      res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                                                                                                  end function
                                                                                                                  real(8) function fmin88(x, y) result (res)
                                                                                                                      real(8), intent (in) :: x
                                                                                                                      real(8), intent (in) :: y
                                                                                                                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                                                                                  end function
                                                                                                                  real(4) function fmin44(x, y) result (res)
                                                                                                                      real(4), intent (in) :: x
                                                                                                                      real(4), intent (in) :: y
                                                                                                                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                                                                                  end function
                                                                                                                  real(8) function fmin84(x, y) result(res)
                                                                                                                      real(8), intent (in) :: x
                                                                                                                      real(4), intent (in) :: y
                                                                                                                      res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                                                                                                  end function
                                                                                                                  real(8) function fmin48(x, y) result(res)
                                                                                                                      real(4), intent (in) :: x
                                                                                                                      real(8), intent (in) :: y
                                                                                                                      res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                                                                                                  end function
                                                                                                              end module
                                                                                                              
                                                                                                              real(8) function code(a, k, m)
                                                                                                              use fmin_fmax_functions
                                                                                                                  real(8), intent (in) :: a
                                                                                                                  real(8), intent (in) :: k
                                                                                                                  real(8), intent (in) :: m
                                                                                                                  real(8) :: tmp
                                                                                                                  if (m <= 0.32d0) then
                                                                                                                      tmp = a
                                                                                                                  else
                                                                                                                      tmp = ((a * k) * k) * 99.0d0
                                                                                                                  end if
                                                                                                                  code = tmp
                                                                                                              end function
                                                                                                              
                                                                                                              public static double code(double a, double k, double m) {
                                                                                                              	double tmp;
                                                                                                              	if (m <= 0.32) {
                                                                                                              		tmp = a;
                                                                                                              	} else {
                                                                                                              		tmp = ((a * k) * k) * 99.0;
                                                                                                              	}
                                                                                                              	return tmp;
                                                                                                              }
                                                                                                              
                                                                                                              def code(a, k, m):
                                                                                                              	tmp = 0
                                                                                                              	if m <= 0.32:
                                                                                                              		tmp = a
                                                                                                              	else:
                                                                                                              		tmp = ((a * k) * k) * 99.0
                                                                                                              	return tmp
                                                                                                              
                                                                                                              function code(a, k, m)
                                                                                                              	tmp = 0.0
                                                                                                              	if (m <= 0.32)
                                                                                                              		tmp = a;
                                                                                                              	else
                                                                                                              		tmp = Float64(Float64(Float64(a * k) * k) * 99.0);
                                                                                                              	end
                                                                                                              	return tmp
                                                                                                              end
                                                                                                              
                                                                                                              function tmp_2 = code(a, k, m)
                                                                                                              	tmp = 0.0;
                                                                                                              	if (m <= 0.32)
                                                                                                              		tmp = a;
                                                                                                              	else
                                                                                                              		tmp = ((a * k) * k) * 99.0;
                                                                                                              	end
                                                                                                              	tmp_2 = tmp;
                                                                                                              end
                                                                                                              
                                                                                                              code[a_, k_, m_] := If[LessEqual[m, 0.32], a, N[(N[(N[(a * k), $MachinePrecision] * k), $MachinePrecision] * 99.0), $MachinePrecision]]
                                                                                                              
                                                                                                              \begin{array}{l}
                                                                                                              
                                                                                                              \\
                                                                                                              \begin{array}{l}
                                                                                                              \mathbf{if}\;m \leq 0.32:\\
                                                                                                              \;\;\;\;a\\
                                                                                                              
                                                                                                              \mathbf{else}:\\
                                                                                                              \;\;\;\;\left(\left(a \cdot k\right) \cdot k\right) \cdot 99\\
                                                                                                              
                                                                                                              
                                                                                                              \end{array}
                                                                                                              \end{array}
                                                                                                              
                                                                                                              Derivation
                                                                                                              1. Split input into 2 regimes
                                                                                                              2. if m < 0.320000000000000007

                                                                                                                1. Initial program 97.1%

                                                                                                                  \[\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. Applied rewrites63.9%

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

                                                                                                                    \[\leadsto a \]
                                                                                                                  3. Step-by-step derivation
                                                                                                                    1. Applied rewrites23.7%

                                                                                                                      \[\leadsto a \]

                                                                                                                    if 0.320000000000000007 < m

                                                                                                                    1. Initial program 74.4%

                                                                                                                      \[\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. Applied rewrites3.1%

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

                                                                                                                        \[\leadsto a + \color{blue}{k \cdot \left(-1 \cdot \left(k \cdot \left(a + -100 \cdot a\right)\right) - 10 \cdot a\right)} \]
                                                                                                                      3. Step-by-step derivation
                                                                                                                        1. Applied rewrites27.7%

                                                                                                                          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(99 \cdot a, k, -10 \cdot a\right), \color{blue}{k}, a\right) \]
                                                                                                                        2. Taylor expanded in k around inf

                                                                                                                          \[\leadsto 99 \cdot \left(a \cdot \color{blue}{{k}^{2}}\right) \]
                                                                                                                        3. Step-by-step derivation
                                                                                                                          1. Applied rewrites49.5%

                                                                                                                            \[\leadsto \left(\left(a \cdot k\right) \cdot k\right) \cdot 99 \]
                                                                                                                        4. Recombined 2 regimes into one program.
                                                                                                                        5. Add Preprocessing

                                                                                                                        Alternative 12: 25.1% accurate, 7.9× speedup?

                                                                                                                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq 2.35 \cdot 10^{+14}:\\ \;\;\;\;a\\ \mathbf{else}:\\ \;\;\;\;\left(-10 \cdot a\right) \cdot k\\ \end{array} \end{array} \]
                                                                                                                        (FPCore (a k m) :precision binary64 (if (<= m 2.35e+14) a (* (* -10.0 a) k)))
                                                                                                                        double code(double a, double k, double m) {
                                                                                                                        	double tmp;
                                                                                                                        	if (m <= 2.35e+14) {
                                                                                                                        		tmp = a;
                                                                                                                        	} else {
                                                                                                                        		tmp = (-10.0 * a) * k;
                                                                                                                        	}
                                                                                                                        	return tmp;
                                                                                                                        }
                                                                                                                        
                                                                                                                        module fmin_fmax_functions
                                                                                                                            implicit none
                                                                                                                            private
                                                                                                                            public fmax
                                                                                                                            public fmin
                                                                                                                        
                                                                                                                            interface fmax
                                                                                                                                module procedure fmax88
                                                                                                                                module procedure fmax44
                                                                                                                                module procedure fmax84
                                                                                                                                module procedure fmax48
                                                                                                                            end interface
                                                                                                                            interface fmin
                                                                                                                                module procedure fmin88
                                                                                                                                module procedure fmin44
                                                                                                                                module procedure fmin84
                                                                                                                                module procedure fmin48
                                                                                                                            end interface
                                                                                                                        contains
                                                                                                                            real(8) function fmax88(x, y) result (res)
                                                                                                                                real(8), intent (in) :: x
                                                                                                                                real(8), intent (in) :: y
                                                                                                                                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                                                                                            end function
                                                                                                                            real(4) function fmax44(x, y) result (res)
                                                                                                                                real(4), intent (in) :: x
                                                                                                                                real(4), intent (in) :: y
                                                                                                                                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                                                                                            end function
                                                                                                                            real(8) function fmax84(x, y) result(res)
                                                                                                                                real(8), intent (in) :: x
                                                                                                                                real(4), intent (in) :: y
                                                                                                                                res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                                                                                                            end function
                                                                                                                            real(8) function fmax48(x, y) result(res)
                                                                                                                                real(4), intent (in) :: x
                                                                                                                                real(8), intent (in) :: y
                                                                                                                                res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                                                                                                            end function
                                                                                                                            real(8) function fmin88(x, y) result (res)
                                                                                                                                real(8), intent (in) :: x
                                                                                                                                real(8), intent (in) :: y
                                                                                                                                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                                                                                            end function
                                                                                                                            real(4) function fmin44(x, y) result (res)
                                                                                                                                real(4), intent (in) :: x
                                                                                                                                real(4), intent (in) :: y
                                                                                                                                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                                                                                            end function
                                                                                                                            real(8) function fmin84(x, y) result(res)
                                                                                                                                real(8), intent (in) :: x
                                                                                                                                real(4), intent (in) :: y
                                                                                                                                res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                                                                                                            end function
                                                                                                                            real(8) function fmin48(x, y) result(res)
                                                                                                                                real(4), intent (in) :: x
                                                                                                                                real(8), intent (in) :: y
                                                                                                                                res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                                                                                                            end function
                                                                                                                        end module
                                                                                                                        
                                                                                                                        real(8) function code(a, k, m)
                                                                                                                        use fmin_fmax_functions
                                                                                                                            real(8), intent (in) :: a
                                                                                                                            real(8), intent (in) :: k
                                                                                                                            real(8), intent (in) :: m
                                                                                                                            real(8) :: tmp
                                                                                                                            if (m <= 2.35d+14) then
                                                                                                                                tmp = a
                                                                                                                            else
                                                                                                                                tmp = ((-10.0d0) * a) * k
                                                                                                                            end if
                                                                                                                            code = tmp
                                                                                                                        end function
                                                                                                                        
                                                                                                                        public static double code(double a, double k, double m) {
                                                                                                                        	double tmp;
                                                                                                                        	if (m <= 2.35e+14) {
                                                                                                                        		tmp = a;
                                                                                                                        	} else {
                                                                                                                        		tmp = (-10.0 * a) * k;
                                                                                                                        	}
                                                                                                                        	return tmp;
                                                                                                                        }
                                                                                                                        
                                                                                                                        def code(a, k, m):
                                                                                                                        	tmp = 0
                                                                                                                        	if m <= 2.35e+14:
                                                                                                                        		tmp = a
                                                                                                                        	else:
                                                                                                                        		tmp = (-10.0 * a) * k
                                                                                                                        	return tmp
                                                                                                                        
                                                                                                                        function code(a, k, m)
                                                                                                                        	tmp = 0.0
                                                                                                                        	if (m <= 2.35e+14)
                                                                                                                        		tmp = a;
                                                                                                                        	else
                                                                                                                        		tmp = Float64(Float64(-10.0 * a) * k);
                                                                                                                        	end
                                                                                                                        	return tmp
                                                                                                                        end
                                                                                                                        
                                                                                                                        function tmp_2 = code(a, k, m)
                                                                                                                        	tmp = 0.0;
                                                                                                                        	if (m <= 2.35e+14)
                                                                                                                        		tmp = a;
                                                                                                                        	else
                                                                                                                        		tmp = (-10.0 * a) * k;
                                                                                                                        	end
                                                                                                                        	tmp_2 = tmp;
                                                                                                                        end
                                                                                                                        
                                                                                                                        code[a_, k_, m_] := If[LessEqual[m, 2.35e+14], a, N[(N[(-10.0 * a), $MachinePrecision] * k), $MachinePrecision]]
                                                                                                                        
                                                                                                                        \begin{array}{l}
                                                                                                                        
                                                                                                                        \\
                                                                                                                        \begin{array}{l}
                                                                                                                        \mathbf{if}\;m \leq 2.35 \cdot 10^{+14}:\\
                                                                                                                        \;\;\;\;a\\
                                                                                                                        
                                                                                                                        \mathbf{else}:\\
                                                                                                                        \;\;\;\;\left(-10 \cdot a\right) \cdot k\\
                                                                                                                        
                                                                                                                        
                                                                                                                        \end{array}
                                                                                                                        \end{array}
                                                                                                                        
                                                                                                                        Derivation
                                                                                                                        1. Split input into 2 regimes
                                                                                                                        2. if m < 2.35e14

                                                                                                                          1. Initial program 97.2%

                                                                                                                            \[\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. Applied rewrites62.1%

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

                                                                                                                              \[\leadsto a \]
                                                                                                                            3. Step-by-step derivation
                                                                                                                              1. Applied rewrites23.1%

                                                                                                                                \[\leadsto a \]

                                                                                                                              if 2.35e14 < m

                                                                                                                              1. Initial program 72.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. Applied rewrites3.1%

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

                                                                                                                                  \[\leadsto a \]
                                                                                                                                3. Step-by-step derivation
                                                                                                                                  1. Applied rewrites4.0%

                                                                                                                                    \[\leadsto a \]
                                                                                                                                  2. Taylor expanded in k around 0

                                                                                                                                    \[\leadsto a + \color{blue}{-10 \cdot \left(a \cdot k\right)} \]
                                                                                                                                  3. Step-by-step derivation
                                                                                                                                    1. Applied rewrites12.7%

                                                                                                                                      \[\leadsto \mathsf{fma}\left(k \cdot a, \color{blue}{-10}, a\right) \]
                                                                                                                                    2. Taylor expanded in k around inf

                                                                                                                                      \[\leadsto -10 \cdot \left(a \cdot \color{blue}{k}\right) \]
                                                                                                                                    3. Step-by-step derivation
                                                                                                                                      1. Applied rewrites26.8%

                                                                                                                                        \[\leadsto \left(-10 \cdot a\right) \cdot k \]
                                                                                                                                    4. Recombined 2 regimes into one program.
                                                                                                                                    5. Add Preprocessing

                                                                                                                                    Alternative 13: 19.8% accurate, 134.0× speedup?

                                                                                                                                    \[\begin{array}{l} \\ a \end{array} \]
                                                                                                                                    (FPCore (a k m) :precision binary64 a)
                                                                                                                                    double code(double a, double k, double m) {
                                                                                                                                    	return a;
                                                                                                                                    }
                                                                                                                                    
                                                                                                                                    module fmin_fmax_functions
                                                                                                                                        implicit none
                                                                                                                                        private
                                                                                                                                        public fmax
                                                                                                                                        public fmin
                                                                                                                                    
                                                                                                                                        interface fmax
                                                                                                                                            module procedure fmax88
                                                                                                                                            module procedure fmax44
                                                                                                                                            module procedure fmax84
                                                                                                                                            module procedure fmax48
                                                                                                                                        end interface
                                                                                                                                        interface fmin
                                                                                                                                            module procedure fmin88
                                                                                                                                            module procedure fmin44
                                                                                                                                            module procedure fmin84
                                                                                                                                            module procedure fmin48
                                                                                                                                        end interface
                                                                                                                                    contains
                                                                                                                                        real(8) function fmax88(x, y) result (res)
                                                                                                                                            real(8), intent (in) :: x
                                                                                                                                            real(8), intent (in) :: y
                                                                                                                                            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                                                                                                        end function
                                                                                                                                        real(4) function fmax44(x, y) result (res)
                                                                                                                                            real(4), intent (in) :: x
                                                                                                                                            real(4), intent (in) :: y
                                                                                                                                            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                                                                                                        end function
                                                                                                                                        real(8) function fmax84(x, y) result(res)
                                                                                                                                            real(8), intent (in) :: x
                                                                                                                                            real(4), intent (in) :: y
                                                                                                                                            res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                                                                                                                        end function
                                                                                                                                        real(8) function fmax48(x, y) result(res)
                                                                                                                                            real(4), intent (in) :: x
                                                                                                                                            real(8), intent (in) :: y
                                                                                                                                            res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                                                                                                                        end function
                                                                                                                                        real(8) function fmin88(x, y) result (res)
                                                                                                                                            real(8), intent (in) :: x
                                                                                                                                            real(8), intent (in) :: y
                                                                                                                                            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                                                                                                        end function
                                                                                                                                        real(4) function fmin44(x, y) result (res)
                                                                                                                                            real(4), intent (in) :: x
                                                                                                                                            real(4), intent (in) :: y
                                                                                                                                            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                                                                                                        end function
                                                                                                                                        real(8) function fmin84(x, y) result(res)
                                                                                                                                            real(8), intent (in) :: x
                                                                                                                                            real(4), intent (in) :: y
                                                                                                                                            res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                                                                                                                        end function
                                                                                                                                        real(8) function fmin48(x, y) result(res)
                                                                                                                                            real(4), intent (in) :: x
                                                                                                                                            real(8), intent (in) :: y
                                                                                                                                            res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                                                                                                                        end function
                                                                                                                                    end module
                                                                                                                                    
                                                                                                                                    real(8) function code(a, k, m)
                                                                                                                                    use fmin_fmax_functions
                                                                                                                                        real(8), intent (in) :: a
                                                                                                                                        real(8), intent (in) :: k
                                                                                                                                        real(8), intent (in) :: m
                                                                                                                                        code = a
                                                                                                                                    end function
                                                                                                                                    
                                                                                                                                    public static double code(double a, double k, double m) {
                                                                                                                                    	return a;
                                                                                                                                    }
                                                                                                                                    
                                                                                                                                    def code(a, k, m):
                                                                                                                                    	return a
                                                                                                                                    
                                                                                                                                    function code(a, k, m)
                                                                                                                                    	return a
                                                                                                                                    end
                                                                                                                                    
                                                                                                                                    function tmp = code(a, k, m)
                                                                                                                                    	tmp = a;
                                                                                                                                    end
                                                                                                                                    
                                                                                                                                    code[a_, k_, m_] := a
                                                                                                                                    
                                                                                                                                    \begin{array}{l}
                                                                                                                                    
                                                                                                                                    \\
                                                                                                                                    a
                                                                                                                                    \end{array}
                                                                                                                                    
                                                                                                                                    Derivation
                                                                                                                                    1. Initial program 89.5%

                                                                                                                                      \[\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. Applied rewrites43.5%

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

                                                                                                                                        \[\leadsto a \]
                                                                                                                                      3. Step-by-step derivation
                                                                                                                                        1. Applied rewrites17.1%

                                                                                                                                          \[\leadsto a \]
                                                                                                                                        2. Add Preprocessing

                                                                                                                                        Reproduce

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