Falkner and Boettcher, Appendix A

Percentage Accurate: 90.1% → 97.0%
Time: 7.6s
Alternatives: 13
Speedup: 1.1×

Specification

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

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

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

\[\begin{array}{l} \\ \begin{array}{l} t_0 := a \cdot {k}^{m}\\ t_1 := \frac{t_0}{\left(1 + k \cdot 10\right) + k \cdot k}\\ \mathbf{if}\;t_1 \leq 5 \cdot 10^{+66}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (a k m)
 :precision binary64
 (let* ((t_0 (* a (pow k m))) (t_1 (/ t_0 (+ (+ 1.0 (* k 10.0)) (* k k)))))
   (if (<= t_1 5e+66) t_1 t_0)))
double code(double a, double k, double m) {
	double t_0 = a * pow(k, m);
	double t_1 = t_0 / ((1.0 + (k * 10.0)) + (k * k));
	double tmp;
	if (t_1 <= 5e+66) {
		tmp = t_1;
	} 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) :: t_1
    real(8) :: tmp
    t_0 = a * (k ** m)
    t_1 = t_0 / ((1.0d0 + (k * 10.0d0)) + (k * k))
    if (t_1 <= 5d+66) then
        tmp = t_1
    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 t_1 = t_0 / ((1.0 + (k * 10.0)) + (k * k));
	double tmp;
	if (t_1 <= 5e+66) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(a, k, m):
	t_0 = a * math.pow(k, m)
	t_1 = t_0 / ((1.0 + (k * 10.0)) + (k * k))
	tmp = 0
	if t_1 <= 5e+66:
		tmp = t_1
	else:
		tmp = t_0
	return tmp
function code(a, k, m)
	t_0 = Float64(a * (k ^ m))
	t_1 = Float64(t_0 / Float64(Float64(1.0 + Float64(k * 10.0)) + Float64(k * k)))
	tmp = 0.0
	if (t_1 <= 5e+66)
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(a, k, m)
	t_0 = a * (k ^ m);
	t_1 = t_0 / ((1.0 + (k * 10.0)) + (k * k));
	tmp = 0.0;
	if (t_1 <= 5e+66)
		tmp = t_1;
	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]}, Block[{t$95$1 = N[(t$95$0 / N[(N[(1.0 + N[(k * 10.0), $MachinePrecision]), $MachinePrecision] + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 5e+66], t$95$1, t$95$0]]]
\begin{array}{l}

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

\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))) < 4.99999999999999991e66

    1. Initial program 97.0%

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

    if 4.99999999999999991e66 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 1 (*.f64 10 k)) (*.f64 k k)))

    1. Initial program 62.7%

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

      \[\leadsto \color{blue}{e^{\log k \cdot m} \cdot a} \]
    3. Step-by-step derivation
      1. exp-to-pow100.0%

        \[\leadsto \color{blue}{{k}^{m}} \cdot a \]
      2. *-commutative100.0%

        \[\leadsto \color{blue}{a \cdot {k}^{m}} \]
    4. Simplified100.0%

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

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

Alternative 2: 97.2% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq -3.7 \cdot 10^{-10} \lor \neg \left(m \leq 0.00041\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.7e-10) (not (<= m 0.00041)))
   (* a (pow k m))
   (/ a (+ 1.0 (* k (+ k 10.0))))))
double code(double a, double k, double m) {
	double tmp;
	if ((m <= -3.7e-10) || !(m <= 0.00041)) {
		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.7d-10)) .or. (.not. (m <= 0.00041d0))) 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.7e-10) || !(m <= 0.00041)) {
		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.7e-10) or not (m <= 0.00041):
		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.7e-10) || !(m <= 0.00041))
		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.7e-10) || ~((m <= 0.00041)))
		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.7e-10], N[Not[LessEqual[m, 0.00041]], $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.7 \cdot 10^{-10} \lor \neg \left(m \leq 0.00041\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.70000000000000015e-10 or 4.0999999999999999e-4 < m

    1. Initial program 84.9%

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

      \[\leadsto \color{blue}{e^{\log k \cdot m} \cdot a} \]
    3. Step-by-step derivation
      1. exp-to-pow100.0%

        \[\leadsto \color{blue}{{k}^{m}} \cdot a \]
      2. *-commutative100.0%

        \[\leadsto \color{blue}{a \cdot {k}^{m}} \]
    4. Simplified100.0%

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

    if -3.70000000000000015e-10 < m < 4.0999999999999999e-4

    1. Initial program 93.6%

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

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

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

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

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

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

        \[\leadsto \frac{a}{{\left(\sqrt[3]{\color{blue}{k \cdot \left(10 + k\right)} + 1}\right)}^{2}} \cdot \frac{{k}^{m}}{\sqrt[3]{\left(1 + 10 \cdot k\right) + k \cdot k}} \]
      7. fma-def93.4%

        \[\leadsto \frac{a}{{\left(\sqrt[3]{\color{blue}{\mathsf{fma}\left(k, 10 + k, 1\right)}}\right)}^{2}} \cdot \frac{{k}^{m}}{\sqrt[3]{\left(1 + 10 \cdot k\right) + k \cdot k}} \]
      8. associate-+l+93.4%

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

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

        \[\leadsto \frac{a}{{\left(\sqrt[3]{\mathsf{fma}\left(k, 10 + k, 1\right)}\right)}^{2}} \cdot \frac{{k}^{m}}{\sqrt[3]{\color{blue}{k \cdot \left(10 + k\right)} + 1}} \]
      11. fma-def93.4%

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

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

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

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

Alternative 3: 62.3% accurate, 7.5× speedup?

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

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

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

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


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

    1. Initial program 100.0%

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

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

      \[\leadsto \color{blue}{\frac{a}{{k}^{2}}} \]
    4. Step-by-step derivation
      1. unpow265.0%

        \[\leadsto \frac{a}{\color{blue}{k \cdot k}} \]
    5. Simplified65.0%

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

    if -5.2e14 < m < 1.94999999999999996

    1. Initial program 93.8%

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

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

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

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

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

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

        \[\leadsto \frac{a}{{\left(\sqrt[3]{\color{blue}{k \cdot \left(10 + k\right)} + 1}\right)}^{2}} \cdot \frac{{k}^{m}}{\sqrt[3]{\left(1 + 10 \cdot k\right) + k \cdot k}} \]
      7. fma-def93.6%

        \[\leadsto \frac{a}{{\left(\sqrt[3]{\color{blue}{\mathsf{fma}\left(k, 10 + k, 1\right)}}\right)}^{2}} \cdot \frac{{k}^{m}}{\sqrt[3]{\left(1 + 10 \cdot k\right) + k \cdot k}} \]
      8. associate-+l+93.6%

        \[\leadsto \frac{a}{{\left(\sqrt[3]{\mathsf{fma}\left(k, 10 + k, 1\right)}\right)}^{2}} \cdot \frac{{k}^{m}}{\sqrt[3]{\color{blue}{1 + \left(10 \cdot k + k \cdot k\right)}}} \]
      9. +-commutative93.6%

        \[\leadsto \frac{a}{{\left(\sqrt[3]{\mathsf{fma}\left(k, 10 + k, 1\right)}\right)}^{2}} \cdot \frac{{k}^{m}}{\sqrt[3]{\color{blue}{\left(10 \cdot k + k \cdot k\right) + 1}}} \]
      10. distribute-rgt-out93.6%

        \[\leadsto \frac{a}{{\left(\sqrt[3]{\mathsf{fma}\left(k, 10 + k, 1\right)}\right)}^{2}} \cdot \frac{{k}^{m}}{\sqrt[3]{\color{blue}{k \cdot \left(10 + k\right)} + 1}} \]
      11. fma-def93.6%

        \[\leadsto \frac{a}{{\left(\sqrt[3]{\mathsf{fma}\left(k, 10 + k, 1\right)}\right)}^{2}} \cdot \frac{{k}^{m}}{\sqrt[3]{\color{blue}{\mathsf{fma}\left(k, 10 + k, 1\right)}}} \]
    3. Applied egg-rr93.6%

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

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

    if 1.94999999999999996 < m

    1. Initial program 67.9%

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

      \[\leadsto \frac{a \cdot {k}^{m}}{\color{blue}{1 + 10 \cdot k}} \]
    3. Taylor expanded in m around 0 2.9%

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

        \[\leadsto \frac{a}{\color{blue}{10 \cdot k + 1}} \]
      2. *-commutative2.9%

        \[\leadsto \frac{a}{\color{blue}{k \cdot 10} + 1} \]
      3. fma-udef2.9%

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

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

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

        \[\leadsto a + \color{blue}{\left(100 \cdot \left({k}^{2} \cdot a\right) + -10 \cdot \left(k \cdot a\right)\right)} \]
      2. unpow226.9%

        \[\leadsto a + \left(100 \cdot \left(\color{blue}{\left(k \cdot k\right)} \cdot a\right) + -10 \cdot \left(k \cdot a\right)\right) \]
      3. associate-*r*26.9%

        \[\leadsto a + \left(\color{blue}{\left(100 \cdot \left(k \cdot k\right)\right) \cdot a} + -10 \cdot \left(k \cdot a\right)\right) \]
      4. associate-*r*26.9%

        \[\leadsto a + \left(\left(100 \cdot \left(k \cdot k\right)\right) \cdot a + \color{blue}{\left(-10 \cdot k\right) \cdot a}\right) \]
      5. *-commutative26.9%

        \[\leadsto a + \left(\left(100 \cdot \left(k \cdot k\right)\right) \cdot a + \color{blue}{\left(k \cdot -10\right)} \cdot a\right) \]
      6. distribute-rgt-out38.5%

        \[\leadsto a + \color{blue}{a \cdot \left(100 \cdot \left(k \cdot k\right) + k \cdot -10\right)} \]
    8. Simplified38.5%

      \[\leadsto \color{blue}{a + a \cdot \left(100 \cdot \left(k \cdot k\right) + k \cdot -10\right)} \]
    9. Step-by-step derivation
      1. associate-*r*38.5%

        \[\leadsto a + a \cdot \left(\color{blue}{\left(100 \cdot k\right) \cdot k} + k \cdot -10\right) \]
      2. *-commutative38.5%

        \[\leadsto a + a \cdot \left(\left(100 \cdot k\right) \cdot k + \color{blue}{-10 \cdot k}\right) \]
      3. distribute-rgt-out38.5%

        \[\leadsto a + a \cdot \color{blue}{\left(k \cdot \left(100 \cdot k + -10\right)\right)} \]
      4. *-commutative38.5%

        \[\leadsto a + a \cdot \left(k \cdot \left(\color{blue}{k \cdot 100} + -10\right)\right) \]
    10. Applied egg-rr38.5%

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

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

Alternative 4: 62.3% accurate, 7.5× speedup?

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

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

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

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


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

    1. Initial program 100.0%

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

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

      \[\leadsto \color{blue}{\frac{a}{{k}^{2}}} \]
    4. Step-by-step derivation
      1. unpow265.0%

        \[\leadsto \frac{a}{\color{blue}{k \cdot k}} \]
    5. Simplified65.0%

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

    if -5.2e14 < m < 2.2000000000000002

    1. Initial program 93.8%

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

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

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

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

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

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

        \[\leadsto \frac{a}{{\left(\sqrt[3]{\color{blue}{k \cdot \left(10 + k\right)} + 1}\right)}^{2}} \cdot \frac{{k}^{m}}{\sqrt[3]{\left(1 + 10 \cdot k\right) + k \cdot k}} \]
      7. fma-def93.6%

        \[\leadsto \frac{a}{{\left(\sqrt[3]{\color{blue}{\mathsf{fma}\left(k, 10 + k, 1\right)}}\right)}^{2}} \cdot \frac{{k}^{m}}{\sqrt[3]{\left(1 + 10 \cdot k\right) + k \cdot k}} \]
      8. associate-+l+93.6%

        \[\leadsto \frac{a}{{\left(\sqrt[3]{\mathsf{fma}\left(k, 10 + k, 1\right)}\right)}^{2}} \cdot \frac{{k}^{m}}{\sqrt[3]{\color{blue}{1 + \left(10 \cdot k + k \cdot k\right)}}} \]
      9. +-commutative93.6%

        \[\leadsto \frac{a}{{\left(\sqrt[3]{\mathsf{fma}\left(k, 10 + k, 1\right)}\right)}^{2}} \cdot \frac{{k}^{m}}{\sqrt[3]{\color{blue}{\left(10 \cdot k + k \cdot k\right) + 1}}} \]
      10. distribute-rgt-out93.6%

        \[\leadsto \frac{a}{{\left(\sqrt[3]{\mathsf{fma}\left(k, 10 + k, 1\right)}\right)}^{2}} \cdot \frac{{k}^{m}}{\sqrt[3]{\color{blue}{k \cdot \left(10 + k\right)} + 1}} \]
      11. fma-def93.6%

        \[\leadsto \frac{a}{{\left(\sqrt[3]{\mathsf{fma}\left(k, 10 + k, 1\right)}\right)}^{2}} \cdot \frac{{k}^{m}}{\sqrt[3]{\color{blue}{\mathsf{fma}\left(k, 10 + k, 1\right)}}} \]
    3. Applied egg-rr93.6%

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

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

    if 2.2000000000000002 < m

    1. Initial program 67.9%

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

      \[\leadsto \frac{a \cdot {k}^{m}}{\color{blue}{1 + 10 \cdot k}} \]
    3. Taylor expanded in m around 0 2.9%

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

        \[\leadsto \frac{a}{\color{blue}{10 \cdot k + 1}} \]
      2. *-commutative2.9%

        \[\leadsto \frac{a}{\color{blue}{k \cdot 10} + 1} \]
      3. fma-udef2.9%

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

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

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

        \[\leadsto a + \color{blue}{\left(100 \cdot \left({k}^{2} \cdot a\right) + -10 \cdot \left(k \cdot a\right)\right)} \]
      2. unpow226.9%

        \[\leadsto a + \left(100 \cdot \left(\color{blue}{\left(k \cdot k\right)} \cdot a\right) + -10 \cdot \left(k \cdot a\right)\right) \]
      3. associate-*r*26.9%

        \[\leadsto a + \left(\color{blue}{\left(100 \cdot \left(k \cdot k\right)\right) \cdot a} + -10 \cdot \left(k \cdot a\right)\right) \]
      4. associate-*r*26.9%

        \[\leadsto a + \left(\left(100 \cdot \left(k \cdot k\right)\right) \cdot a + \color{blue}{\left(-10 \cdot k\right) \cdot a}\right) \]
      5. *-commutative26.9%

        \[\leadsto a + \left(\left(100 \cdot \left(k \cdot k\right)\right) \cdot a + \color{blue}{\left(k \cdot -10\right)} \cdot a\right) \]
      6. distribute-rgt-out38.5%

        \[\leadsto a + \color{blue}{a \cdot \left(100 \cdot \left(k \cdot k\right) + k \cdot -10\right)} \]
    8. Simplified38.5%

      \[\leadsto \color{blue}{a + a \cdot \left(100 \cdot \left(k \cdot k\right) + k \cdot -10\right)} \]
    9. Step-by-step derivation
      1. add-sqr-sqrt6.5%

        \[\leadsto a + a \cdot \left(100 \cdot \left(k \cdot k\right) + \color{blue}{\sqrt{k \cdot -10} \cdot \sqrt{k \cdot -10}}\right) \]
      2. sqrt-unprod38.5%

        \[\leadsto a + a \cdot \left(100 \cdot \left(k \cdot k\right) + \color{blue}{\sqrt{\left(k \cdot -10\right) \cdot \left(k \cdot -10\right)}}\right) \]
      3. swap-sqr38.5%

        \[\leadsto a + a \cdot \left(100 \cdot \left(k \cdot k\right) + \sqrt{\color{blue}{\left(k \cdot k\right) \cdot \left(-10 \cdot -10\right)}}\right) \]
      4. metadata-eval38.5%

        \[\leadsto a + a \cdot \left(100 \cdot \left(k \cdot k\right) + \sqrt{\left(k \cdot k\right) \cdot \color{blue}{100}}\right) \]
      5. sqrt-prod38.5%

        \[\leadsto a + a \cdot \left(100 \cdot \left(k \cdot k\right) + \color{blue}{\sqrt{k \cdot k} \cdot \sqrt{100}}\right) \]
      6. sqrt-prod31.9%

        \[\leadsto a + a \cdot \left(100 \cdot \left(k \cdot k\right) + \color{blue}{\left(\sqrt{k} \cdot \sqrt{k}\right)} \cdot \sqrt{100}\right) \]
      7. add-sqr-sqrt38.5%

        \[\leadsto a + a \cdot \left(100 \cdot \left(k \cdot k\right) + \color{blue}{k} \cdot \sqrt{100}\right) \]
      8. metadata-eval38.5%

        \[\leadsto a + a \cdot \left(100 \cdot \left(k \cdot k\right) + k \cdot \color{blue}{10}\right) \]
      9. *-commutative38.5%

        \[\leadsto a + a \cdot \left(100 \cdot \left(k \cdot k\right) + \color{blue}{10 \cdot k}\right) \]
      10. metadata-eval38.5%

        \[\leadsto a + a \cdot \left(100 \cdot \left(k \cdot k\right) + \color{blue}{\left(--10\right)} \cdot k\right) \]
      11. cancel-sign-sub-inv38.5%

        \[\leadsto a + a \cdot \color{blue}{\left(100 \cdot \left(k \cdot k\right) - -10 \cdot k\right)} \]
      12. associate-*r*38.5%

        \[\leadsto a + a \cdot \left(\color{blue}{\left(100 \cdot k\right) \cdot k} - -10 \cdot k\right) \]
      13. distribute-rgt-out--38.5%

        \[\leadsto a + a \cdot \color{blue}{\left(k \cdot \left(100 \cdot k - -10\right)\right)} \]
      14. *-commutative38.5%

        \[\leadsto a + a \cdot \left(k \cdot \left(\color{blue}{k \cdot 100} - -10\right)\right) \]
    10. Applied egg-rr38.5%

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

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

Alternative 5: 59.7% accurate, 8.7× speedup?

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

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

\mathbf{elif}\;m \leq 1.9:\\
\;\;\;\;\frac{a}{1 + k \cdot k}\\

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


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

    1. Initial program 100.0%

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

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

      \[\leadsto \color{blue}{\frac{a}{{k}^{2}}} \]
    4. Step-by-step derivation
      1. unpow265.0%

        \[\leadsto \frac{a}{\color{blue}{k \cdot k}} \]
    5. Simplified65.0%

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

    if -5.2e14 < m < 1.8999999999999999

    1. Initial program 93.8%

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

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

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

    if 1.8999999999999999 < m

    1. Initial program 67.9%

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

      \[\leadsto \frac{a \cdot {k}^{m}}{\color{blue}{1 + 10 \cdot k}} \]
    3. Taylor expanded in m around 0 2.9%

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

        \[\leadsto \frac{a}{\color{blue}{10 \cdot k + 1}} \]
      2. *-commutative2.9%

        \[\leadsto \frac{a}{\color{blue}{k \cdot 10} + 1} \]
      3. fma-udef2.9%

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

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

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

        \[\leadsto a + \color{blue}{\left(100 \cdot \left({k}^{2} \cdot a\right) + -10 \cdot \left(k \cdot a\right)\right)} \]
      2. unpow226.9%

        \[\leadsto a + \left(100 \cdot \left(\color{blue}{\left(k \cdot k\right)} \cdot a\right) + -10 \cdot \left(k \cdot a\right)\right) \]
      3. associate-*r*26.9%

        \[\leadsto a + \left(\color{blue}{\left(100 \cdot \left(k \cdot k\right)\right) \cdot a} + -10 \cdot \left(k \cdot a\right)\right) \]
      4. associate-*r*26.9%

        \[\leadsto a + \left(\left(100 \cdot \left(k \cdot k\right)\right) \cdot a + \color{blue}{\left(-10 \cdot k\right) \cdot a}\right) \]
      5. *-commutative26.9%

        \[\leadsto a + \left(\left(100 \cdot \left(k \cdot k\right)\right) \cdot a + \color{blue}{\left(k \cdot -10\right)} \cdot a\right) \]
      6. distribute-rgt-out38.5%

        \[\leadsto a + \color{blue}{a \cdot \left(100 \cdot \left(k \cdot k\right) + k \cdot -10\right)} \]
    8. Simplified38.5%

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

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

        \[\leadsto a + 100 \cdot \left(\color{blue}{\left(k \cdot k\right)} \cdot a\right) \]
      2. associate-*r*38.5%

        \[\leadsto a + \color{blue}{\left(100 \cdot \left(k \cdot k\right)\right) \cdot a} \]
      3. *-commutative38.5%

        \[\leadsto a + \color{blue}{\left(\left(k \cdot k\right) \cdot 100\right)} \cdot a \]
      4. associate-*r*38.5%

        \[\leadsto a + \color{blue}{\left(k \cdot k\right) \cdot \left(100 \cdot a\right)} \]
      5. associate-*l*30.1%

        \[\leadsto a + \color{blue}{k \cdot \left(k \cdot \left(100 \cdot a\right)\right)} \]
      6. *-commutative30.1%

        \[\leadsto a + k \cdot \left(k \cdot \color{blue}{\left(a \cdot 100\right)}\right) \]
    11. Simplified30.1%

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

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

Alternative 6: 60.5% accurate, 8.7× speedup?

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

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

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

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


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

    1. Initial program 100.0%

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

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

      \[\leadsto \color{blue}{\frac{a}{{k}^{2}}} \]
    4. Step-by-step derivation
      1. unpow265.0%

        \[\leadsto \frac{a}{\color{blue}{k \cdot k}} \]
    5. Simplified65.0%

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

    if -5.2e14 < m < 2.2000000000000002

    1. Initial program 93.8%

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

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

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

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

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

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

        \[\leadsto \frac{a}{{\left(\sqrt[3]{\color{blue}{k \cdot \left(10 + k\right)} + 1}\right)}^{2}} \cdot \frac{{k}^{m}}{\sqrt[3]{\left(1 + 10 \cdot k\right) + k \cdot k}} \]
      7. fma-def93.6%

        \[\leadsto \frac{a}{{\left(\sqrt[3]{\color{blue}{\mathsf{fma}\left(k, 10 + k, 1\right)}}\right)}^{2}} \cdot \frac{{k}^{m}}{\sqrt[3]{\left(1 + 10 \cdot k\right) + k \cdot k}} \]
      8. associate-+l+93.6%

        \[\leadsto \frac{a}{{\left(\sqrt[3]{\mathsf{fma}\left(k, 10 + k, 1\right)}\right)}^{2}} \cdot \frac{{k}^{m}}{\sqrt[3]{\color{blue}{1 + \left(10 \cdot k + k \cdot k\right)}}} \]
      9. +-commutative93.6%

        \[\leadsto \frac{a}{{\left(\sqrt[3]{\mathsf{fma}\left(k, 10 + k, 1\right)}\right)}^{2}} \cdot \frac{{k}^{m}}{\sqrt[3]{\color{blue}{\left(10 \cdot k + k \cdot k\right) + 1}}} \]
      10. distribute-rgt-out93.6%

        \[\leadsto \frac{a}{{\left(\sqrt[3]{\mathsf{fma}\left(k, 10 + k, 1\right)}\right)}^{2}} \cdot \frac{{k}^{m}}{\sqrt[3]{\color{blue}{k \cdot \left(10 + k\right)} + 1}} \]
      11. fma-def93.6%

        \[\leadsto \frac{a}{{\left(\sqrt[3]{\mathsf{fma}\left(k, 10 + k, 1\right)}\right)}^{2}} \cdot \frac{{k}^{m}}{\sqrt[3]{\color{blue}{\mathsf{fma}\left(k, 10 + k, 1\right)}}} \]
    3. Applied egg-rr93.6%

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

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

    if 2.2000000000000002 < m

    1. Initial program 67.9%

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

      \[\leadsto \frac{a \cdot {k}^{m}}{\color{blue}{1 + 10 \cdot k}} \]
    3. Taylor expanded in m around 0 2.9%

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

        \[\leadsto \frac{a}{\color{blue}{10 \cdot k + 1}} \]
      2. *-commutative2.9%

        \[\leadsto \frac{a}{\color{blue}{k \cdot 10} + 1} \]
      3. fma-udef2.9%

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

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

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

        \[\leadsto a + \color{blue}{\left(100 \cdot \left({k}^{2} \cdot a\right) + -10 \cdot \left(k \cdot a\right)\right)} \]
      2. unpow226.9%

        \[\leadsto a + \left(100 \cdot \left(\color{blue}{\left(k \cdot k\right)} \cdot a\right) + -10 \cdot \left(k \cdot a\right)\right) \]
      3. associate-*r*26.9%

        \[\leadsto a + \left(\color{blue}{\left(100 \cdot \left(k \cdot k\right)\right) \cdot a} + -10 \cdot \left(k \cdot a\right)\right) \]
      4. associate-*r*26.9%

        \[\leadsto a + \left(\left(100 \cdot \left(k \cdot k\right)\right) \cdot a + \color{blue}{\left(-10 \cdot k\right) \cdot a}\right) \]
      5. *-commutative26.9%

        \[\leadsto a + \left(\left(100 \cdot \left(k \cdot k\right)\right) \cdot a + \color{blue}{\left(k \cdot -10\right)} \cdot a\right) \]
      6. distribute-rgt-out38.5%

        \[\leadsto a + \color{blue}{a \cdot \left(100 \cdot \left(k \cdot k\right) + k \cdot -10\right)} \]
    8. Simplified38.5%

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

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

        \[\leadsto a + 100 \cdot \left(\color{blue}{\left(k \cdot k\right)} \cdot a\right) \]
      2. associate-*r*38.5%

        \[\leadsto a + \color{blue}{\left(100 \cdot \left(k \cdot k\right)\right) \cdot a} \]
      3. *-commutative38.5%

        \[\leadsto a + \color{blue}{\left(\left(k \cdot k\right) \cdot 100\right)} \cdot a \]
      4. associate-*r*38.5%

        \[\leadsto a + \color{blue}{\left(k \cdot k\right) \cdot \left(100 \cdot a\right)} \]
      5. associate-*l*30.1%

        \[\leadsto a + \color{blue}{k \cdot \left(k \cdot \left(100 \cdot a\right)\right)} \]
      6. *-commutative30.1%

        \[\leadsto a + k \cdot \left(k \cdot \color{blue}{\left(a \cdot 100\right)}\right) \]
    11. Simplified30.1%

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

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

Alternative 7: 46.9% accurate, 10.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;k \leq 9.2 \cdot 10^{-300}:\\
\;\;\;\;\frac{a}{k \cdot k}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if k < 9.20000000000000003e-300

    1. Initial program 95.5%

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

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

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

        \[\leadsto \frac{a}{\color{blue}{k \cdot k}} \]
    5. Simplified35.9%

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

    if 9.20000000000000003e-300 < k < 5.0000000000000001e-9

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{-10 \cdot \left(k \cdot \left(e^{\log k \cdot m} \cdot a\right)\right) + e^{\log k \cdot m} \cdot a} \]
    3. Step-by-step derivation
      1. exp-to-pow72.1%

        \[\leadsto -10 \cdot \left(k \cdot \left(\color{blue}{{k}^{m}} \cdot a\right)\right) + e^{\log k \cdot m} \cdot a \]
      2. exp-to-pow72.1%

        \[\leadsto -10 \cdot \left(k \cdot \left(\color{blue}{e^{\log k \cdot m}} \cdot a\right)\right) + e^{\log k \cdot m} \cdot a \]
      3. exp-to-pow72.1%

        \[\leadsto -10 \cdot \left(k \cdot \left(e^{\log k \cdot m} \cdot a\right)\right) + \color{blue}{{k}^{m}} \cdot a \]
      4. *-commutative72.1%

        \[\leadsto -10 \cdot \left(k \cdot \left(e^{\log k \cdot m} \cdot a\right)\right) + \color{blue}{a \cdot {k}^{m}} \]
      5. associate-*r*72.1%

        \[\leadsto \color{blue}{\left(-10 \cdot k\right) \cdot \left(e^{\log k \cdot m} \cdot a\right)} + a \cdot {k}^{m} \]
      6. exp-to-pow72.1%

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

        \[\leadsto \left(-10 \cdot k\right) \cdot \color{blue}{\left(a \cdot {k}^{m}\right)} + a \cdot {k}^{m} \]
      8. distribute-lft1-in100.0%

        \[\leadsto \color{blue}{\left(-10 \cdot k + 1\right) \cdot \left(a \cdot {k}^{m}\right)} \]
      9. *-commutative100.0%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(k, -10, 1\right)} \cdot \left(a \cdot {k}^{m}\right) \]
    4. Simplified100.0%

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

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

    if 5.0000000000000001e-9 < k

    1. Initial program 73.1%

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

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

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

        \[\leadsto \frac{a}{\color{blue}{k \cdot k}} \]
    5. Simplified52.9%

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

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

        \[\leadsto \frac{a}{\color{blue}{k \cdot k}} \]
      2. associate-/r*57.5%

        \[\leadsto \color{blue}{\frac{\frac{a}{k}}{k}} \]
    8. Simplified57.5%

      \[\leadsto \color{blue}{\frac{\frac{a}{k}}{k}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification50.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;k \leq 9.2 \cdot 10^{-300}:\\ \;\;\;\;\frac{a}{k \cdot k}\\ \mathbf{elif}\;k \leq 5 \cdot 10^{-9}:\\ \;\;\;\;a \cdot \left(1 + k \cdot -10\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{a}{k}}{k}\\ \end{array} \]

Alternative 8: 47.2% accurate, 10.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;k \leq 9.8 \cdot 10^{-300}:\\
\;\;\;\;\frac{a}{k \cdot k}\\

\mathbf{elif}\;k \leq 10:\\
\;\;\;\;\frac{a}{1 + k \cdot 10}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if k < 9.8e-300

    1. Initial program 95.5%

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

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

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

        \[\leadsto \frac{a}{\color{blue}{k \cdot k}} \]
    5. Simplified35.9%

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

    if 9.8e-300 < k < 10

    1. Initial program 99.9%

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

      \[\leadsto \frac{a \cdot {k}^{m}}{\color{blue}{1 + 10 \cdot k}} \]
    3. Taylor expanded in m around 0 52.7%

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

    if 10 < k

    1. Initial program 72.6%

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

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

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

        \[\leadsto \frac{a}{\color{blue}{k \cdot k}} \]
    5. Simplified53.8%

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

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

        \[\leadsto \frac{a}{\color{blue}{k \cdot k}} \]
      2. associate-/r*58.5%

        \[\leadsto \color{blue}{\frac{\frac{a}{k}}{k}} \]
    8. Simplified58.5%

      \[\leadsto \color{blue}{\frac{\frac{a}{k}}{k}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification50.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;k \leq 9.8 \cdot 10^{-300}:\\ \;\;\;\;\frac{a}{k \cdot k}\\ \mathbf{elif}\;k \leq 10:\\ \;\;\;\;\frac{a}{1 + k \cdot 10}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{a}{k}}{k}\\ \end{array} \]

Alternative 9: 27.5% accurate, 12.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;k \leq -9 \cdot 10^{+94} \lor \neg \left(k \leq 5 \cdot 10^{-9}\right):\\
\;\;\;\;\frac{a}{k} \cdot 0.1\\

\mathbf{else}:\\
\;\;\;\;a\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if k < -8.99999999999999944e94 or 5.0000000000000001e-9 < k

    1. Initial program 75.4%

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

      \[\leadsto \frac{a \cdot {k}^{m}}{\color{blue}{1 + 10 \cdot k}} \]
    3. Taylor expanded in m around 0 23.9%

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

        \[\leadsto \frac{a}{\color{blue}{10 \cdot k + 1}} \]
      2. *-commutative23.9%

        \[\leadsto \frac{a}{\color{blue}{k \cdot 10} + 1} \]
      3. fma-udef23.9%

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

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

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

    if -8.99999999999999944e94 < k < 5.0000000000000001e-9

    1. Initial program 100.0%

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

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

      \[\leadsto \frac{a}{\color{blue}{1} + k \cdot k} \]
    4. Taylor expanded in k around 0 36.3%

      \[\leadsto \color{blue}{a} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification30.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;k \leq -9 \cdot 10^{+94} \lor \neg \left(k \leq 5 \cdot 10^{-9}\right):\\ \;\;\;\;\frac{a}{k} \cdot 0.1\\ \mathbf{else}:\\ \;\;\;\;a\\ \end{array} \]

Alternative 10: 45.9% accurate, 12.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;k \leq 1.16 \cdot 10^{-299} \lor \neg \left(k \leq 5 \cdot 10^{-9}\right):\\
\;\;\;\;\frac{a}{k \cdot k}\\

\mathbf{else}:\\
\;\;\;\;a\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if k < 1.15999999999999997e-299 or 5.0000000000000001e-9 < k

    1. Initial program 81.9%

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

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

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

        \[\leadsto \frac{a}{\color{blue}{k \cdot k}} \]
    5. Simplified46.2%

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

    if 1.15999999999999997e-299 < k < 5.0000000000000001e-9

    1. Initial program 100.0%

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

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

      \[\leadsto \frac{a}{\color{blue}{1} + k \cdot k} \]
    4. Taylor expanded in k around 0 53.3%

      \[\leadsto \color{blue}{a} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification48.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;k \leq 1.16 \cdot 10^{-299} \lor \neg \left(k \leq 5 \cdot 10^{-9}\right):\\ \;\;\;\;\frac{a}{k \cdot k}\\ \mathbf{else}:\\ \;\;\;\;a\\ \end{array} \]

Alternative 11: 46.8% accurate, 12.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;k \leq 1.12 \cdot 10^{-299}:\\ \;\;\;\;\frac{a}{k \cdot k}\\ \mathbf{elif}\;k \leq 5 \cdot 10^{-9}:\\ \;\;\;\;a\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{a}{k}}{k}\\ \end{array} \end{array} \]
(FPCore (a k m)
 :precision binary64
 (if (<= k 1.12e-299) (/ a (* k k)) (if (<= k 5e-9) a (/ (/ a k) k))))
double code(double a, double k, double m) {
	double tmp;
	if (k <= 1.12e-299) {
		tmp = a / (k * k);
	} else if (k <= 5e-9) {
		tmp = a;
	} else {
		tmp = (a / k) / 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 (k <= 1.12d-299) then
        tmp = a / (k * k)
    else if (k <= 5d-9) then
        tmp = a
    else
        tmp = (a / k) / k
    end if
    code = tmp
end function
public static double code(double a, double k, double m) {
	double tmp;
	if (k <= 1.12e-299) {
		tmp = a / (k * k);
	} else if (k <= 5e-9) {
		tmp = a;
	} else {
		tmp = (a / k) / k;
	}
	return tmp;
}
def code(a, k, m):
	tmp = 0
	if k <= 1.12e-299:
		tmp = a / (k * k)
	elif k <= 5e-9:
		tmp = a
	else:
		tmp = (a / k) / k
	return tmp
function code(a, k, m)
	tmp = 0.0
	if (k <= 1.12e-299)
		tmp = Float64(a / Float64(k * k));
	elseif (k <= 5e-9)
		tmp = a;
	else
		tmp = Float64(Float64(a / k) / k);
	end
	return tmp
end
function tmp_2 = code(a, k, m)
	tmp = 0.0;
	if (k <= 1.12e-299)
		tmp = a / (k * k);
	elseif (k <= 5e-9)
		tmp = a;
	else
		tmp = (a / k) / k;
	end
	tmp_2 = tmp;
end
code[a_, k_, m_] := If[LessEqual[k, 1.12e-299], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[k, 5e-9], a, N[(N[(a / k), $MachinePrecision] / k), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;k \leq 1.12 \cdot 10^{-299}:\\
\;\;\;\;\frac{a}{k \cdot k}\\

\mathbf{elif}\;k \leq 5 \cdot 10^{-9}:\\
\;\;\;\;a\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if k < 1.11999999999999998e-299

    1. Initial program 95.5%

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

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

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

        \[\leadsto \frac{a}{\color{blue}{k \cdot k}} \]
    5. Simplified35.9%

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

    if 1.11999999999999998e-299 < k < 5.0000000000000001e-9

    1. Initial program 100.0%

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

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

      \[\leadsto \frac{a}{\color{blue}{1} + k \cdot k} \]
    4. Taylor expanded in k around 0 53.3%

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

    if 5.0000000000000001e-9 < k

    1. Initial program 73.1%

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

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

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

        \[\leadsto \frac{a}{\color{blue}{k \cdot k}} \]
    5. Simplified52.9%

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

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

        \[\leadsto \frac{a}{\color{blue}{k \cdot k}} \]
      2. associate-/r*57.5%

        \[\leadsto \color{blue}{\frac{\frac{a}{k}}{k}} \]
    8. Simplified57.5%

      \[\leadsto \color{blue}{\frac{\frac{a}{k}}{k}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification50.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;k \leq 1.12 \cdot 10^{-299}:\\ \;\;\;\;\frac{a}{k \cdot k}\\ \mathbf{elif}\;k \leq 5 \cdot 10^{-9}:\\ \;\;\;\;a\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{a}{k}}{k}\\ \end{array} \]

Alternative 12: 51.4% accurate, 12.6× speedup?

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

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

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


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

    1. Initial program 100.0%

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

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

      \[\leadsto \color{blue}{\frac{a}{{k}^{2}}} \]
    4. Step-by-step derivation
      1. unpow265.0%

        \[\leadsto \frac{a}{\color{blue}{k \cdot k}} \]
    5. Simplified65.0%

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

    if -5.2e14 < m

    1. Initial program 82.0%

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

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

      \[\leadsto \frac{a}{\color{blue}{1} + k \cdot k} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification55.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;m \leq -5.2 \cdot 10^{+14}:\\ \;\;\;\;\frac{a}{k \cdot k}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{1 + k \cdot k}\\ \end{array} \]

Alternative 13: 19.6% 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 88.0%

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

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

    \[\leadsto \frac{a}{\color{blue}{1} + k \cdot k} \]
  4. Taylor expanded in k around 0 20.7%

    \[\leadsto \color{blue}{a} \]
  5. Final simplification20.7%

    \[\leadsto a \]

Reproduce

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