Falkner and Boettcher, Appendix A

Percentage Accurate: 90.4% → 97.3%
Time: 7.8s
Alternatives: 10
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 10 alternatives:

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

Initial Program: 90.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \end{array} \]
(FPCore (a k m)
 :precision binary64
 (/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))
double code(double a, double k, double m) {
	return (a * pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
}
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.3% 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 10^{+146}:\\ \;\;\;\;a \cdot \frac{-{k}^{m}}{-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))) 1e+146)
     (* a (/ (- (pow k m)) (- -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))) <= 1e+146) {
		tmp = a * (-pow(k, m) / (-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))) <= 1d+146) then
        tmp = a * (-(k ** m) / ((-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))) <= 1e+146) {
		tmp = a * (-Math.pow(k, m) / (-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))) <= 1e+146:
		tmp = a * (-math.pow(k, m) / (-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))) <= 1e+146)
		tmp = Float64(a * Float64(Float64(-(k ^ m)) / 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))) <= 1e+146)
		tmp = a * (-(k ^ m) / (-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], 1e+146], N[(a * N[((-N[Power[k, m], $MachinePrecision]) / N[(-1.0 - N[(k * N[(k + 10.0), $MachinePrecision]), $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 10^{+146}:\\
\;\;\;\;a \cdot \frac{-{k}^{m}}{-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))) < 9.99999999999999934e145

    1. Initial program 97.7%

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Step-by-step derivation
      1. sqr-neg97.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+97.7%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(a \cdot \left(-{k}^{m}\right)\right) \cdot \frac{1}{-\mathsf{fma}\left(k, \color{blue}{k + 10}, 1\right)} \]
    5. Applied egg-rr97.7%

      \[\leadsto \color{blue}{\left(a \cdot \left(-{k}^{m}\right)\right) \cdot \frac{1}{-\mathsf{fma}\left(k, k + 10, 1\right)}} \]
    6. Step-by-step derivation
      1. associate-*l*97.7%

        \[\leadsto \color{blue}{a \cdot \left(\left(-{k}^{m}\right) \cdot \frac{1}{-\mathsf{fma}\left(k, k + 10, 1\right)}\right)} \]
      2. associate-*r/97.7%

        \[\leadsto a \cdot \color{blue}{\frac{\left(-{k}^{m}\right) \cdot 1}{-\mathsf{fma}\left(k, k + 10, 1\right)}} \]
      3. *-rgt-identity97.7%

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

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

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

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

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

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

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

    if 9.99999999999999934e145 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 1 (*.f64 10 k)) (*.f64 k k)))

    1. Initial program 67.4%

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

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

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

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

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

      \[\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 10^{+146}:\\ \;\;\;\;a \cdot \frac{-{k}^{m}}{-1 - k \cdot \left(k + 10\right)}\\ \mathbf{else}:\\ \;\;\;\;a \cdot {k}^{m}\\ \end{array} \]

Alternative 2: 97.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := a \cdot {k}^{m}\\ \mathbf{if}\;m \leq 2.75 \cdot 10^{-11}:\\ \;\;\;\;\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 (<= m 2.75e-11) (/ 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 (m <= 2.75e-11) {
		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 (m <= 2.75d-11) 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 (m <= 2.75e-11) {
		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 m <= 2.75e-11:
		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 (m <= 2.75e-11)
		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 (m <= 2.75e-11)
		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[m, 2.75e-11], 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}\;m \leq 2.75 \cdot 10^{-11}:\\
\;\;\;\;\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 m < 2.74999999999999987e-11

    1. Initial program 97.1%

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Step-by-step derivation
      1. sqr-neg97.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+97.1%

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

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

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

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

    if 2.74999999999999987e-11 < m

    1. Initial program 83.7%

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Step-by-step derivation
      1. sqr-neg83.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+83.7%

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

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

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

      \[\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}\;m \leq 2.75 \cdot 10^{-11}:\\ \;\;\;\;\frac{a \cdot {k}^{m}}{1 + k \cdot \left(k + 10\right)}\\ \mathbf{else}:\\ \;\;\;\;a \cdot {k}^{m}\\ \end{array} \]

Alternative 3: 96.6% accurate, 1.1× speedup?

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

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

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


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

    1. Initial program 91.6%

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Step-by-step derivation
      1. sqr-neg91.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+91.6%

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

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

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

      \[\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}} \]

    if -1.42e-11 < m < 2.70000000000000005e-11

    1. Initial program 93.7%

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Step-by-step derivation
      1. sqr-neg93.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+93.7%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(a \cdot \left(-{k}^{m}\right)\right) \cdot \frac{1}{-\mathsf{fma}\left(k, k + 10, 1\right)}} \]
    6. Step-by-step derivation
      1. associate-*l*93.8%

        \[\leadsto \color{blue}{a \cdot \left(\left(-{k}^{m}\right) \cdot \frac{1}{-\mathsf{fma}\left(k, k + 10, 1\right)}\right)} \]
      2. associate-*r/93.8%

        \[\leadsto a \cdot \color{blue}{\frac{\left(-{k}^{m}\right) \cdot 1}{-\mathsf{fma}\left(k, k + 10, 1\right)}} \]
      3. *-rgt-identity93.8%

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

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

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

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

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

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

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

      \[\leadsto a \cdot \color{blue}{\frac{1}{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 -1.42 \cdot 10^{-11} \lor \neg \left(m \leq 2.7 \cdot 10^{-11}\right):\\ \;\;\;\;a \cdot {k}^{m}\\ \mathbf{else}:\\ \;\;\;\;a \cdot \frac{1}{1 + k \cdot \left(k + 10\right)}\\ \end{array} \]

Alternative 4: 44.9% accurate, 10.4× speedup?

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

\\
a \cdot \frac{1}{1 + k \cdot \left(k + 10\right)}
\end{array}
Derivation
  1. Initial program 92.3%

    \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
  2. Step-by-step derivation
    1. sqr-neg92.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+92.3%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\left(a \cdot \left(-{k}^{m}\right)\right) \cdot \frac{1}{-\mathsf{fma}\left(k, k + 10, 1\right)}} \]
  6. Step-by-step derivation
    1. associate-*l*92.3%

      \[\leadsto \color{blue}{a \cdot \left(\left(-{k}^{m}\right) \cdot \frac{1}{-\mathsf{fma}\left(k, k + 10, 1\right)}\right)} \]
    2. associate-*r/92.3%

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

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

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

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

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

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

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

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

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

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

Alternative 5: 44.9% accurate, 10.4× speedup?

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

\\
\frac{1}{\frac{1 + k \cdot \left(k + 10\right)}{a}}
\end{array}
Derivation
  1. Initial program 92.3%

    \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
  2. Step-by-step derivation
    1. sqr-neg92.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+92.3%

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

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

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

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

    \[\leadsto \color{blue}{\frac{a}{1 + k \cdot \left(10 + k\right)}} \]
  5. Step-by-step derivation
    1. clear-num43.7%

      \[\leadsto \color{blue}{\frac{1}{\frac{1 + k \cdot \left(10 + k\right)}{a}}} \]
    2. inv-pow43.7%

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

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

      \[\leadsto {\left(\frac{k \cdot \color{blue}{\left(k + 10\right)} + 1}{a}\right)}^{-1} \]
    5. fma-def43.7%

      \[\leadsto {\left(\frac{\color{blue}{\mathsf{fma}\left(k, k + 10, 1\right)}}{a}\right)}^{-1} \]
  6. Applied egg-rr43.7%

    \[\leadsto \color{blue}{{\left(\frac{\mathsf{fma}\left(k, k + 10, 1\right)}{a}\right)}^{-1}} \]
  7. Step-by-step derivation
    1. unpow-143.7%

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

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

    \[\leadsto \frac{1}{\color{blue}{\frac{1 + k \cdot \left(10 + k\right)}{a}}} \]
  10. Final simplification43.7%

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

Alternative 6: 27.4% accurate, 12.6× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if k < 0.0749999999999999972

    1. Initial program 96.5%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(a \cdot \left(-{k}^{m}\right)\right) \cdot \frac{1}{-\mathsf{fma}\left(k, k + 10, 1\right)}} \]
    6. Step-by-step derivation
      1. associate-*l*96.5%

        \[\leadsto \color{blue}{a \cdot \left(\left(-{k}^{m}\right) \cdot \frac{1}{-\mathsf{fma}\left(k, k + 10, 1\right)}\right)} \]
      2. associate-*r/96.5%

        \[\leadsto a \cdot \color{blue}{\frac{\left(-{k}^{m}\right) \cdot 1}{-\mathsf{fma}\left(k, k + 10, 1\right)}} \]
      3. *-rgt-identity96.5%

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

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

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

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

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

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

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

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

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

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

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

    if 0.0749999999999999972 < k

    1. Initial program 84.0%

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Step-by-step derivation
      1. sqr-neg84.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+84.0%

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

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

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

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

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

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

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

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

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

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

Alternative 7: 45.0% accurate, 12.7× speedup?

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

\\
\frac{a}{1 + k \cdot \left(k + 10\right)}
\end{array}
Derivation
  1. Initial program 92.3%

    \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
  2. Step-by-step derivation
    1. sqr-neg92.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+92.3%

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

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

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

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

    \[\leadsto \color{blue}{\frac{a}{1 + k \cdot \left(10 + k\right)}} \]
  5. Final simplification43.3%

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

Alternative 8: 25.7% accurate, 16.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;k \leq 0.1:\\
\;\;\;\;a\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if k < 0.10000000000000001

    1. Initial program 96.5%

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

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

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

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

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

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

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

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

    if 0.10000000000000001 < k

    1. Initial program 84.0%

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Step-by-step derivation
      1. sqr-neg84.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+84.0%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;k \leq 0.1:\\ \;\;\;\;a\\ \mathbf{else}:\\ \;\;\;\;0.1 \cdot \frac{a}{k}\\ \end{array} \]

Alternative 9: 28.1% accurate, 16.3× speedup?

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

\\
\frac{a}{1 + k \cdot 10}
\end{array}
Derivation
  1. Initial program 92.3%

    \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
  2. Step-by-step derivation
    1. sqr-neg92.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+92.3%

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

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

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

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

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

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

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

    \[\leadsto \frac{a}{1 + \color{blue}{k \cdot 10}} \]
  8. Final simplification25.8%

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

Alternative 10: 19.4% 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 92.3%

    \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
  2. Step-by-step derivation
    1. sqr-neg92.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+92.3%

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

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

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

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

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

    \[\leadsto \color{blue}{a} \]
  6. Final simplification17.8%

    \[\leadsto a \]

Reproduce

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