Falkner and Boettcher, Appendix A

Percentage Accurate: 90.3% → 98.0%
Time: 11.5s
Alternatives: 10
Speedup: 1.0×

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

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

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

Alternative 1: 98.0% accurate, 0.5× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\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.9999999999999998e274

    1. Initial program 99.1%

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Step-by-step derivation
      1. associate-*l/98.6%

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

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

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

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

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

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

    if 4.9999999999999998e274 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 1 (*.f64 10 k)) (*.f64 k k)))

    1. Initial program 70.7%

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Step-by-step derivation
      1. associate-*l/65.5%

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

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

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

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

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

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

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

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

Alternative 2: 97.4% accurate, 1.0× speedup?

\[\begin{array}{l} a_m = \left|a\right| \\ a_s = \mathsf{copysign}\left(1, a\right) \\ a\_s \cdot \begin{array}{l} \mathbf{if}\;m \leq -3.5 \cdot 10^{-14} \lor \neg \left(m \leq 0.185\right):\\ \;\;\;\;a\_m \cdot {k}^{m}\\ \mathbf{else}:\\ \;\;\;\;\frac{a\_m}{1 + k \cdot \left(k + 10\right)}\\ \end{array} \end{array} \]
a_m = (fabs.f64 a)
a_s = (copysign.f64 1 a)
(FPCore (a_s a_m k m)
 :precision binary64
 (*
  a_s
  (if (or (<= m -3.5e-14) (not (<= m 0.185)))
    (* a_m (pow k m))
    (/ a_m (+ 1.0 (* k (+ k 10.0)))))))
a_m = fabs(a);
a_s = copysign(1.0, a);
double code(double a_s, double a_m, double k, double m) {
	double tmp;
	if ((m <= -3.5e-14) || !(m <= 0.185)) {
		tmp = a_m * pow(k, m);
	} else {
		tmp = a_m / (1.0 + (k * (k + 10.0)));
	}
	return a_s * tmp;
}
a_m = abs(a)
a_s = copysign(1.0d0, a)
real(8) function code(a_s, a_m, k, m)
    real(8), intent (in) :: a_s
    real(8), intent (in) :: a_m
    real(8), intent (in) :: k
    real(8), intent (in) :: m
    real(8) :: tmp
    if ((m <= (-3.5d-14)) .or. (.not. (m <= 0.185d0))) then
        tmp = a_m * (k ** m)
    else
        tmp = a_m / (1.0d0 + (k * (k + 10.0d0)))
    end if
    code = a_s * tmp
end function
a_m = Math.abs(a);
a_s = Math.copySign(1.0, a);
public static double code(double a_s, double a_m, double k, double m) {
	double tmp;
	if ((m <= -3.5e-14) || !(m <= 0.185)) {
		tmp = a_m * Math.pow(k, m);
	} else {
		tmp = a_m / (1.0 + (k * (k + 10.0)));
	}
	return a_s * tmp;
}
a_m = math.fabs(a)
a_s = math.copysign(1.0, a)
def code(a_s, a_m, k, m):
	tmp = 0
	if (m <= -3.5e-14) or not (m <= 0.185):
		tmp = a_m * math.pow(k, m)
	else:
		tmp = a_m / (1.0 + (k * (k + 10.0)))
	return a_s * tmp
a_m = abs(a)
a_s = copysign(1.0, a)
function code(a_s, a_m, k, m)
	tmp = 0.0
	if ((m <= -3.5e-14) || !(m <= 0.185))
		tmp = Float64(a_m * (k ^ m));
	else
		tmp = Float64(a_m / Float64(1.0 + Float64(k * Float64(k + 10.0))));
	end
	return Float64(a_s * tmp)
end
a_m = abs(a);
a_s = sign(a) * abs(1.0);
function tmp_2 = code(a_s, a_m, k, m)
	tmp = 0.0;
	if ((m <= -3.5e-14) || ~((m <= 0.185)))
		tmp = a_m * (k ^ m);
	else
		tmp = a_m / (1.0 + (k * (k + 10.0)));
	end
	tmp_2 = a_s * tmp;
end
a_m = N[Abs[a], $MachinePrecision]
a_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, a$95$m_, k_, m_] := N[(a$95$s * If[Or[LessEqual[m, -3.5e-14], N[Not[LessEqual[m, 0.185]], $MachinePrecision]], N[(a$95$m * N[Power[k, m], $MachinePrecision]), $MachinePrecision], N[(a$95$m / N[(1.0 + N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
a_m = \left|a\right|
\\
a_s = \mathsf{copysign}\left(1, a\right)

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if m < -3.5000000000000002e-14 or 0.185 < m

    1. Initial program 90.8%

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Step-by-step derivation
      1. associate-*l/88.7%

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

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

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

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

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

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

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

    if -3.5000000000000002e-14 < m < 0.185

    1. Initial program 97.5%

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Step-by-step derivation
      1. associate-*l/97.5%

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

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

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

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

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

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

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

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

Alternative 3: 48.7% accurate, 6.0× speedup?

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

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

\mathbf{elif}\;m \leq 52000:\\
\;\;\;\;\frac{a\_m}{1 + t\_0}\\

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


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

    1. Initial program 100.0%

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Step-by-step derivation
      1. associate-*l/100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{{k}^{m}}{\frac{\color{blue}{10 \cdot k + {k}^{2}}}{a}} \]
    8. Step-by-step derivation
      1. unpow276.7%

        \[\leadsto \frac{{k}^{m}}{\frac{10 \cdot k + \color{blue}{k \cdot k}}{a}} \]
      2. distribute-rgt-in76.7%

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

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

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

    if -3.90000000000000019e34 < m < 52000

    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. associate-*l/97.7%

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

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

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

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

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

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

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

    if 52000 < m

    1. Initial program 80.9%

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Step-by-step derivation
      1. associate-*l/76.4%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;m \leq -3.9 \cdot 10^{+34}:\\ \;\;\;\;\frac{a}{k \cdot \left(k + 10\right)}\\ \mathbf{elif}\;m \leq 52000:\\ \;\;\;\;\frac{a}{1 + k \cdot \left(k + 10\right)}\\ \mathbf{else}:\\ \;\;\;\;a + -10 \cdot \left(a \cdot k\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 43.2% accurate, 6.7× speedup?

\[\begin{array}{l} a_m = \left|a\right| \\ a_s = \mathsf{copysign}\left(1, a\right) \\ a\_s \cdot \begin{array}{l} \mathbf{if}\;k \leq 1.1 \cdot 10^{-282} \lor \neg \left(k \leq 0.075\right):\\ \;\;\;\;\frac{a\_m}{k \cdot \left(k + 10\right)}\\ \mathbf{else}:\\ \;\;\;\;a\_m + -10 \cdot \left(a\_m \cdot k\right)\\ \end{array} \end{array} \]
a_m = (fabs.f64 a)
a_s = (copysign.f64 1 a)
(FPCore (a_s a_m k m)
 :precision binary64
 (*
  a_s
  (if (or (<= k 1.1e-282) (not (<= k 0.075)))
    (/ a_m (* k (+ k 10.0)))
    (+ a_m (* -10.0 (* a_m k))))))
a_m = fabs(a);
a_s = copysign(1.0, a);
double code(double a_s, double a_m, double k, double m) {
	double tmp;
	if ((k <= 1.1e-282) || !(k <= 0.075)) {
		tmp = a_m / (k * (k + 10.0));
	} else {
		tmp = a_m + (-10.0 * (a_m * k));
	}
	return a_s * tmp;
}
a_m = abs(a)
a_s = copysign(1.0d0, a)
real(8) function code(a_s, a_m, k, m)
    real(8), intent (in) :: a_s
    real(8), intent (in) :: a_m
    real(8), intent (in) :: k
    real(8), intent (in) :: m
    real(8) :: tmp
    if ((k <= 1.1d-282) .or. (.not. (k <= 0.075d0))) then
        tmp = a_m / (k * (k + 10.0d0))
    else
        tmp = a_m + ((-10.0d0) * (a_m * k))
    end if
    code = a_s * tmp
end function
a_m = Math.abs(a);
a_s = Math.copySign(1.0, a);
public static double code(double a_s, double a_m, double k, double m) {
	double tmp;
	if ((k <= 1.1e-282) || !(k <= 0.075)) {
		tmp = a_m / (k * (k + 10.0));
	} else {
		tmp = a_m + (-10.0 * (a_m * k));
	}
	return a_s * tmp;
}
a_m = math.fabs(a)
a_s = math.copysign(1.0, a)
def code(a_s, a_m, k, m):
	tmp = 0
	if (k <= 1.1e-282) or not (k <= 0.075):
		tmp = a_m / (k * (k + 10.0))
	else:
		tmp = a_m + (-10.0 * (a_m * k))
	return a_s * tmp
a_m = abs(a)
a_s = copysign(1.0, a)
function code(a_s, a_m, k, m)
	tmp = 0.0
	if ((k <= 1.1e-282) || !(k <= 0.075))
		tmp = Float64(a_m / Float64(k * Float64(k + 10.0)));
	else
		tmp = Float64(a_m + Float64(-10.0 * Float64(a_m * k)));
	end
	return Float64(a_s * tmp)
end
a_m = abs(a);
a_s = sign(a) * abs(1.0);
function tmp_2 = code(a_s, a_m, k, m)
	tmp = 0.0;
	if ((k <= 1.1e-282) || ~((k <= 0.075)))
		tmp = a_m / (k * (k + 10.0));
	else
		tmp = a_m + (-10.0 * (a_m * k));
	end
	tmp_2 = a_s * tmp;
end
a_m = N[Abs[a], $MachinePrecision]
a_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, a$95$m_, k_, m_] := N[(a$95$s * If[Or[LessEqual[k, 1.1e-282], N[Not[LessEqual[k, 0.075]], $MachinePrecision]], N[(a$95$m / N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a$95$m + N[(-10.0 * N[(a$95$m * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
a_m = \left|a\right|
\\
a_s = \mathsf{copysign}\left(1, a\right)

\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;k \leq 1.1 \cdot 10^{-282} \lor \neg \left(k \leq 0.075\right):\\
\;\;\;\;\frac{a\_m}{k \cdot \left(k + 10\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if k < 1.09999999999999991e-282 or 0.0749999999999999972 < k

    1. Initial program 89.0%

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Step-by-step derivation
      1. associate-*l/86.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{{k}^{m}}{\frac{\color{blue}{10 \cdot k + {k}^{2}}}{a}} \]
    8. Step-by-step derivation
      1. unpow268.3%

        \[\leadsto \frac{{k}^{m}}{\frac{10 \cdot k + \color{blue}{k \cdot k}}{a}} \]
      2. distribute-rgt-in68.3%

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

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

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

    if 1.09999999999999991e-282 < k < 0.0749999999999999972

    1. Initial program 99.9%

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Step-by-step derivation
      1. associate-*l/99.9%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;k \leq 1.1 \cdot 10^{-282} \lor \neg \left(k \leq 0.075\right):\\ \;\;\;\;\frac{a}{k \cdot \left(k + 10\right)}\\ \mathbf{else}:\\ \;\;\;\;a + -10 \cdot \left(a \cdot k\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 43.1% accurate, 6.7× speedup?

\[\begin{array}{l} a_m = \left|a\right| \\ a_s = \mathsf{copysign}\left(1, a\right) \\ a\_s \cdot \begin{array}{l} \mathbf{if}\;k \leq 1.06 \cdot 10^{-278} \lor \neg \left(k \leq 0.12\right):\\ \;\;\;\;\frac{a\_m}{k \cdot \left(k + 10\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{a\_m}{1 + k \cdot 10}\\ \end{array} \end{array} \]
a_m = (fabs.f64 a)
a_s = (copysign.f64 1 a)
(FPCore (a_s a_m k m)
 :precision binary64
 (*
  a_s
  (if (or (<= k 1.06e-278) (not (<= k 0.12)))
    (/ a_m (* k (+ k 10.0)))
    (/ a_m (+ 1.0 (* k 10.0))))))
a_m = fabs(a);
a_s = copysign(1.0, a);
double code(double a_s, double a_m, double k, double m) {
	double tmp;
	if ((k <= 1.06e-278) || !(k <= 0.12)) {
		tmp = a_m / (k * (k + 10.0));
	} else {
		tmp = a_m / (1.0 + (k * 10.0));
	}
	return a_s * tmp;
}
a_m = abs(a)
a_s = copysign(1.0d0, a)
real(8) function code(a_s, a_m, k, m)
    real(8), intent (in) :: a_s
    real(8), intent (in) :: a_m
    real(8), intent (in) :: k
    real(8), intent (in) :: m
    real(8) :: tmp
    if ((k <= 1.06d-278) .or. (.not. (k <= 0.12d0))) then
        tmp = a_m / (k * (k + 10.0d0))
    else
        tmp = a_m / (1.0d0 + (k * 10.0d0))
    end if
    code = a_s * tmp
end function
a_m = Math.abs(a);
a_s = Math.copySign(1.0, a);
public static double code(double a_s, double a_m, double k, double m) {
	double tmp;
	if ((k <= 1.06e-278) || !(k <= 0.12)) {
		tmp = a_m / (k * (k + 10.0));
	} else {
		tmp = a_m / (1.0 + (k * 10.0));
	}
	return a_s * tmp;
}
a_m = math.fabs(a)
a_s = math.copysign(1.0, a)
def code(a_s, a_m, k, m):
	tmp = 0
	if (k <= 1.06e-278) or not (k <= 0.12):
		tmp = a_m / (k * (k + 10.0))
	else:
		tmp = a_m / (1.0 + (k * 10.0))
	return a_s * tmp
a_m = abs(a)
a_s = copysign(1.0, a)
function code(a_s, a_m, k, m)
	tmp = 0.0
	if ((k <= 1.06e-278) || !(k <= 0.12))
		tmp = Float64(a_m / Float64(k * Float64(k + 10.0)));
	else
		tmp = Float64(a_m / Float64(1.0 + Float64(k * 10.0)));
	end
	return Float64(a_s * tmp)
end
a_m = abs(a);
a_s = sign(a) * abs(1.0);
function tmp_2 = code(a_s, a_m, k, m)
	tmp = 0.0;
	if ((k <= 1.06e-278) || ~((k <= 0.12)))
		tmp = a_m / (k * (k + 10.0));
	else
		tmp = a_m / (1.0 + (k * 10.0));
	end
	tmp_2 = a_s * tmp;
end
a_m = N[Abs[a], $MachinePrecision]
a_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, a$95$m_, k_, m_] := N[(a$95$s * If[Or[LessEqual[k, 1.06e-278], N[Not[LessEqual[k, 0.12]], $MachinePrecision]], N[(a$95$m / N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a$95$m / N[(1.0 + N[(k * 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
a_m = \left|a\right|
\\
a_s = \mathsf{copysign}\left(1, a\right)

\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;k \leq 1.06 \cdot 10^{-278} \lor \neg \left(k \leq 0.12\right):\\
\;\;\;\;\frac{a\_m}{k \cdot \left(k + 10\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if k < 1.0600000000000001e-278 or 0.12 < k

    1. Initial program 89.0%

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Step-by-step derivation
      1. associate-*l/86.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{{k}^{m}}{\frac{\color{blue}{10 \cdot k + {k}^{2}}}{a}} \]
    8. Step-by-step derivation
      1. unpow268.3%

        \[\leadsto \frac{{k}^{m}}{\frac{10 \cdot k + \color{blue}{k \cdot k}}{a}} \]
      2. distribute-rgt-in68.3%

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

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

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

    if 1.0600000000000001e-278 < k < 0.12

    1. Initial program 99.9%

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Step-by-step derivation
      1. associate-*l/99.9%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{a}{1 + \color{blue}{k \cdot 10}} \cdot {k}^{m} \]
    8. Simplified40.6%

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

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

Alternative 6: 26.6% accurate, 7.6× speedup?

\[\begin{array}{l} a_m = \left|a\right| \\ a_s = \mathsf{copysign}\left(1, a\right) \\ a\_s \cdot \begin{array}{l} \mathbf{if}\;k \leq 3.5 \cdot 10^{-281} \lor \neg \left(k \leq 0.122\right):\\ \;\;\;\;0.1 \cdot \frac{a\_m}{k}\\ \mathbf{else}:\\ \;\;\;\;a\_m\\ \end{array} \end{array} \]
a_m = (fabs.f64 a)
a_s = (copysign.f64 1 a)
(FPCore (a_s a_m k m)
 :precision binary64
 (* a_s (if (or (<= k 3.5e-281) (not (<= k 0.122))) (* 0.1 (/ a_m k)) a_m)))
a_m = fabs(a);
a_s = copysign(1.0, a);
double code(double a_s, double a_m, double k, double m) {
	double tmp;
	if ((k <= 3.5e-281) || !(k <= 0.122)) {
		tmp = 0.1 * (a_m / k);
	} else {
		tmp = a_m;
	}
	return a_s * tmp;
}
a_m = abs(a)
a_s = copysign(1.0d0, a)
real(8) function code(a_s, a_m, k, m)
    real(8), intent (in) :: a_s
    real(8), intent (in) :: a_m
    real(8), intent (in) :: k
    real(8), intent (in) :: m
    real(8) :: tmp
    if ((k <= 3.5d-281) .or. (.not. (k <= 0.122d0))) then
        tmp = 0.1d0 * (a_m / k)
    else
        tmp = a_m
    end if
    code = a_s * tmp
end function
a_m = Math.abs(a);
a_s = Math.copySign(1.0, a);
public static double code(double a_s, double a_m, double k, double m) {
	double tmp;
	if ((k <= 3.5e-281) || !(k <= 0.122)) {
		tmp = 0.1 * (a_m / k);
	} else {
		tmp = a_m;
	}
	return a_s * tmp;
}
a_m = math.fabs(a)
a_s = math.copysign(1.0, a)
def code(a_s, a_m, k, m):
	tmp = 0
	if (k <= 3.5e-281) or not (k <= 0.122):
		tmp = 0.1 * (a_m / k)
	else:
		tmp = a_m
	return a_s * tmp
a_m = abs(a)
a_s = copysign(1.0, a)
function code(a_s, a_m, k, m)
	tmp = 0.0
	if ((k <= 3.5e-281) || !(k <= 0.122))
		tmp = Float64(0.1 * Float64(a_m / k));
	else
		tmp = a_m;
	end
	return Float64(a_s * tmp)
end
a_m = abs(a);
a_s = sign(a) * abs(1.0);
function tmp_2 = code(a_s, a_m, k, m)
	tmp = 0.0;
	if ((k <= 3.5e-281) || ~((k <= 0.122)))
		tmp = 0.1 * (a_m / k);
	else
		tmp = a_m;
	end
	tmp_2 = a_s * tmp;
end
a_m = N[Abs[a], $MachinePrecision]
a_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, a$95$m_, k_, m_] := N[(a$95$s * If[Or[LessEqual[k, 3.5e-281], N[Not[LessEqual[k, 0.122]], $MachinePrecision]], N[(0.1 * N[(a$95$m / k), $MachinePrecision]), $MachinePrecision], a$95$m]), $MachinePrecision]
\begin{array}{l}
a_m = \left|a\right|
\\
a_s = \mathsf{copysign}\left(1, a\right)

\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;k \leq 3.5 \cdot 10^{-281} \lor \neg \left(k \leq 0.122\right):\\
\;\;\;\;0.1 \cdot \frac{a\_m}{k}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if k < 3.50000000000000022e-281 or 0.122 < k

    1. Initial program 88.9%

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Step-by-step derivation
      1. associate-*l/86.5%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(0.1 \cdot \frac{a}{k}\right)} \cdot {k}^{m} \]
    9. Step-by-step derivation
      1. associate-*r/53.8%

        \[\leadsto \color{blue}{\frac{0.1 \cdot a}{k}} \cdot {k}^{m} \]
    10. Simplified53.8%

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

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

    if 3.50000000000000022e-281 < k < 0.122

    1. Initial program 99.9%

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Step-by-step derivation
      1. associate-*l/99.9%

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

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

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

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

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

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

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

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

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

Alternative 7: 26.9% accurate, 7.6× speedup?

\[\begin{array}{l} a_m = \left|a\right| \\ a_s = \mathsf{copysign}\left(1, a\right) \\ a\_s \cdot \begin{array}{l} \mathbf{if}\;k \leq 1.1 \cdot 10^{-282}:\\ \;\;\;\;0.1 \cdot \frac{a\_m}{k}\\ \mathbf{elif}\;k \leq 0.122:\\ \;\;\;\;a\_m\\ \mathbf{else}:\\ \;\;\;\;\frac{0.1}{\frac{k}{a\_m}}\\ \end{array} \end{array} \]
a_m = (fabs.f64 a)
a_s = (copysign.f64 1 a)
(FPCore (a_s a_m k m)
 :precision binary64
 (*
  a_s
  (if (<= k 1.1e-282)
    (* 0.1 (/ a_m k))
    (if (<= k 0.122) a_m (/ 0.1 (/ k a_m))))))
a_m = fabs(a);
a_s = copysign(1.0, a);
double code(double a_s, double a_m, double k, double m) {
	double tmp;
	if (k <= 1.1e-282) {
		tmp = 0.1 * (a_m / k);
	} else if (k <= 0.122) {
		tmp = a_m;
	} else {
		tmp = 0.1 / (k / a_m);
	}
	return a_s * tmp;
}
a_m = abs(a)
a_s = copysign(1.0d0, a)
real(8) function code(a_s, a_m, k, m)
    real(8), intent (in) :: a_s
    real(8), intent (in) :: a_m
    real(8), intent (in) :: k
    real(8), intent (in) :: m
    real(8) :: tmp
    if (k <= 1.1d-282) then
        tmp = 0.1d0 * (a_m / k)
    else if (k <= 0.122d0) then
        tmp = a_m
    else
        tmp = 0.1d0 / (k / a_m)
    end if
    code = a_s * tmp
end function
a_m = Math.abs(a);
a_s = Math.copySign(1.0, a);
public static double code(double a_s, double a_m, double k, double m) {
	double tmp;
	if (k <= 1.1e-282) {
		tmp = 0.1 * (a_m / k);
	} else if (k <= 0.122) {
		tmp = a_m;
	} else {
		tmp = 0.1 / (k / a_m);
	}
	return a_s * tmp;
}
a_m = math.fabs(a)
a_s = math.copysign(1.0, a)
def code(a_s, a_m, k, m):
	tmp = 0
	if k <= 1.1e-282:
		tmp = 0.1 * (a_m / k)
	elif k <= 0.122:
		tmp = a_m
	else:
		tmp = 0.1 / (k / a_m)
	return a_s * tmp
a_m = abs(a)
a_s = copysign(1.0, a)
function code(a_s, a_m, k, m)
	tmp = 0.0
	if (k <= 1.1e-282)
		tmp = Float64(0.1 * Float64(a_m / k));
	elseif (k <= 0.122)
		tmp = a_m;
	else
		tmp = Float64(0.1 / Float64(k / a_m));
	end
	return Float64(a_s * tmp)
end
a_m = abs(a);
a_s = sign(a) * abs(1.0);
function tmp_2 = code(a_s, a_m, k, m)
	tmp = 0.0;
	if (k <= 1.1e-282)
		tmp = 0.1 * (a_m / k);
	elseif (k <= 0.122)
		tmp = a_m;
	else
		tmp = 0.1 / (k / a_m);
	end
	tmp_2 = a_s * tmp;
end
a_m = N[Abs[a], $MachinePrecision]
a_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, a$95$m_, k_, m_] := N[(a$95$s * If[LessEqual[k, 1.1e-282], N[(0.1 * N[(a$95$m / k), $MachinePrecision]), $MachinePrecision], If[LessEqual[k, 0.122], a$95$m, N[(0.1 / N[(k / a$95$m), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
a_m = \left|a\right|
\\
a_s = \mathsf{copysign}\left(1, a\right)

\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;k \leq 1.1 \cdot 10^{-282}:\\
\;\;\;\;0.1 \cdot \frac{a\_m}{k}\\

\mathbf{elif}\;k \leq 0.122:\\
\;\;\;\;a\_m\\

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


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

    1. Initial program 89.5%

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Step-by-step derivation
      1. associate-*l/87.4%

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

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

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

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

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

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

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

        \[\leadsto \frac{a}{1 + \color{blue}{k \cdot 10}} \cdot {k}^{m} \]
    7. Simplified80.0%

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

      \[\leadsto \color{blue}{\left(0.1 \cdot \frac{a}{k}\right)} \cdot {k}^{m} \]
    9. Step-by-step derivation
      1. associate-*r/47.4%

        \[\leadsto \color{blue}{\frac{0.1 \cdot a}{k}} \cdot {k}^{m} \]
    10. Simplified47.4%

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

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

    if 1.09999999999999991e-282 < k < 0.122

    1. Initial program 99.9%

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Step-by-step derivation
      1. associate-*l/99.9%

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

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

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

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

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

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

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

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

    if 0.122 < k

    1. Initial program 88.1%

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Step-by-step derivation
      1. associate-*l/85.4%

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

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

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

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

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

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

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

        \[\leadsto \frac{a}{1 + \color{blue}{k \cdot 10}} \cdot {k}^{m} \]
    7. Simplified63.3%

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

      \[\leadsto \color{blue}{\left(0.1 \cdot \frac{a}{k}\right)} \cdot {k}^{m} \]
    9. Step-by-step derivation
      1. associate-*r/62.0%

        \[\leadsto \color{blue}{\frac{0.1 \cdot a}{k}} \cdot {k}^{m} \]
    10. Simplified62.0%

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

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

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

        \[\leadsto \color{blue}{\frac{0.1}{\frac{k}{a}}} \]
    13. Applied egg-rr26.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;k \leq 1.1 \cdot 10^{-282}:\\ \;\;\;\;0.1 \cdot \frac{a}{k}\\ \mathbf{elif}\;k \leq 0.122:\\ \;\;\;\;a\\ \mathbf{else}:\\ \;\;\;\;\frac{0.1}{\frac{k}{a}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 27.7% accurate, 9.5× speedup?

\[\begin{array}{l} a_m = \left|a\right| \\ a_s = \mathsf{copysign}\left(1, a\right) \\ a\_s \cdot \begin{array}{l} \mathbf{if}\;m \leq -0.000105:\\ \;\;\;\;0.1 \cdot \frac{a\_m}{k}\\ \mathbf{else}:\\ \;\;\;\;a\_m + -10 \cdot \left(a\_m \cdot k\right)\\ \end{array} \end{array} \]
a_m = (fabs.f64 a)
a_s = (copysign.f64 1 a)
(FPCore (a_s a_m k m)
 :precision binary64
 (* a_s (if (<= m -0.000105) (* 0.1 (/ a_m k)) (+ a_m (* -10.0 (* a_m k))))))
a_m = fabs(a);
a_s = copysign(1.0, a);
double code(double a_s, double a_m, double k, double m) {
	double tmp;
	if (m <= -0.000105) {
		tmp = 0.1 * (a_m / k);
	} else {
		tmp = a_m + (-10.0 * (a_m * k));
	}
	return a_s * tmp;
}
a_m = abs(a)
a_s = copysign(1.0d0, a)
real(8) function code(a_s, a_m, k, m)
    real(8), intent (in) :: a_s
    real(8), intent (in) :: a_m
    real(8), intent (in) :: k
    real(8), intent (in) :: m
    real(8) :: tmp
    if (m <= (-0.000105d0)) then
        tmp = 0.1d0 * (a_m / k)
    else
        tmp = a_m + ((-10.0d0) * (a_m * k))
    end if
    code = a_s * tmp
end function
a_m = Math.abs(a);
a_s = Math.copySign(1.0, a);
public static double code(double a_s, double a_m, double k, double m) {
	double tmp;
	if (m <= -0.000105) {
		tmp = 0.1 * (a_m / k);
	} else {
		tmp = a_m + (-10.0 * (a_m * k));
	}
	return a_s * tmp;
}
a_m = math.fabs(a)
a_s = math.copysign(1.0, a)
def code(a_s, a_m, k, m):
	tmp = 0
	if m <= -0.000105:
		tmp = 0.1 * (a_m / k)
	else:
		tmp = a_m + (-10.0 * (a_m * k))
	return a_s * tmp
a_m = abs(a)
a_s = copysign(1.0, a)
function code(a_s, a_m, k, m)
	tmp = 0.0
	if (m <= -0.000105)
		tmp = Float64(0.1 * Float64(a_m / k));
	else
		tmp = Float64(a_m + Float64(-10.0 * Float64(a_m * k)));
	end
	return Float64(a_s * tmp)
end
a_m = abs(a);
a_s = sign(a) * abs(1.0);
function tmp_2 = code(a_s, a_m, k, m)
	tmp = 0.0;
	if (m <= -0.000105)
		tmp = 0.1 * (a_m / k);
	else
		tmp = a_m + (-10.0 * (a_m * k));
	end
	tmp_2 = a_s * tmp;
end
a_m = N[Abs[a], $MachinePrecision]
a_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, a$95$m_, k_, m_] := N[(a$95$s * If[LessEqual[m, -0.000105], N[(0.1 * N[(a$95$m / k), $MachinePrecision]), $MachinePrecision], N[(a$95$m + N[(-10.0 * N[(a$95$m * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
a_m = \left|a\right|
\\
a_s = \mathsf{copysign}\left(1, a\right)

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

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


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

    1. Initial program 100.0%

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Step-by-step derivation
      1. associate-*l/100.0%

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

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

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

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

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

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

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

        \[\leadsto \frac{a}{1 + \color{blue}{k \cdot 10}} \cdot {k}^{m} \]
    7. Simplified100.0%

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

      \[\leadsto \color{blue}{\left(0.1 \cdot \frac{a}{k}\right)} \cdot {k}^{m} \]
    9. Step-by-step derivation
      1. associate-*r/76.3%

        \[\leadsto \color{blue}{\frac{0.1 \cdot a}{k}} \cdot {k}^{m} \]
    10. Simplified76.3%

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

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

    if -1.05e-4 < m

    1. Initial program 88.5%

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Step-by-step derivation
      1. associate-*l/86.0%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;m \leq -0.000105:\\ \;\;\;\;0.1 \cdot \frac{a}{k}\\ \mathbf{else}:\\ \;\;\;\;a + -10 \cdot \left(a \cdot k\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 28.8% accurate, 9.5× speedup?

\[\begin{array}{l} a_m = \left|a\right| \\ a_s = \mathsf{copysign}\left(1, a\right) \\ a\_s \cdot \begin{array}{l} \mathbf{if}\;k \leq 0.075:\\ \;\;\;\;a\_m + -10 \cdot \left(a\_m \cdot k\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{k}{a\_m \cdot 0.1}}\\ \end{array} \end{array} \]
a_m = (fabs.f64 a)
a_s = (copysign.f64 1 a)
(FPCore (a_s a_m k m)
 :precision binary64
 (*
  a_s
  (if (<= k 0.075) (+ a_m (* -10.0 (* a_m k))) (/ 1.0 (/ k (* a_m 0.1))))))
a_m = fabs(a);
a_s = copysign(1.0, a);
double code(double a_s, double a_m, double k, double m) {
	double tmp;
	if (k <= 0.075) {
		tmp = a_m + (-10.0 * (a_m * k));
	} else {
		tmp = 1.0 / (k / (a_m * 0.1));
	}
	return a_s * tmp;
}
a_m = abs(a)
a_s = copysign(1.0d0, a)
real(8) function code(a_s, a_m, k, m)
    real(8), intent (in) :: a_s
    real(8), intent (in) :: a_m
    real(8), intent (in) :: k
    real(8), intent (in) :: m
    real(8) :: tmp
    if (k <= 0.075d0) then
        tmp = a_m + ((-10.0d0) * (a_m * k))
    else
        tmp = 1.0d0 / (k / (a_m * 0.1d0))
    end if
    code = a_s * tmp
end function
a_m = Math.abs(a);
a_s = Math.copySign(1.0, a);
public static double code(double a_s, double a_m, double k, double m) {
	double tmp;
	if (k <= 0.075) {
		tmp = a_m + (-10.0 * (a_m * k));
	} else {
		tmp = 1.0 / (k / (a_m * 0.1));
	}
	return a_s * tmp;
}
a_m = math.fabs(a)
a_s = math.copysign(1.0, a)
def code(a_s, a_m, k, m):
	tmp = 0
	if k <= 0.075:
		tmp = a_m + (-10.0 * (a_m * k))
	else:
		tmp = 1.0 / (k / (a_m * 0.1))
	return a_s * tmp
a_m = abs(a)
a_s = copysign(1.0, a)
function code(a_s, a_m, k, m)
	tmp = 0.0
	if (k <= 0.075)
		tmp = Float64(a_m + Float64(-10.0 * Float64(a_m * k)));
	else
		tmp = Float64(1.0 / Float64(k / Float64(a_m * 0.1)));
	end
	return Float64(a_s * tmp)
end
a_m = abs(a);
a_s = sign(a) * abs(1.0);
function tmp_2 = code(a_s, a_m, k, m)
	tmp = 0.0;
	if (k <= 0.075)
		tmp = a_m + (-10.0 * (a_m * k));
	else
		tmp = 1.0 / (k / (a_m * 0.1));
	end
	tmp_2 = a_s * tmp;
end
a_m = N[Abs[a], $MachinePrecision]
a_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, a$95$m_, k_, m_] := N[(a$95$s * If[LessEqual[k, 0.075], N[(a$95$m + N[(-10.0 * N[(a$95$m * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(k / N[(a$95$m * 0.1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
a_m = \left|a\right|
\\
a_s = \mathsf{copysign}\left(1, a\right)

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

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


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

    1. Initial program 94.4%

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Step-by-step derivation
      1. associate-*l/93.3%

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

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

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

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

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

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

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

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

    if 0.0749999999999999972 < k

    1. Initial program 88.3%

      \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
    2. Step-by-step derivation
      1. associate-*l/85.6%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(0.1 \cdot \frac{a}{k}\right)} \cdot {k}^{m} \]
    9. Step-by-step derivation
      1. associate-*r/62.5%

        \[\leadsto \color{blue}{\frac{0.1 \cdot a}{k}} \cdot {k}^{m} \]
    10. Simplified62.5%

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

      \[\leadsto \color{blue}{0.1 \cdot \frac{a}{k}} \]
    12. Step-by-step derivation
      1. associate-*r/24.2%

        \[\leadsto \color{blue}{\frac{0.1 \cdot a}{k}} \]
      2. clear-num26.7%

        \[\leadsto \color{blue}{\frac{1}{\frac{k}{0.1 \cdot a}}} \]
      3. *-commutative26.7%

        \[\leadsto \frac{1}{\frac{k}{\color{blue}{a \cdot 0.1}}} \]
    13. Applied egg-rr26.7%

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

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

Alternative 10: 20.1% accurate, 114.0× speedup?

\[\begin{array}{l} a_m = \left|a\right| \\ a_s = \mathsf{copysign}\left(1, a\right) \\ a\_s \cdot a\_m \end{array} \]
a_m = (fabs.f64 a)
a_s = (copysign.f64 1 a)
(FPCore (a_s a_m k m) :precision binary64 (* a_s a_m))
a_m = fabs(a);
a_s = copysign(1.0, a);
double code(double a_s, double a_m, double k, double m) {
	return a_s * a_m;
}
a_m = abs(a)
a_s = copysign(1.0d0, a)
real(8) function code(a_s, a_m, k, m)
    real(8), intent (in) :: a_s
    real(8), intent (in) :: a_m
    real(8), intent (in) :: k
    real(8), intent (in) :: m
    code = a_s * a_m
end function
a_m = Math.abs(a);
a_s = Math.copySign(1.0, a);
public static double code(double a_s, double a_m, double k, double m) {
	return a_s * a_m;
}
a_m = math.fabs(a)
a_s = math.copysign(1.0, a)
def code(a_s, a_m, k, m):
	return a_s * a_m
a_m = abs(a)
a_s = copysign(1.0, a)
function code(a_s, a_m, k, m)
	return Float64(a_s * a_m)
end
a_m = abs(a);
a_s = sign(a) * abs(1.0);
function tmp = code(a_s, a_m, k, m)
	tmp = a_s * a_m;
end
a_m = N[Abs[a], $MachinePrecision]
a_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, a$95$m_, k_, m_] := N[(a$95$s * a$95$m), $MachinePrecision]
\begin{array}{l}
a_m = \left|a\right|
\\
a_s = \mathsf{copysign}\left(1, a\right)

\\
a\_s \cdot a\_m
\end{array}
Derivation
  1. Initial program 92.6%

    \[\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \]
  2. Step-by-step derivation
    1. associate-*l/91.1%

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{a} \]
  7. Final simplification16.4%

    \[\leadsto a \]
  8. Add Preprocessing

Reproduce

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