Falkner and Boettcher, Appendix A

Percentage Accurate: 91.0% → 97.5%
Time: 5.7s
Alternatives: 12
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 12 alternatives:

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

Initial Program: 91.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \end{array} \]
(FPCore (a k m)
 :precision binary64
 (/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))
double code(double a, double k, double m) {
	return (a * pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
}
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: 97.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq 2.2 \cdot 10^{-9}:\\ \;\;\;\;a \cdot \frac{{k}^{m}}{\left(10 + k\right) \cdot k + 1}\\ \mathbf{else}:\\ \;\;\;\;{k}^{m} \cdot a\\ \end{array} \end{array} \]
(FPCore (a k m)
 :precision binary64
 (if (<= m 2.2e-9)
   (* a (/ (pow k m) (+ (* (+ 10.0 k) k) 1.0)))
   (* (pow k m) a)))
double code(double a, double k, double m) {
	double tmp;
	if (m <= 2.2e-9) {
		tmp = a * (pow(k, m) / (((10.0 + k) * k) + 1.0));
	} else {
		tmp = pow(k, m) * a;
	}
	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.2d-9) then
        tmp = a * ((k ** m) / (((10.0d0 + k) * k) + 1.0d0))
    else
        tmp = (k ** m) * a
    end if
    code = tmp
end function
public static double code(double a, double k, double m) {
	double tmp;
	if (m <= 2.2e-9) {
		tmp = a * (Math.pow(k, m) / (((10.0 + k) * k) + 1.0));
	} else {
		tmp = Math.pow(k, m) * a;
	}
	return tmp;
}
def code(a, k, m):
	tmp = 0
	if m <= 2.2e-9:
		tmp = a * (math.pow(k, m) / (((10.0 + k) * k) + 1.0))
	else:
		tmp = math.pow(k, m) * a
	return tmp
function code(a, k, m)
	tmp = 0.0
	if (m <= 2.2e-9)
		tmp = Float64(a * Float64((k ^ m) / Float64(Float64(Float64(10.0 + k) * k) + 1.0)));
	else
		tmp = Float64((k ^ m) * a);
	end
	return tmp
end
function tmp_2 = code(a, k, m)
	tmp = 0.0;
	if (m <= 2.2e-9)
		tmp = a * ((k ^ m) / (((10.0 + k) * k) + 1.0));
	else
		tmp = (k ^ m) * a;
	end
	tmp_2 = tmp;
end
code[a_, k_, m_] := If[LessEqual[m, 2.2e-9], N[(a * N[(N[Power[k, m], $MachinePrecision] / N[(N[(N[(10.0 + k), $MachinePrecision] * k), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;m \leq 2.2 \cdot 10^{-9}:\\
\;\;\;\;a \cdot \frac{{k}^{m}}{\left(10 + k\right) \cdot k + 1}\\

\mathbf{else}:\\
\;\;\;\;{k}^{m} \cdot a\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if m < 2.1999999999999998e-9

    1. Initial program 99.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.1999999999999998e-9 < m

    1. Initial program 75.3%

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

        \[\leadsto {k}^{m} \cdot \color{blue}{a} \]
      2. lower-*.f64N/A

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

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

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

Alternative 2: 97.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq -2 \cdot 10^{-17}:\\ \;\;\;\;\frac{a \cdot {k}^{m}}{10 \cdot k + 1}\\ \mathbf{elif}\;m \leq 2 \cdot 10^{-9}:\\ \;\;\;\;\frac{a}{\left(\left(\frac{10}{k} + 1\right) \cdot k\right) \cdot k + 1}\\ \mathbf{else}:\\ \;\;\;\;{k}^{m} \cdot a\\ \end{array} \end{array} \]
(FPCore (a k m)
 :precision binary64
 (if (<= m -2e-17)
   (/ (* a (pow k m)) (+ (* 10.0 k) 1.0))
   (if (<= m 2e-9)
     (/ a (+ (* (* (+ (/ 10.0 k) 1.0) k) k) 1.0))
     (* (pow k m) a))))
double code(double a, double k, double m) {
	double tmp;
	if (m <= -2e-17) {
		tmp = (a * pow(k, m)) / ((10.0 * k) + 1.0);
	} else if (m <= 2e-9) {
		tmp = a / (((((10.0 / k) + 1.0) * k) * k) + 1.0);
	} else {
		tmp = pow(k, m) * a;
	}
	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 <= (-2d-17)) then
        tmp = (a * (k ** m)) / ((10.0d0 * k) + 1.0d0)
    else if (m <= 2d-9) then
        tmp = a / (((((10.0d0 / k) + 1.0d0) * k) * k) + 1.0d0)
    else
        tmp = (k ** m) * a
    end if
    code = tmp
end function
public static double code(double a, double k, double m) {
	double tmp;
	if (m <= -2e-17) {
		tmp = (a * Math.pow(k, m)) / ((10.0 * k) + 1.0);
	} else if (m <= 2e-9) {
		tmp = a / (((((10.0 / k) + 1.0) * k) * k) + 1.0);
	} else {
		tmp = Math.pow(k, m) * a;
	}
	return tmp;
}
def code(a, k, m):
	tmp = 0
	if m <= -2e-17:
		tmp = (a * math.pow(k, m)) / ((10.0 * k) + 1.0)
	elif m <= 2e-9:
		tmp = a / (((((10.0 / k) + 1.0) * k) * k) + 1.0)
	else:
		tmp = math.pow(k, m) * a
	return tmp
function code(a, k, m)
	tmp = 0.0
	if (m <= -2e-17)
		tmp = Float64(Float64(a * (k ^ m)) / Float64(Float64(10.0 * k) + 1.0));
	elseif (m <= 2e-9)
		tmp = Float64(a / Float64(Float64(Float64(Float64(Float64(10.0 / k) + 1.0) * k) * k) + 1.0));
	else
		tmp = Float64((k ^ m) * a);
	end
	return tmp
end
function tmp_2 = code(a, k, m)
	tmp = 0.0;
	if (m <= -2e-17)
		tmp = (a * (k ^ m)) / ((10.0 * k) + 1.0);
	elseif (m <= 2e-9)
		tmp = a / (((((10.0 / k) + 1.0) * k) * k) + 1.0);
	else
		tmp = (k ^ m) * a;
	end
	tmp_2 = tmp;
end
code[a_, k_, m_] := If[LessEqual[m, -2e-17], N[(N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision] / N[(N[(10.0 * k), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 2e-9], N[(a / N[(N[(N[(N[(N[(10.0 / k), $MachinePrecision] + 1.0), $MachinePrecision] * k), $MachinePrecision] * k), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;m \leq -2 \cdot 10^{-17}:\\
\;\;\;\;\frac{a \cdot {k}^{m}}{10 \cdot k + 1}\\

\mathbf{elif}\;m \leq 2 \cdot 10^{-9}:\\
\;\;\;\;\frac{a}{\left(\left(\frac{10}{k} + 1\right) \cdot k\right) \cdot k + 1}\\

\mathbf{else}:\\
\;\;\;\;{k}^{m} \cdot a\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if m < -2.00000000000000014e-17

    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 k around 0

      \[\leadsto \frac{a \cdot {k}^{m}}{\color{blue}{1 + 10 \cdot k}} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

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

        \[\leadsto \frac{a \cdot {k}^{m}}{10 \cdot k + \color{blue}{1}} \]
      3. lift-*.f64100.0

        \[\leadsto \frac{a \cdot {k}^{m}}{10 \cdot k + 1} \]
    5. Applied rewrites100.0%

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

    if -2.00000000000000014e-17 < m < 2.00000000000000012e-9

    1. Initial program 98.6%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{a}{\left(10 + k\right) \cdot k + 1} \]
      8. lower-+.f6497.5

        \[\leadsto \frac{a}{\left(10 + k\right) \cdot k + 1} \]
    5. Applied rewrites97.5%

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

      \[\leadsto \frac{a}{\left(k \cdot \left(1 + 10 \cdot \frac{1}{k}\right)\right) \cdot k + 1} \]
    7. Step-by-step derivation
      1. *-commutativeN/A

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

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

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

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

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

        \[\leadsto \frac{a}{\left(\left(\frac{10}{k} + 1\right) \cdot k\right) \cdot k + 1} \]
      7. lower-/.f6497.5

        \[\leadsto \frac{a}{\left(\left(\frac{10}{k} + 1\right) \cdot k\right) \cdot k + 1} \]
    8. Applied rewrites97.5%

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

    if 2.00000000000000012e-9 < m

    1. Initial program 75.3%

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

        \[\leadsto {k}^{m} \cdot \color{blue}{a} \]
      2. lower-*.f64N/A

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

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

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

Alternative 3: 97.1% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq -1.05 \cdot 10^{-6} \lor \neg \left(m \leq 2 \cdot 10^{-9}\right):\\ \;\;\;\;{k}^{m} \cdot a\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{\left(\left(\frac{10}{k} + 1\right) \cdot k\right) \cdot k + 1}\\ \end{array} \end{array} \]
(FPCore (a k m)
 :precision binary64
 (if (or (<= m -1.05e-6) (not (<= m 2e-9)))
   (* (pow k m) a)
   (/ a (+ (* (* (+ (/ 10.0 k) 1.0) k) k) 1.0))))
double code(double a, double k, double m) {
	double tmp;
	if ((m <= -1.05e-6) || !(m <= 2e-9)) {
		tmp = pow(k, m) * a;
	} else {
		tmp = a / (((((10.0 / k) + 1.0) * k) * k) + 1.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.05d-6)) .or. (.not. (m <= 2d-9))) then
        tmp = (k ** m) * a
    else
        tmp = a / (((((10.0d0 / k) + 1.0d0) * k) * k) + 1.0d0)
    end if
    code = tmp
end function
public static double code(double a, double k, double m) {
	double tmp;
	if ((m <= -1.05e-6) || !(m <= 2e-9)) {
		tmp = Math.pow(k, m) * a;
	} else {
		tmp = a / (((((10.0 / k) + 1.0) * k) * k) + 1.0);
	}
	return tmp;
}
def code(a, k, m):
	tmp = 0
	if (m <= -1.05e-6) or not (m <= 2e-9):
		tmp = math.pow(k, m) * a
	else:
		tmp = a / (((((10.0 / k) + 1.0) * k) * k) + 1.0)
	return tmp
function code(a, k, m)
	tmp = 0.0
	if ((m <= -1.05e-6) || !(m <= 2e-9))
		tmp = Float64((k ^ m) * a);
	else
		tmp = Float64(a / Float64(Float64(Float64(Float64(Float64(10.0 / k) + 1.0) * k) * k) + 1.0));
	end
	return tmp
end
function tmp_2 = code(a, k, m)
	tmp = 0.0;
	if ((m <= -1.05e-6) || ~((m <= 2e-9)))
		tmp = (k ^ m) * a;
	else
		tmp = a / (((((10.0 / k) + 1.0) * k) * k) + 1.0);
	end
	tmp_2 = tmp;
end
code[a_, k_, m_] := If[Or[LessEqual[m, -1.05e-6], N[Not[LessEqual[m, 2e-9]], $MachinePrecision]], N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision], N[(a / N[(N[(N[(N[(N[(10.0 / k), $MachinePrecision] + 1.0), $MachinePrecision] * k), $MachinePrecision] * k), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;m \leq -1.05 \cdot 10^{-6} \lor \neg \left(m \leq 2 \cdot 10^{-9}\right):\\
\;\;\;\;{k}^{m} \cdot a\\

\mathbf{else}:\\
\;\;\;\;\frac{a}{\left(\left(\frac{10}{k} + 1\right) \cdot k\right) \cdot k + 1}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if m < -1.0499999999999999e-6 or 2.00000000000000012e-9 < m

    1. Initial program 87.9%

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

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

        \[\leadsto {k}^{m} \cdot \color{blue}{a} \]
      2. lower-*.f64N/A

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

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

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

    if -1.0499999999999999e-6 < m < 2.00000000000000012e-9

    1. Initial program 98.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. lower-/.f64N/A

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

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

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

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

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

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

        \[\leadsto \frac{a}{\left(10 + k\right) \cdot k + 1} \]
      8. lower-+.f6497.0

        \[\leadsto \frac{a}{\left(10 + k\right) \cdot k + 1} \]
    5. Applied rewrites97.0%

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

      \[\leadsto \frac{a}{\left(k \cdot \left(1 + 10 \cdot \frac{1}{k}\right)\right) \cdot k + 1} \]
    7. Step-by-step derivation
      1. *-commutativeN/A

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

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

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

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

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

        \[\leadsto \frac{a}{\left(\left(\frac{10}{k} + 1\right) \cdot k\right) \cdot k + 1} \]
      7. lower-/.f6497.0

        \[\leadsto \frac{a}{\left(\left(\frac{10}{k} + 1\right) \cdot k\right) \cdot k + 1} \]
    8. Applied rewrites97.0%

      \[\leadsto \frac{a}{\left(\left(\frac{10}{k} + 1\right) \cdot k\right) \cdot k + 1} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;m \leq -1.05 \cdot 10^{-6} \lor \neg \left(m \leq 2 \cdot 10^{-9}\right):\\ \;\;\;\;{k}^{m} \cdot a\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{\left(\left(\frac{10}{k} + 1\right) \cdot k\right) \cdot k + 1}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 74.3% accurate, 2.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq -0.27:\\ \;\;\;\;\frac{\frac{99 \cdot \frac{a}{k} - 10 \cdot a}{k} + a}{k \cdot k}\\ \mathbf{elif}\;m \leq 1.2:\\ \;\;\;\;\frac{a}{\left(\left(\frac{10}{k} + 1\right) \cdot k\right) \cdot k + 1}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(k \cdot k\right) \cdot a\right) \cdot 99\\ \end{array} \end{array} \]
(FPCore (a k m)
 :precision binary64
 (if (<= m -0.27)
   (/ (+ (/ (- (* 99.0 (/ a k)) (* 10.0 a)) k) a) (* k k))
   (if (<= m 1.2)
     (/ a (+ (* (* (+ (/ 10.0 k) 1.0) k) k) 1.0))
     (* (* (* k k) a) 99.0))))
double code(double a, double k, double m) {
	double tmp;
	if (m <= -0.27) {
		tmp = ((((99.0 * (a / k)) - (10.0 * a)) / k) + a) / (k * k);
	} else if (m <= 1.2) {
		tmp = a / (((((10.0 / k) + 1.0) * k) * k) + 1.0);
	} else {
		tmp = ((k * k) * a) * 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.27d0)) then
        tmp = ((((99.0d0 * (a / k)) - (10.0d0 * a)) / k) + a) / (k * k)
    else if (m <= 1.2d0) then
        tmp = a / (((((10.0d0 / k) + 1.0d0) * k) * k) + 1.0d0)
    else
        tmp = ((k * k) * a) * 99.0d0
    end if
    code = tmp
end function
public static double code(double a, double k, double m) {
	double tmp;
	if (m <= -0.27) {
		tmp = ((((99.0 * (a / k)) - (10.0 * a)) / k) + a) / (k * k);
	} else if (m <= 1.2) {
		tmp = a / (((((10.0 / k) + 1.0) * k) * k) + 1.0);
	} else {
		tmp = ((k * k) * a) * 99.0;
	}
	return tmp;
}
def code(a, k, m):
	tmp = 0
	if m <= -0.27:
		tmp = ((((99.0 * (a / k)) - (10.0 * a)) / k) + a) / (k * k)
	elif m <= 1.2:
		tmp = a / (((((10.0 / k) + 1.0) * k) * k) + 1.0)
	else:
		tmp = ((k * k) * a) * 99.0
	return tmp
function code(a, k, m)
	tmp = 0.0
	if (m <= -0.27)
		tmp = Float64(Float64(Float64(Float64(Float64(99.0 * Float64(a / k)) - Float64(10.0 * a)) / k) + a) / Float64(k * k));
	elseif (m <= 1.2)
		tmp = Float64(a / Float64(Float64(Float64(Float64(Float64(10.0 / k) + 1.0) * k) * k) + 1.0));
	else
		tmp = Float64(Float64(Float64(k * k) * a) * 99.0);
	end
	return tmp
end
function tmp_2 = code(a, k, m)
	tmp = 0.0;
	if (m <= -0.27)
		tmp = ((((99.0 * (a / k)) - (10.0 * a)) / k) + a) / (k * k);
	elseif (m <= 1.2)
		tmp = a / (((((10.0 / k) + 1.0) * k) * k) + 1.0);
	else
		tmp = ((k * k) * a) * 99.0;
	end
	tmp_2 = tmp;
end
code[a_, k_, m_] := If[LessEqual[m, -0.27], N[(N[(N[(N[(N[(99.0 * N[(a / k), $MachinePrecision]), $MachinePrecision] - N[(10.0 * a), $MachinePrecision]), $MachinePrecision] / k), $MachinePrecision] + a), $MachinePrecision] / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1.2], N[(a / N[(N[(N[(N[(N[(10.0 / k), $MachinePrecision] + 1.0), $MachinePrecision] * k), $MachinePrecision] * k), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(k * k), $MachinePrecision] * a), $MachinePrecision] * 99.0), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.27:\\
\;\;\;\;\frac{\frac{99 \cdot \frac{a}{k} - 10 \cdot a}{k} + a}{k \cdot k}\\

\mathbf{elif}\;m \leq 1.2:\\
\;\;\;\;\frac{a}{\left(\left(\frac{10}{k} + 1\right) \cdot k\right) \cdot k + 1}\\

\mathbf{else}:\\
\;\;\;\;\left(\left(k \cdot k\right) \cdot a\right) \cdot 99\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if m < -0.27000000000000002

    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. lower-/.f64N/A

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

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

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

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

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

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

        \[\leadsto \frac{a}{\left(10 + k\right) \cdot k + 1} \]
      8. lower-+.f6438.7

        \[\leadsto \frac{a}{\left(10 + k\right) \cdot k + 1} \]
    5. Applied rewrites38.7%

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

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

        \[\leadsto \frac{a + -1 \cdot \frac{-1 \cdot \frac{\left(10 \cdot \frac{a}{k} + 10 \cdot \frac{a + -100 \cdot a}{k}\right) - \left(a + -100 \cdot a\right)}{k} - -10 \cdot a}{k}}{{k}^{\color{blue}{2}}} \]
    8. Applied rewrites48.6%

      \[\leadsto \frac{\left(-\frac{\left(-\frac{10 \cdot \left(\frac{a}{k} + -99 \cdot \frac{a}{k}\right) - -99 \cdot a}{k}\right) - -10 \cdot a}{k}\right) + a}{\color{blue}{k \cdot k}} \]
    9. Taylor expanded in k around inf

      \[\leadsto \frac{\frac{99 \cdot \frac{a}{k} - 10 \cdot a}{k} + a}{k \cdot k} \]
    10. Step-by-step derivation
      1. fp-cancel-sub-sign-invN/A

        \[\leadsto \frac{\frac{99 \cdot \frac{a}{k} + \left(\mathsf{neg}\left(10\right)\right) \cdot a}{k} + a}{k \cdot k} \]
      2. metadata-evalN/A

        \[\leadsto \frac{\frac{99 \cdot \frac{a}{k} + -10 \cdot a}{k} + a}{k \cdot k} \]
      3. +-commutativeN/A

        \[\leadsto \frac{\frac{-10 \cdot a + 99 \cdot \frac{a}{k}}{k} + a}{k \cdot k} \]
      4. lower-/.f64N/A

        \[\leadsto \frac{\frac{-10 \cdot a + 99 \cdot \frac{a}{k}}{k} + a}{k \cdot k} \]
      5. +-commutativeN/A

        \[\leadsto \frac{\frac{99 \cdot \frac{a}{k} + -10 \cdot a}{k} + a}{k \cdot k} \]
      6. metadata-evalN/A

        \[\leadsto \frac{\frac{99 \cdot \frac{a}{k} + \left(\mathsf{neg}\left(10\right)\right) \cdot a}{k} + a}{k \cdot k} \]
      7. fp-cancel-sub-sign-invN/A

        \[\leadsto \frac{\frac{99 \cdot \frac{a}{k} - 10 \cdot a}{k} + a}{k \cdot k} \]
      8. lower--.f64N/A

        \[\leadsto \frac{\frac{99 \cdot \frac{a}{k} - 10 \cdot a}{k} + a}{k \cdot k} \]
      9. lower-*.f64N/A

        \[\leadsto \frac{\frac{99 \cdot \frac{a}{k} - 10 \cdot a}{k} + a}{k \cdot k} \]
      10. lift-/.f64N/A

        \[\leadsto \frac{\frac{99 \cdot \frac{a}{k} - 10 \cdot a}{k} + a}{k \cdot k} \]
      11. lower-*.f6471.6

        \[\leadsto \frac{\frac{99 \cdot \frac{a}{k} - 10 \cdot a}{k} + a}{k \cdot k} \]
    11. Applied rewrites71.6%

      \[\leadsto \frac{\frac{99 \cdot \frac{a}{k} - 10 \cdot a}{k} + a}{k \cdot k} \]

    if -0.27000000000000002 < m < 1.19999999999999996

    1. Initial program 98.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. lower-/.f64N/A

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

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

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

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

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

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

        \[\leadsto \frac{a}{\left(10 + k\right) \cdot k + 1} \]
      8. lower-+.f6495.4

        \[\leadsto \frac{a}{\left(10 + k\right) \cdot k + 1} \]
    5. Applied rewrites95.4%

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

      \[\leadsto \frac{a}{\left(k \cdot \left(1 + 10 \cdot \frac{1}{k}\right)\right) \cdot k + 1} \]
    7. Step-by-step derivation
      1. *-commutativeN/A

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

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

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

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

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

        \[\leadsto \frac{a}{\left(\left(\frac{10}{k} + 1\right) \cdot k\right) \cdot k + 1} \]
      7. lower-/.f6495.4

        \[\leadsto \frac{a}{\left(\left(\frac{10}{k} + 1\right) \cdot k\right) \cdot k + 1} \]
    8. Applied rewrites95.4%

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

    if 1.19999999999999996 < m

    1. Initial program 75.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. lower-/.f64N/A

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

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

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

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

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

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

        \[\leadsto \frac{a}{\left(10 + k\right) \cdot k + 1} \]
      8. lower-+.f642.9

        \[\leadsto \frac{a}{\left(10 + k\right) \cdot k + 1} \]
    5. Applied rewrites2.9%

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

      \[\leadsto a \]
    7. Step-by-step derivation
      1. Applied rewrites3.8%

        \[\leadsto a \]
      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. +-commutativeN/A

          \[\leadsto k \cdot \left(-1 \cdot \left(k \cdot \left(a + -100 \cdot a\right)\right) - 10 \cdot a\right) + a \]
        2. lower-+.f64N/A

          \[\leadsto k \cdot \left(-1 \cdot \left(k \cdot \left(a + -100 \cdot a\right)\right) - 10 \cdot a\right) + a \]
        3. *-commutativeN/A

          \[\leadsto \left(-1 \cdot \left(k \cdot \left(a + -100 \cdot a\right)\right) - 10 \cdot a\right) \cdot k + a \]
        4. lower-*.f64N/A

          \[\leadsto \left(-1 \cdot \left(k \cdot \left(a + -100 \cdot a\right)\right) - 10 \cdot a\right) \cdot k + a \]
        5. lower--.f64N/A

          \[\leadsto \left(-1 \cdot \left(k \cdot \left(a + -100 \cdot a\right)\right) - 10 \cdot a\right) \cdot k + a \]
        6. mul-1-negN/A

          \[\leadsto \left(\left(\mathsf{neg}\left(k \cdot \left(a + -100 \cdot a\right)\right)\right) - 10 \cdot a\right) \cdot k + a \]
        7. distribute-rgt1-inN/A

          \[\leadsto \left(\left(\mathsf{neg}\left(k \cdot \left(\left(-100 + 1\right) \cdot a\right)\right)\right) - 10 \cdot a\right) \cdot k + a \]
        8. metadata-evalN/A

          \[\leadsto \left(\left(\mathsf{neg}\left(k \cdot \left(-99 \cdot a\right)\right)\right) - 10 \cdot a\right) \cdot k + a \]
        9. *-commutativeN/A

          \[\leadsto \left(\left(\mathsf{neg}\left(\left(-99 \cdot a\right) \cdot k\right)\right) - 10 \cdot a\right) \cdot k + a \]
        10. associate-*r*N/A

          \[\leadsto \left(\left(\mathsf{neg}\left(-99 \cdot \left(a \cdot k\right)\right)\right) - 10 \cdot a\right) \cdot k + a \]
        11. lower-neg.f64N/A

          \[\leadsto \left(\left(--99 \cdot \left(a \cdot k\right)\right) - 10 \cdot a\right) \cdot k + a \]
        12. *-commutativeN/A

          \[\leadsto \left(\left(-\left(a \cdot k\right) \cdot -99\right) - 10 \cdot a\right) \cdot k + a \]
        13. lower-*.f64N/A

          \[\leadsto \left(\left(-\left(a \cdot k\right) \cdot -99\right) - 10 \cdot a\right) \cdot k + a \]
        14. *-commutativeN/A

          \[\leadsto \left(\left(-\left(k \cdot a\right) \cdot -99\right) - 10 \cdot a\right) \cdot k + a \]
        15. lower-*.f64N/A

          \[\leadsto \left(\left(-\left(k \cdot a\right) \cdot -99\right) - 10 \cdot a\right) \cdot k + a \]
        16. lower-*.f6428.3

          \[\leadsto \left(\left(-\left(k \cdot a\right) \cdot -99\right) - 10 \cdot a\right) \cdot k + a \]
      4. Applied rewrites28.3%

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

        \[\leadsto 99 \cdot \left(a \cdot \color{blue}{{k}^{2}}\right) \]
      6. Step-by-step derivation
        1. *-commutativeN/A

          \[\leadsto \left(a \cdot {k}^{2}\right) \cdot 99 \]
        2. lower-*.f64N/A

          \[\leadsto \left(a \cdot {k}^{2}\right) \cdot 99 \]
        3. *-commutativeN/A

          \[\leadsto \left({k}^{2} \cdot a\right) \cdot 99 \]
        4. lower-*.f64N/A

          \[\leadsto \left({k}^{2} \cdot a\right) \cdot 99 \]
        5. pow2N/A

          \[\leadsto \left(\left(k \cdot k\right) \cdot a\right) \cdot 99 \]
        6. lift-*.f6464.7

          \[\leadsto \left(\left(k \cdot k\right) \cdot a\right) \cdot 99 \]
      7. Applied rewrites64.7%

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

    Alternative 5: 72.4% accurate, 2.6× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq -0.27:\\ \;\;\;\;\frac{a}{k \cdot k}\\ \mathbf{elif}\;m \leq 1.2:\\ \;\;\;\;\frac{a}{\left(\left(\frac{10}{k} + 1\right) \cdot k\right) \cdot k + 1}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(k \cdot k\right) \cdot a\right) \cdot 99\\ \end{array} \end{array} \]
    (FPCore (a k m)
     :precision binary64
     (if (<= m -0.27)
       (/ a (* k k))
       (if (<= m 1.2)
         (/ a (+ (* (* (+ (/ 10.0 k) 1.0) k) k) 1.0))
         (* (* (* k k) a) 99.0))))
    double code(double a, double k, double m) {
    	double tmp;
    	if (m <= -0.27) {
    		tmp = a / (k * k);
    	} else if (m <= 1.2) {
    		tmp = a / (((((10.0 / k) + 1.0) * k) * k) + 1.0);
    	} else {
    		tmp = ((k * k) * a) * 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.27d0)) then
            tmp = a / (k * k)
        else if (m <= 1.2d0) then
            tmp = a / (((((10.0d0 / k) + 1.0d0) * k) * k) + 1.0d0)
        else
            tmp = ((k * k) * a) * 99.0d0
        end if
        code = tmp
    end function
    
    public static double code(double a, double k, double m) {
    	double tmp;
    	if (m <= -0.27) {
    		tmp = a / (k * k);
    	} else if (m <= 1.2) {
    		tmp = a / (((((10.0 / k) + 1.0) * k) * k) + 1.0);
    	} else {
    		tmp = ((k * k) * a) * 99.0;
    	}
    	return tmp;
    }
    
    def code(a, k, m):
    	tmp = 0
    	if m <= -0.27:
    		tmp = a / (k * k)
    	elif m <= 1.2:
    		tmp = a / (((((10.0 / k) + 1.0) * k) * k) + 1.0)
    	else:
    		tmp = ((k * k) * a) * 99.0
    	return tmp
    
    function code(a, k, m)
    	tmp = 0.0
    	if (m <= -0.27)
    		tmp = Float64(a / Float64(k * k));
    	elseif (m <= 1.2)
    		tmp = Float64(a / Float64(Float64(Float64(Float64(Float64(10.0 / k) + 1.0) * k) * k) + 1.0));
    	else
    		tmp = Float64(Float64(Float64(k * k) * a) * 99.0);
    	end
    	return tmp
    end
    
    function tmp_2 = code(a, k, m)
    	tmp = 0.0;
    	if (m <= -0.27)
    		tmp = a / (k * k);
    	elseif (m <= 1.2)
    		tmp = a / (((((10.0 / k) + 1.0) * k) * k) + 1.0);
    	else
    		tmp = ((k * k) * a) * 99.0;
    	end
    	tmp_2 = tmp;
    end
    
    code[a_, k_, m_] := If[LessEqual[m, -0.27], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1.2], N[(a / N[(N[(N[(N[(N[(10.0 / k), $MachinePrecision] + 1.0), $MachinePrecision] * k), $MachinePrecision] * k), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(k * k), $MachinePrecision] * a), $MachinePrecision] * 99.0), $MachinePrecision]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;m \leq -0.27:\\
    \;\;\;\;\frac{a}{k \cdot k}\\
    
    \mathbf{elif}\;m \leq 1.2:\\
    \;\;\;\;\frac{a}{\left(\left(\frac{10}{k} + 1\right) \cdot k\right) \cdot k + 1}\\
    
    \mathbf{else}:\\
    \;\;\;\;\left(\left(k \cdot k\right) \cdot a\right) \cdot 99\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if m < -0.27000000000000002

      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 k around inf

        \[\leadsto \frac{a \cdot {k}^{m}}{\color{blue}{{k}^{2}}} \]
      4. Step-by-step derivation
        1. pow2N/A

          \[\leadsto \frac{a \cdot {k}^{m}}{k \cdot \color{blue}{k}} \]
        2. lift-*.f64100.0

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

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

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

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

        if -0.27000000000000002 < m < 1.19999999999999996

        1. Initial program 98.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. lower-/.f64N/A

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

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

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

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

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

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

            \[\leadsto \frac{a}{\left(10 + k\right) \cdot k + 1} \]
          8. lower-+.f6495.4

            \[\leadsto \frac{a}{\left(10 + k\right) \cdot k + 1} \]
        5. Applied rewrites95.4%

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

          \[\leadsto \frac{a}{\left(k \cdot \left(1 + 10 \cdot \frac{1}{k}\right)\right) \cdot k + 1} \]
        7. Step-by-step derivation
          1. *-commutativeN/A

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

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

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

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

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

            \[\leadsto \frac{a}{\left(\left(\frac{10}{k} + 1\right) \cdot k\right) \cdot k + 1} \]
          7. lower-/.f6495.4

            \[\leadsto \frac{a}{\left(\left(\frac{10}{k} + 1\right) \cdot k\right) \cdot k + 1} \]
        8. Applied rewrites95.4%

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

        if 1.19999999999999996 < m

        1. Initial program 75.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. lower-/.f64N/A

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

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

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

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

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

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

            \[\leadsto \frac{a}{\left(10 + k\right) \cdot k + 1} \]
          8. lower-+.f642.9

            \[\leadsto \frac{a}{\left(10 + k\right) \cdot k + 1} \]
        5. Applied rewrites2.9%

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

          \[\leadsto a \]
        7. Step-by-step derivation
          1. Applied rewrites3.8%

            \[\leadsto a \]
          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. +-commutativeN/A

              \[\leadsto k \cdot \left(-1 \cdot \left(k \cdot \left(a + -100 \cdot a\right)\right) - 10 \cdot a\right) + a \]
            2. lower-+.f64N/A

              \[\leadsto k \cdot \left(-1 \cdot \left(k \cdot \left(a + -100 \cdot a\right)\right) - 10 \cdot a\right) + a \]
            3. *-commutativeN/A

              \[\leadsto \left(-1 \cdot \left(k \cdot \left(a + -100 \cdot a\right)\right) - 10 \cdot a\right) \cdot k + a \]
            4. lower-*.f64N/A

              \[\leadsto \left(-1 \cdot \left(k \cdot \left(a + -100 \cdot a\right)\right) - 10 \cdot a\right) \cdot k + a \]
            5. lower--.f64N/A

              \[\leadsto \left(-1 \cdot \left(k \cdot \left(a + -100 \cdot a\right)\right) - 10 \cdot a\right) \cdot k + a \]
            6. mul-1-negN/A

              \[\leadsto \left(\left(\mathsf{neg}\left(k \cdot \left(a + -100 \cdot a\right)\right)\right) - 10 \cdot a\right) \cdot k + a \]
            7. distribute-rgt1-inN/A

              \[\leadsto \left(\left(\mathsf{neg}\left(k \cdot \left(\left(-100 + 1\right) \cdot a\right)\right)\right) - 10 \cdot a\right) \cdot k + a \]
            8. metadata-evalN/A

              \[\leadsto \left(\left(\mathsf{neg}\left(k \cdot \left(-99 \cdot a\right)\right)\right) - 10 \cdot a\right) \cdot k + a \]
            9. *-commutativeN/A

              \[\leadsto \left(\left(\mathsf{neg}\left(\left(-99 \cdot a\right) \cdot k\right)\right) - 10 \cdot a\right) \cdot k + a \]
            10. associate-*r*N/A

              \[\leadsto \left(\left(\mathsf{neg}\left(-99 \cdot \left(a \cdot k\right)\right)\right) - 10 \cdot a\right) \cdot k + a \]
            11. lower-neg.f64N/A

              \[\leadsto \left(\left(--99 \cdot \left(a \cdot k\right)\right) - 10 \cdot a\right) \cdot k + a \]
            12. *-commutativeN/A

              \[\leadsto \left(\left(-\left(a \cdot k\right) \cdot -99\right) - 10 \cdot a\right) \cdot k + a \]
            13. lower-*.f64N/A

              \[\leadsto \left(\left(-\left(a \cdot k\right) \cdot -99\right) - 10 \cdot a\right) \cdot k + a \]
            14. *-commutativeN/A

              \[\leadsto \left(\left(-\left(k \cdot a\right) \cdot -99\right) - 10 \cdot a\right) \cdot k + a \]
            15. lower-*.f64N/A

              \[\leadsto \left(\left(-\left(k \cdot a\right) \cdot -99\right) - 10 \cdot a\right) \cdot k + a \]
            16. lower-*.f6428.3

              \[\leadsto \left(\left(-\left(k \cdot a\right) \cdot -99\right) - 10 \cdot a\right) \cdot k + a \]
          4. Applied rewrites28.3%

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

            \[\leadsto 99 \cdot \left(a \cdot \color{blue}{{k}^{2}}\right) \]
          6. Step-by-step derivation
            1. *-commutativeN/A

              \[\leadsto \left(a \cdot {k}^{2}\right) \cdot 99 \]
            2. lower-*.f64N/A

              \[\leadsto \left(a \cdot {k}^{2}\right) \cdot 99 \]
            3. *-commutativeN/A

              \[\leadsto \left({k}^{2} \cdot a\right) \cdot 99 \]
            4. lower-*.f64N/A

              \[\leadsto \left({k}^{2} \cdot a\right) \cdot 99 \]
            5. pow2N/A

              \[\leadsto \left(\left(k \cdot k\right) \cdot a\right) \cdot 99 \]
            6. lift-*.f6464.7

              \[\leadsto \left(\left(k \cdot k\right) \cdot a\right) \cdot 99 \]
          7. Applied rewrites64.7%

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

        Alternative 6: 72.4% accurate, 3.8× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq -0.27:\\ \;\;\;\;\frac{a}{k \cdot k}\\ \mathbf{elif}\;m \leq 1.2:\\ \;\;\;\;\frac{a}{\left(10 + k\right) \cdot k + 1}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(k \cdot k\right) \cdot a\right) \cdot 99\\ \end{array} \end{array} \]
        (FPCore (a k m)
         :precision binary64
         (if (<= m -0.27)
           (/ a (* k k))
           (if (<= m 1.2) (/ a (+ (* (+ 10.0 k) k) 1.0)) (* (* (* k k) a) 99.0))))
        double code(double a, double k, double m) {
        	double tmp;
        	if (m <= -0.27) {
        		tmp = a / (k * k);
        	} else if (m <= 1.2) {
        		tmp = a / (((10.0 + k) * k) + 1.0);
        	} else {
        		tmp = ((k * k) * a) * 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.27d0)) then
                tmp = a / (k * k)
            else if (m <= 1.2d0) then
                tmp = a / (((10.0d0 + k) * k) + 1.0d0)
            else
                tmp = ((k * k) * a) * 99.0d0
            end if
            code = tmp
        end function
        
        public static double code(double a, double k, double m) {
        	double tmp;
        	if (m <= -0.27) {
        		tmp = a / (k * k);
        	} else if (m <= 1.2) {
        		tmp = a / (((10.0 + k) * k) + 1.0);
        	} else {
        		tmp = ((k * k) * a) * 99.0;
        	}
        	return tmp;
        }
        
        def code(a, k, m):
        	tmp = 0
        	if m <= -0.27:
        		tmp = a / (k * k)
        	elif m <= 1.2:
        		tmp = a / (((10.0 + k) * k) + 1.0)
        	else:
        		tmp = ((k * k) * a) * 99.0
        	return tmp
        
        function code(a, k, m)
        	tmp = 0.0
        	if (m <= -0.27)
        		tmp = Float64(a / Float64(k * k));
        	elseif (m <= 1.2)
        		tmp = Float64(a / Float64(Float64(Float64(10.0 + k) * k) + 1.0));
        	else
        		tmp = Float64(Float64(Float64(k * k) * a) * 99.0);
        	end
        	return tmp
        end
        
        function tmp_2 = code(a, k, m)
        	tmp = 0.0;
        	if (m <= -0.27)
        		tmp = a / (k * k);
        	elseif (m <= 1.2)
        		tmp = a / (((10.0 + k) * k) + 1.0);
        	else
        		tmp = ((k * k) * a) * 99.0;
        	end
        	tmp_2 = tmp;
        end
        
        code[a_, k_, m_] := If[LessEqual[m, -0.27], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1.2], N[(a / N[(N[(N[(10.0 + k), $MachinePrecision] * k), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(k * k), $MachinePrecision] * a), $MachinePrecision] * 99.0), $MachinePrecision]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;m \leq -0.27:\\
        \;\;\;\;\frac{a}{k \cdot k}\\
        
        \mathbf{elif}\;m \leq 1.2:\\
        \;\;\;\;\frac{a}{\left(10 + k\right) \cdot k + 1}\\
        
        \mathbf{else}:\\
        \;\;\;\;\left(\left(k \cdot k\right) \cdot a\right) \cdot 99\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if m < -0.27000000000000002

          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 k around inf

            \[\leadsto \frac{a \cdot {k}^{m}}{\color{blue}{{k}^{2}}} \]
          4. Step-by-step derivation
            1. pow2N/A

              \[\leadsto \frac{a \cdot {k}^{m}}{k \cdot \color{blue}{k}} \]
            2. lift-*.f64100.0

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

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

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

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

            if -0.27000000000000002 < m < 1.19999999999999996

            1. Initial program 98.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. lower-/.f64N/A

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

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

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

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

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

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

                \[\leadsto \frac{a}{\left(10 + k\right) \cdot k + 1} \]
              8. lower-+.f6495.4

                \[\leadsto \frac{a}{\left(10 + k\right) \cdot k + 1} \]
            5. Applied rewrites95.4%

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

            if 1.19999999999999996 < m

            1. Initial program 75.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. lower-/.f64N/A

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

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

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

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

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

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

                \[\leadsto \frac{a}{\left(10 + k\right) \cdot k + 1} \]
              8. lower-+.f642.9

                \[\leadsto \frac{a}{\left(10 + k\right) \cdot k + 1} \]
            5. Applied rewrites2.9%

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

              \[\leadsto a \]
            7. Step-by-step derivation
              1. Applied rewrites3.8%

                \[\leadsto a \]
              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. +-commutativeN/A

                  \[\leadsto k \cdot \left(-1 \cdot \left(k \cdot \left(a + -100 \cdot a\right)\right) - 10 \cdot a\right) + a \]
                2. lower-+.f64N/A

                  \[\leadsto k \cdot \left(-1 \cdot \left(k \cdot \left(a + -100 \cdot a\right)\right) - 10 \cdot a\right) + a \]
                3. *-commutativeN/A

                  \[\leadsto \left(-1 \cdot \left(k \cdot \left(a + -100 \cdot a\right)\right) - 10 \cdot a\right) \cdot k + a \]
                4. lower-*.f64N/A

                  \[\leadsto \left(-1 \cdot \left(k \cdot \left(a + -100 \cdot a\right)\right) - 10 \cdot a\right) \cdot k + a \]
                5. lower--.f64N/A

                  \[\leadsto \left(-1 \cdot \left(k \cdot \left(a + -100 \cdot a\right)\right) - 10 \cdot a\right) \cdot k + a \]
                6. mul-1-negN/A

                  \[\leadsto \left(\left(\mathsf{neg}\left(k \cdot \left(a + -100 \cdot a\right)\right)\right) - 10 \cdot a\right) \cdot k + a \]
                7. distribute-rgt1-inN/A

                  \[\leadsto \left(\left(\mathsf{neg}\left(k \cdot \left(\left(-100 + 1\right) \cdot a\right)\right)\right) - 10 \cdot a\right) \cdot k + a \]
                8. metadata-evalN/A

                  \[\leadsto \left(\left(\mathsf{neg}\left(k \cdot \left(-99 \cdot a\right)\right)\right) - 10 \cdot a\right) \cdot k + a \]
                9. *-commutativeN/A

                  \[\leadsto \left(\left(\mathsf{neg}\left(\left(-99 \cdot a\right) \cdot k\right)\right) - 10 \cdot a\right) \cdot k + a \]
                10. associate-*r*N/A

                  \[\leadsto \left(\left(\mathsf{neg}\left(-99 \cdot \left(a \cdot k\right)\right)\right) - 10 \cdot a\right) \cdot k + a \]
                11. lower-neg.f64N/A

                  \[\leadsto \left(\left(--99 \cdot \left(a \cdot k\right)\right) - 10 \cdot a\right) \cdot k + a \]
                12. *-commutativeN/A

                  \[\leadsto \left(\left(-\left(a \cdot k\right) \cdot -99\right) - 10 \cdot a\right) \cdot k + a \]
                13. lower-*.f64N/A

                  \[\leadsto \left(\left(-\left(a \cdot k\right) \cdot -99\right) - 10 \cdot a\right) \cdot k + a \]
                14. *-commutativeN/A

                  \[\leadsto \left(\left(-\left(k \cdot a\right) \cdot -99\right) - 10 \cdot a\right) \cdot k + a \]
                15. lower-*.f64N/A

                  \[\leadsto \left(\left(-\left(k \cdot a\right) \cdot -99\right) - 10 \cdot a\right) \cdot k + a \]
                16. lower-*.f6428.3

                  \[\leadsto \left(\left(-\left(k \cdot a\right) \cdot -99\right) - 10 \cdot a\right) \cdot k + a \]
              4. Applied rewrites28.3%

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

                \[\leadsto 99 \cdot \left(a \cdot \color{blue}{{k}^{2}}\right) \]
              6. Step-by-step derivation
                1. *-commutativeN/A

                  \[\leadsto \left(a \cdot {k}^{2}\right) \cdot 99 \]
                2. lower-*.f64N/A

                  \[\leadsto \left(a \cdot {k}^{2}\right) \cdot 99 \]
                3. *-commutativeN/A

                  \[\leadsto \left({k}^{2} \cdot a\right) \cdot 99 \]
                4. lower-*.f64N/A

                  \[\leadsto \left({k}^{2} \cdot a\right) \cdot 99 \]
                5. pow2N/A

                  \[\leadsto \left(\left(k \cdot k\right) \cdot a\right) \cdot 99 \]
                6. lift-*.f6464.7

                  \[\leadsto \left(\left(k \cdot k\right) \cdot a\right) \cdot 99 \]
              7. Applied rewrites64.7%

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

            Alternative 7: 71.6% accurate, 4.2× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq -0.27:\\ \;\;\;\;\frac{a}{k \cdot k}\\ \mathbf{elif}\;m \leq 1.2:\\ \;\;\;\;\frac{a}{k \cdot k + 1}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(k \cdot k\right) \cdot a\right) \cdot 99\\ \end{array} \end{array} \]
            (FPCore (a k m)
             :precision binary64
             (if (<= m -0.27)
               (/ a (* k k))
               (if (<= m 1.2) (/ a (+ (* k k) 1.0)) (* (* (* k k) a) 99.0))))
            double code(double a, double k, double m) {
            	double tmp;
            	if (m <= -0.27) {
            		tmp = a / (k * k);
            	} else if (m <= 1.2) {
            		tmp = a / ((k * k) + 1.0);
            	} else {
            		tmp = ((k * k) * a) * 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.27d0)) then
                    tmp = a / (k * k)
                else if (m <= 1.2d0) then
                    tmp = a / ((k * k) + 1.0d0)
                else
                    tmp = ((k * k) * a) * 99.0d0
                end if
                code = tmp
            end function
            
            public static double code(double a, double k, double m) {
            	double tmp;
            	if (m <= -0.27) {
            		tmp = a / (k * k);
            	} else if (m <= 1.2) {
            		tmp = a / ((k * k) + 1.0);
            	} else {
            		tmp = ((k * k) * a) * 99.0;
            	}
            	return tmp;
            }
            
            def code(a, k, m):
            	tmp = 0
            	if m <= -0.27:
            		tmp = a / (k * k)
            	elif m <= 1.2:
            		tmp = a / ((k * k) + 1.0)
            	else:
            		tmp = ((k * k) * a) * 99.0
            	return tmp
            
            function code(a, k, m)
            	tmp = 0.0
            	if (m <= -0.27)
            		tmp = Float64(a / Float64(k * k));
            	elseif (m <= 1.2)
            		tmp = Float64(a / Float64(Float64(k * k) + 1.0));
            	else
            		tmp = Float64(Float64(Float64(k * k) * a) * 99.0);
            	end
            	return tmp
            end
            
            function tmp_2 = code(a, k, m)
            	tmp = 0.0;
            	if (m <= -0.27)
            		tmp = a / (k * k);
            	elseif (m <= 1.2)
            		tmp = a / ((k * k) + 1.0);
            	else
            		tmp = ((k * k) * a) * 99.0;
            	end
            	tmp_2 = tmp;
            end
            
            code[a_, k_, m_] := If[LessEqual[m, -0.27], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1.2], N[(a / N[(N[(k * k), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(k * k), $MachinePrecision] * a), $MachinePrecision] * 99.0), $MachinePrecision]]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            \mathbf{if}\;m \leq -0.27:\\
            \;\;\;\;\frac{a}{k \cdot k}\\
            
            \mathbf{elif}\;m \leq 1.2:\\
            \;\;\;\;\frac{a}{k \cdot k + 1}\\
            
            \mathbf{else}:\\
            \;\;\;\;\left(\left(k \cdot k\right) \cdot a\right) \cdot 99\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 3 regimes
            2. if m < -0.27000000000000002

              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 k around inf

                \[\leadsto \frac{a \cdot {k}^{m}}{\color{blue}{{k}^{2}}} \]
              4. Step-by-step derivation
                1. pow2N/A

                  \[\leadsto \frac{a \cdot {k}^{m}}{k \cdot \color{blue}{k}} \]
                2. lift-*.f64100.0

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

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

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

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

                if -0.27000000000000002 < m < 1.19999999999999996

                1. Initial program 98.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. lower-/.f64N/A

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

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

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

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

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

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

                    \[\leadsto \frac{a}{\left(10 + k\right) \cdot k + 1} \]
                  8. lower-+.f6495.4

                    \[\leadsto \frac{a}{\left(10 + k\right) \cdot k + 1} \]
                5. Applied rewrites95.4%

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

                  \[\leadsto \frac{a}{k \cdot k + 1} \]
                7. Step-by-step derivation
                  1. Applied rewrites90.2%

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

                  if 1.19999999999999996 < m

                  1. Initial program 75.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. lower-/.f64N/A

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

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

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

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

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

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

                      \[\leadsto \frac{a}{\left(10 + k\right) \cdot k + 1} \]
                    8. lower-+.f642.9

                      \[\leadsto \frac{a}{\left(10 + k\right) \cdot k + 1} \]
                  5. Applied rewrites2.9%

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

                    \[\leadsto a \]
                  7. Step-by-step derivation
                    1. Applied rewrites3.8%

                      \[\leadsto a \]
                    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. +-commutativeN/A

                        \[\leadsto k \cdot \left(-1 \cdot \left(k \cdot \left(a + -100 \cdot a\right)\right) - 10 \cdot a\right) + a \]
                      2. lower-+.f64N/A

                        \[\leadsto k \cdot \left(-1 \cdot \left(k \cdot \left(a + -100 \cdot a\right)\right) - 10 \cdot a\right) + a \]
                      3. *-commutativeN/A

                        \[\leadsto \left(-1 \cdot \left(k \cdot \left(a + -100 \cdot a\right)\right) - 10 \cdot a\right) \cdot k + a \]
                      4. lower-*.f64N/A

                        \[\leadsto \left(-1 \cdot \left(k \cdot \left(a + -100 \cdot a\right)\right) - 10 \cdot a\right) \cdot k + a \]
                      5. lower--.f64N/A

                        \[\leadsto \left(-1 \cdot \left(k \cdot \left(a + -100 \cdot a\right)\right) - 10 \cdot a\right) \cdot k + a \]
                      6. mul-1-negN/A

                        \[\leadsto \left(\left(\mathsf{neg}\left(k \cdot \left(a + -100 \cdot a\right)\right)\right) - 10 \cdot a\right) \cdot k + a \]
                      7. distribute-rgt1-inN/A

                        \[\leadsto \left(\left(\mathsf{neg}\left(k \cdot \left(\left(-100 + 1\right) \cdot a\right)\right)\right) - 10 \cdot a\right) \cdot k + a \]
                      8. metadata-evalN/A

                        \[\leadsto \left(\left(\mathsf{neg}\left(k \cdot \left(-99 \cdot a\right)\right)\right) - 10 \cdot a\right) \cdot k + a \]
                      9. *-commutativeN/A

                        \[\leadsto \left(\left(\mathsf{neg}\left(\left(-99 \cdot a\right) \cdot k\right)\right) - 10 \cdot a\right) \cdot k + a \]
                      10. associate-*r*N/A

                        \[\leadsto \left(\left(\mathsf{neg}\left(-99 \cdot \left(a \cdot k\right)\right)\right) - 10 \cdot a\right) \cdot k + a \]
                      11. lower-neg.f64N/A

                        \[\leadsto \left(\left(--99 \cdot \left(a \cdot k\right)\right) - 10 \cdot a\right) \cdot k + a \]
                      12. *-commutativeN/A

                        \[\leadsto \left(\left(-\left(a \cdot k\right) \cdot -99\right) - 10 \cdot a\right) \cdot k + a \]
                      13. lower-*.f64N/A

                        \[\leadsto \left(\left(-\left(a \cdot k\right) \cdot -99\right) - 10 \cdot a\right) \cdot k + a \]
                      14. *-commutativeN/A

                        \[\leadsto \left(\left(-\left(k \cdot a\right) \cdot -99\right) - 10 \cdot a\right) \cdot k + a \]
                      15. lower-*.f64N/A

                        \[\leadsto \left(\left(-\left(k \cdot a\right) \cdot -99\right) - 10 \cdot a\right) \cdot k + a \]
                      16. lower-*.f6428.3

                        \[\leadsto \left(\left(-\left(k \cdot a\right) \cdot -99\right) - 10 \cdot a\right) \cdot k + a \]
                    4. Applied rewrites28.3%

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

                      \[\leadsto 99 \cdot \left(a \cdot \color{blue}{{k}^{2}}\right) \]
                    6. Step-by-step derivation
                      1. *-commutativeN/A

                        \[\leadsto \left(a \cdot {k}^{2}\right) \cdot 99 \]
                      2. lower-*.f64N/A

                        \[\leadsto \left(a \cdot {k}^{2}\right) \cdot 99 \]
                      3. *-commutativeN/A

                        \[\leadsto \left({k}^{2} \cdot a\right) \cdot 99 \]
                      4. lower-*.f64N/A

                        \[\leadsto \left({k}^{2} \cdot a\right) \cdot 99 \]
                      5. pow2N/A

                        \[\leadsto \left(\left(k \cdot k\right) \cdot a\right) \cdot 99 \]
                      6. lift-*.f6464.7

                        \[\leadsto \left(\left(k \cdot k\right) \cdot a\right) \cdot 99 \]
                    7. Applied rewrites64.7%

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

                  Alternative 8: 65.6% accurate, 4.7× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq -6.8 \cdot 10^{-12}:\\ \;\;\;\;\frac{a}{k \cdot k}\\ \mathbf{elif}\;m \leq 0.48:\\ \;\;\;\;a \cdot \mathsf{ratio\_square\_sum}\left(1, \left(\left(10 + k\right) \cdot k\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(k \cdot k\right) \cdot a\right) \cdot 99\\ \end{array} \end{array} \]
                  (FPCore (a k m)
                   :precision binary64
                   (if (<= m -6.8e-12)
                     (/ a (* k k))
                     (if (<= m 0.48)
                       (* a (ratio-square-sum 1.0 (* (+ 10.0 k) k)))
                       (* (* (* k k) a) 99.0))))
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  \mathbf{if}\;m \leq -6.8 \cdot 10^{-12}:\\
                  \;\;\;\;\frac{a}{k \cdot k}\\
                  
                  \mathbf{elif}\;m \leq 0.48:\\
                  \;\;\;\;a \cdot \mathsf{ratio\_square\_sum}\left(1, \left(\left(10 + k\right) \cdot k\right)\right)\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;\left(\left(k \cdot k\right) \cdot a\right) \cdot 99\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 3 regimes
                  2. if m < -6.8000000000000001e-12

                    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 k around inf

                      \[\leadsto \frac{a \cdot {k}^{m}}{\color{blue}{{k}^{2}}} \]
                    4. Step-by-step derivation
                      1. pow2N/A

                        \[\leadsto \frac{a \cdot {k}^{m}}{k \cdot \color{blue}{k}} \]
                      2. lift-*.f6499.0

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

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

                      \[\leadsto \frac{\color{blue}{a}}{k \cdot k} \]
                    7. Step-by-step derivation
                      1. Applied rewrites64.8%

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

                      if -6.8000000000000001e-12 < m < 0.47999999999999998

                      1. Initial program 98.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                          \[\leadsto a \cdot \mathsf{ratio\_square\_sum}\left(1, \color{blue}{\left(k \cdot \left(10 + k\right)\right)}\right) \]
                        3. *-commutativeN/A

                          \[\leadsto a \cdot \mathsf{ratio\_square\_sum}\left(1, \left(\left(10 + k\right) \cdot \color{blue}{k}\right)\right) \]
                        4. lift-*.f64N/A

                          \[\leadsto a \cdot \mathsf{ratio\_square\_sum}\left(1, \left(\left(10 + k\right) \cdot \color{blue}{k}\right)\right) \]
                        5. lift-+.f6480.5

                          \[\leadsto a \cdot \mathsf{ratio\_square\_sum}\left(1, \left(\left(10 + k\right) \cdot k\right)\right) \]
                      7. Applied rewrites80.5%

                        \[\leadsto a \cdot \color{blue}{\mathsf{ratio\_square\_sum}\left(1, \left(\left(10 + k\right) \cdot k\right)\right)} \]

                      if 0.47999999999999998 < m

                      1. Initial program 75.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. lower-/.f64N/A

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

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

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

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

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

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

                          \[\leadsto \frac{a}{\left(10 + k\right) \cdot k + 1} \]
                        8. lower-+.f642.9

                          \[\leadsto \frac{a}{\left(10 + k\right) \cdot k + 1} \]
                      5. Applied rewrites2.9%

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

                        \[\leadsto a \]
                      7. Step-by-step derivation
                        1. Applied rewrites3.8%

                          \[\leadsto a \]
                        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. +-commutativeN/A

                            \[\leadsto k \cdot \left(-1 \cdot \left(k \cdot \left(a + -100 \cdot a\right)\right) - 10 \cdot a\right) + a \]
                          2. lower-+.f64N/A

                            \[\leadsto k \cdot \left(-1 \cdot \left(k \cdot \left(a + -100 \cdot a\right)\right) - 10 \cdot a\right) + a \]
                          3. *-commutativeN/A

                            \[\leadsto \left(-1 \cdot \left(k \cdot \left(a + -100 \cdot a\right)\right) - 10 \cdot a\right) \cdot k + a \]
                          4. lower-*.f64N/A

                            \[\leadsto \left(-1 \cdot \left(k \cdot \left(a + -100 \cdot a\right)\right) - 10 \cdot a\right) \cdot k + a \]
                          5. lower--.f64N/A

                            \[\leadsto \left(-1 \cdot \left(k \cdot \left(a + -100 \cdot a\right)\right) - 10 \cdot a\right) \cdot k + a \]
                          6. mul-1-negN/A

                            \[\leadsto \left(\left(\mathsf{neg}\left(k \cdot \left(a + -100 \cdot a\right)\right)\right) - 10 \cdot a\right) \cdot k + a \]
                          7. distribute-rgt1-inN/A

                            \[\leadsto \left(\left(\mathsf{neg}\left(k \cdot \left(\left(-100 + 1\right) \cdot a\right)\right)\right) - 10 \cdot a\right) \cdot k + a \]
                          8. metadata-evalN/A

                            \[\leadsto \left(\left(\mathsf{neg}\left(k \cdot \left(-99 \cdot a\right)\right)\right) - 10 \cdot a\right) \cdot k + a \]
                          9. *-commutativeN/A

                            \[\leadsto \left(\left(\mathsf{neg}\left(\left(-99 \cdot a\right) \cdot k\right)\right) - 10 \cdot a\right) \cdot k + a \]
                          10. associate-*r*N/A

                            \[\leadsto \left(\left(\mathsf{neg}\left(-99 \cdot \left(a \cdot k\right)\right)\right) - 10 \cdot a\right) \cdot k + a \]
                          11. lower-neg.f64N/A

                            \[\leadsto \left(\left(--99 \cdot \left(a \cdot k\right)\right) - 10 \cdot a\right) \cdot k + a \]
                          12. *-commutativeN/A

                            \[\leadsto \left(\left(-\left(a \cdot k\right) \cdot -99\right) - 10 \cdot a\right) \cdot k + a \]
                          13. lower-*.f64N/A

                            \[\leadsto \left(\left(-\left(a \cdot k\right) \cdot -99\right) - 10 \cdot a\right) \cdot k + a \]
                          14. *-commutativeN/A

                            \[\leadsto \left(\left(-\left(k \cdot a\right) \cdot -99\right) - 10 \cdot a\right) \cdot k + a \]
                          15. lower-*.f64N/A

                            \[\leadsto \left(\left(-\left(k \cdot a\right) \cdot -99\right) - 10 \cdot a\right) \cdot k + a \]
                          16. lower-*.f6428.3

                            \[\leadsto \left(\left(-\left(k \cdot a\right) \cdot -99\right) - 10 \cdot a\right) \cdot k + a \]
                        4. Applied rewrites28.3%

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

                          \[\leadsto 99 \cdot \left(a \cdot \color{blue}{{k}^{2}}\right) \]
                        6. Step-by-step derivation
                          1. *-commutativeN/A

                            \[\leadsto \left(a \cdot {k}^{2}\right) \cdot 99 \]
                          2. lower-*.f64N/A

                            \[\leadsto \left(a \cdot {k}^{2}\right) \cdot 99 \]
                          3. *-commutativeN/A

                            \[\leadsto \left({k}^{2} \cdot a\right) \cdot 99 \]
                          4. lower-*.f64N/A

                            \[\leadsto \left({k}^{2} \cdot a\right) \cdot 99 \]
                          5. pow2N/A

                            \[\leadsto \left(\left(k \cdot k\right) \cdot a\right) \cdot 99 \]
                          6. lift-*.f6464.7

                            \[\leadsto \left(\left(k \cdot k\right) \cdot a\right) \cdot 99 \]
                        7. Applied rewrites64.7%

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

                      Alternative 9: 49.7% accurate, 5.9× speedup?

                      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq 0.48:\\ \;\;\;\;a \cdot \mathsf{ratio\_square\_sum}\left(1, \left(\left(10 + k\right) \cdot k\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(k \cdot k\right) \cdot a\right) \cdot 99\\ \end{array} \end{array} \]
                      (FPCore (a k m)
                       :precision binary64
                       (if (<= m 0.48)
                         (* a (ratio-square-sum 1.0 (* (+ 10.0 k) k)))
                         (* (* (* k k) a) 99.0)))
                      \begin{array}{l}
                      
                      \\
                      \begin{array}{l}
                      \mathbf{if}\;m \leq 0.48:\\
                      \;\;\;\;a \cdot \mathsf{ratio\_square\_sum}\left(1, \left(\left(10 + k\right) \cdot k\right)\right)\\
                      
                      \mathbf{else}:\\
                      \;\;\;\;\left(\left(k \cdot k\right) \cdot a\right) \cdot 99\\
                      
                      
                      \end{array}
                      \end{array}
                      
                      Derivation
                      1. Split input into 2 regimes
                      2. if m < 0.47999999999999998

                        1. Initial program 99.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                            \[\leadsto a \cdot \mathsf{ratio\_square\_sum}\left(1, \color{blue}{\left(k \cdot \left(10 + k\right)\right)}\right) \]
                          3. *-commutativeN/A

                            \[\leadsto a \cdot \mathsf{ratio\_square\_sum}\left(1, \left(\left(10 + k\right) \cdot \color{blue}{k}\right)\right) \]
                          4. lift-*.f64N/A

                            \[\leadsto a \cdot \mathsf{ratio\_square\_sum}\left(1, \left(\left(10 + k\right) \cdot \color{blue}{k}\right)\right) \]
                          5. lift-+.f6443.7

                            \[\leadsto a \cdot \mathsf{ratio\_square\_sum}\left(1, \left(\left(10 + k\right) \cdot k\right)\right) \]
                        7. Applied rewrites43.7%

                          \[\leadsto a \cdot \color{blue}{\mathsf{ratio\_square\_sum}\left(1, \left(\left(10 + k\right) \cdot k\right)\right)} \]

                        if 0.47999999999999998 < m

                        1. Initial program 75.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. lower-/.f64N/A

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

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

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

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

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

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

                            \[\leadsto \frac{a}{\left(10 + k\right) \cdot k + 1} \]
                          8. lower-+.f642.9

                            \[\leadsto \frac{a}{\left(10 + k\right) \cdot k + 1} \]
                        5. Applied rewrites2.9%

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

                          \[\leadsto a \]
                        7. Step-by-step derivation
                          1. Applied rewrites3.8%

                            \[\leadsto a \]
                          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. +-commutativeN/A

                              \[\leadsto k \cdot \left(-1 \cdot \left(k \cdot \left(a + -100 \cdot a\right)\right) - 10 \cdot a\right) + a \]
                            2. lower-+.f64N/A

                              \[\leadsto k \cdot \left(-1 \cdot \left(k \cdot \left(a + -100 \cdot a\right)\right) - 10 \cdot a\right) + a \]
                            3. *-commutativeN/A

                              \[\leadsto \left(-1 \cdot \left(k \cdot \left(a + -100 \cdot a\right)\right) - 10 \cdot a\right) \cdot k + a \]
                            4. lower-*.f64N/A

                              \[\leadsto \left(-1 \cdot \left(k \cdot \left(a + -100 \cdot a\right)\right) - 10 \cdot a\right) \cdot k + a \]
                            5. lower--.f64N/A

                              \[\leadsto \left(-1 \cdot \left(k \cdot \left(a + -100 \cdot a\right)\right) - 10 \cdot a\right) \cdot k + a \]
                            6. mul-1-negN/A

                              \[\leadsto \left(\left(\mathsf{neg}\left(k \cdot \left(a + -100 \cdot a\right)\right)\right) - 10 \cdot a\right) \cdot k + a \]
                            7. distribute-rgt1-inN/A

                              \[\leadsto \left(\left(\mathsf{neg}\left(k \cdot \left(\left(-100 + 1\right) \cdot a\right)\right)\right) - 10 \cdot a\right) \cdot k + a \]
                            8. metadata-evalN/A

                              \[\leadsto \left(\left(\mathsf{neg}\left(k \cdot \left(-99 \cdot a\right)\right)\right) - 10 \cdot a\right) \cdot k + a \]
                            9. *-commutativeN/A

                              \[\leadsto \left(\left(\mathsf{neg}\left(\left(-99 \cdot a\right) \cdot k\right)\right) - 10 \cdot a\right) \cdot k + a \]
                            10. associate-*r*N/A

                              \[\leadsto \left(\left(\mathsf{neg}\left(-99 \cdot \left(a \cdot k\right)\right)\right) - 10 \cdot a\right) \cdot k + a \]
                            11. lower-neg.f64N/A

                              \[\leadsto \left(\left(--99 \cdot \left(a \cdot k\right)\right) - 10 \cdot a\right) \cdot k + a \]
                            12. *-commutativeN/A

                              \[\leadsto \left(\left(-\left(a \cdot k\right) \cdot -99\right) - 10 \cdot a\right) \cdot k + a \]
                            13. lower-*.f64N/A

                              \[\leadsto \left(\left(-\left(a \cdot k\right) \cdot -99\right) - 10 \cdot a\right) \cdot k + a \]
                            14. *-commutativeN/A

                              \[\leadsto \left(\left(-\left(k \cdot a\right) \cdot -99\right) - 10 \cdot a\right) \cdot k + a \]
                            15. lower-*.f64N/A

                              \[\leadsto \left(\left(-\left(k \cdot a\right) \cdot -99\right) - 10 \cdot a\right) \cdot k + a \]
                            16. lower-*.f6428.3

                              \[\leadsto \left(\left(-\left(k \cdot a\right) \cdot -99\right) - 10 \cdot a\right) \cdot k + a \]
                          4. Applied rewrites28.3%

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

                            \[\leadsto 99 \cdot \left(a \cdot \color{blue}{{k}^{2}}\right) \]
                          6. Step-by-step derivation
                            1. *-commutativeN/A

                              \[\leadsto \left(a \cdot {k}^{2}\right) \cdot 99 \]
                            2. lower-*.f64N/A

                              \[\leadsto \left(a \cdot {k}^{2}\right) \cdot 99 \]
                            3. *-commutativeN/A

                              \[\leadsto \left({k}^{2} \cdot a\right) \cdot 99 \]
                            4. lower-*.f64N/A

                              \[\leadsto \left({k}^{2} \cdot a\right) \cdot 99 \]
                            5. pow2N/A

                              \[\leadsto \left(\left(k \cdot k\right) \cdot a\right) \cdot 99 \]
                            6. lift-*.f6464.7

                              \[\leadsto \left(\left(k \cdot k\right) \cdot a\right) \cdot 99 \]
                          7. Applied rewrites64.7%

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

                        Alternative 10: 39.8% accurate, 6.1× speedup?

                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq 0.4:\\ \;\;\;\;a\\ \mathbf{else}:\\ \;\;\;\;\left(\left(k \cdot k\right) \cdot a\right) \cdot 99\\ \end{array} \end{array} \]
                        (FPCore (a k m) :precision binary64 (if (<= m 0.4) a (* (* (* k k) a) 99.0)))
                        double code(double a, double k, double m) {
                        	double tmp;
                        	if (m <= 0.4) {
                        		tmp = a;
                        	} else {
                        		tmp = ((k * k) * a) * 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.4d0) then
                                tmp = a
                            else
                                tmp = ((k * k) * a) * 99.0d0
                            end if
                            code = tmp
                        end function
                        
                        public static double code(double a, double k, double m) {
                        	double tmp;
                        	if (m <= 0.4) {
                        		tmp = a;
                        	} else {
                        		tmp = ((k * k) * a) * 99.0;
                        	}
                        	return tmp;
                        }
                        
                        def code(a, k, m):
                        	tmp = 0
                        	if m <= 0.4:
                        		tmp = a
                        	else:
                        		tmp = ((k * k) * a) * 99.0
                        	return tmp
                        
                        function code(a, k, m)
                        	tmp = 0.0
                        	if (m <= 0.4)
                        		tmp = a;
                        	else
                        		tmp = Float64(Float64(Float64(k * k) * a) * 99.0);
                        	end
                        	return tmp
                        end
                        
                        function tmp_2 = code(a, k, m)
                        	tmp = 0.0;
                        	if (m <= 0.4)
                        		tmp = a;
                        	else
                        		tmp = ((k * k) * a) * 99.0;
                        	end
                        	tmp_2 = tmp;
                        end
                        
                        code[a_, k_, m_] := If[LessEqual[m, 0.4], a, N[(N[(N[(k * k), $MachinePrecision] * a), $MachinePrecision] * 99.0), $MachinePrecision]]
                        
                        \begin{array}{l}
                        
                        \\
                        \begin{array}{l}
                        \mathbf{if}\;m \leq 0.4:\\
                        \;\;\;\;a\\
                        
                        \mathbf{else}:\\
                        \;\;\;\;\left(\left(k \cdot k\right) \cdot a\right) \cdot 99\\
                        
                        
                        \end{array}
                        \end{array}
                        
                        Derivation
                        1. Split input into 2 regimes
                        2. if m < 0.40000000000000002

                          1. Initial program 99.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. lower-/.f64N/A

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

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

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

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

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

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

                              \[\leadsto \frac{a}{\left(10 + k\right) \cdot k + 1} \]
                            8. lower-+.f6466.4

                              \[\leadsto \frac{a}{\left(10 + k\right) \cdot k + 1} \]
                          5. Applied rewrites66.4%

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

                            \[\leadsto a \]
                          7. Step-by-step derivation
                            1. Applied rewrites28.0%

                              \[\leadsto a \]

                            if 0.40000000000000002 < m

                            1. Initial program 75.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. lower-/.f64N/A

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

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

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

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

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

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

                                \[\leadsto \frac{a}{\left(10 + k\right) \cdot k + 1} \]
                              8. lower-+.f642.9

                                \[\leadsto \frac{a}{\left(10 + k\right) \cdot k + 1} \]
                            5. Applied rewrites2.9%

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

                              \[\leadsto a \]
                            7. Step-by-step derivation
                              1. Applied rewrites3.8%

                                \[\leadsto a \]
                              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. +-commutativeN/A

                                  \[\leadsto k \cdot \left(-1 \cdot \left(k \cdot \left(a + -100 \cdot a\right)\right) - 10 \cdot a\right) + a \]
                                2. lower-+.f64N/A

                                  \[\leadsto k \cdot \left(-1 \cdot \left(k \cdot \left(a + -100 \cdot a\right)\right) - 10 \cdot a\right) + a \]
                                3. *-commutativeN/A

                                  \[\leadsto \left(-1 \cdot \left(k \cdot \left(a + -100 \cdot a\right)\right) - 10 \cdot a\right) \cdot k + a \]
                                4. lower-*.f64N/A

                                  \[\leadsto \left(-1 \cdot \left(k \cdot \left(a + -100 \cdot a\right)\right) - 10 \cdot a\right) \cdot k + a \]
                                5. lower--.f64N/A

                                  \[\leadsto \left(-1 \cdot \left(k \cdot \left(a + -100 \cdot a\right)\right) - 10 \cdot a\right) \cdot k + a \]
                                6. mul-1-negN/A

                                  \[\leadsto \left(\left(\mathsf{neg}\left(k \cdot \left(a + -100 \cdot a\right)\right)\right) - 10 \cdot a\right) \cdot k + a \]
                                7. distribute-rgt1-inN/A

                                  \[\leadsto \left(\left(\mathsf{neg}\left(k \cdot \left(\left(-100 + 1\right) \cdot a\right)\right)\right) - 10 \cdot a\right) \cdot k + a \]
                                8. metadata-evalN/A

                                  \[\leadsto \left(\left(\mathsf{neg}\left(k \cdot \left(-99 \cdot a\right)\right)\right) - 10 \cdot a\right) \cdot k + a \]
                                9. *-commutativeN/A

                                  \[\leadsto \left(\left(\mathsf{neg}\left(\left(-99 \cdot a\right) \cdot k\right)\right) - 10 \cdot a\right) \cdot k + a \]
                                10. associate-*r*N/A

                                  \[\leadsto \left(\left(\mathsf{neg}\left(-99 \cdot \left(a \cdot k\right)\right)\right) - 10 \cdot a\right) \cdot k + a \]
                                11. lower-neg.f64N/A

                                  \[\leadsto \left(\left(--99 \cdot \left(a \cdot k\right)\right) - 10 \cdot a\right) \cdot k + a \]
                                12. *-commutativeN/A

                                  \[\leadsto \left(\left(-\left(a \cdot k\right) \cdot -99\right) - 10 \cdot a\right) \cdot k + a \]
                                13. lower-*.f64N/A

                                  \[\leadsto \left(\left(-\left(a \cdot k\right) \cdot -99\right) - 10 \cdot a\right) \cdot k + a \]
                                14. *-commutativeN/A

                                  \[\leadsto \left(\left(-\left(k \cdot a\right) \cdot -99\right) - 10 \cdot a\right) \cdot k + a \]
                                15. lower-*.f64N/A

                                  \[\leadsto \left(\left(-\left(k \cdot a\right) \cdot -99\right) - 10 \cdot a\right) \cdot k + a \]
                                16. lower-*.f6428.3

                                  \[\leadsto \left(\left(-\left(k \cdot a\right) \cdot -99\right) - 10 \cdot a\right) \cdot k + a \]
                              4. Applied rewrites28.3%

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

                                \[\leadsto 99 \cdot \left(a \cdot \color{blue}{{k}^{2}}\right) \]
                              6. Step-by-step derivation
                                1. *-commutativeN/A

                                  \[\leadsto \left(a \cdot {k}^{2}\right) \cdot 99 \]
                                2. lower-*.f64N/A

                                  \[\leadsto \left(a \cdot {k}^{2}\right) \cdot 99 \]
                                3. *-commutativeN/A

                                  \[\leadsto \left({k}^{2} \cdot a\right) \cdot 99 \]
                                4. lower-*.f64N/A

                                  \[\leadsto \left({k}^{2} \cdot a\right) \cdot 99 \]
                                5. pow2N/A

                                  \[\leadsto \left(\left(k \cdot k\right) \cdot a\right) \cdot 99 \]
                                6. lift-*.f6464.7

                                  \[\leadsto \left(\left(k \cdot k\right) \cdot a\right) \cdot 99 \]
                              7. Applied rewrites64.7%

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

                            Alternative 11: 25.6% accurate, 7.9× speedup?

                            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq 0.4:\\ \;\;\;\;a\\ \mathbf{else}:\\ \;\;\;\;\left(k \cdot a\right) \cdot -10\\ \end{array} \end{array} \]
                            (FPCore (a k m) :precision binary64 (if (<= m 0.4) a (* (* k a) -10.0)))
                            double code(double a, double k, double m) {
                            	double tmp;
                            	if (m <= 0.4) {
                            		tmp = a;
                            	} else {
                            		tmp = (k * a) * -10.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.4d0) then
                                    tmp = a
                                else
                                    tmp = (k * a) * (-10.0d0)
                                end if
                                code = tmp
                            end function
                            
                            public static double code(double a, double k, double m) {
                            	double tmp;
                            	if (m <= 0.4) {
                            		tmp = a;
                            	} else {
                            		tmp = (k * a) * -10.0;
                            	}
                            	return tmp;
                            }
                            
                            def code(a, k, m):
                            	tmp = 0
                            	if m <= 0.4:
                            		tmp = a
                            	else:
                            		tmp = (k * a) * -10.0
                            	return tmp
                            
                            function code(a, k, m)
                            	tmp = 0.0
                            	if (m <= 0.4)
                            		tmp = a;
                            	else
                            		tmp = Float64(Float64(k * a) * -10.0);
                            	end
                            	return tmp
                            end
                            
                            function tmp_2 = code(a, k, m)
                            	tmp = 0.0;
                            	if (m <= 0.4)
                            		tmp = a;
                            	else
                            		tmp = (k * a) * -10.0;
                            	end
                            	tmp_2 = tmp;
                            end
                            
                            code[a_, k_, m_] := If[LessEqual[m, 0.4], a, N[(N[(k * a), $MachinePrecision] * -10.0), $MachinePrecision]]
                            
                            \begin{array}{l}
                            
                            \\
                            \begin{array}{l}
                            \mathbf{if}\;m \leq 0.4:\\
                            \;\;\;\;a\\
                            
                            \mathbf{else}:\\
                            \;\;\;\;\left(k \cdot a\right) \cdot -10\\
                            
                            
                            \end{array}
                            \end{array}
                            
                            Derivation
                            1. Split input into 2 regimes
                            2. if m < 0.40000000000000002

                              1. Initial program 99.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. lower-/.f64N/A

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

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

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

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

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

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

                                  \[\leadsto \frac{a}{\left(10 + k\right) \cdot k + 1} \]
                                8. lower-+.f6466.4

                                  \[\leadsto \frac{a}{\left(10 + k\right) \cdot k + 1} \]
                              5. Applied rewrites66.4%

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

                                \[\leadsto a \]
                              7. Step-by-step derivation
                                1. Applied rewrites28.0%

                                  \[\leadsto a \]

                                if 0.40000000000000002 < m

                                1. Initial program 75.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. lower-/.f64N/A

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

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

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

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

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

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

                                    \[\leadsto \frac{a}{\left(10 + k\right) \cdot k + 1} \]
                                  8. lower-+.f642.9

                                    \[\leadsto \frac{a}{\left(10 + k\right) \cdot k + 1} \]
                                5. Applied rewrites2.9%

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

                                  \[\leadsto a + \color{blue}{-10 \cdot \left(a \cdot k\right)} \]
                                7. Step-by-step derivation
                                  1. +-commutativeN/A

                                    \[\leadsto -10 \cdot \left(a \cdot k\right) + a \]
                                  2. lower-+.f64N/A

                                    \[\leadsto -10 \cdot \left(a \cdot k\right) + a \]
                                  3. *-commutativeN/A

                                    \[\leadsto \left(a \cdot k\right) \cdot -10 + a \]
                                  4. lower-*.f64N/A

                                    \[\leadsto \left(a \cdot k\right) \cdot -10 + a \]
                                  5. *-commutativeN/A

                                    \[\leadsto \left(k \cdot a\right) \cdot -10 + a \]
                                  6. lower-*.f646.3

                                    \[\leadsto \left(k \cdot a\right) \cdot -10 + a \]
                                8. Applied rewrites6.3%

                                  \[\leadsto \left(k \cdot a\right) \cdot -10 + \color{blue}{a} \]
                                9. Taylor expanded in k around inf

                                  \[\leadsto -10 \cdot \left(a \cdot \color{blue}{k}\right) \]
                                10. Step-by-step derivation
                                  1. *-commutativeN/A

                                    \[\leadsto \left(a \cdot k\right) \cdot -10 \]
                                  2. *-commutativeN/A

                                    \[\leadsto \left(k \cdot a\right) \cdot -10 \]
                                  3. lift-*.f64N/A

                                    \[\leadsto \left(k \cdot a\right) \cdot -10 \]
                                  4. lift-*.f6417.1

                                    \[\leadsto \left(k \cdot a\right) \cdot -10 \]
                                11. Applied rewrites17.1%

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

                              Alternative 12: 20.0% 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 91.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. lower-/.f64N/A

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

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

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

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

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

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

                                  \[\leadsto \frac{a}{\left(10 + k\right) \cdot k + 1} \]
                                8. lower-+.f6445.6

                                  \[\leadsto \frac{a}{\left(10 + k\right) \cdot k + 1} \]
                              5. Applied rewrites45.6%

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

                                \[\leadsto a \]
                              7. Step-by-step derivation
                                1. Applied rewrites20.0%

                                  \[\leadsto a \]
                                2. Add Preprocessing

                                Reproduce

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