Falkner and Boettcher, Appendix A

Percentage Accurate: 90.3% → 97.7%
Time: 6.0s
Alternatives: 8
Speedup: 1.1×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 8 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.3% accurate, 1.0× speedup?

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

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

Alternative 1: 97.7% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := a \cdot {k}^{m}\\ \mathbf{if}\;\frac{t_0}{\left(1 + k \cdot 10\right) + k \cdot k} \leq 2 \cdot 10^{+207}:\\ \;\;\;\;\frac{t_0}{1 + k \cdot \left(k + 10\right)}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (a k m)
 :precision binary64
 (let* ((t_0 (* a (pow k m))))
   (if (<= (/ t_0 (+ (+ 1.0 (* k 10.0)) (* k k))) 2e+207)
     (/ t_0 (+ 1.0 (* k (+ k 10.0))))
     t_0)))
double code(double a, double k, double m) {
	double t_0 = a * pow(k, m);
	double tmp;
	if ((t_0 / ((1.0 + (k * 10.0)) + (k * k))) <= 2e+207) {
		tmp = t_0 / (1.0 + (k * (k + 10.0)));
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(a, k, m)
    real(8), intent (in) :: a
    real(8), intent (in) :: k
    real(8), intent (in) :: m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = a * (k ** m)
    if ((t_0 / ((1.0d0 + (k * 10.0d0)) + (k * k))) <= 2d+207) then
        tmp = t_0 / (1.0d0 + (k * (k + 10.0d0)))
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double a, double k, double m) {
	double t_0 = a * Math.pow(k, m);
	double tmp;
	if ((t_0 / ((1.0 + (k * 10.0)) + (k * k))) <= 2e+207) {
		tmp = t_0 / (1.0 + (k * (k + 10.0)));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(a, k, m):
	t_0 = a * math.pow(k, m)
	tmp = 0
	if (t_0 / ((1.0 + (k * 10.0)) + (k * k))) <= 2e+207:
		tmp = t_0 / (1.0 + (k * (k + 10.0)))
	else:
		tmp = t_0
	return tmp
function code(a, k, m)
	t_0 = Float64(a * (k ^ m))
	tmp = 0.0
	if (Float64(t_0 / Float64(Float64(1.0 + Float64(k * 10.0)) + Float64(k * k))) <= 2e+207)
		tmp = Float64(t_0 / Float64(1.0 + Float64(k * Float64(k + 10.0))));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(a, k, m)
	t_0 = a * (k ^ m);
	tmp = 0.0;
	if ((t_0 / ((1.0 + (k * 10.0)) + (k * k))) <= 2e+207)
		tmp = t_0 / (1.0 + (k * (k + 10.0)));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[a_, k_, m_] := Block[{t$95$0 = N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 / N[(N[(1.0 + N[(k * 10.0), $MachinePrecision]), $MachinePrecision] + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2e+207], N[(t$95$0 / N[(1.0 + N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := a \cdot {k}^{m}\\
\mathbf{if}\;\frac{t_0}{\left(1 + k \cdot 10\right) + k \cdot k} \leq 2 \cdot 10^{+207}:\\
\;\;\;\;\frac{t_0}{1 + k \cdot \left(k + 10\right)}\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 1 (*.f64 10 k)) (*.f64 k k))) < 2.0000000000000001e207

    1. Initial program 97.6%

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Step-by-step derivation
      1. sqr-neg97.6%

        \[\leadsto \frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + \color{blue}{\left(-k\right) \cdot \left(-k\right)}} \]
      2. associate-+l+97.6%

        \[\leadsto \frac{a \cdot {k}^{m}}{\color{blue}{1 + \left(10 \cdot k + \left(-k\right) \cdot \left(-k\right)\right)}} \]
      3. sqr-neg97.6%

        \[\leadsto \frac{a \cdot {k}^{m}}{1 + \left(10 \cdot k + \color{blue}{k \cdot k}\right)} \]
      4. distribute-rgt-out97.6%

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

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

    if 2.0000000000000001e207 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 1 (*.f64 10 k)) (*.f64 k k)))

    1. Initial program 67.2%

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Step-by-step derivation
      1. sqr-neg67.2%

        \[\leadsto \frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + \color{blue}{\left(-k\right) \cdot \left(-k\right)}} \]
      2. associate-+l+67.2%

        \[\leadsto \frac{a \cdot {k}^{m}}{\color{blue}{1 + \left(10 \cdot k + \left(-k\right) \cdot \left(-k\right)\right)}} \]
      3. sqr-neg67.2%

        \[\leadsto \frac{a \cdot {k}^{m}}{1 + \left(10 \cdot k + \color{blue}{k \cdot k}\right)} \]
      4. distribute-rgt-out67.2%

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

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

      \[\leadsto \color{blue}{a \cdot {k}^{m}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{a \cdot {k}^{m}}{\left(1 + k \cdot 10\right) + k \cdot k} \leq 2 \cdot 10^{+207}:\\ \;\;\;\;\frac{a \cdot {k}^{m}}{1 + k \cdot \left(k + 10\right)}\\ \mathbf{else}:\\ \;\;\;\;a \cdot {k}^{m}\\ \end{array} \]

Alternative 2: 97.1% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;m \leq -3.3 \cdot 10^{-17} \lor \neg \left(m \leq 1.25 \cdot 10^{-11}\right):\\
\;\;\;\;a \cdot {k}^{m}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if m < -3.3e-17 or 1.25000000000000005e-11 < m

    1. Initial program 87.9%

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Step-by-step derivation
      1. sqr-neg87.9%

        \[\leadsto \frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + \color{blue}{\left(-k\right) \cdot \left(-k\right)}} \]
      2. associate-+l+87.9%

        \[\leadsto \frac{a \cdot {k}^{m}}{\color{blue}{1 + \left(10 \cdot k + \left(-k\right) \cdot \left(-k\right)\right)}} \]
      3. sqr-neg87.9%

        \[\leadsto \frac{a \cdot {k}^{m}}{1 + \left(10 \cdot k + \color{blue}{k \cdot k}\right)} \]
      4. distribute-rgt-out87.9%

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

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

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

    if -3.3e-17 < m < 1.25000000000000005e-11

    1. Initial program 95.8%

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Step-by-step derivation
      1. sqr-neg95.8%

        \[\leadsto \frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + \color{blue}{\left(-k\right) \cdot \left(-k\right)}} \]
      2. associate-+l+95.8%

        \[\leadsto \frac{a \cdot {k}^{m}}{\color{blue}{1 + \left(10 \cdot k + \left(-k\right) \cdot \left(-k\right)\right)}} \]
      3. sqr-neg95.8%

        \[\leadsto \frac{a \cdot {k}^{m}}{1 + \left(10 \cdot k + \color{blue}{k \cdot k}\right)} \]
      4. distribute-rgt-out95.8%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;m \leq -3.3 \cdot 10^{-17} \lor \neg \left(m \leq 1.25 \cdot 10^{-11}\right):\\ \;\;\;\;a \cdot {k}^{m}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{1 + k \cdot \left(k + 10\right)}\\ \end{array} \]

Alternative 3: 50.5% accurate, 10.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq 1.35:\\ \;\;\;\;\frac{a}{1 + k \cdot \left(k + 10\right)}\\ \mathbf{else}:\\ \;\;\;\;-10 \cdot \left(a \cdot k\right)\\ \end{array} \end{array} \]
(FPCore (a k m)
 :precision binary64
 (if (<= m 1.35) (/ a (+ 1.0 (* k (+ k 10.0)))) (* -10.0 (* a k))))
double code(double a, double k, double m) {
	double tmp;
	if (m <= 1.35) {
		tmp = a / (1.0 + (k * (k + 10.0)));
	} else {
		tmp = -10.0 * (a * k);
	}
	return tmp;
}
real(8) function code(a, k, m)
    real(8), intent (in) :: a
    real(8), intent (in) :: k
    real(8), intent (in) :: m
    real(8) :: tmp
    if (m <= 1.35d0) then
        tmp = a / (1.0d0 + (k * (k + 10.0d0)))
    else
        tmp = (-10.0d0) * (a * k)
    end if
    code = tmp
end function
public static double code(double a, double k, double m) {
	double tmp;
	if (m <= 1.35) {
		tmp = a / (1.0 + (k * (k + 10.0)));
	} else {
		tmp = -10.0 * (a * k);
	}
	return tmp;
}
def code(a, k, m):
	tmp = 0
	if m <= 1.35:
		tmp = a / (1.0 + (k * (k + 10.0)))
	else:
		tmp = -10.0 * (a * k)
	return tmp
function code(a, k, m)
	tmp = 0.0
	if (m <= 1.35)
		tmp = Float64(a / Float64(1.0 + Float64(k * Float64(k + 10.0))));
	else
		tmp = Float64(-10.0 * Float64(a * k));
	end
	return tmp
end
function tmp_2 = code(a, k, m)
	tmp = 0.0;
	if (m <= 1.35)
		tmp = a / (1.0 + (k * (k + 10.0)));
	else
		tmp = -10.0 * (a * k);
	end
	tmp_2 = tmp;
end
code[a_, k_, m_] := If[LessEqual[m, 1.35], N[(a / N[(1.0 + N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-10.0 * N[(a * k), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 97.3%

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Step-by-step derivation
      1. sqr-neg97.3%

        \[\leadsto \frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + \color{blue}{\left(-k\right) \cdot \left(-k\right)}} \]
      2. associate-+l+97.3%

        \[\leadsto \frac{a \cdot {k}^{m}}{\color{blue}{1 + \left(10 \cdot k + \left(-k\right) \cdot \left(-k\right)\right)}} \]
      3. sqr-neg97.3%

        \[\leadsto \frac{a \cdot {k}^{m}}{1 + \left(10 \cdot k + \color{blue}{k \cdot k}\right)} \]
      4. distribute-rgt-out97.3%

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

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

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

    if 1.3500000000000001 < m

    1. Initial program 77.1%

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Step-by-step derivation
      1. sqr-neg77.1%

        \[\leadsto \frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + \color{blue}{\left(-k\right) \cdot \left(-k\right)}} \]
      2. associate-+l+77.1%

        \[\leadsto \frac{a \cdot {k}^{m}}{\color{blue}{1 + \left(10 \cdot k + \left(-k\right) \cdot \left(-k\right)\right)}} \]
      3. sqr-neg77.1%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;m \leq 1.35:\\ \;\;\;\;\frac{a}{1 + k \cdot \left(k + 10\right)}\\ \mathbf{else}:\\ \;\;\;\;-10 \cdot \left(a \cdot k\right)\\ \end{array} \]

Alternative 4: 31.4% accurate, 12.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq -3.7 \cdot 10^{-9}:\\ \;\;\;\;0.1 \cdot \frac{a}{k}\\ \mathbf{elif}\;m \leq 0.215:\\ \;\;\;\;a\\ \mathbf{else}:\\ \;\;\;\;-10 \cdot \left(a \cdot k\right)\\ \end{array} \end{array} \]
(FPCore (a k m)
 :precision binary64
 (if (<= m -3.7e-9) (* 0.1 (/ a k)) (if (<= m 0.215) a (* -10.0 (* a k)))))
double code(double a, double k, double m) {
	double tmp;
	if (m <= -3.7e-9) {
		tmp = 0.1 * (a / k);
	} else if (m <= 0.215) {
		tmp = a;
	} else {
		tmp = -10.0 * (a * k);
	}
	return tmp;
}
real(8) function code(a, k, m)
    real(8), intent (in) :: a
    real(8), intent (in) :: k
    real(8), intent (in) :: m
    real(8) :: tmp
    if (m <= (-3.7d-9)) then
        tmp = 0.1d0 * (a / k)
    else if (m <= 0.215d0) then
        tmp = a
    else
        tmp = (-10.0d0) * (a * k)
    end if
    code = tmp
end function
public static double code(double a, double k, double m) {
	double tmp;
	if (m <= -3.7e-9) {
		tmp = 0.1 * (a / k);
	} else if (m <= 0.215) {
		tmp = a;
	} else {
		tmp = -10.0 * (a * k);
	}
	return tmp;
}
def code(a, k, m):
	tmp = 0
	if m <= -3.7e-9:
		tmp = 0.1 * (a / k)
	elif m <= 0.215:
		tmp = a
	else:
		tmp = -10.0 * (a * k)
	return tmp
function code(a, k, m)
	tmp = 0.0
	if (m <= -3.7e-9)
		tmp = Float64(0.1 * Float64(a / k));
	elseif (m <= 0.215)
		tmp = a;
	else
		tmp = Float64(-10.0 * Float64(a * k));
	end
	return tmp
end
function tmp_2 = code(a, k, m)
	tmp = 0.0;
	if (m <= -3.7e-9)
		tmp = 0.1 * (a / k);
	elseif (m <= 0.215)
		tmp = a;
	else
		tmp = -10.0 * (a * k);
	end
	tmp_2 = tmp;
end
code[a_, k_, m_] := If[LessEqual[m, -3.7e-9], N[(0.1 * N[(a / k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 0.215], a, N[(-10.0 * N[(a * k), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;m \leq -3.7 \cdot 10^{-9}:\\
\;\;\;\;0.1 \cdot \frac{a}{k}\\

\mathbf{elif}\;m \leq 0.215:\\
\;\;\;\;a\\

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


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

    1. Initial program 98.8%

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Step-by-step derivation
      1. sqr-neg98.8%

        \[\leadsto \frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + \color{blue}{\left(-k\right) \cdot \left(-k\right)}} \]
      2. associate-+l+98.8%

        \[\leadsto \frac{a \cdot {k}^{m}}{\color{blue}{1 + \left(10 \cdot k + \left(-k\right) \cdot \left(-k\right)\right)}} \]
      3. sqr-neg98.8%

        \[\leadsto \frac{a \cdot {k}^{m}}{1 + \left(10 \cdot k + \color{blue}{k \cdot k}\right)} \]
      4. distribute-rgt-out98.8%

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

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

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

      \[\leadsto \frac{a}{1 + \color{blue}{10 \cdot k}} \]
    6. Step-by-step derivation
      1. *-commutative19.5%

        \[\leadsto \frac{a}{1 + \color{blue}{k \cdot 10}} \]
    7. Simplified19.5%

      \[\leadsto \frac{a}{1 + \color{blue}{k \cdot 10}} \]
    8. Taylor expanded in k around inf 22.7%

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

    if -3.7e-9 < m < 0.214999999999999997

    1. Initial program 96.0%

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Step-by-step derivation
      1. sqr-neg96.0%

        \[\leadsto \frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + \color{blue}{\left(-k\right) \cdot \left(-k\right)}} \]
      2. associate-+l+96.0%

        \[\leadsto \frac{a \cdot {k}^{m}}{\color{blue}{1 + \left(10 \cdot k + \left(-k\right) \cdot \left(-k\right)\right)}} \]
      3. sqr-neg96.0%

        \[\leadsto \frac{a \cdot {k}^{m}}{1 + \left(10 \cdot k + \color{blue}{k \cdot k}\right)} \]
      4. distribute-rgt-out96.0%

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

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

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

      \[\leadsto \color{blue}{a} \]

    if 0.214999999999999997 < m

    1. Initial program 77.1%

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Step-by-step derivation
      1. sqr-neg77.1%

        \[\leadsto \frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + \color{blue}{\left(-k\right) \cdot \left(-k\right)}} \]
      2. associate-+l+77.1%

        \[\leadsto \frac{a \cdot {k}^{m}}{\color{blue}{1 + \left(10 \cdot k + \left(-k\right) \cdot \left(-k\right)\right)}} \]
      3. sqr-neg77.1%

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

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

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

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

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

      \[\leadsto \color{blue}{-10 \cdot \left(a \cdot k\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification34.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;m \leq -3.7 \cdot 10^{-9}:\\ \;\;\;\;0.1 \cdot \frac{a}{k}\\ \mathbf{elif}\;m \leq 0.215:\\ \;\;\;\;a\\ \mathbf{else}:\\ \;\;\;\;-10 \cdot \left(a \cdot k\right)\\ \end{array} \]

Alternative 5: 31.5% accurate, 12.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq -8.8 \cdot 10^{-8}:\\ \;\;\;\;\frac{0.1}{\frac{k}{a}}\\ \mathbf{elif}\;m \leq 0.62:\\ \;\;\;\;a\\ \mathbf{else}:\\ \;\;\;\;-10 \cdot \left(a \cdot k\right)\\ \end{array} \end{array} \]
(FPCore (a k m)
 :precision binary64
 (if (<= m -8.8e-8) (/ 0.1 (/ k a)) (if (<= m 0.62) a (* -10.0 (* a k)))))
double code(double a, double k, double m) {
	double tmp;
	if (m <= -8.8e-8) {
		tmp = 0.1 / (k / a);
	} else if (m <= 0.62) {
		tmp = a;
	} else {
		tmp = -10.0 * (a * k);
	}
	return tmp;
}
real(8) function code(a, k, m)
    real(8), intent (in) :: a
    real(8), intent (in) :: k
    real(8), intent (in) :: m
    real(8) :: tmp
    if (m <= (-8.8d-8)) then
        tmp = 0.1d0 / (k / a)
    else if (m <= 0.62d0) then
        tmp = a
    else
        tmp = (-10.0d0) * (a * k)
    end if
    code = tmp
end function
public static double code(double a, double k, double m) {
	double tmp;
	if (m <= -8.8e-8) {
		tmp = 0.1 / (k / a);
	} else if (m <= 0.62) {
		tmp = a;
	} else {
		tmp = -10.0 * (a * k);
	}
	return tmp;
}
def code(a, k, m):
	tmp = 0
	if m <= -8.8e-8:
		tmp = 0.1 / (k / a)
	elif m <= 0.62:
		tmp = a
	else:
		tmp = -10.0 * (a * k)
	return tmp
function code(a, k, m)
	tmp = 0.0
	if (m <= -8.8e-8)
		tmp = Float64(0.1 / Float64(k / a));
	elseif (m <= 0.62)
		tmp = a;
	else
		tmp = Float64(-10.0 * Float64(a * k));
	end
	return tmp
end
function tmp_2 = code(a, k, m)
	tmp = 0.0;
	if (m <= -8.8e-8)
		tmp = 0.1 / (k / a);
	elseif (m <= 0.62)
		tmp = a;
	else
		tmp = -10.0 * (a * k);
	end
	tmp_2 = tmp;
end
code[a_, k_, m_] := If[LessEqual[m, -8.8e-8], N[(0.1 / N[(k / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 0.62], a, N[(-10.0 * N[(a * k), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;m \leq -8.8 \cdot 10^{-8}:\\
\;\;\;\;\frac{0.1}{\frac{k}{a}}\\

\mathbf{elif}\;m \leq 0.62:\\
\;\;\;\;a\\

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


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

    1. Initial program 98.8%

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Step-by-step derivation
      1. sqr-neg98.8%

        \[\leadsto \frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + \color{blue}{\left(-k\right) \cdot \left(-k\right)}} \]
      2. associate-+l+98.8%

        \[\leadsto \frac{a \cdot {k}^{m}}{\color{blue}{1 + \left(10 \cdot k + \left(-k\right) \cdot \left(-k\right)\right)}} \]
      3. sqr-neg98.8%

        \[\leadsto \frac{a \cdot {k}^{m}}{1 + \left(10 \cdot k + \color{blue}{k \cdot k}\right)} \]
      4. distribute-rgt-out98.8%

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

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

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

      \[\leadsto \frac{a}{1 + \color{blue}{10 \cdot k}} \]
    6. Step-by-step derivation
      1. *-commutative19.5%

        \[\leadsto \frac{a}{1 + \color{blue}{k \cdot 10}} \]
    7. Simplified19.5%

      \[\leadsto \frac{a}{1 + \color{blue}{k \cdot 10}} \]
    8. Taylor expanded in k around inf 22.7%

      \[\leadsto \color{blue}{0.1 \cdot \frac{a}{k}} \]
    9. Step-by-step derivation
      1. clear-num23.1%

        \[\leadsto 0.1 \cdot \color{blue}{\frac{1}{\frac{k}{a}}} \]
      2. un-div-inv23.1%

        \[\leadsto \color{blue}{\frac{0.1}{\frac{k}{a}}} \]
    10. Applied egg-rr23.1%

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

    if -8.7999999999999994e-8 < m < 0.619999999999999996

    1. Initial program 96.0%

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Step-by-step derivation
      1. sqr-neg96.0%

        \[\leadsto \frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + \color{blue}{\left(-k\right) \cdot \left(-k\right)}} \]
      2. associate-+l+96.0%

        \[\leadsto \frac{a \cdot {k}^{m}}{\color{blue}{1 + \left(10 \cdot k + \left(-k\right) \cdot \left(-k\right)\right)}} \]
      3. sqr-neg96.0%

        \[\leadsto \frac{a \cdot {k}^{m}}{1 + \left(10 \cdot k + \color{blue}{k \cdot k}\right)} \]
      4. distribute-rgt-out96.0%

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

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

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

      \[\leadsto \color{blue}{a} \]

    if 0.619999999999999996 < m

    1. Initial program 77.1%

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Step-by-step derivation
      1. sqr-neg77.1%

        \[\leadsto \frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + \color{blue}{\left(-k\right) \cdot \left(-k\right)}} \]
      2. associate-+l+77.1%

        \[\leadsto \frac{a \cdot {k}^{m}}{\color{blue}{1 + \left(10 \cdot k + \left(-k\right) \cdot \left(-k\right)\right)}} \]
      3. sqr-neg77.1%

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

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

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

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

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

      \[\leadsto \color{blue}{-10 \cdot \left(a \cdot k\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification34.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;m \leq -8.8 \cdot 10^{-8}:\\ \;\;\;\;\frac{0.1}{\frac{k}{a}}\\ \mathbf{elif}\;m \leq 0.62:\\ \;\;\;\;a\\ \mathbf{else}:\\ \;\;\;\;-10 \cdot \left(a \cdot k\right)\\ \end{array} \]

Alternative 6: 34.0% accurate, 12.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq 1.7:\\ \;\;\;\;\frac{a}{1 + k \cdot 10}\\ \mathbf{else}:\\ \;\;\;\;-10 \cdot \left(a \cdot k\right)\\ \end{array} \end{array} \]
(FPCore (a k m)
 :precision binary64
 (if (<= m 1.7) (/ a (+ 1.0 (* k 10.0))) (* -10.0 (* a k))))
double code(double a, double k, double m) {
	double tmp;
	if (m <= 1.7) {
		tmp = a / (1.0 + (k * 10.0));
	} else {
		tmp = -10.0 * (a * k);
	}
	return tmp;
}
real(8) function code(a, k, m)
    real(8), intent (in) :: a
    real(8), intent (in) :: k
    real(8), intent (in) :: m
    real(8) :: tmp
    if (m <= 1.7d0) then
        tmp = a / (1.0d0 + (k * 10.0d0))
    else
        tmp = (-10.0d0) * (a * k)
    end if
    code = tmp
end function
public static double code(double a, double k, double m) {
	double tmp;
	if (m <= 1.7) {
		tmp = a / (1.0 + (k * 10.0));
	} else {
		tmp = -10.0 * (a * k);
	}
	return tmp;
}
def code(a, k, m):
	tmp = 0
	if m <= 1.7:
		tmp = a / (1.0 + (k * 10.0))
	else:
		tmp = -10.0 * (a * k)
	return tmp
function code(a, k, m)
	tmp = 0.0
	if (m <= 1.7)
		tmp = Float64(a / Float64(1.0 + Float64(k * 10.0)));
	else
		tmp = Float64(-10.0 * Float64(a * k));
	end
	return tmp
end
function tmp_2 = code(a, k, m)
	tmp = 0.0;
	if (m <= 1.7)
		tmp = a / (1.0 + (k * 10.0));
	else
		tmp = -10.0 * (a * k);
	end
	tmp_2 = tmp;
end
code[a_, k_, m_] := If[LessEqual[m, 1.7], N[(a / N[(1.0 + N[(k * 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-10.0 * N[(a * k), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;m \leq 1.7:\\
\;\;\;\;\frac{a}{1 + k \cdot 10}\\

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


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

    1. Initial program 97.3%

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Step-by-step derivation
      1. sqr-neg97.3%

        \[\leadsto \frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + \color{blue}{\left(-k\right) \cdot \left(-k\right)}} \]
      2. associate-+l+97.3%

        \[\leadsto \frac{a \cdot {k}^{m}}{\color{blue}{1 + \left(10 \cdot k + \left(-k\right) \cdot \left(-k\right)\right)}} \]
      3. sqr-neg97.3%

        \[\leadsto \frac{a \cdot {k}^{m}}{1 + \left(10 \cdot k + \color{blue}{k \cdot k}\right)} \]
      4. distribute-rgt-out97.3%

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

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

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

      \[\leadsto \frac{a}{1 + \color{blue}{10 \cdot k}} \]
    6. Step-by-step derivation
      1. *-commutative46.9%

        \[\leadsto \frac{a}{1 + \color{blue}{k \cdot 10}} \]
    7. Simplified46.9%

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

    if 1.69999999999999996 < m

    1. Initial program 77.1%

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Step-by-step derivation
      1. sqr-neg77.1%

        \[\leadsto \frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + \color{blue}{\left(-k\right) \cdot \left(-k\right)}} \]
      2. associate-+l+77.1%

        \[\leadsto \frac{a \cdot {k}^{m}}{\color{blue}{1 + \left(10 \cdot k + \left(-k\right) \cdot \left(-k\right)\right)}} \]
      3. sqr-neg77.1%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;m \leq 1.7:\\ \;\;\;\;\frac{a}{1 + k \cdot 10}\\ \mathbf{else}:\\ \;\;\;\;-10 \cdot \left(a \cdot k\right)\\ \end{array} \]

Alternative 7: 25.6% accurate, 16.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq 7:\\ \;\;\;\;a\\ \mathbf{else}:\\ \;\;\;\;-10 \cdot \left(a \cdot k\right)\\ \end{array} \end{array} \]
(FPCore (a k m) :precision binary64 (if (<= m 7.0) a (* -10.0 (* a k))))
double code(double a, double k, double m) {
	double tmp;
	if (m <= 7.0) {
		tmp = a;
	} else {
		tmp = -10.0 * (a * k);
	}
	return tmp;
}
real(8) function code(a, k, m)
    real(8), intent (in) :: a
    real(8), intent (in) :: k
    real(8), intent (in) :: m
    real(8) :: tmp
    if (m <= 7.0d0) then
        tmp = a
    else
        tmp = (-10.0d0) * (a * k)
    end if
    code = tmp
end function
public static double code(double a, double k, double m) {
	double tmp;
	if (m <= 7.0) {
		tmp = a;
	} else {
		tmp = -10.0 * (a * k);
	}
	return tmp;
}
def code(a, k, m):
	tmp = 0
	if m <= 7.0:
		tmp = a
	else:
		tmp = -10.0 * (a * k)
	return tmp
function code(a, k, m)
	tmp = 0.0
	if (m <= 7.0)
		tmp = a;
	else
		tmp = Float64(-10.0 * Float64(a * k));
	end
	return tmp
end
function tmp_2 = code(a, k, m)
	tmp = 0.0;
	if (m <= 7.0)
		tmp = a;
	else
		tmp = -10.0 * (a * k);
	end
	tmp_2 = tmp;
end
code[a_, k_, m_] := If[LessEqual[m, 7.0], a, N[(-10.0 * N[(a * k), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;m \leq 7:\\
\;\;\;\;a\\

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


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

    1. Initial program 97.3%

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Step-by-step derivation
      1. sqr-neg97.3%

        \[\leadsto \frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + \color{blue}{\left(-k\right) \cdot \left(-k\right)}} \]
      2. associate-+l+97.3%

        \[\leadsto \frac{a \cdot {k}^{m}}{\color{blue}{1 + \left(10 \cdot k + \left(-k\right) \cdot \left(-k\right)\right)}} \]
      3. sqr-neg97.3%

        \[\leadsto \frac{a \cdot {k}^{m}}{1 + \left(10 \cdot k + \color{blue}{k \cdot k}\right)} \]
      4. distribute-rgt-out97.3%

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

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

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

      \[\leadsto \color{blue}{a} \]

    if 7 < m

    1. Initial program 77.1%

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Step-by-step derivation
      1. sqr-neg77.1%

        \[\leadsto \frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + \color{blue}{\left(-k\right) \cdot \left(-k\right)}} \]
      2. associate-+l+77.1%

        \[\leadsto \frac{a \cdot {k}^{m}}{\color{blue}{1 + \left(10 \cdot k + \left(-k\right) \cdot \left(-k\right)\right)}} \]
      3. sqr-neg77.1%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;m \leq 7:\\ \;\;\;\;a\\ \mathbf{else}:\\ \;\;\;\;-10 \cdot \left(a \cdot k\right)\\ \end{array} \]

Alternative 8: 20.0% accurate, 114.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;
}
real(8) function code(a, k, m)
    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 90.7%

    \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
  2. Step-by-step derivation
    1. sqr-neg90.7%

      \[\leadsto \frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + \color{blue}{\left(-k\right) \cdot \left(-k\right)}} \]
    2. associate-+l+90.7%

      \[\leadsto \frac{a \cdot {k}^{m}}{\color{blue}{1 + \left(10 \cdot k + \left(-k\right) \cdot \left(-k\right)\right)}} \]
    3. sqr-neg90.7%

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

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

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

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

    \[\leadsto \color{blue}{a} \]
  6. Final simplification22.5%

    \[\leadsto a \]

Reproduce

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