Falkner and Boettcher, Appendix A

Percentage Accurate: 90.3% → 97.0%
Time: 13.7s
Alternatives: 14
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 14 alternatives:

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

Initial Program: 90.3% accurate, 1.0× speedup?

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

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

Alternative 1: 97.0% accurate, 0.3× 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}\;\frac{a\_m \cdot {k}^{m}}{k \cdot k + \left(1 + k \cdot 10\right)} \leq 2 \cdot 10^{+124}:\\ \;\;\;\;{k}^{m} \cdot \frac{a\_m}{1 + k \cdot \left(k + 10\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{a\_m}{\mathsf{fma}\left(10, \frac{k}{{k}^{m}}, {k}^{\left(-m\right)}\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 (<= (/ (* a_m (pow k m)) (+ (* k k) (+ 1.0 (* k 10.0)))) 2e+124)
    (* (pow k m) (/ a_m (+ 1.0 (* k (+ k 10.0)))))
    (/ a_m (fma 10.0 (/ k (pow k m)) (pow k (- 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 (((a_m * pow(k, m)) / ((k * k) + (1.0 + (k * 10.0)))) <= 2e+124) {
		tmp = pow(k, m) * (a_m / (1.0 + (k * (k + 10.0))));
	} else {
		tmp = a_m / fma(10.0, (k / pow(k, m)), pow(k, -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 (Float64(Float64(a_m * (k ^ m)) / Float64(Float64(k * k) + Float64(1.0 + Float64(k * 10.0)))) <= 2e+124)
		tmp = Float64((k ^ m) * Float64(a_m / Float64(1.0 + Float64(k * Float64(k + 10.0)))));
	else
		tmp = Float64(a_m / fma(10.0, Float64(k / (k ^ m)), (k ^ Float64(-m))));
	end
	return Float64(a_s * tmp)
end
a_m = N[Abs[a], $MachinePrecision]
a_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, a$95$m_, k_, m_] := N[(a$95$s * If[LessEqual[N[(N[(a$95$m * N[Power[k, m], $MachinePrecision]), $MachinePrecision] / N[(N[(k * k), $MachinePrecision] + N[(1.0 + N[(k * 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2e+124], N[(N[Power[k, m], $MachinePrecision] * N[(a$95$m / N[(1.0 + N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a$95$m / N[(10.0 * N[(k / N[Power[k, m], $MachinePrecision]), $MachinePrecision] + N[Power[k, (-m)], $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}\;\frac{a\_m \cdot {k}^{m}}{k \cdot k + \left(1 + k \cdot 10\right)} \leq 2 \cdot 10^{+124}:\\
\;\;\;\;{k}^{m} \cdot \frac{a\_m}{1 + k \cdot \left(k + 10\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{a\_m}{\mathsf{fma}\left(10, \frac{k}{{k}^{m}}, {k}^{\left(-m\right)}\right)}\\


\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))) < 1.9999999999999999e124

    1. Initial program 96.1%

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

        \[\leadsto \color{blue}{\frac{a}{\left(1 + 10 \cdot k\right) + k \cdot k} \cdot {k}^{m}} \]
      2. sqr-neg94.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+94.5%

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

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

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

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

    if 1.9999999999999999e124 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 1 (*.f64 10 k)) (*.f64 k k)))

    1. Initial program 64.5%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{a}{\color{blue}{\mathsf{fma}\left(10, \frac{k}{{k}^{m}}, \frac{1}{{k}^{m}}\right)}} \]
      2. exp-to-pow69.4%

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

        \[\leadsto \frac{a}{\mathsf{fma}\left(10, \frac{k}{{k}^{m}}, \frac{1}{e^{\color{blue}{m \cdot \log k}}}\right)} \]
      4. exp-neg69.4%

        \[\leadsto \frac{a}{\mathsf{fma}\left(10, \frac{k}{{k}^{m}}, \color{blue}{e^{-m \cdot \log k}}\right)} \]
      5. distribute-lft-neg-out69.4%

        \[\leadsto \frac{a}{\mathsf{fma}\left(10, \frac{k}{{k}^{m}}, e^{\color{blue}{\left(-m\right) \cdot \log k}}\right)} \]
      6. *-commutative69.4%

        \[\leadsto \frac{a}{\mathsf{fma}\left(10, \frac{k}{{k}^{m}}, e^{\color{blue}{\log k \cdot \left(-m\right)}}\right)} \]
      7. exp-to-pow100.0%

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

      \[\leadsto \frac{a}{\color{blue}{\mathsf{fma}\left(10, \frac{k}{{k}^{m}}, {k}^{\left(-m\right)}\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification95.9%

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

Alternative 2: 97.6% 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 1.1 \cdot 10^{-7}:\\ \;\;\;\;{k}^{m} \cdot \frac{a\_m}{1 + k \cdot \left(k + 10\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{a\_m}{{k}^{\left(-m\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 1.1e-7)
    (* (pow k m) (/ a_m (+ 1.0 (* k (+ k 10.0)))))
    (/ a_m (pow k (- m))))))
a_m = fabs(a);
a_s = copysign(1.0, a);
double code(double a_s, double a_m, double k, double m) {
	double tmp;
	if (m <= 1.1e-7) {
		tmp = pow(k, m) * (a_m / (1.0 + (k * (k + 10.0))));
	} else {
		tmp = a_m / pow(k, -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 (m <= 1.1d-7) then
        tmp = (k ** m) * (a_m / (1.0d0 + (k * (k + 10.0d0))))
    else
        tmp = a_m / (k ** -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 (m <= 1.1e-7) {
		tmp = Math.pow(k, m) * (a_m / (1.0 + (k * (k + 10.0))));
	} else {
		tmp = a_m / Math.pow(k, -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 m <= 1.1e-7:
		tmp = math.pow(k, m) * (a_m / (1.0 + (k * (k + 10.0))))
	else:
		tmp = a_m / math.pow(k, -m)
	return a_s * tmp
a_m = abs(a)
a_s = copysign(1.0, a)
function code(a_s, a_m, k, m)
	tmp = 0.0
	if (m <= 1.1e-7)
		tmp = Float64((k ^ m) * Float64(a_m / Float64(1.0 + Float64(k * Float64(k + 10.0)))));
	else
		tmp = Float64(a_m / (k ^ Float64(-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 (m <= 1.1e-7)
		tmp = (k ^ m) * (a_m / (1.0 + (k * (k + 10.0))));
	else
		tmp = a_m / (k ^ -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[m, 1.1e-7], N[(N[Power[k, m], $MachinePrecision] * N[(a$95$m / N[(1.0 + N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a$95$m / N[Power[k, (-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}\;m \leq 1.1 \cdot 10^{-7}:\\
\;\;\;\;{k}^{m} \cdot \frac{a\_m}{1 + k \cdot \left(k + 10\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{a\_m}{{k}^{\left(-m\right)}}\\


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

    1. Initial program 95.7%

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

        \[\leadsto \color{blue}{\frac{a}{\left(1 + 10 \cdot k\right) + k \cdot k} \cdot {k}^{m}} \]
      2. sqr-neg95.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+95.7%

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

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

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

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

    if 1.1000000000000001e-7 < m

    1. Initial program 72.1%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{a}{\color{blue}{\frac{1}{{k}^{m}}}} \]
    7. Step-by-step derivation
      1. exp-to-pow58.2%

        \[\leadsto \frac{a}{\frac{1}{\color{blue}{e^{\log k \cdot m}}}} \]
      2. *-commutative58.2%

        \[\leadsto \frac{a}{\frac{1}{e^{\color{blue}{m \cdot \log k}}}} \]
      3. exp-neg58.2%

        \[\leadsto \frac{a}{\color{blue}{e^{-m \cdot \log k}}} \]
      4. distribute-lft-neg-out58.2%

        \[\leadsto \frac{a}{e^{\color{blue}{\left(-m\right) \cdot \log k}}} \]
      5. *-commutative58.2%

        \[\leadsto \frac{a}{e^{\color{blue}{\log k \cdot \left(-m\right)}}} \]
      6. exp-to-pow100.0%

        \[\leadsto \frac{a}{\color{blue}{{k}^{\left(-m\right)}}} \]
    8. Simplified100.0%

      \[\leadsto \frac{a}{\color{blue}{{k}^{\left(-m\right)}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification97.0%

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

Alternative 3: 97.2% 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^{-9}:\\ \;\;\;\;a\_m \cdot {k}^{m}\\ \mathbf{elif}\;m \leq 9.2 \cdot 10^{-8}:\\ \;\;\;\;\frac{a\_m}{1 + k \cdot \left(k + 10\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{a\_m}{{k}^{\left(-m\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 -3.5e-9)
    (* a_m (pow k m))
    (if (<= m 9.2e-8)
      (/ a_m (+ 1.0 (* k (+ k 10.0))))
      (/ a_m (pow k (- m)))))))
a_m = fabs(a);
a_s = copysign(1.0, a);
double code(double a_s, double a_m, double k, double m) {
	double tmp;
	if (m <= -3.5e-9) {
		tmp = a_m * pow(k, m);
	} else if (m <= 9.2e-8) {
		tmp = a_m / (1.0 + (k * (k + 10.0)));
	} else {
		tmp = a_m / pow(k, -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 (m <= (-3.5d-9)) then
        tmp = a_m * (k ** m)
    else if (m <= 9.2d-8) then
        tmp = a_m / (1.0d0 + (k * (k + 10.0d0)))
    else
        tmp = a_m / (k ** -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 (m <= -3.5e-9) {
		tmp = a_m * Math.pow(k, m);
	} else if (m <= 9.2e-8) {
		tmp = a_m / (1.0 + (k * (k + 10.0)));
	} else {
		tmp = a_m / Math.pow(k, -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 m <= -3.5e-9:
		tmp = a_m * math.pow(k, m)
	elif m <= 9.2e-8:
		tmp = a_m / (1.0 + (k * (k + 10.0)))
	else:
		tmp = a_m / math.pow(k, -m)
	return a_s * tmp
a_m = abs(a)
a_s = copysign(1.0, a)
function code(a_s, a_m, k, m)
	tmp = 0.0
	if (m <= -3.5e-9)
		tmp = Float64(a_m * (k ^ m));
	elseif (m <= 9.2e-8)
		tmp = Float64(a_m / Float64(1.0 + Float64(k * Float64(k + 10.0))));
	else
		tmp = Float64(a_m / (k ^ Float64(-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 (m <= -3.5e-9)
		tmp = a_m * (k ^ m);
	elseif (m <= 9.2e-8)
		tmp = a_m / (1.0 + (k * (k + 10.0)));
	else
		tmp = a_m / (k ^ -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[m, -3.5e-9], N[(a$95$m * N[Power[k, m], $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 9.2e-8], N[(a$95$m / N[(1.0 + N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a$95$m / N[Power[k, (-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}\;m \leq -3.5 \cdot 10^{-9}:\\
\;\;\;\;a\_m \cdot {k}^{m}\\

\mathbf{elif}\;m \leq 9.2 \cdot 10^{-8}:\\
\;\;\;\;\frac{a\_m}{1 + k \cdot \left(k + 10\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{a\_m}{{k}^{\left(-m\right)}}\\


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

    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 99.9%

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

    if -3.4999999999999999e-9 < m < 9.2000000000000003e-8

    1. Initial program 90.4%

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

        \[\leadsto \color{blue}{\frac{a}{\left(1 + 10 \cdot k\right) + k \cdot k} \cdot {k}^{m}} \]
      2. sqr-neg90.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+90.4%

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

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

        \[\leadsto \frac{a}{1 + \color{blue}{k \cdot \left(10 + k\right)}} \cdot {k}^{m} \]
    3. Simplified90.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 89.9%

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

    if 9.2000000000000003e-8 < m

    1. Initial program 72.1%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{a}{\color{blue}{\frac{1}{{k}^{m}}}} \]
    7. Step-by-step derivation
      1. exp-to-pow58.2%

        \[\leadsto \frac{a}{\frac{1}{\color{blue}{e^{\log k \cdot m}}}} \]
      2. *-commutative58.2%

        \[\leadsto \frac{a}{\frac{1}{e^{\color{blue}{m \cdot \log k}}}} \]
      3. exp-neg58.2%

        \[\leadsto \frac{a}{\color{blue}{e^{-m \cdot \log k}}} \]
      4. distribute-lft-neg-out58.2%

        \[\leadsto \frac{a}{e^{\color{blue}{\left(-m\right) \cdot \log k}}} \]
      5. *-commutative58.2%

        \[\leadsto \frac{a}{e^{\color{blue}{\log k \cdot \left(-m\right)}}} \]
      6. exp-to-pow100.0%

        \[\leadsto \frac{a}{\color{blue}{{k}^{\left(-m\right)}}} \]
    8. Simplified100.0%

      \[\leadsto \frac{a}{\color{blue}{{k}^{\left(-m\right)}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification96.8%

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

Alternative 4: 97.3% 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 -1.2 \cdot 10^{-9}:\\ \;\;\;\;{k}^{m} \cdot \frac{a\_m}{1 + k \cdot 10}\\ \mathbf{elif}\;m \leq 4 \cdot 10^{-8}:\\ \;\;\;\;\frac{a\_m}{1 + k \cdot \left(k + 10\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{a\_m}{{k}^{\left(-m\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 -1.2e-9)
    (* (pow k m) (/ a_m (+ 1.0 (* k 10.0))))
    (if (<= m 4e-8) (/ a_m (+ 1.0 (* k (+ k 10.0)))) (/ a_m (pow k (- m)))))))
a_m = fabs(a);
a_s = copysign(1.0, a);
double code(double a_s, double a_m, double k, double m) {
	double tmp;
	if (m <= -1.2e-9) {
		tmp = pow(k, m) * (a_m / (1.0 + (k * 10.0)));
	} else if (m <= 4e-8) {
		tmp = a_m / (1.0 + (k * (k + 10.0)));
	} else {
		tmp = a_m / pow(k, -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 (m <= (-1.2d-9)) then
        tmp = (k ** m) * (a_m / (1.0d0 + (k * 10.0d0)))
    else if (m <= 4d-8) then
        tmp = a_m / (1.0d0 + (k * (k + 10.0d0)))
    else
        tmp = a_m / (k ** -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 (m <= -1.2e-9) {
		tmp = Math.pow(k, m) * (a_m / (1.0 + (k * 10.0)));
	} else if (m <= 4e-8) {
		tmp = a_m / (1.0 + (k * (k + 10.0)));
	} else {
		tmp = a_m / Math.pow(k, -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 m <= -1.2e-9:
		tmp = math.pow(k, m) * (a_m / (1.0 + (k * 10.0)))
	elif m <= 4e-8:
		tmp = a_m / (1.0 + (k * (k + 10.0)))
	else:
		tmp = a_m / math.pow(k, -m)
	return a_s * tmp
a_m = abs(a)
a_s = copysign(1.0, a)
function code(a_s, a_m, k, m)
	tmp = 0.0
	if (m <= -1.2e-9)
		tmp = Float64((k ^ m) * Float64(a_m / Float64(1.0 + Float64(k * 10.0))));
	elseif (m <= 4e-8)
		tmp = Float64(a_m / Float64(1.0 + Float64(k * Float64(k + 10.0))));
	else
		tmp = Float64(a_m / (k ^ Float64(-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 (m <= -1.2e-9)
		tmp = (k ^ m) * (a_m / (1.0 + (k * 10.0)));
	elseif (m <= 4e-8)
		tmp = a_m / (1.0 + (k * (k + 10.0)));
	else
		tmp = a_m / (k ^ -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[m, -1.2e-9], N[(N[Power[k, m], $MachinePrecision] * N[(a$95$m / N[(1.0 + N[(k * 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 4e-8], N[(a$95$m / N[(1.0 + N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a$95$m / N[Power[k, (-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}\;m \leq -1.2 \cdot 10^{-9}:\\
\;\;\;\;{k}^{m} \cdot \frac{a\_m}{1 + k \cdot 10}\\

\mathbf{elif}\;m \leq 4 \cdot 10^{-8}:\\
\;\;\;\;\frac{a\_m}{1 + k \cdot \left(k + 10\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{a\_m}{{k}^{\left(-m\right)}}\\


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

    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. *-commutative21.0%

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

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

    if -1.2e-9 < m < 4.0000000000000001e-8

    1. Initial program 90.4%

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

        \[\leadsto \color{blue}{\frac{a}{\left(1 + 10 \cdot k\right) + k \cdot k} \cdot {k}^{m}} \]
      2. sqr-neg90.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+90.4%

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

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

        \[\leadsto \frac{a}{1 + \color{blue}{k \cdot \left(10 + k\right)}} \cdot {k}^{m} \]
    3. Simplified90.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 89.9%

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

    if 4.0000000000000001e-8 < m

    1. Initial program 72.1%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{a}{\color{blue}{\frac{1}{{k}^{m}}}} \]
    7. Step-by-step derivation
      1. exp-to-pow58.2%

        \[\leadsto \frac{a}{\frac{1}{\color{blue}{e^{\log k \cdot m}}}} \]
      2. *-commutative58.2%

        \[\leadsto \frac{a}{\frac{1}{e^{\color{blue}{m \cdot \log k}}}} \]
      3. exp-neg58.2%

        \[\leadsto \frac{a}{\color{blue}{e^{-m \cdot \log k}}} \]
      4. distribute-lft-neg-out58.2%

        \[\leadsto \frac{a}{e^{\color{blue}{\left(-m\right) \cdot \log k}}} \]
      5. *-commutative58.2%

        \[\leadsto \frac{a}{e^{\color{blue}{\log k \cdot \left(-m\right)}}} \]
      6. exp-to-pow100.0%

        \[\leadsto \frac{a}{\color{blue}{{k}^{\left(-m\right)}}} \]
    8. Simplified100.0%

      \[\leadsto \frac{a}{\color{blue}{{k}^{\left(-m\right)}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification96.9%

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

Alternative 5: 97.3% 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 -4 \cdot 10^{-11}:\\ \;\;\;\;\frac{a\_m}{\frac{1 + k \cdot 10}{{k}^{m}}}\\ \mathbf{elif}\;m \leq 4.5 \cdot 10^{-10}:\\ \;\;\;\;\frac{a\_m}{1 + k \cdot \left(k + 10\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{a\_m}{{k}^{\left(-m\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 -4e-11)
    (/ a_m (/ (+ 1.0 (* k 10.0)) (pow k m)))
    (if (<= m 4.5e-10)
      (/ a_m (+ 1.0 (* k (+ k 10.0))))
      (/ a_m (pow k (- m)))))))
a_m = fabs(a);
a_s = copysign(1.0, a);
double code(double a_s, double a_m, double k, double m) {
	double tmp;
	if (m <= -4e-11) {
		tmp = a_m / ((1.0 + (k * 10.0)) / pow(k, m));
	} else if (m <= 4.5e-10) {
		tmp = a_m / (1.0 + (k * (k + 10.0)));
	} else {
		tmp = a_m / pow(k, -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 (m <= (-4d-11)) then
        tmp = a_m / ((1.0d0 + (k * 10.0d0)) / (k ** m))
    else if (m <= 4.5d-10) then
        tmp = a_m / (1.0d0 + (k * (k + 10.0d0)))
    else
        tmp = a_m / (k ** -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 (m <= -4e-11) {
		tmp = a_m / ((1.0 + (k * 10.0)) / Math.pow(k, m));
	} else if (m <= 4.5e-10) {
		tmp = a_m / (1.0 + (k * (k + 10.0)));
	} else {
		tmp = a_m / Math.pow(k, -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 m <= -4e-11:
		tmp = a_m / ((1.0 + (k * 10.0)) / math.pow(k, m))
	elif m <= 4.5e-10:
		tmp = a_m / (1.0 + (k * (k + 10.0)))
	else:
		tmp = a_m / math.pow(k, -m)
	return a_s * tmp
a_m = abs(a)
a_s = copysign(1.0, a)
function code(a_s, a_m, k, m)
	tmp = 0.0
	if (m <= -4e-11)
		tmp = Float64(a_m / Float64(Float64(1.0 + Float64(k * 10.0)) / (k ^ m)));
	elseif (m <= 4.5e-10)
		tmp = Float64(a_m / Float64(1.0 + Float64(k * Float64(k + 10.0))));
	else
		tmp = Float64(a_m / (k ^ Float64(-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 (m <= -4e-11)
		tmp = a_m / ((1.0 + (k * 10.0)) / (k ^ m));
	elseif (m <= 4.5e-10)
		tmp = a_m / (1.0 + (k * (k + 10.0)));
	else
		tmp = a_m / (k ^ -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[m, -4e-11], N[(a$95$m / N[(N[(1.0 + N[(k * 10.0), $MachinePrecision]), $MachinePrecision] / N[Power[k, m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 4.5e-10], N[(a$95$m / N[(1.0 + N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a$95$m / N[Power[k, (-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}\;m \leq -4 \cdot 10^{-11}:\\
\;\;\;\;\frac{a\_m}{\frac{1 + k \cdot 10}{{k}^{m}}}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{a\_m}{{k}^{\left(-m\right)}}\\


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

    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}{\frac{\left(1 + 10 \cdot k\right) + k \cdot k}{{k}^{m}}}} \]
      2. sqr-neg100.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.99999999999999976e-11 < m < 4.5e-10

    1. Initial program 90.4%

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

        \[\leadsto \color{blue}{\frac{a}{\left(1 + 10 \cdot k\right) + k \cdot k} \cdot {k}^{m}} \]
      2. sqr-neg90.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+90.4%

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

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

        \[\leadsto \frac{a}{1 + \color{blue}{k \cdot \left(10 + k\right)}} \cdot {k}^{m} \]
    3. Simplified90.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 89.9%

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

    if 4.5e-10 < m

    1. Initial program 72.1%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{a}{\color{blue}{\frac{1}{{k}^{m}}}} \]
    7. Step-by-step derivation
      1. exp-to-pow58.2%

        \[\leadsto \frac{a}{\frac{1}{\color{blue}{e^{\log k \cdot m}}}} \]
      2. *-commutative58.2%

        \[\leadsto \frac{a}{\frac{1}{e^{\color{blue}{m \cdot \log k}}}} \]
      3. exp-neg58.2%

        \[\leadsto \frac{a}{\color{blue}{e^{-m \cdot \log k}}} \]
      4. distribute-lft-neg-out58.2%

        \[\leadsto \frac{a}{e^{\color{blue}{\left(-m\right) \cdot \log k}}} \]
      5. *-commutative58.2%

        \[\leadsto \frac{a}{e^{\color{blue}{\log k \cdot \left(-m\right)}}} \]
      6. exp-to-pow100.0%

        \[\leadsto \frac{a}{\color{blue}{{k}^{\left(-m\right)}}} \]
    8. Simplified100.0%

      \[\leadsto \frac{a}{\color{blue}{{k}^{\left(-m\right)}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification96.9%

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

Alternative 6: 97.2% 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.2 \cdot 10^{-9} \lor \neg \left(m \leq 2.5 \cdot 10^{-10}\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.2e-9) (not (<= m 2.5e-10)))
    (* 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.2e-9) || !(m <= 2.5e-10)) {
		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.2d-9)) .or. (.not. (m <= 2.5d-10))) 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.2e-9) || !(m <= 2.5e-10)) {
		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.2e-9) or not (m <= 2.5e-10):
		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.2e-9) || !(m <= 2.5e-10))
		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.2e-9) || ~((m <= 2.5e-10)))
		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.2e-9], N[Not[LessEqual[m, 2.5e-10]], $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.2 \cdot 10^{-9} \lor \neg \left(m \leq 2.5 \cdot 10^{-10}\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.20000000000000012e-9 or 2.50000000000000016e-10 < m

    1. Initial program 87.6%

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

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

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

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

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

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

      \[\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 99.9%

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

    if -3.20000000000000012e-9 < m < 2.50000000000000016e-10

    1. Initial program 90.4%

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

        \[\leadsto \color{blue}{\frac{a}{\left(1 + 10 \cdot k\right) + k \cdot k} \cdot {k}^{m}} \]
      2. sqr-neg90.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+90.4%

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

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

        \[\leadsto \frac{a}{1 + \color{blue}{k \cdot \left(10 + k\right)}} \cdot {k}^{m} \]
    3. Simplified90.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 89.9%

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

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

Alternative 7: 43.3% accurate, 6.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}\;k \leq 6.5 \cdot 10^{-295} \lor \neg \left(k \leq 25000000000000\right):\\ \;\;\;\;\frac{1}{\frac{k \cdot \left(k + 10\right)}{a\_m}}\\ \mathbf{else}:\\ \;\;\;\;a\_m \cdot \frac{1}{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 6.5e-295) (not (<= k 25000000000000.0)))
    (/ 1.0 (/ (* k (+ k 10.0)) a_m))
    (* a_m (/ 1.0 (+ 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 <= 6.5e-295) || !(k <= 25000000000000.0)) {
		tmp = 1.0 / ((k * (k + 10.0)) / a_m);
	} else {
		tmp = a_m * (1.0 / (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 <= 6.5d-295) .or. (.not. (k <= 25000000000000.0d0))) then
        tmp = 1.0d0 / ((k * (k + 10.0d0)) / a_m)
    else
        tmp = a_m * (1.0d0 / (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 <= 6.5e-295) || !(k <= 25000000000000.0)) {
		tmp = 1.0 / ((k * (k + 10.0)) / a_m);
	} else {
		tmp = a_m * (1.0 / (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 <= 6.5e-295) or not (k <= 25000000000000.0):
		tmp = 1.0 / ((k * (k + 10.0)) / a_m)
	else:
		tmp = a_m * (1.0 / (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 <= 6.5e-295) || !(k <= 25000000000000.0))
		tmp = Float64(1.0 / Float64(Float64(k * Float64(k + 10.0)) / a_m));
	else
		tmp = Float64(a_m * Float64(1.0 / 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 <= 6.5e-295) || ~((k <= 25000000000000.0)))
		tmp = 1.0 / ((k * (k + 10.0)) / a_m);
	else
		tmp = a_m * (1.0 / (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, 6.5e-295], N[Not[LessEqual[k, 25000000000000.0]], $MachinePrecision]], N[(1.0 / N[(N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision] / a$95$m), $MachinePrecision]), $MachinePrecision], N[(a$95$m * N[(1.0 / N[(1.0 + 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}\;k \leq 6.5 \cdot 10^{-295} \lor \neg \left(k \leq 25000000000000\right):\\
\;\;\;\;\frac{1}{\frac{k \cdot \left(k + 10\right)}{a\_m}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if k < 6.4999999999999998e-295 or 2.5e13 < k

    1. Initial program 82.2%

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

        \[\leadsto \color{blue}{\frac{a}{\left(1 + 10 \cdot k\right) + k \cdot k} \cdot {k}^{m}} \]
      2. sqr-neg78.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+78.5%

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

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

        \[\leadsto \frac{a}{1 + \color{blue}{k \cdot \left(10 + k\right)}} \cdot {k}^{m} \]
    3. Simplified78.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 43.6%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\frac{\color{blue}{10 \cdot k + {k}^{2}}}{a}} \]
    11. Step-by-step derivation
      1. unpow243.9%

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

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

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

    if 6.4999999999999998e-295 < k < 2.5e13

    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*100.0%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{a}{\frac{\mathsf{fma}\left(k, k + 10, 1\right)}{{k}^{m}}}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. clear-num99.8%

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

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

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

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

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

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

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

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

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

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

Alternative 8: 28.0% 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.2 \cdot 10^{-302} \lor \neg \left(k \leq 25000000000000\right):\\ \;\;\;\;\frac{0.1}{\frac{k}{a\_m}}\\ \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 1.2e-302) (not (<= k 25000000000000.0)))
    (/ 0.1 (/ k a_m))
    a_m)))
a_m = fabs(a);
a_s = copysign(1.0, a);
double code(double a_s, double a_m, double k, double m) {
	double tmp;
	if ((k <= 1.2e-302) || !(k <= 25000000000000.0)) {
		tmp = 0.1 / (k / a_m);
	} 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 <= 1.2d-302) .or. (.not. (k <= 25000000000000.0d0))) then
        tmp = 0.1d0 / (k / a_m)
    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 <= 1.2e-302) || !(k <= 25000000000000.0)) {
		tmp = 0.1 / (k / a_m);
	} 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 <= 1.2e-302) or not (k <= 25000000000000.0):
		tmp = 0.1 / (k / a_m)
	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 <= 1.2e-302) || !(k <= 25000000000000.0))
		tmp = Float64(0.1 / Float64(k / a_m));
	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 <= 1.2e-302) || ~((k <= 25000000000000.0)))
		tmp = 0.1 / (k / a_m);
	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, 1.2e-302], N[Not[LessEqual[k, 25000000000000.0]], $MachinePrecision]], N[(0.1 / N[(k / a$95$m), $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 1.2 \cdot 10^{-302} \lor \neg \left(k \leq 25000000000000\right):\\
\;\;\;\;\frac{0.1}{\frac{k}{a\_m}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if k < 1.20000000000000011e-302 or 2.5e13 < k

    1. Initial program 82.2%

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

        \[\leadsto \color{blue}{\frac{a}{\left(1 + 10 \cdot k\right) + k \cdot k} \cdot {k}^{m}} \]
      2. sqr-neg78.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+78.5%

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

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

        \[\leadsto \frac{a}{1 + \color{blue}{k \cdot \left(10 + k\right)}} \cdot {k}^{m} \]
    3. Simplified78.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 43.6%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{0.1}{\frac{k}{a}}} \]
    11. Applied egg-rr19.2%

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

    if 1.20000000000000011e-302 < k < 2.5e13

    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*100.0%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{a}{\color{blue}{\frac{1}{{k}^{m}}}} \]
    6. Taylor expanded in m around 0 46.0%

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

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

Alternative 9: 30.4% accurate, 8.1× speedup?

\[\begin{array}{l} a_m = \left|a\right| \\ a_s = \mathsf{copysign}\left(1, a\right) \\ a\_s \cdot \begin{array}{l} \mathbf{if}\;m \leq -8 \cdot 10^{+34}:\\ \;\;\;\;\frac{0.1}{\frac{k}{a\_m}}\\ \mathbf{else}:\\ \;\;\;\;a\_m \cdot \frac{1}{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 (<= m -8e+34) (/ 0.1 (/ k a_m)) (* a_m (/ 1.0 (+ 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 (m <= -8e+34) {
		tmp = 0.1 / (k / a_m);
	} else {
		tmp = a_m * (1.0 / (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 (m <= (-8d+34)) then
        tmp = 0.1d0 / (k / a_m)
    else
        tmp = a_m * (1.0d0 / (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 (m <= -8e+34) {
		tmp = 0.1 / (k / a_m);
	} else {
		tmp = a_m * (1.0 / (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 m <= -8e+34:
		tmp = 0.1 / (k / a_m)
	else:
		tmp = a_m * (1.0 / (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 (m <= -8e+34)
		tmp = Float64(0.1 / Float64(k / a_m));
	else
		tmp = Float64(a_m * Float64(1.0 / 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 (m <= -8e+34)
		tmp = 0.1 / (k / a_m);
	else
		tmp = a_m * (1.0 / (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[LessEqual[m, -8e+34], N[(0.1 / N[(k / a$95$m), $MachinePrecision]), $MachinePrecision], N[(a$95$m * N[(1.0 / N[(1.0 + 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 -8 \cdot 10^{+34}:\\
\;\;\;\;\frac{0.1}{\frac{k}{a\_m}}\\

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


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

    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 m around 0 42.9%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{0.1}{\frac{k}{a}}} \]
    11. Applied egg-rr29.3%

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

    if -7.99999999999999956e34 < m

    1. Initial program 82.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{a}{1 + \color{blue}{k \cdot 10}} \]
    10. Simplified30.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;m \leq -8 \cdot 10^{+34}:\\ \;\;\;\;\frac{0.1}{\frac{k}{a}}\\ \mathbf{else}:\\ \;\;\;\;a \cdot \frac{1}{1 + k \cdot 10}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 46.8% accurate, 8.1× 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 -4.1 \cdot 10^{+34}:\\ \;\;\;\;\frac{1}{\frac{t\_0}{a\_m}}\\ \mathbf{else}:\\ \;\;\;\;\frac{a\_m}{1 + 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 (* k (+ k 10.0))))
   (* a_s (if (<= m -4.1e+34) (/ 1.0 (/ t_0 a_m)) (/ a_m (+ 1.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 = k * (k + 10.0);
	double tmp;
	if (m <= -4.1e+34) {
		tmp = 1.0 / (t_0 / a_m);
	} else {
		tmp = a_m / (1.0 + 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 = k * (k + 10.0d0)
    if (m <= (-4.1d+34)) then
        tmp = 1.0d0 / (t_0 / a_m)
    else
        tmp = a_m / (1.0d0 + 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 = k * (k + 10.0);
	double tmp;
	if (m <= -4.1e+34) {
		tmp = 1.0 / (t_0 / a_m);
	} else {
		tmp = a_m / (1.0 + 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 = k * (k + 10.0)
	tmp = 0
	if m <= -4.1e+34:
		tmp = 1.0 / (t_0 / a_m)
	else:
		tmp = a_m / (1.0 + 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(k * Float64(k + 10.0))
	tmp = 0.0
	if (m <= -4.1e+34)
		tmp = Float64(1.0 / Float64(t_0 / a_m));
	else
		tmp = Float64(a_m / Float64(1.0 + 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 = k * (k + 10.0);
	tmp = 0.0;
	if (m <= -4.1e+34)
		tmp = 1.0 / (t_0 / a_m);
	else
		tmp = a_m / (1.0 + 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[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]}, N[(a$95$s * If[LessEqual[m, -4.1e+34], N[(1.0 / N[(t$95$0 / a$95$m), $MachinePrecision]), $MachinePrecision], N[(a$95$m / N[(1.0 + t$95$0), $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 -4.1 \cdot 10^{+34}:\\
\;\;\;\;\frac{1}{\frac{t\_0}{a\_m}}\\

\mathbf{else}:\\
\;\;\;\;\frac{a\_m}{1 + t\_0}\\


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

    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 m around 0 42.9%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\frac{\color{blue}{10 \cdot k + {k}^{2}}}{a}} \]
    11. Step-by-step derivation
      1. unpow247.9%

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

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

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

    if -4.0999999999999998e34 < m

    1. Initial program 82.9%

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

        \[\leadsto \color{blue}{\frac{a}{\left(1 + 10 \cdot k\right) + k \cdot k} \cdot {k}^{m}} \]
      2. sqr-neg79.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+79.4%

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

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

        \[\leadsto \frac{a}{1 + \color{blue}{k \cdot \left(10 + k\right)}} \cdot {k}^{m} \]
    3. Simplified79.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 45.4%

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

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

Alternative 11: 26.6% 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 -5.8 \cdot 10^{-22}:\\ \;\;\;\;\frac{0.1}{\frac{k}{a\_m}}\\ \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 -5.8e-22) (/ 0.1 (/ k a_m)) (+ 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 <= -5.8e-22) {
		tmp = 0.1 / (k / a_m);
	} 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 <= (-5.8d-22)) then
        tmp = 0.1d0 / (k / a_m)
    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 <= -5.8e-22) {
		tmp = 0.1 / (k / a_m);
	} 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 <= -5.8e-22:
		tmp = 0.1 / (k / a_m)
	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 <= -5.8e-22)
		tmp = Float64(0.1 / Float64(k / a_m));
	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 <= -5.8e-22)
		tmp = 0.1 / (k / a_m);
	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, -5.8e-22], N[(0.1 / N[(k / a$95$m), $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 -5.8 \cdot 10^{-22}:\\
\;\;\;\;\frac{0.1}{\frac{k}{a\_m}}\\

\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 < -5.8000000000000003e-22

    1. Initial program 98.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{0.1}{\frac{k}{a}}} \]
    11. Applied egg-rr25.5%

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

    if -5.8000000000000003e-22 < m

    1. Initial program 81.9%

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

        \[\leadsto \color{blue}{\frac{a}{\left(1 + 10 \cdot k\right) + k \cdot k} \cdot {k}^{m}} \]
      2. sqr-neg78.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+78.0%

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

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

        \[\leadsto \frac{a}{1 + \color{blue}{k \cdot \left(10 + k\right)}} \cdot {k}^{m} \]
    3. Simplified78.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 46.3%

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

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

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

Alternative 12: 30.4% 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 -3.85 \cdot 10^{+34}:\\ \;\;\;\;\frac{0.1}{\frac{k}{a\_m}}\\ \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 (<= m -3.85e+34) (/ 0.1 (/ k a_m)) (/ 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 (m <= -3.85e+34) {
		tmp = 0.1 / (k / a_m);
	} 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 (m <= (-3.85d+34)) then
        tmp = 0.1d0 / (k / a_m)
    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 (m <= -3.85e+34) {
		tmp = 0.1 / (k / a_m);
	} 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 m <= -3.85e+34:
		tmp = 0.1 / (k / a_m)
	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 (m <= -3.85e+34)
		tmp = Float64(0.1 / Float64(k / a_m));
	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 (m <= -3.85e+34)
		tmp = 0.1 / (k / a_m);
	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[LessEqual[m, -3.85e+34], N[(0.1 / N[(k / a$95$m), $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}\;m \leq -3.85 \cdot 10^{+34}:\\
\;\;\;\;\frac{0.1}{\frac{k}{a\_m}}\\

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


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

    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 m around 0 42.9%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{0.1}{\frac{k}{a}}} \]
    11. Applied egg-rr29.3%

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

    if -3.8499999999999999e34 < m

    1. Initial program 82.9%

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

        \[\leadsto \color{blue}{\frac{a}{\left(1 + 10 \cdot k\right) + k \cdot k} \cdot {k}^{m}} \]
      2. sqr-neg79.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+79.4%

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

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

        \[\leadsto \frac{a}{1 + \color{blue}{k \cdot \left(10 + k\right)}} \cdot {k}^{m} \]
    3. Simplified79.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 45.4%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;m \leq -3.85 \cdot 10^{+34}:\\ \;\;\;\;\frac{0.1}{\frac{k}{a}}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{1 + k \cdot 10}\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 25.6% accurate, 11.4× 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 -5.8 \cdot 10^{-22}:\\ \;\;\;\;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 (<= m -5.8e-22) (* 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 (m <= -5.8e-22) {
		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 (m <= (-5.8d-22)) 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 (m <= -5.8e-22) {
		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 m <= -5.8e-22:
		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 (m <= -5.8e-22)
		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 (m <= -5.8e-22)
		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[LessEqual[m, -5.8e-22], 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}\;m \leq -5.8 \cdot 10^{-22}:\\
\;\;\;\;0.1 \cdot \frac{a\_m}{k}\\

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


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

    1. Initial program 98.2%

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.8000000000000003e-22 < m

    1. Initial program 81.9%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{a}{\color{blue}{\frac{1}{{k}^{m}}}} \]
    6. Taylor expanded in m around 0 28.1%

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

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

Alternative 14: 19.8% 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 88.4%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{a}{\color{blue}{\frac{1}{{k}^{m}}}} \]
  6. Taylor expanded in m around 0 18.7%

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

    \[\leadsto a \]
  8. Add Preprocessing

Reproduce

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