Falkner and Boettcher, Appendix A

Percentage Accurate: 90.4% → 97.2%
Time: 5.0s
Alternatives: 9
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 9 alternatives:

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

Initial Program: 90.4% 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.2% accurate, 0.5× speedup?

\[\begin{array}{l} a\_m = \left|a\right| \\ a\_s = \mathsf{copysign}\left(1, a\right) \\ \begin{array}{l} t_0 := \frac{a\_m \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k}\\ a\_s \cdot \begin{array}{l} \mathbf{if}\;t\_0 \leq 5 \cdot 10^{+159}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;{k}^{m} \cdot a\_m\\ \end{array} \end{array} \end{array} \]
a\_m = (fabs.f64 a)
a\_s = (copysign.f64 #s(literal 1 binary64) a)
(FPCore (a_s a_m k m)
 :precision binary64
 (let* ((t_0 (/ (* a_m (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k)))))
   (* a_s (if (<= t_0 5e+159) t_0 (* (pow k m) a_m)))))
a\_m = fabs(a);
a\_s = copysign(1.0, a);
double code(double a_s, double a_m, double k, double m) {
	double t_0 = (a_m * pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
	double tmp;
	if (t_0 <= 5e+159) {
		tmp = t_0;
	} else {
		tmp = pow(k, m) * a_m;
	}
	return a_s * tmp;
}
a\_m =     private
a\_s =     private
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_s, a_m, k, m)
use fmin_fmax_functions
    real(8), intent (in) :: a_s
    real(8), intent (in) :: a_m
    real(8), intent (in) :: k
    real(8), intent (in) :: m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (a_m * (k ** m)) / ((1.0d0 + (10.0d0 * k)) + (k * k))
    if (t_0 <= 5d+159) then
        tmp = t_0
    else
        tmp = (k ** m) * a_m
    end if
    code = a_s * tmp
end function
a\_m = Math.abs(a);
a\_s = Math.copySign(1.0, a);
public static double code(double a_s, double a_m, double k, double m) {
	double t_0 = (a_m * Math.pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
	double tmp;
	if (t_0 <= 5e+159) {
		tmp = t_0;
	} else {
		tmp = Math.pow(k, m) * a_m;
	}
	return a_s * tmp;
}
a\_m = math.fabs(a)
a\_s = math.copysign(1.0, a)
def code(a_s, a_m, k, m):
	t_0 = (a_m * math.pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k))
	tmp = 0
	if t_0 <= 5e+159:
		tmp = t_0
	else:
		tmp = math.pow(k, m) * a_m
	return a_s * tmp
a\_m = abs(a)
a\_s = copysign(1.0, a)
function code(a_s, a_m, k, m)
	t_0 = Float64(Float64(a_m * (k ^ m)) / Float64(Float64(1.0 + Float64(10.0 * k)) + Float64(k * k)))
	tmp = 0.0
	if (t_0 <= 5e+159)
		tmp = t_0;
	else
		tmp = Float64((k ^ m) * a_m);
	end
	return Float64(a_s * tmp)
end
a\_m = abs(a);
a\_s = sign(a) * abs(1.0);
function tmp_2 = code(a_s, a_m, k, m)
	t_0 = (a_m * (k ^ m)) / ((1.0 + (10.0 * k)) + (k * k));
	tmp = 0.0;
	if (t_0 <= 5e+159)
		tmp = t_0;
	else
		tmp = (k ^ m) * a_m;
	end
	tmp_2 = a_s * tmp;
end
a\_m = N[Abs[a], $MachinePrecision]
a\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, a$95$m_, k_, m_] := Block[{t$95$0 = N[(N[(a$95$m * N[Power[k, m], $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 + N[(10.0 * k), $MachinePrecision]), $MachinePrecision] + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(a$95$s * If[LessEqual[t$95$0, 5e+159], t$95$0, N[(N[Power[k, m], $MachinePrecision] * a$95$m), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)

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

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


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

    1. Initial program 97.4%

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

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

    1. Initial program 64.6%

      \[\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.f6497.9

        \[\leadsto {k}^{m} \cdot a \]
    5. Applied rewrites97.9%

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

Alternative 2: 97.2% accurate, 1.1× speedup?

\[\begin{array}{l} a\_m = \left|a\right| \\ a\_s = \mathsf{copysign}\left(1, a\right) \\ a\_s \cdot \begin{array}{l} \mathbf{if}\;m \leq -8.8 \cdot 10^{-11} \lor \neg \left(m \leq 0.00012\right):\\ \;\;\;\;{k}^{m} \cdot a\_m\\ \mathbf{else}:\\ \;\;\;\;\frac{a\_m}{\mathsf{fma}\left(10 + k, k, 1\right)}\\ \end{array} \end{array} \]
a\_m = (fabs.f64 a)
a\_s = (copysign.f64 #s(literal 1 binary64) a)
(FPCore (a_s a_m k m)
 :precision binary64
 (*
  a_s
  (if (or (<= m -8.8e-11) (not (<= m 0.00012)))
    (* (pow k m) a_m)
    (/ a_m (fma (+ 10.0 k) k 1.0)))))
a\_m = fabs(a);
a\_s = copysign(1.0, a);
double code(double a_s, double a_m, double k, double m) {
	double tmp;
	if ((m <= -8.8e-11) || !(m <= 0.00012)) {
		tmp = pow(k, m) * a_m;
	} else {
		tmp = a_m / fma((10.0 + k), k, 1.0);
	}
	return a_s * tmp;
}
a\_m = abs(a)
a\_s = copysign(1.0, a)
function code(a_s, a_m, k, m)
	tmp = 0.0
	if ((m <= -8.8e-11) || !(m <= 0.00012))
		tmp = Float64((k ^ m) * a_m);
	else
		tmp = Float64(a_m / fma(Float64(10.0 + k), k, 1.0));
	end
	return Float64(a_s * tmp)
end
a\_m = N[Abs[a], $MachinePrecision]
a\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, a$95$m_, k_, m_] := N[(a$95$s * If[Or[LessEqual[m, -8.8e-11], N[Not[LessEqual[m, 0.00012]], $MachinePrecision]], N[(N[Power[k, m], $MachinePrecision] * a$95$m), $MachinePrecision], N[(a$95$m / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)

\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;m \leq -8.8 \cdot 10^{-11} \lor \neg \left(m \leq 0.00012\right):\\
\;\;\;\;{k}^{m} \cdot a\_m\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if m < -8.8000000000000006e-11 or 1.20000000000000003e-4 < m

    1. Initial program 89.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.f6499.4

        \[\leadsto {k}^{m} \cdot a \]
    5. Applied rewrites99.4%

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

    if -8.8000000000000006e-11 < m < 1.20000000000000003e-4

    1. Initial program 93.8%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{a}{\mathsf{fma}\left(10 + k, k, 1\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification97.0%

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

Alternative 3: 64.9% accurate, 3.0× speedup?

\[\begin{array}{l} a\_m = \left|a\right| \\ a\_s = \mathsf{copysign}\left(1, a\right) \\ a\_s \cdot \begin{array}{l} \mathbf{if}\;m \leq -0.25:\\ \;\;\;\;\frac{\frac{a\_m}{k \cdot k} \cdot 99}{k \cdot k}\\ \mathbf{elif}\;m \leq 0.019:\\ \;\;\;\;\frac{a\_m}{\mathsf{fma}\left(10 + k, k, 1\right)}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(99, k \cdot a\_m, -10 \cdot a\_m\right), k, a\_m\right)\\ \end{array} \end{array} \]
a\_m = (fabs.f64 a)
a\_s = (copysign.f64 #s(literal 1 binary64) a)
(FPCore (a_s a_m k m)
 :precision binary64
 (*
  a_s
  (if (<= m -0.25)
    (/ (* (/ a_m (* k k)) 99.0) (* k k))
    (if (<= m 0.019)
      (/ a_m (fma (+ 10.0 k) k 1.0))
      (fma (fma 99.0 (* k a_m) (* -10.0 a_m)) k a_m)))))
a\_m = fabs(a);
a\_s = copysign(1.0, a);
double code(double a_s, double a_m, double k, double m) {
	double tmp;
	if (m <= -0.25) {
		tmp = ((a_m / (k * k)) * 99.0) / (k * k);
	} else if (m <= 0.019) {
		tmp = a_m / fma((10.0 + k), k, 1.0);
	} else {
		tmp = fma(fma(99.0, (k * a_m), (-10.0 * a_m)), k, a_m);
	}
	return a_s * tmp;
}
a\_m = abs(a)
a\_s = copysign(1.0, a)
function code(a_s, a_m, k, m)
	tmp = 0.0
	if (m <= -0.25)
		tmp = Float64(Float64(Float64(a_m / Float64(k * k)) * 99.0) / Float64(k * k));
	elseif (m <= 0.019)
		tmp = Float64(a_m / fma(Float64(10.0 + k), k, 1.0));
	else
		tmp = fma(fma(99.0, Float64(k * a_m), Float64(-10.0 * a_m)), k, a_m);
	end
	return Float64(a_s * tmp)
end
a\_m = N[Abs[a], $MachinePrecision]
a\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, a$95$m_, k_, m_] := N[(a$95$s * If[LessEqual[m, -0.25], N[(N[(N[(a$95$m / N[(k * k), $MachinePrecision]), $MachinePrecision] * 99.0), $MachinePrecision] / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 0.019], N[(a$95$m / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(99.0 * N[(k * a$95$m), $MachinePrecision] + N[(-10.0 * a$95$m), $MachinePrecision]), $MachinePrecision] * k + a$95$m), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)

\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;m \leq -0.25:\\
\;\;\;\;\frac{\frac{a\_m}{k \cdot k} \cdot 99}{k \cdot k}\\

\mathbf{elif}\;m \leq 0.019:\\
\;\;\;\;\frac{a\_m}{\mathsf{fma}\left(10 + k, k, 1\right)}\\

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


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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(\frac{\left(-100 \cdot \frac{a}{k} + \frac{a}{k}\right) - -10 \cdot a}{k}, -1, a\right)}{{k}^{2}} \]
      6. fp-cancel-sub-sign-invN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{\left(-100 \cdot \frac{a}{k} + \frac{a}{k}\right) + \left(\mathsf{neg}\left(-10\right)\right) \cdot a}{k}, -1, a\right)}{{k}^{2}} \]
      7. distribute-lft1-inN/A

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(\frac{\mathsf{fma}\left(-99, \frac{a}{k}, 10 \cdot a\right)}{k}, -1, a\right)}{{k}^{2}} \]
      11. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{\mathsf{fma}\left(-99, \frac{a}{k}, 10 \cdot a\right)}{k}, -1, a\right)}{{k}^{2}} \]
      12. lower-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{\mathsf{fma}\left(-99, \frac{a}{k}, 10 \cdot a\right)}{k}, -1, a\right)}{{k}^{2}} \]
      13. pow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{\mathsf{fma}\left(-99, \frac{a}{k}, 10 \cdot a\right)}{k}, -1, a\right)}{k \cdot k} \]
    8. Applied rewrites63.4%

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

      \[\leadsto \frac{99 \cdot \frac{a}{{k}^{2}}}{k \cdot k} \]
    10. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \frac{\frac{a}{{k}^{2}} \cdot 99}{k \cdot k} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{\frac{a}{{k}^{2}} \cdot 99}{k \cdot k} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{\frac{a}{{k}^{2}} \cdot 99}{k \cdot k} \]
      4. pow2N/A

        \[\leadsto \frac{\frac{a}{k \cdot k} \cdot 99}{k \cdot k} \]
      5. lift-*.f6471.8

        \[\leadsto \frac{\frac{a}{k \cdot k} \cdot 99}{k \cdot k} \]
    11. Applied rewrites71.8%

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

    if -0.25 < m < 0.0189999999999999995

    1. Initial program 94.1%

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

      \[\leadsto \color{blue}{\frac{a}{1 + \left(10 \cdot k + {k}^{2}\right)}} \]
    4. Step-by-step derivation
      1. 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. *-commutativeN/A

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

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

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

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

    if 0.0189999999999999995 < m

    1. Initial program 80.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. *-commutativeN/A

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(k \cdot \left(-1 \cdot \left(k \cdot \left(-10 \cdot a + -10 \cdot \left(a + -100 \cdot a\right)\right)\right) - \left(a + -100 \cdot a\right)\right) - 10 \cdot a, k, a\right) \]
    8. Applied rewrites20.8%

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

      \[\leadsto \mathsf{fma}\left(-10 \cdot a + 99 \cdot \left(a \cdot k\right), k, a\right) \]
    10. Step-by-step derivation
      1. +-commutativeN/A

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

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(99, a \cdot k, -10 \cdot a\right), k, a\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(99, k \cdot a, -10 \cdot a\right), k, a\right) \]
      4. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(99, k \cdot a, -10 \cdot a\right), k, a\right) \]
      5. lift-*.f6427.4

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(99, k \cdot a, -10 \cdot a\right), k, a\right) \]
    11. Applied rewrites27.4%

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

Alternative 4: 60.9% accurate, 3.8× speedup?

\[\begin{array}{l} a\_m = \left|a\right| \\ a\_s = \mathsf{copysign}\left(1, a\right) \\ a\_s \cdot \begin{array}{l} \mathbf{if}\;m \leq -490:\\ \;\;\;\;\frac{a\_m}{k \cdot k}\\ \mathbf{elif}\;m \leq 0.019:\\ \;\;\;\;\frac{a\_m}{\mathsf{fma}\left(10 + k, k, 1\right)}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(99, k \cdot a\_m, -10 \cdot a\_m\right), k, a\_m\right)\\ \end{array} \end{array} \]
a\_m = (fabs.f64 a)
a\_s = (copysign.f64 #s(literal 1 binary64) a)
(FPCore (a_s a_m k m)
 :precision binary64
 (*
  a_s
  (if (<= m -490.0)
    (/ a_m (* k k))
    (if (<= m 0.019)
      (/ a_m (fma (+ 10.0 k) k 1.0))
      (fma (fma 99.0 (* k a_m) (* -10.0 a_m)) k a_m)))))
a\_m = fabs(a);
a\_s = copysign(1.0, a);
double code(double a_s, double a_m, double k, double m) {
	double tmp;
	if (m <= -490.0) {
		tmp = a_m / (k * k);
	} else if (m <= 0.019) {
		tmp = a_m / fma((10.0 + k), k, 1.0);
	} else {
		tmp = fma(fma(99.0, (k * a_m), (-10.0 * a_m)), k, a_m);
	}
	return a_s * tmp;
}
a\_m = abs(a)
a\_s = copysign(1.0, a)
function code(a_s, a_m, k, m)
	tmp = 0.0
	if (m <= -490.0)
		tmp = Float64(a_m / Float64(k * k));
	elseif (m <= 0.019)
		tmp = Float64(a_m / fma(Float64(10.0 + k), k, 1.0));
	else
		tmp = fma(fma(99.0, Float64(k * a_m), Float64(-10.0 * a_m)), k, a_m);
	end
	return Float64(a_s * tmp)
end
a\_m = N[Abs[a], $MachinePrecision]
a\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, a$95$m_, k_, m_] := N[(a$95$s * If[LessEqual[m, -490.0], N[(a$95$m / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 0.019], N[(a$95$m / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(99.0 * N[(k * a$95$m), $MachinePrecision] + N[(-10.0 * a$95$m), $MachinePrecision]), $MachinePrecision] * k + a$95$m), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)

\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;m \leq -490:\\
\;\;\;\;\frac{a\_m}{k \cdot k}\\

\mathbf{elif}\;m \leq 0.019:\\
\;\;\;\;\frac{a\_m}{\mathsf{fma}\left(10 + k, k, 1\right)}\\

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


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

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

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

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

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

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

      \[\leadsto \frac{a}{\color{blue}{{k}^{2}}} \]
    7. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{a}{{k}^{\color{blue}{2}}} \]
      2. pow2N/A

        \[\leadsto \frac{a}{k \cdot k} \]
      3. lift-*.f6455.9

        \[\leadsto \frac{a}{k \cdot k} \]
    8. Applied rewrites55.9%

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

    if -490 < m < 0.0189999999999999995

    1. Initial program 94.1%

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

      \[\leadsto \color{blue}{\frac{a}{1 + \left(10 \cdot k + {k}^{2}\right)}} \]
    4. Step-by-step derivation
      1. 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. *-commutativeN/A

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

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

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

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

    if 0.0189999999999999995 < m

    1. Initial program 80.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. *-commutativeN/A

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(k \cdot \left(-1 \cdot \left(k \cdot \left(-10 \cdot a + -10 \cdot \left(a + -100 \cdot a\right)\right)\right) - \left(a + -100 \cdot a\right)\right) - 10 \cdot a, k, a\right) \]
    8. Applied rewrites20.8%

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

      \[\leadsto \mathsf{fma}\left(-10 \cdot a + 99 \cdot \left(a \cdot k\right), k, a\right) \]
    10. Step-by-step derivation
      1. +-commutativeN/A

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

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(99, a \cdot k, -10 \cdot a\right), k, a\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(99, k \cdot a, -10 \cdot a\right), k, a\right) \]
      4. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(99, k \cdot a, -10 \cdot a\right), k, a\right) \]
      5. lift-*.f6427.4

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(99, k \cdot a, -10 \cdot a\right), k, a\right) \]
    11. Applied rewrites27.4%

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

Alternative 5: 58.4% accurate, 4.1× speedup?

\[\begin{array}{l} a\_m = \left|a\right| \\ a\_s = \mathsf{copysign}\left(1, a\right) \\ a\_s \cdot \begin{array}{l} \mathbf{if}\;m \leq -490:\\ \;\;\;\;\frac{a\_m}{k \cdot k}\\ \mathbf{elif}\;m \leq 6.5 \cdot 10^{+33}:\\ \;\;\;\;\frac{a\_m}{\mathsf{fma}\left(10 + k, k, 1\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(-10 \cdot a\_m\right) \cdot k\\ \end{array} \end{array} \]
a\_m = (fabs.f64 a)
a\_s = (copysign.f64 #s(literal 1 binary64) a)
(FPCore (a_s a_m k m)
 :precision binary64
 (*
  a_s
  (if (<= m -490.0)
    (/ a_m (* k k))
    (if (<= m 6.5e+33) (/ a_m (fma (+ 10.0 k) k 1.0)) (* (* -10.0 a_m) k)))))
a\_m = fabs(a);
a\_s = copysign(1.0, a);
double code(double a_s, double a_m, double k, double m) {
	double tmp;
	if (m <= -490.0) {
		tmp = a_m / (k * k);
	} else if (m <= 6.5e+33) {
		tmp = a_m / fma((10.0 + k), k, 1.0);
	} else {
		tmp = (-10.0 * a_m) * k;
	}
	return a_s * tmp;
}
a\_m = abs(a)
a\_s = copysign(1.0, a)
function code(a_s, a_m, k, m)
	tmp = 0.0
	if (m <= -490.0)
		tmp = Float64(a_m / Float64(k * k));
	elseif (m <= 6.5e+33)
		tmp = Float64(a_m / fma(Float64(10.0 + k), k, 1.0));
	else
		tmp = Float64(Float64(-10.0 * a_m) * k);
	end
	return Float64(a_s * tmp)
end
a\_m = N[Abs[a], $MachinePrecision]
a\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, a$95$m_, k_, m_] := N[(a$95$s * If[LessEqual[m, -490.0], N[(a$95$m / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 6.5e+33], N[(a$95$m / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(-10.0 * a$95$m), $MachinePrecision] * k), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)

\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;m \leq -490:\\
\;\;\;\;\frac{a\_m}{k \cdot k}\\

\mathbf{elif}\;m \leq 6.5 \cdot 10^{+33}:\\
\;\;\;\;\frac{a\_m}{\mathsf{fma}\left(10 + k, k, 1\right)}\\

\mathbf{else}:\\
\;\;\;\;\left(-10 \cdot a\_m\right) \cdot k\\


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

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

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

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

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

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

      \[\leadsto \frac{a}{\color{blue}{{k}^{2}}} \]
    7. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{a}{{k}^{\color{blue}{2}}} \]
      2. pow2N/A

        \[\leadsto \frac{a}{k \cdot k} \]
      3. lift-*.f6455.9

        \[\leadsto \frac{a}{k \cdot k} \]
    8. Applied rewrites55.9%

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

    if -490 < m < 6.49999999999999993e33

    1. Initial program 92.5%

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

      \[\leadsto \color{blue}{\frac{a}{1 + \left(10 \cdot k + {k}^{2}\right)}} \]
    4. Step-by-step derivation
      1. 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. *-commutativeN/A

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

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

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

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

    if 6.49999999999999993e33 < m

    1. Initial program 81.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. *-commutativeN/A

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

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

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

      \[\leadsto \color{blue}{\frac{a}{\mathsf{fma}\left(10 + k, k, 1\right)}} \]
    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. *-commutativeN/A

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

        \[\leadsto \mathsf{fma}\left(a \cdot k, -10, a\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(k \cdot a, -10, a\right) \]
      5. lower-*.f649.0

        \[\leadsto \mathsf{fma}\left(k \cdot a, -10, a\right) \]
    8. Applied rewrites9.0%

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

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

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

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

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

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

Alternative 6: 57.6% accurate, 4.5× speedup?

\[\begin{array}{l} a\_m = \left|a\right| \\ a\_s = \mathsf{copysign}\left(1, a\right) \\ a\_s \cdot \begin{array}{l} \mathbf{if}\;m \leq -490:\\ \;\;\;\;\frac{a\_m}{k \cdot k}\\ \mathbf{elif}\;m \leq 6.5 \cdot 10^{+33}:\\ \;\;\;\;\frac{a\_m}{\mathsf{fma}\left(k, k, 1\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(-10 \cdot a\_m\right) \cdot k\\ \end{array} \end{array} \]
a\_m = (fabs.f64 a)
a\_s = (copysign.f64 #s(literal 1 binary64) a)
(FPCore (a_s a_m k m)
 :precision binary64
 (*
  a_s
  (if (<= m -490.0)
    (/ a_m (* k k))
    (if (<= m 6.5e+33) (/ a_m (fma k k 1.0)) (* (* -10.0 a_m) k)))))
a\_m = fabs(a);
a\_s = copysign(1.0, a);
double code(double a_s, double a_m, double k, double m) {
	double tmp;
	if (m <= -490.0) {
		tmp = a_m / (k * k);
	} else if (m <= 6.5e+33) {
		tmp = a_m / fma(k, k, 1.0);
	} else {
		tmp = (-10.0 * a_m) * k;
	}
	return a_s * tmp;
}
a\_m = abs(a)
a\_s = copysign(1.0, a)
function code(a_s, a_m, k, m)
	tmp = 0.0
	if (m <= -490.0)
		tmp = Float64(a_m / Float64(k * k));
	elseif (m <= 6.5e+33)
		tmp = Float64(a_m / fma(k, k, 1.0));
	else
		tmp = Float64(Float64(-10.0 * a_m) * k);
	end
	return Float64(a_s * tmp)
end
a\_m = N[Abs[a], $MachinePrecision]
a\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, a$95$m_, k_, m_] := N[(a$95$s * If[LessEqual[m, -490.0], N[(a$95$m / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 6.5e+33], N[(a$95$m / N[(k * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(-10.0 * a$95$m), $MachinePrecision] * k), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)

\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;m \leq -490:\\
\;\;\;\;\frac{a\_m}{k \cdot k}\\

\mathbf{elif}\;m \leq 6.5 \cdot 10^{+33}:\\
\;\;\;\;\frac{a\_m}{\mathsf{fma}\left(k, k, 1\right)}\\

\mathbf{else}:\\
\;\;\;\;\left(-10 \cdot a\_m\right) \cdot k\\


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

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

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

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

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

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

      \[\leadsto \frac{a}{\color{blue}{{k}^{2}}} \]
    7. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{a}{{k}^{\color{blue}{2}}} \]
      2. pow2N/A

        \[\leadsto \frac{a}{k \cdot k} \]
      3. lift-*.f6455.9

        \[\leadsto \frac{a}{k \cdot k} \]
    8. Applied rewrites55.9%

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

    if -490 < m < 6.49999999999999993e33

    1. Initial program 92.5%

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

      \[\leadsto \color{blue}{\frac{a}{1 + \left(10 \cdot k + {k}^{2}\right)}} \]
    4. Step-by-step derivation
      1. 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. *-commutativeN/A

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

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

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

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

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

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

      if 6.49999999999999993e33 < m

      1. Initial program 81.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. *-commutativeN/A

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

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

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

        \[\leadsto \color{blue}{\frac{a}{\mathsf{fma}\left(10 + k, k, 1\right)}} \]
      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. *-commutativeN/A

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

          \[\leadsto \mathsf{fma}\left(a \cdot k, -10, a\right) \]
        4. *-commutativeN/A

          \[\leadsto \mathsf{fma}\left(k \cdot a, -10, a\right) \]
        5. lower-*.f649.0

          \[\leadsto \mathsf{fma}\left(k \cdot a, -10, a\right) \]
      8. Applied rewrites9.0%

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

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

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

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

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

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

    Alternative 7: 46.2% accurate, 4.6× speedup?

    \[\begin{array}{l} a\_m = \left|a\right| \\ a\_s = \mathsf{copysign}\left(1, a\right) \\ a\_s \cdot \begin{array}{l} \mathbf{if}\;k \leq 4.1 \cdot 10^{-265} \lor \neg \left(k \leq 0.1\right):\\ \;\;\;\;\frac{a\_m}{k \cdot k}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(k \cdot a\_m, -10, a\_m\right)\\ \end{array} \end{array} \]
    a\_m = (fabs.f64 a)
    a\_s = (copysign.f64 #s(literal 1 binary64) a)
    (FPCore (a_s a_m k m)
     :precision binary64
     (*
      a_s
      (if (or (<= k 4.1e-265) (not (<= k 0.1)))
        (/ a_m (* k k))
        (fma (* k a_m) -10.0 a_m))))
    a\_m = fabs(a);
    a\_s = copysign(1.0, a);
    double code(double a_s, double a_m, double k, double m) {
    	double tmp;
    	if ((k <= 4.1e-265) || !(k <= 0.1)) {
    		tmp = a_m / (k * k);
    	} else {
    		tmp = fma((k * a_m), -10.0, a_m);
    	}
    	return a_s * tmp;
    }
    
    a\_m = abs(a)
    a\_s = copysign(1.0, a)
    function code(a_s, a_m, k, m)
    	tmp = 0.0
    	if ((k <= 4.1e-265) || !(k <= 0.1))
    		tmp = Float64(a_m / Float64(k * k));
    	else
    		tmp = fma(Float64(k * a_m), -10.0, a_m);
    	end
    	return Float64(a_s * tmp)
    end
    
    a\_m = N[Abs[a], $MachinePrecision]
    a\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
    code[a$95$s_, a$95$m_, k_, m_] := N[(a$95$s * If[Or[LessEqual[k, 4.1e-265], N[Not[LessEqual[k, 0.1]], $MachinePrecision]], N[(a$95$m / N[(k * k), $MachinePrecision]), $MachinePrecision], N[(N[(k * a$95$m), $MachinePrecision] * -10.0 + a$95$m), $MachinePrecision]]), $MachinePrecision]
    
    \begin{array}{l}
    a\_m = \left|a\right|
    \\
    a\_s = \mathsf{copysign}\left(1, a\right)
    
    \\
    a\_s \cdot \begin{array}{l}
    \mathbf{if}\;k \leq 4.1 \cdot 10^{-265} \lor \neg \left(k \leq 0.1\right):\\
    \;\;\;\;\frac{a\_m}{k \cdot k}\\
    
    \mathbf{else}:\\
    \;\;\;\;\mathsf{fma}\left(k \cdot a\_m, -10, a\_m\right)\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if k < 4.1e-265 or 0.10000000000000001 < k

      1. Initial program 87.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. *-commutativeN/A

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

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

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

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

        \[\leadsto \frac{a}{\color{blue}{{k}^{2}}} \]
      7. Step-by-step derivation
        1. lower-/.f64N/A

          \[\leadsto \frac{a}{{k}^{\color{blue}{2}}} \]
        2. pow2N/A

          \[\leadsto \frac{a}{k \cdot k} \]
        3. lift-*.f6442.8

          \[\leadsto \frac{a}{k \cdot k} \]
      8. Applied rewrites42.8%

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

      if 4.1e-265 < k < 0.10000000000000001

      1. Initial program 99.9%

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

        \[\leadsto \color{blue}{\frac{a}{1 + \left(10 \cdot k + {k}^{2}\right)}} \]
      4. Step-by-step derivation
        1. 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. *-commutativeN/A

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

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

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

        \[\leadsto \color{blue}{\frac{a}{\mathsf{fma}\left(10 + k, k, 1\right)}} \]
      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. *-commutativeN/A

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

          \[\leadsto \mathsf{fma}\left(a \cdot k, -10, a\right) \]
        4. *-commutativeN/A

          \[\leadsto \mathsf{fma}\left(k \cdot a, -10, a\right) \]
        5. lower-*.f6449.5

          \[\leadsto \mathsf{fma}\left(k \cdot a, -10, a\right) \]
      8. Applied rewrites49.5%

        \[\leadsto \mathsf{fma}\left(k \cdot a, \color{blue}{-10}, a\right) \]
    3. Recombined 2 regimes into one program.
    4. Final simplification45.0%

      \[\leadsto \begin{array}{l} \mathbf{if}\;k \leq 4.1 \cdot 10^{-265} \lor \neg \left(k \leq 0.1\right):\\ \;\;\;\;\frac{a}{k \cdot k}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(k \cdot a, -10, a\right)\\ \end{array} \]
    5. Add Preprocessing

    Alternative 8: 25.5% accurate, 7.9× speedup?

    \[\begin{array}{l} a\_m = \left|a\right| \\ a\_s = \mathsf{copysign}\left(1, a\right) \\ a\_s \cdot \begin{array}{l} \mathbf{if}\;m \leq 6.5 \cdot 10^{+33}:\\ \;\;\;\;a\_m\\ \mathbf{else}:\\ \;\;\;\;\left(-10 \cdot a\_m\right) \cdot k\\ \end{array} \end{array} \]
    a\_m = (fabs.f64 a)
    a\_s = (copysign.f64 #s(literal 1 binary64) a)
    (FPCore (a_s a_m k m)
     :precision binary64
     (* a_s (if (<= m 6.5e+33) a_m (* (* -10.0 a_m) k))))
    a\_m = fabs(a);
    a\_s = copysign(1.0, a);
    double code(double a_s, double a_m, double k, double m) {
    	double tmp;
    	if (m <= 6.5e+33) {
    		tmp = a_m;
    	} else {
    		tmp = (-10.0 * a_m) * k;
    	}
    	return a_s * tmp;
    }
    
    a\_m =     private
    a\_s =     private
    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_s, a_m, k, m)
    use fmin_fmax_functions
        real(8), intent (in) :: a_s
        real(8), intent (in) :: a_m
        real(8), intent (in) :: k
        real(8), intent (in) :: m
        real(8) :: tmp
        if (m <= 6.5d+33) then
            tmp = a_m
        else
            tmp = ((-10.0d0) * a_m) * k
        end if
        code = a_s * tmp
    end function
    
    a\_m = Math.abs(a);
    a\_s = Math.copySign(1.0, a);
    public static double code(double a_s, double a_m, double k, double m) {
    	double tmp;
    	if (m <= 6.5e+33) {
    		tmp = a_m;
    	} else {
    		tmp = (-10.0 * a_m) * k;
    	}
    	return a_s * tmp;
    }
    
    a\_m = math.fabs(a)
    a\_s = math.copysign(1.0, a)
    def code(a_s, a_m, k, m):
    	tmp = 0
    	if m <= 6.5e+33:
    		tmp = a_m
    	else:
    		tmp = (-10.0 * a_m) * k
    	return a_s * tmp
    
    a\_m = abs(a)
    a\_s = copysign(1.0, a)
    function code(a_s, a_m, k, m)
    	tmp = 0.0
    	if (m <= 6.5e+33)
    		tmp = a_m;
    	else
    		tmp = Float64(Float64(-10.0 * a_m) * k);
    	end
    	return Float64(a_s * tmp)
    end
    
    a\_m = abs(a);
    a\_s = sign(a) * abs(1.0);
    function tmp_2 = code(a_s, a_m, k, m)
    	tmp = 0.0;
    	if (m <= 6.5e+33)
    		tmp = a_m;
    	else
    		tmp = (-10.0 * a_m) * k;
    	end
    	tmp_2 = a_s * tmp;
    end
    
    a\_m = N[Abs[a], $MachinePrecision]
    a\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
    code[a$95$s_, a$95$m_, k_, m_] := N[(a$95$s * If[LessEqual[m, 6.5e+33], a$95$m, N[(N[(-10.0 * a$95$m), $MachinePrecision] * k), $MachinePrecision]]), $MachinePrecision]
    
    \begin{array}{l}
    a\_m = \left|a\right|
    \\
    a\_s = \mathsf{copysign}\left(1, a\right)
    
    \\
    a\_s \cdot \begin{array}{l}
    \mathbf{if}\;m \leq 6.5 \cdot 10^{+33}:\\
    \;\;\;\;a\_m\\
    
    \mathbf{else}:\\
    \;\;\;\;\left(-10 \cdot a\_m\right) \cdot k\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if m < 6.49999999999999993e33

      1. Initial program 95.8%

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

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

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

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

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

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

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

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

          \[\leadsto a \]

        if 6.49999999999999993e33 < m

        1. Initial program 81.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. *-commutativeN/A

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

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

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

          \[\leadsto \color{blue}{\frac{a}{\mathsf{fma}\left(10 + k, k, 1\right)}} \]
        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. *-commutativeN/A

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

            \[\leadsto \mathsf{fma}\left(a \cdot k, -10, a\right) \]
          4. *-commutativeN/A

            \[\leadsto \mathsf{fma}\left(k \cdot a, -10, a\right) \]
          5. lower-*.f649.0

            \[\leadsto \mathsf{fma}\left(k \cdot a, -10, a\right) \]
        8. Applied rewrites9.0%

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

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

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

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

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

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

      Alternative 9: 20.3% accurate, 134.0× speedup?

      \[\begin{array}{l} a\_m = \left|a\right| \\ a\_s = \mathsf{copysign}\left(1, a\right) \\ a\_s \cdot a\_m \end{array} \]
      a\_m = (fabs.f64 a)
      a\_s = (copysign.f64 #s(literal 1 binary64) a)
      (FPCore (a_s a_m k m) :precision binary64 (* a_s a_m))
      a\_m = fabs(a);
      a\_s = copysign(1.0, a);
      double code(double a_s, double a_m, double k, double m) {
      	return a_s * a_m;
      }
      
      a\_m =     private
      a\_s =     private
      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_s, a_m, k, m)
      use fmin_fmax_functions
          real(8), intent (in) :: a_s
          real(8), intent (in) :: a_m
          real(8), intent (in) :: k
          real(8), intent (in) :: m
          code = a_s * a_m
      end function
      
      a\_m = Math.abs(a);
      a\_s = Math.copySign(1.0, a);
      public static double code(double a_s, double a_m, double k, double m) {
      	return a_s * a_m;
      }
      
      a\_m = math.fabs(a)
      a\_s = math.copysign(1.0, a)
      def code(a_s, a_m, k, m):
      	return a_s * a_m
      
      a\_m = abs(a)
      a\_s = copysign(1.0, a)
      function code(a_s, a_m, k, m)
      	return Float64(a_s * a_m)
      end
      
      a\_m = abs(a);
      a\_s = sign(a) * abs(1.0);
      function tmp = code(a_s, a_m, k, m)
      	tmp = a_s * a_m;
      end
      
      a\_m = N[Abs[a], $MachinePrecision]
      a\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
      code[a$95$s_, a$95$m_, k_, m_] := N[(a$95$s * a$95$m), $MachinePrecision]
      
      \begin{array}{l}
      a\_m = \left|a\right|
      \\
      a\_s = \mathsf{copysign}\left(1, a\right)
      
      \\
      a\_s \cdot a\_m
      \end{array}
      
      Derivation
      1. Initial program 91.2%

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

        \[\leadsto \color{blue}{\frac{a}{1 + \left(10 \cdot k + {k}^{2}\right)}} \]
      4. Step-by-step derivation
        1. 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. *-commutativeN/A

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

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

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

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

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

          \[\leadsto a \]
        2. Add Preprocessing

        Reproduce

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