Data.Colour.Matrix:inverse from colour-2.3.3, B

Percentage Accurate: 91.0% → 94.5%
Time: 10.5s
Alternatives: 10
Speedup: 0.6×

Specification

?
\[\begin{array}{l} \\ \frac{x \cdot y - z \cdot t}{a} \end{array} \]
(FPCore (x y z t a) :precision binary64 (/ (- (* x y) (* z t)) a))
double code(double x, double y, double z, double t, double a) {
	return ((x * y) - (z * t)) / a;
}
real(8) function code(x, y, z, t, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    code = ((x * y) - (z * t)) / a
end function
public static double code(double x, double y, double z, double t, double a) {
	return ((x * y) - (z * t)) / a;
}
def code(x, y, z, t, a):
	return ((x * y) - (z * t)) / a
function code(x, y, z, t, a)
	return Float64(Float64(Float64(x * y) - Float64(z * t)) / a)
end
function tmp = code(x, y, z, t, a)
	tmp = ((x * y) - (z * t)) / a;
end
code[x_, y_, z_, t_, a_] := N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]
\begin{array}{l}

\\
\frac{x \cdot y - z \cdot t}{a}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 10 alternatives:

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

Initial Program: 91.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{x \cdot y - z \cdot t}{a} \end{array} \]
(FPCore (x y z t a) :precision binary64 (/ (- (* x y) (* z t)) a))
double code(double x, double y, double z, double t, double a) {
	return ((x * y) - (z * t)) / a;
}
real(8) function code(x, y, z, t, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    code = ((x * y) - (z * t)) / a
end function
public static double code(double x, double y, double z, double t, double a) {
	return ((x * y) - (z * t)) / a;
}
def code(x, y, z, t, a):
	return ((x * y) - (z * t)) / a
function code(x, y, z, t, a)
	return Float64(Float64(Float64(x * y) - Float64(z * t)) / a)
end
function tmp = code(x, y, z, t, a)
	tmp = ((x * y) - (z * t)) / a;
end
code[x_, y_, z_, t_, a_] := N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]
\begin{array}{l}

\\
\frac{x \cdot y - z \cdot t}{a}
\end{array}

Alternative 1: 94.5% accurate, 0.0× speedup?

\[\begin{array}{l} a_m = \left|a\right| \\ a_s = \mathsf{copysign}\left(1, a\right) \\ [x, y, z, t, a_m] = \mathsf{sort}([x, y, z, t, a_m])\\ \\ a\_s \cdot \begin{array}{l} \mathbf{if}\;a\_m \leq 2.2 \cdot 10^{+118}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x, y, z \cdot \left(-t\right)\right)}{a\_m}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot \frac{x}{\sqrt{a\_m}}}{\sqrt{a\_m}} - t \cdot \frac{z}{a\_m}\\ \end{array} \end{array} \]
a_m = (fabs.f64 a)
a_s = (copysign.f64 1 a)
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
(FPCore (a_s x y z t a_m)
 :precision binary64
 (*
  a_s
  (if (<= a_m 2.2e+118)
    (/ (fma x y (* z (- t))) a_m)
    (- (/ (* y (/ x (sqrt a_m))) (sqrt a_m)) (* t (/ z a_m))))))
a_m = fabs(a);
a_s = copysign(1.0, a);
assert(x < y && y < z && z < t && t < a_m);
double code(double a_s, double x, double y, double z, double t, double a_m) {
	double tmp;
	if (a_m <= 2.2e+118) {
		tmp = fma(x, y, (z * -t)) / a_m;
	} else {
		tmp = ((y * (x / sqrt(a_m))) / sqrt(a_m)) - (t * (z / a_m));
	}
	return a_s * tmp;
}
a_m = abs(a)
a_s = copysign(1.0, a)
x, y, z, t, a_m = sort([x, y, z, t, a_m])
function code(a_s, x, y, z, t, a_m)
	tmp = 0.0
	if (a_m <= 2.2e+118)
		tmp = Float64(fma(x, y, Float64(z * Float64(-t))) / a_m);
	else
		tmp = Float64(Float64(Float64(y * Float64(x / sqrt(a_m))) / sqrt(a_m)) - Float64(t * Float64(z / a_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]
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
code[a$95$s_, x_, y_, z_, t_, a$95$m_] := N[(a$95$s * If[LessEqual[a$95$m, 2.2e+118], N[(N[(x * y + N[(z * (-t)), $MachinePrecision]), $MachinePrecision] / a$95$m), $MachinePrecision], N[(N[(N[(y * N[(x / N[Sqrt[a$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[a$95$m], $MachinePrecision]), $MachinePrecision] - N[(t * N[(z / a$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
a_m = \left|a\right|
\\
a_s = \mathsf{copysign}\left(1, a\right)
\\
[x, y, z, t, a_m] = \mathsf{sort}([x, y, z, t, a_m])\\
\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;a\_m \leq 2.2 \cdot 10^{+118}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, y, z \cdot \left(-t\right)\right)}{a\_m}\\

\mathbf{else}:\\
\;\;\;\;\frac{y \cdot \frac{x}{\sqrt{a\_m}}}{\sqrt{a\_m}} - t \cdot \frac{z}{a\_m}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < 2.19999999999999986e118

    1. Initial program 92.2%

      \[\frac{x \cdot y - z \cdot t}{a} \]
    2. Step-by-step derivation
      1. div-sub89.4%

        \[\leadsto \color{blue}{\frac{x \cdot y}{a} - \frac{z \cdot t}{a}} \]
      2. *-commutative89.4%

        \[\leadsto \frac{x \cdot y}{a} - \frac{\color{blue}{t \cdot z}}{a} \]
      3. div-sub92.2%

        \[\leadsto \color{blue}{\frac{x \cdot y - t \cdot z}{a}} \]
      4. *-commutative92.2%

        \[\leadsto \frac{x \cdot y - \color{blue}{z \cdot t}}{a} \]
      5. fma-neg92.6%

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(x, y, -z \cdot t\right)}}{a} \]
      6. distribute-rgt-neg-out92.6%

        \[\leadsto \frac{\mathsf{fma}\left(x, y, \color{blue}{z \cdot \left(-t\right)}\right)}{a} \]
    3. Simplified92.6%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x, y, z \cdot \left(-t\right)\right)}{a}} \]
    4. Add Preprocessing

    if 2.19999999999999986e118 < a

    1. Initial program 65.4%

      \[\frac{x \cdot y - z \cdot t}{a} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. div-sub65.4%

        \[\leadsto \color{blue}{\frac{x \cdot y}{a} - \frac{z \cdot t}{a}} \]
      2. *-un-lft-identity65.4%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(x \cdot y\right)}}{a} - \frac{z \cdot t}{a} \]
      3. add-sqr-sqrt65.2%

        \[\leadsto \frac{1 \cdot \left(x \cdot y\right)}{\color{blue}{\sqrt{a} \cdot \sqrt{a}}} - \frac{z \cdot t}{a} \]
      4. times-frac65.3%

        \[\leadsto \color{blue}{\frac{1}{\sqrt{a}} \cdot \frac{x \cdot y}{\sqrt{a}}} - \frac{z \cdot t}{a} \]
      5. fma-neg65.3%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\sqrt{a}}, \frac{x \cdot y}{\sqrt{a}}, -\frac{z \cdot t}{a}\right)} \]
      6. associate-/l*85.9%

        \[\leadsto \mathsf{fma}\left(\frac{1}{\sqrt{a}}, \frac{x \cdot y}{\sqrt{a}}, -\color{blue}{z \cdot \frac{t}{a}}\right) \]
    4. Applied egg-rr85.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\sqrt{a}}, \frac{x \cdot y}{\sqrt{a}}, -z \cdot \frac{t}{a}\right)} \]
    5. Step-by-step derivation
      1. fma-undefine85.9%

        \[\leadsto \color{blue}{\frac{1}{\sqrt{a}} \cdot \frac{x \cdot y}{\sqrt{a}} + \left(-z \cdot \frac{t}{a}\right)} \]
      2. distribute-lft-neg-in85.9%

        \[\leadsto \frac{1}{\sqrt{a}} \cdot \frac{x \cdot y}{\sqrt{a}} + \color{blue}{\left(-z\right) \cdot \frac{t}{a}} \]
      3. cancel-sign-sub-inv85.9%

        \[\leadsto \color{blue}{\frac{1}{\sqrt{a}} \cdot \frac{x \cdot y}{\sqrt{a}} - z \cdot \frac{t}{a}} \]
      4. associate-*r/65.3%

        \[\leadsto \frac{1}{\sqrt{a}} \cdot \frac{x \cdot y}{\sqrt{a}} - \color{blue}{\frac{z \cdot t}{a}} \]
      5. *-commutative65.3%

        \[\leadsto \frac{1}{\sqrt{a}} \cdot \frac{x \cdot y}{\sqrt{a}} - \frac{\color{blue}{t \cdot z}}{a} \]
      6. associate-/l*83.5%

        \[\leadsto \frac{1}{\sqrt{a}} \cdot \frac{x \cdot y}{\sqrt{a}} - \color{blue}{t \cdot \frac{z}{a}} \]
      7. associate-*l/83.5%

        \[\leadsto \color{blue}{\frac{1 \cdot \frac{x \cdot y}{\sqrt{a}}}{\sqrt{a}}} - t \cdot \frac{z}{a} \]
      8. *-lft-identity83.5%

        \[\leadsto \frac{\color{blue}{\frac{x \cdot y}{\sqrt{a}}}}{\sqrt{a}} - t \cdot \frac{z}{a} \]
      9. *-commutative83.5%

        \[\leadsto \frac{\frac{\color{blue}{y \cdot x}}{\sqrt{a}}}{\sqrt{a}} - t \cdot \frac{z}{a} \]
      10. associate-/l*87.9%

        \[\leadsto \frac{\color{blue}{y \cdot \frac{x}{\sqrt{a}}}}{\sqrt{a}} - t \cdot \frac{z}{a} \]
    6. Simplified87.9%

      \[\leadsto \color{blue}{\frac{y \cdot \frac{x}{\sqrt{a}}}{\sqrt{a}} - t \cdot \frac{z}{a}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification91.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq 2.2 \cdot 10^{+118}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x, y, z \cdot \left(-t\right)\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot \frac{x}{\sqrt{a}}}{\sqrt{a}} - t \cdot \frac{z}{a}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 95.1% accurate, 0.1× speedup?

\[\begin{array}{l} a_m = \left|a\right| \\ a_s = \mathsf{copysign}\left(1, a\right) \\ [x, y, z, t, a_m] = \mathsf{sort}([x, y, z, t, a_m])\\ \\ a\_s \cdot \begin{array}{l} \mathbf{if}\;a\_m \leq 5 \cdot 10^{+39}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x, y, z \cdot \left(-t\right)\right)}{a\_m}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{a\_m} - \frac{z}{\frac{a\_m}{t}}\\ \end{array} \end{array} \]
a_m = (fabs.f64 a)
a_s = (copysign.f64 1 a)
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
(FPCore (a_s x y z t a_m)
 :precision binary64
 (*
  a_s
  (if (<= a_m 5e+39)
    (/ (fma x y (* z (- t))) a_m)
    (- (* x (/ y a_m)) (/ z (/ a_m t))))))
a_m = fabs(a);
a_s = copysign(1.0, a);
assert(x < y && y < z && z < t && t < a_m);
double code(double a_s, double x, double y, double z, double t, double a_m) {
	double tmp;
	if (a_m <= 5e+39) {
		tmp = fma(x, y, (z * -t)) / a_m;
	} else {
		tmp = (x * (y / a_m)) - (z / (a_m / t));
	}
	return a_s * tmp;
}
a_m = abs(a)
a_s = copysign(1.0, a)
x, y, z, t, a_m = sort([x, y, z, t, a_m])
function code(a_s, x, y, z, t, a_m)
	tmp = 0.0
	if (a_m <= 5e+39)
		tmp = Float64(fma(x, y, Float64(z * Float64(-t))) / a_m);
	else
		tmp = Float64(Float64(x * Float64(y / a_m)) - Float64(z / Float64(a_m / t)));
	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]
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
code[a$95$s_, x_, y_, z_, t_, a$95$m_] := N[(a$95$s * If[LessEqual[a$95$m, 5e+39], N[(N[(x * y + N[(z * (-t)), $MachinePrecision]), $MachinePrecision] / a$95$m), $MachinePrecision], N[(N[(x * N[(y / a$95$m), $MachinePrecision]), $MachinePrecision] - N[(z / N[(a$95$m / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
a_m = \left|a\right|
\\
a_s = \mathsf{copysign}\left(1, a\right)
\\
[x, y, z, t, a_m] = \mathsf{sort}([x, y, z, t, a_m])\\
\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;a\_m \leq 5 \cdot 10^{+39}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, y, z \cdot \left(-t\right)\right)}{a\_m}\\

\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{a\_m} - \frac{z}{\frac{a\_m}{t}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < 5.00000000000000015e39

    1. Initial program 92.4%

      \[\frac{x \cdot y - z \cdot t}{a} \]
    2. Step-by-step derivation
      1. div-sub89.3%

        \[\leadsto \color{blue}{\frac{x \cdot y}{a} - \frac{z \cdot t}{a}} \]
      2. *-commutative89.3%

        \[\leadsto \frac{x \cdot y}{a} - \frac{\color{blue}{t \cdot z}}{a} \]
      3. div-sub92.4%

        \[\leadsto \color{blue}{\frac{x \cdot y - t \cdot z}{a}} \]
      4. *-commutative92.4%

        \[\leadsto \frac{x \cdot y - \color{blue}{z \cdot t}}{a} \]
      5. fma-neg92.9%

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(x, y, -z \cdot t\right)}}{a} \]
      6. distribute-rgt-neg-out92.9%

        \[\leadsto \frac{\mathsf{fma}\left(x, y, \color{blue}{z \cdot \left(-t\right)}\right)}{a} \]
    3. Simplified92.9%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x, y, z \cdot \left(-t\right)\right)}{a}} \]
    4. Add Preprocessing

    if 5.00000000000000015e39 < a

    1. Initial program 73.5%

      \[\frac{x \cdot y - z \cdot t}{a} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. div-sub73.5%

        \[\leadsto \color{blue}{\frac{x \cdot y}{a} - \frac{z \cdot t}{a}} \]
      2. associate-/l*78.0%

        \[\leadsto \color{blue}{x \cdot \frac{y}{a}} - \frac{z \cdot t}{a} \]
      3. associate-/l*92.0%

        \[\leadsto x \cdot \frac{y}{a} - \color{blue}{z \cdot \frac{t}{a}} \]
    4. Applied egg-rr92.0%

      \[\leadsto \color{blue}{x \cdot \frac{y}{a} - z \cdot \frac{t}{a}} \]
    5. Step-by-step derivation
      1. clear-num91.9%

        \[\leadsto x \cdot \frac{y}{a} - z \cdot \color{blue}{\frac{1}{\frac{a}{t}}} \]
      2. un-div-inv92.0%

        \[\leadsto x \cdot \frac{y}{a} - \color{blue}{\frac{z}{\frac{a}{t}}} \]
    6. Applied egg-rr92.0%

      \[\leadsto x \cdot \frac{y}{a} - \color{blue}{\frac{z}{\frac{a}{t}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification92.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq 5 \cdot 10^{+39}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x, y, z \cdot \left(-t\right)\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{a} - \frac{z}{\frac{a}{t}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 71.8% accurate, 0.3× speedup?

\[\begin{array}{l} a_m = \left|a\right| \\ a_s = \mathsf{copysign}\left(1, a\right) \\ [x, y, z, t, a_m] = \mathsf{sort}([x, y, z, t, a_m])\\ \\ \begin{array}{l} t_1 := t \cdot \frac{z}{-a\_m}\\ t_2 := x \cdot \frac{y}{a\_m}\\ a\_s \cdot \begin{array}{l} \mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+140}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;x \cdot y \leq -5 \cdot 10^{+51}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \cdot y \leq -0.05:\\ \;\;\;\;\frac{y}{\frac{a\_m}{x}}\\ \mathbf{elif}\;x \cdot y \leq 10^{+77}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \end{array} \]
a_m = (fabs.f64 a)
a_s = (copysign.f64 1 a)
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
(FPCore (a_s x y z t a_m)
 :precision binary64
 (let* ((t_1 (* t (/ z (- a_m)))) (t_2 (* x (/ y a_m))))
   (*
    a_s
    (if (<= (* x y) -5e+140)
      t_2
      (if (<= (* x y) -5e+51)
        t_1
        (if (<= (* x y) -0.05)
          (/ y (/ a_m x))
          (if (<= (* x y) 1e+77) t_1 t_2)))))))
a_m = fabs(a);
a_s = copysign(1.0, a);
assert(x < y && y < z && z < t && t < a_m);
double code(double a_s, double x, double y, double z, double t, double a_m) {
	double t_1 = t * (z / -a_m);
	double t_2 = x * (y / a_m);
	double tmp;
	if ((x * y) <= -5e+140) {
		tmp = t_2;
	} else if ((x * y) <= -5e+51) {
		tmp = t_1;
	} else if ((x * y) <= -0.05) {
		tmp = y / (a_m / x);
	} else if ((x * y) <= 1e+77) {
		tmp = t_1;
	} else {
		tmp = t_2;
	}
	return a_s * tmp;
}
a_m = abs(a)
a_s = copysign(1.0d0, a)
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
real(8) function code(a_s, x, y, z, t, a_m)
    real(8), intent (in) :: a_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a_m
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = t * (z / -a_m)
    t_2 = x * (y / a_m)
    if ((x * y) <= (-5d+140)) then
        tmp = t_2
    else if ((x * y) <= (-5d+51)) then
        tmp = t_1
    else if ((x * y) <= (-0.05d0)) then
        tmp = y / (a_m / x)
    else if ((x * y) <= 1d+77) then
        tmp = t_1
    else
        tmp = t_2
    end if
    code = a_s * tmp
end function
a_m = Math.abs(a);
a_s = Math.copySign(1.0, a);
assert x < y && y < z && z < t && t < a_m;
public static double code(double a_s, double x, double y, double z, double t, double a_m) {
	double t_1 = t * (z / -a_m);
	double t_2 = x * (y / a_m);
	double tmp;
	if ((x * y) <= -5e+140) {
		tmp = t_2;
	} else if ((x * y) <= -5e+51) {
		tmp = t_1;
	} else if ((x * y) <= -0.05) {
		tmp = y / (a_m / x);
	} else if ((x * y) <= 1e+77) {
		tmp = t_1;
	} else {
		tmp = t_2;
	}
	return a_s * tmp;
}
a_m = math.fabs(a)
a_s = math.copysign(1.0, a)
[x, y, z, t, a_m] = sort([x, y, z, t, a_m])
def code(a_s, x, y, z, t, a_m):
	t_1 = t * (z / -a_m)
	t_2 = x * (y / a_m)
	tmp = 0
	if (x * y) <= -5e+140:
		tmp = t_2
	elif (x * y) <= -5e+51:
		tmp = t_1
	elif (x * y) <= -0.05:
		tmp = y / (a_m / x)
	elif (x * y) <= 1e+77:
		tmp = t_1
	else:
		tmp = t_2
	return a_s * tmp
a_m = abs(a)
a_s = copysign(1.0, a)
x, y, z, t, a_m = sort([x, y, z, t, a_m])
function code(a_s, x, y, z, t, a_m)
	t_1 = Float64(t * Float64(z / Float64(-a_m)))
	t_2 = Float64(x * Float64(y / a_m))
	tmp = 0.0
	if (Float64(x * y) <= -5e+140)
		tmp = t_2;
	elseif (Float64(x * y) <= -5e+51)
		tmp = t_1;
	elseif (Float64(x * y) <= -0.05)
		tmp = Float64(y / Float64(a_m / x));
	elseif (Float64(x * y) <= 1e+77)
		tmp = t_1;
	else
		tmp = t_2;
	end
	return Float64(a_s * tmp)
end
a_m = abs(a);
a_s = sign(a) * abs(1.0);
x, y, z, t, a_m = num2cell(sort([x, y, z, t, a_m])){:}
function tmp_2 = code(a_s, x, y, z, t, a_m)
	t_1 = t * (z / -a_m);
	t_2 = x * (y / a_m);
	tmp = 0.0;
	if ((x * y) <= -5e+140)
		tmp = t_2;
	elseif ((x * y) <= -5e+51)
		tmp = t_1;
	elseif ((x * y) <= -0.05)
		tmp = y / (a_m / x);
	elseif ((x * y) <= 1e+77)
		tmp = t_1;
	else
		tmp = t_2;
	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]
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
code[a$95$s_, x_, y_, z_, t_, a$95$m_] := Block[{t$95$1 = N[(t * N[(z / (-a$95$m)), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x * N[(y / a$95$m), $MachinePrecision]), $MachinePrecision]}, N[(a$95$s * If[LessEqual[N[(x * y), $MachinePrecision], -5e+140], t$95$2, If[LessEqual[N[(x * y), $MachinePrecision], -5e+51], t$95$1, If[LessEqual[N[(x * y), $MachinePrecision], -0.05], N[(y / N[(a$95$m / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 1e+77], t$95$1, t$95$2]]]]), $MachinePrecision]]]
\begin{array}{l}
a_m = \left|a\right|
\\
a_s = \mathsf{copysign}\left(1, a\right)
\\
[x, y, z, t, a_m] = \mathsf{sort}([x, y, z, t, a_m])\\
\\
\begin{array}{l}
t_1 := t \cdot \frac{z}{-a\_m}\\
t_2 := x \cdot \frac{y}{a\_m}\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+140}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;x \cdot y \leq -5 \cdot 10^{+51}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \cdot y \leq -0.05:\\
\;\;\;\;\frac{y}{\frac{a\_m}{x}}\\

\mathbf{elif}\;x \cdot y \leq 10^{+77}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 x y) < -5.00000000000000008e140 or 9.99999999999999983e76 < (*.f64 x y)

    1. Initial program 78.9%

      \[\frac{x \cdot y - z \cdot t}{a} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 75.9%

      \[\leadsto \color{blue}{\frac{x \cdot y}{a}} \]
    4. Step-by-step derivation
      1. associate-*r/89.0%

        \[\leadsto \color{blue}{x \cdot \frac{y}{a}} \]
    5. Simplified89.0%

      \[\leadsto \color{blue}{x \cdot \frac{y}{a}} \]

    if -5.00000000000000008e140 < (*.f64 x y) < -5e51 or -0.050000000000000003 < (*.f64 x y) < 9.99999999999999983e76

    1. Initial program 91.8%

      \[\frac{x \cdot y - z \cdot t}{a} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 71.8%

      \[\leadsto \color{blue}{-1 \cdot \frac{t \cdot z}{a}} \]
    4. Step-by-step derivation
      1. mul-1-neg71.8%

        \[\leadsto \color{blue}{-\frac{t \cdot z}{a}} \]
      2. associate-/l*76.7%

        \[\leadsto -\color{blue}{t \cdot \frac{z}{a}} \]
      3. distribute-rgt-neg-in76.7%

        \[\leadsto \color{blue}{t \cdot \left(-\frac{z}{a}\right)} \]
      4. distribute-neg-frac276.7%

        \[\leadsto t \cdot \color{blue}{\frac{z}{-a}} \]
    5. Simplified76.7%

      \[\leadsto \color{blue}{t \cdot \frac{z}{-a}} \]

    if -5e51 < (*.f64 x y) < -0.050000000000000003

    1. Initial program 99.6%

      \[\frac{x \cdot y - z \cdot t}{a} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 70.9%

      \[\leadsto \color{blue}{\frac{x \cdot y}{a}} \]
    4. Step-by-step derivation
      1. *-commutative70.9%

        \[\leadsto \frac{\color{blue}{y \cdot x}}{a} \]
      2. associate-*r/63.5%

        \[\leadsto \color{blue}{y \cdot \frac{x}{a}} \]
    5. Simplified63.5%

      \[\leadsto \color{blue}{y \cdot \frac{x}{a}} \]
    6. Step-by-step derivation
      1. clear-num63.4%

        \[\leadsto y \cdot \color{blue}{\frac{1}{\frac{a}{x}}} \]
      2. div-inv65.8%

        \[\leadsto \color{blue}{\frac{y}{\frac{a}{x}}} \]
    7. Applied egg-rr65.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+140}:\\ \;\;\;\;x \cdot \frac{y}{a}\\ \mathbf{elif}\;x \cdot y \leq -5 \cdot 10^{+51}:\\ \;\;\;\;t \cdot \frac{z}{-a}\\ \mathbf{elif}\;x \cdot y \leq -0.05:\\ \;\;\;\;\frac{y}{\frac{a}{x}}\\ \mathbf{elif}\;x \cdot y \leq 10^{+77}:\\ \;\;\;\;t \cdot \frac{z}{-a}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{a}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 71.4% accurate, 0.3× speedup?

\[\begin{array}{l} a_m = \left|a\right| \\ a_s = \mathsf{copysign}\left(1, a\right) \\ [x, y, z, t, a_m] = \mathsf{sort}([x, y, z, t, a_m])\\ \\ \begin{array}{l} t_1 := x \cdot \frac{y}{a\_m}\\ a\_s \cdot \begin{array}{l} \mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+140}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \cdot y \leq -5 \cdot 10^{+51}:\\ \;\;\;\;t \cdot \frac{z}{-a\_m}\\ \mathbf{elif}\;x \cdot y \leq -0.05:\\ \;\;\;\;\frac{y}{\frac{a\_m}{x}}\\ \mathbf{elif}\;x \cdot y \leq 10^{+77}:\\ \;\;\;\;\frac{t}{a\_m} \cdot \left(-z\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \end{array} \]
a_m = (fabs.f64 a)
a_s = (copysign.f64 1 a)
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
(FPCore (a_s x y z t a_m)
 :precision binary64
 (let* ((t_1 (* x (/ y a_m))))
   (*
    a_s
    (if (<= (* x y) -5e+140)
      t_1
      (if (<= (* x y) -5e+51)
        (* t (/ z (- a_m)))
        (if (<= (* x y) -0.05)
          (/ y (/ a_m x))
          (if (<= (* x y) 1e+77) (* (/ t a_m) (- z)) t_1)))))))
a_m = fabs(a);
a_s = copysign(1.0, a);
assert(x < y && y < z && z < t && t < a_m);
double code(double a_s, double x, double y, double z, double t, double a_m) {
	double t_1 = x * (y / a_m);
	double tmp;
	if ((x * y) <= -5e+140) {
		tmp = t_1;
	} else if ((x * y) <= -5e+51) {
		tmp = t * (z / -a_m);
	} else if ((x * y) <= -0.05) {
		tmp = y / (a_m / x);
	} else if ((x * y) <= 1e+77) {
		tmp = (t / a_m) * -z;
	} else {
		tmp = t_1;
	}
	return a_s * tmp;
}
a_m = abs(a)
a_s = copysign(1.0d0, a)
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
real(8) function code(a_s, x, y, z, t, a_m)
    real(8), intent (in) :: a_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a_m
    real(8) :: t_1
    real(8) :: tmp
    t_1 = x * (y / a_m)
    if ((x * y) <= (-5d+140)) then
        tmp = t_1
    else if ((x * y) <= (-5d+51)) then
        tmp = t * (z / -a_m)
    else if ((x * y) <= (-0.05d0)) then
        tmp = y / (a_m / x)
    else if ((x * y) <= 1d+77) then
        tmp = (t / a_m) * -z
    else
        tmp = t_1
    end if
    code = a_s * tmp
end function
a_m = Math.abs(a);
a_s = Math.copySign(1.0, a);
assert x < y && y < z && z < t && t < a_m;
public static double code(double a_s, double x, double y, double z, double t, double a_m) {
	double t_1 = x * (y / a_m);
	double tmp;
	if ((x * y) <= -5e+140) {
		tmp = t_1;
	} else if ((x * y) <= -5e+51) {
		tmp = t * (z / -a_m);
	} else if ((x * y) <= -0.05) {
		tmp = y / (a_m / x);
	} else if ((x * y) <= 1e+77) {
		tmp = (t / a_m) * -z;
	} else {
		tmp = t_1;
	}
	return a_s * tmp;
}
a_m = math.fabs(a)
a_s = math.copysign(1.0, a)
[x, y, z, t, a_m] = sort([x, y, z, t, a_m])
def code(a_s, x, y, z, t, a_m):
	t_1 = x * (y / a_m)
	tmp = 0
	if (x * y) <= -5e+140:
		tmp = t_1
	elif (x * y) <= -5e+51:
		tmp = t * (z / -a_m)
	elif (x * y) <= -0.05:
		tmp = y / (a_m / x)
	elif (x * y) <= 1e+77:
		tmp = (t / a_m) * -z
	else:
		tmp = t_1
	return a_s * tmp
a_m = abs(a)
a_s = copysign(1.0, a)
x, y, z, t, a_m = sort([x, y, z, t, a_m])
function code(a_s, x, y, z, t, a_m)
	t_1 = Float64(x * Float64(y / a_m))
	tmp = 0.0
	if (Float64(x * y) <= -5e+140)
		tmp = t_1;
	elseif (Float64(x * y) <= -5e+51)
		tmp = Float64(t * Float64(z / Float64(-a_m)));
	elseif (Float64(x * y) <= -0.05)
		tmp = Float64(y / Float64(a_m / x));
	elseif (Float64(x * y) <= 1e+77)
		tmp = Float64(Float64(t / a_m) * Float64(-z));
	else
		tmp = t_1;
	end
	return Float64(a_s * tmp)
end
a_m = abs(a);
a_s = sign(a) * abs(1.0);
x, y, z, t, a_m = num2cell(sort([x, y, z, t, a_m])){:}
function tmp_2 = code(a_s, x, y, z, t, a_m)
	t_1 = x * (y / a_m);
	tmp = 0.0;
	if ((x * y) <= -5e+140)
		tmp = t_1;
	elseif ((x * y) <= -5e+51)
		tmp = t * (z / -a_m);
	elseif ((x * y) <= -0.05)
		tmp = y / (a_m / x);
	elseif ((x * y) <= 1e+77)
		tmp = (t / a_m) * -z;
	else
		tmp = t_1;
	end
	tmp_2 = a_s * tmp;
end
a_m = N[Abs[a], $MachinePrecision]
a_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
code[a$95$s_, x_, y_, z_, t_, a$95$m_] := Block[{t$95$1 = N[(x * N[(y / a$95$m), $MachinePrecision]), $MachinePrecision]}, N[(a$95$s * If[LessEqual[N[(x * y), $MachinePrecision], -5e+140], t$95$1, If[LessEqual[N[(x * y), $MachinePrecision], -5e+51], N[(t * N[(z / (-a$95$m)), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], -0.05], N[(y / N[(a$95$m / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 1e+77], N[(N[(t / a$95$m), $MachinePrecision] * (-z)), $MachinePrecision], t$95$1]]]]), $MachinePrecision]]
\begin{array}{l}
a_m = \left|a\right|
\\
a_s = \mathsf{copysign}\left(1, a\right)
\\
[x, y, z, t, a_m] = \mathsf{sort}([x, y, z, t, a_m])\\
\\
\begin{array}{l}
t_1 := x \cdot \frac{y}{a\_m}\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+140}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \cdot y \leq -5 \cdot 10^{+51}:\\
\;\;\;\;t \cdot \frac{z}{-a\_m}\\

\mathbf{elif}\;x \cdot y \leq -0.05:\\
\;\;\;\;\frac{y}{\frac{a\_m}{x}}\\

\mathbf{elif}\;x \cdot y \leq 10^{+77}:\\
\;\;\;\;\frac{t}{a\_m} \cdot \left(-z\right)\\

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (*.f64 x y) < -5.00000000000000008e140 or 9.99999999999999983e76 < (*.f64 x y)

    1. Initial program 78.9%

      \[\frac{x \cdot y - z \cdot t}{a} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 75.9%

      \[\leadsto \color{blue}{\frac{x \cdot y}{a}} \]
    4. Step-by-step derivation
      1. associate-*r/89.0%

        \[\leadsto \color{blue}{x \cdot \frac{y}{a}} \]
    5. Simplified89.0%

      \[\leadsto \color{blue}{x \cdot \frac{y}{a}} \]

    if -5.00000000000000008e140 < (*.f64 x y) < -5e51

    1. Initial program 88.5%

      \[\frac{x \cdot y - z \cdot t}{a} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 55.0%

      \[\leadsto \color{blue}{-1 \cdot \frac{t \cdot z}{a}} \]
    4. Step-by-step derivation
      1. mul-1-neg55.0%

        \[\leadsto \color{blue}{-\frac{t \cdot z}{a}} \]
      2. associate-/l*71.4%

        \[\leadsto -\color{blue}{t \cdot \frac{z}{a}} \]
      3. distribute-rgt-neg-in71.4%

        \[\leadsto \color{blue}{t \cdot \left(-\frac{z}{a}\right)} \]
      4. distribute-neg-frac271.4%

        \[\leadsto t \cdot \color{blue}{\frac{z}{-a}} \]
    5. Simplified71.4%

      \[\leadsto \color{blue}{t \cdot \frac{z}{-a}} \]

    if -5e51 < (*.f64 x y) < -0.050000000000000003

    1. Initial program 99.6%

      \[\frac{x \cdot y - z \cdot t}{a} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 70.9%

      \[\leadsto \color{blue}{\frac{x \cdot y}{a}} \]
    4. Step-by-step derivation
      1. *-commutative70.9%

        \[\leadsto \frac{\color{blue}{y \cdot x}}{a} \]
      2. associate-*r/63.5%

        \[\leadsto \color{blue}{y \cdot \frac{x}{a}} \]
    5. Simplified63.5%

      \[\leadsto \color{blue}{y \cdot \frac{x}{a}} \]
    6. Step-by-step derivation
      1. clear-num63.4%

        \[\leadsto y \cdot \color{blue}{\frac{1}{\frac{a}{x}}} \]
      2. div-inv65.8%

        \[\leadsto \color{blue}{\frac{y}{\frac{a}{x}}} \]
    7. Applied egg-rr65.8%

      \[\leadsto \color{blue}{\frac{y}{\frac{a}{x}}} \]

    if -0.050000000000000003 < (*.f64 x y) < 9.99999999999999983e76

    1. Initial program 92.2%

      \[\frac{x \cdot y - z \cdot t}{a} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 73.9%

      \[\leadsto \color{blue}{-1 \cdot \frac{t \cdot z}{a}} \]
    4. Step-by-step derivation
      1. associate-*r/73.9%

        \[\leadsto \color{blue}{\frac{-1 \cdot \left(t \cdot z\right)}{a}} \]
      2. mul-1-neg73.9%

        \[\leadsto \frac{\color{blue}{-t \cdot z}}{a} \]
      3. distribute-rgt-neg-in73.9%

        \[\leadsto \frac{\color{blue}{t \cdot \left(-z\right)}}{a} \]
      4. associate-*l/75.7%

        \[\leadsto \color{blue}{\frac{t}{a} \cdot \left(-z\right)} \]
    5. Simplified75.7%

      \[\leadsto \color{blue}{\frac{t}{a} \cdot \left(-z\right)} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification79.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+140}:\\ \;\;\;\;x \cdot \frac{y}{a}\\ \mathbf{elif}\;x \cdot y \leq -5 \cdot 10^{+51}:\\ \;\;\;\;t \cdot \frac{z}{-a}\\ \mathbf{elif}\;x \cdot y \leq -0.05:\\ \;\;\;\;\frac{y}{\frac{a}{x}}\\ \mathbf{elif}\;x \cdot y \leq 10^{+77}:\\ \;\;\;\;\frac{t}{a} \cdot \left(-z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{a}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 94.9% accurate, 0.4× speedup?

\[\begin{array}{l} a_m = \left|a\right| \\ a_s = \mathsf{copysign}\left(1, a\right) \\ [x, y, z, t, a_m] = \mathsf{sort}([x, y, z, t, a_m])\\ \\ a\_s \cdot \begin{array}{l} \mathbf{if}\;z \cdot t \leq -4 \cdot 10^{+278}:\\ \;\;\;\;\frac{t}{a\_m} \cdot \left(-z\right)\\ \mathbf{elif}\;z \cdot t \leq 5 \cdot 10^{+260}:\\ \;\;\;\;\frac{x \cdot y - z \cdot t}{a\_m}\\ \mathbf{else}:\\ \;\;\;\;t \cdot \frac{z}{-a\_m}\\ \end{array} \end{array} \]
a_m = (fabs.f64 a)
a_s = (copysign.f64 1 a)
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
(FPCore (a_s x y z t a_m)
 :precision binary64
 (*
  a_s
  (if (<= (* z t) -4e+278)
    (* (/ t a_m) (- z))
    (if (<= (* z t) 5e+260) (/ (- (* x y) (* z t)) a_m) (* t (/ z (- a_m)))))))
a_m = fabs(a);
a_s = copysign(1.0, a);
assert(x < y && y < z && z < t && t < a_m);
double code(double a_s, double x, double y, double z, double t, double a_m) {
	double tmp;
	if ((z * t) <= -4e+278) {
		tmp = (t / a_m) * -z;
	} else if ((z * t) <= 5e+260) {
		tmp = ((x * y) - (z * t)) / a_m;
	} else {
		tmp = t * (z / -a_m);
	}
	return a_s * tmp;
}
a_m = abs(a)
a_s = copysign(1.0d0, a)
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
real(8) function code(a_s, x, y, z, t, a_m)
    real(8), intent (in) :: a_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a_m
    real(8) :: tmp
    if ((z * t) <= (-4d+278)) then
        tmp = (t / a_m) * -z
    else if ((z * t) <= 5d+260) then
        tmp = ((x * y) - (z * t)) / a_m
    else
        tmp = t * (z / -a_m)
    end if
    code = a_s * tmp
end function
a_m = Math.abs(a);
a_s = Math.copySign(1.0, a);
assert x < y && y < z && z < t && t < a_m;
public static double code(double a_s, double x, double y, double z, double t, double a_m) {
	double tmp;
	if ((z * t) <= -4e+278) {
		tmp = (t / a_m) * -z;
	} else if ((z * t) <= 5e+260) {
		tmp = ((x * y) - (z * t)) / a_m;
	} else {
		tmp = t * (z / -a_m);
	}
	return a_s * tmp;
}
a_m = math.fabs(a)
a_s = math.copysign(1.0, a)
[x, y, z, t, a_m] = sort([x, y, z, t, a_m])
def code(a_s, x, y, z, t, a_m):
	tmp = 0
	if (z * t) <= -4e+278:
		tmp = (t / a_m) * -z
	elif (z * t) <= 5e+260:
		tmp = ((x * y) - (z * t)) / a_m
	else:
		tmp = t * (z / -a_m)
	return a_s * tmp
a_m = abs(a)
a_s = copysign(1.0, a)
x, y, z, t, a_m = sort([x, y, z, t, a_m])
function code(a_s, x, y, z, t, a_m)
	tmp = 0.0
	if (Float64(z * t) <= -4e+278)
		tmp = Float64(Float64(t / a_m) * Float64(-z));
	elseif (Float64(z * t) <= 5e+260)
		tmp = Float64(Float64(Float64(x * y) - Float64(z * t)) / a_m);
	else
		tmp = Float64(t * Float64(z / Float64(-a_m)));
	end
	return Float64(a_s * tmp)
end
a_m = abs(a);
a_s = sign(a) * abs(1.0);
x, y, z, t, a_m = num2cell(sort([x, y, z, t, a_m])){:}
function tmp_2 = code(a_s, x, y, z, t, a_m)
	tmp = 0.0;
	if ((z * t) <= -4e+278)
		tmp = (t / a_m) * -z;
	elseif ((z * t) <= 5e+260)
		tmp = ((x * y) - (z * t)) / a_m;
	else
		tmp = t * (z / -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]
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
code[a$95$s_, x_, y_, z_, t_, a$95$m_] := N[(a$95$s * If[LessEqual[N[(z * t), $MachinePrecision], -4e+278], N[(N[(t / a$95$m), $MachinePrecision] * (-z)), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 5e+260], N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a$95$m), $MachinePrecision], N[(t * N[(z / (-a$95$m)), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
a_m = \left|a\right|
\\
a_s = \mathsf{copysign}\left(1, a\right)
\\
[x, y, z, t, a_m] = \mathsf{sort}([x, y, z, t, a_m])\\
\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;z \cdot t \leq -4 \cdot 10^{+278}:\\
\;\;\;\;\frac{t}{a\_m} \cdot \left(-z\right)\\

\mathbf{elif}\;z \cdot t \leq 5 \cdot 10^{+260}:\\
\;\;\;\;\frac{x \cdot y - z \cdot t}{a\_m}\\

\mathbf{else}:\\
\;\;\;\;t \cdot \frac{z}{-a\_m}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 z t) < -3.99999999999999985e278

    1. Initial program 63.6%

      \[\frac{x \cdot y - z \cdot t}{a} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 63.6%

      \[\leadsto \color{blue}{-1 \cdot \frac{t \cdot z}{a}} \]
    4. Step-by-step derivation
      1. associate-*r/63.6%

        \[\leadsto \color{blue}{\frac{-1 \cdot \left(t \cdot z\right)}{a}} \]
      2. mul-1-neg63.6%

        \[\leadsto \frac{\color{blue}{-t \cdot z}}{a} \]
      3. distribute-rgt-neg-in63.6%

        \[\leadsto \frac{\color{blue}{t \cdot \left(-z\right)}}{a} \]
      4. associate-*l/95.0%

        \[\leadsto \color{blue}{\frac{t}{a} \cdot \left(-z\right)} \]
    5. Simplified95.0%

      \[\leadsto \color{blue}{\frac{t}{a} \cdot \left(-z\right)} \]

    if -3.99999999999999985e278 < (*.f64 z t) < 4.9999999999999996e260

    1. Initial program 93.9%

      \[\frac{x \cdot y - z \cdot t}{a} \]
    2. Add Preprocessing

    if 4.9999999999999996e260 < (*.f64 z t)

    1. Initial program 54.2%

      \[\frac{x \cdot y - z \cdot t}{a} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 58.6%

      \[\leadsto \color{blue}{-1 \cdot \frac{t \cdot z}{a}} \]
    4. Step-by-step derivation
      1. mul-1-neg58.6%

        \[\leadsto \color{blue}{-\frac{t \cdot z}{a}} \]
      2. associate-/l*94.1%

        \[\leadsto -\color{blue}{t \cdot \frac{z}{a}} \]
      3. distribute-rgt-neg-in94.1%

        \[\leadsto \color{blue}{t \cdot \left(-\frac{z}{a}\right)} \]
      4. distribute-neg-frac294.1%

        \[\leadsto t \cdot \color{blue}{\frac{z}{-a}} \]
    5. Simplified94.1%

      \[\leadsto \color{blue}{t \cdot \frac{z}{-a}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification94.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \cdot t \leq -4 \cdot 10^{+278}:\\ \;\;\;\;\frac{t}{a} \cdot \left(-z\right)\\ \mathbf{elif}\;z \cdot t \leq 5 \cdot 10^{+260}:\\ \;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\ \mathbf{else}:\\ \;\;\;\;t \cdot \frac{z}{-a}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 95.0% accurate, 0.6× speedup?

\[\begin{array}{l} a_m = \left|a\right| \\ a_s = \mathsf{copysign}\left(1, a\right) \\ [x, y, z, t, a_m] = \mathsf{sort}([x, y, z, t, a_m])\\ \\ a\_s \cdot \begin{array}{l} \mathbf{if}\;a\_m \leq 9.5 \cdot 10^{+39}:\\ \;\;\;\;\frac{x \cdot y - z \cdot t}{a\_m}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{a\_m} - z \cdot \frac{t}{a\_m}\\ \end{array} \end{array} \]
a_m = (fabs.f64 a)
a_s = (copysign.f64 1 a)
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
(FPCore (a_s x y z t a_m)
 :precision binary64
 (*
  a_s
  (if (<= a_m 9.5e+39)
    (/ (- (* x y) (* z t)) a_m)
    (- (* x (/ y a_m)) (* z (/ t a_m))))))
a_m = fabs(a);
a_s = copysign(1.0, a);
assert(x < y && y < z && z < t && t < a_m);
double code(double a_s, double x, double y, double z, double t, double a_m) {
	double tmp;
	if (a_m <= 9.5e+39) {
		tmp = ((x * y) - (z * t)) / a_m;
	} else {
		tmp = (x * (y / a_m)) - (z * (t / a_m));
	}
	return a_s * tmp;
}
a_m = abs(a)
a_s = copysign(1.0d0, a)
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
real(8) function code(a_s, x, y, z, t, a_m)
    real(8), intent (in) :: a_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a_m
    real(8) :: tmp
    if (a_m <= 9.5d+39) then
        tmp = ((x * y) - (z * t)) / a_m
    else
        tmp = (x * (y / a_m)) - (z * (t / a_m))
    end if
    code = a_s * tmp
end function
a_m = Math.abs(a);
a_s = Math.copySign(1.0, a);
assert x < y && y < z && z < t && t < a_m;
public static double code(double a_s, double x, double y, double z, double t, double a_m) {
	double tmp;
	if (a_m <= 9.5e+39) {
		tmp = ((x * y) - (z * t)) / a_m;
	} else {
		tmp = (x * (y / a_m)) - (z * (t / a_m));
	}
	return a_s * tmp;
}
a_m = math.fabs(a)
a_s = math.copysign(1.0, a)
[x, y, z, t, a_m] = sort([x, y, z, t, a_m])
def code(a_s, x, y, z, t, a_m):
	tmp = 0
	if a_m <= 9.5e+39:
		tmp = ((x * y) - (z * t)) / a_m
	else:
		tmp = (x * (y / a_m)) - (z * (t / a_m))
	return a_s * tmp
a_m = abs(a)
a_s = copysign(1.0, a)
x, y, z, t, a_m = sort([x, y, z, t, a_m])
function code(a_s, x, y, z, t, a_m)
	tmp = 0.0
	if (a_m <= 9.5e+39)
		tmp = Float64(Float64(Float64(x * y) - Float64(z * t)) / a_m);
	else
		tmp = Float64(Float64(x * Float64(y / a_m)) - Float64(z * Float64(t / a_m)));
	end
	return Float64(a_s * tmp)
end
a_m = abs(a);
a_s = sign(a) * abs(1.0);
x, y, z, t, a_m = num2cell(sort([x, y, z, t, a_m])){:}
function tmp_2 = code(a_s, x, y, z, t, a_m)
	tmp = 0.0;
	if (a_m <= 9.5e+39)
		tmp = ((x * y) - (z * t)) / a_m;
	else
		tmp = (x * (y / a_m)) - (z * (t / 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]
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
code[a$95$s_, x_, y_, z_, t_, a$95$m_] := N[(a$95$s * If[LessEqual[a$95$m, 9.5e+39], N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a$95$m), $MachinePrecision], N[(N[(x * N[(y / a$95$m), $MachinePrecision]), $MachinePrecision] - N[(z * N[(t / a$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
a_m = \left|a\right|
\\
a_s = \mathsf{copysign}\left(1, a\right)
\\
[x, y, z, t, a_m] = \mathsf{sort}([x, y, z, t, a_m])\\
\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;a\_m \leq 9.5 \cdot 10^{+39}:\\
\;\;\;\;\frac{x \cdot y - z \cdot t}{a\_m}\\

\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{a\_m} - z \cdot \frac{t}{a\_m}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < 9.50000000000000011e39

    1. Initial program 92.4%

      \[\frac{x \cdot y - z \cdot t}{a} \]
    2. Add Preprocessing

    if 9.50000000000000011e39 < a

    1. Initial program 73.5%

      \[\frac{x \cdot y - z \cdot t}{a} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. div-sub73.5%

        \[\leadsto \color{blue}{\frac{x \cdot y}{a} - \frac{z \cdot t}{a}} \]
      2. associate-/l*78.0%

        \[\leadsto \color{blue}{x \cdot \frac{y}{a}} - \frac{z \cdot t}{a} \]
      3. associate-/l*92.0%

        \[\leadsto x \cdot \frac{y}{a} - \color{blue}{z \cdot \frac{t}{a}} \]
    4. Applied egg-rr92.0%

      \[\leadsto \color{blue}{x \cdot \frac{y}{a} - z \cdot \frac{t}{a}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification92.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq 9.5 \cdot 10^{+39}:\\ \;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{a} - z \cdot \frac{t}{a}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 94.9% accurate, 0.6× speedup?

\[\begin{array}{l} a_m = \left|a\right| \\ a_s = \mathsf{copysign}\left(1, a\right) \\ [x, y, z, t, a_m] = \mathsf{sort}([x, y, z, t, a_m])\\ \\ a\_s \cdot \begin{array}{l} \mathbf{if}\;a\_m \leq 5 \cdot 10^{+39}:\\ \;\;\;\;\frac{x \cdot y - z \cdot t}{a\_m}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{a\_m} - \frac{z}{\frac{a\_m}{t}}\\ \end{array} \end{array} \]
a_m = (fabs.f64 a)
a_s = (copysign.f64 1 a)
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
(FPCore (a_s x y z t a_m)
 :precision binary64
 (*
  a_s
  (if (<= a_m 5e+39)
    (/ (- (* x y) (* z t)) a_m)
    (- (* x (/ y a_m)) (/ z (/ a_m t))))))
a_m = fabs(a);
a_s = copysign(1.0, a);
assert(x < y && y < z && z < t && t < a_m);
double code(double a_s, double x, double y, double z, double t, double a_m) {
	double tmp;
	if (a_m <= 5e+39) {
		tmp = ((x * y) - (z * t)) / a_m;
	} else {
		tmp = (x * (y / a_m)) - (z / (a_m / t));
	}
	return a_s * tmp;
}
a_m = abs(a)
a_s = copysign(1.0d0, a)
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
real(8) function code(a_s, x, y, z, t, a_m)
    real(8), intent (in) :: a_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a_m
    real(8) :: tmp
    if (a_m <= 5d+39) then
        tmp = ((x * y) - (z * t)) / a_m
    else
        tmp = (x * (y / a_m)) - (z / (a_m / t))
    end if
    code = a_s * tmp
end function
a_m = Math.abs(a);
a_s = Math.copySign(1.0, a);
assert x < y && y < z && z < t && t < a_m;
public static double code(double a_s, double x, double y, double z, double t, double a_m) {
	double tmp;
	if (a_m <= 5e+39) {
		tmp = ((x * y) - (z * t)) / a_m;
	} else {
		tmp = (x * (y / a_m)) - (z / (a_m / t));
	}
	return a_s * tmp;
}
a_m = math.fabs(a)
a_s = math.copysign(1.0, a)
[x, y, z, t, a_m] = sort([x, y, z, t, a_m])
def code(a_s, x, y, z, t, a_m):
	tmp = 0
	if a_m <= 5e+39:
		tmp = ((x * y) - (z * t)) / a_m
	else:
		tmp = (x * (y / a_m)) - (z / (a_m / t))
	return a_s * tmp
a_m = abs(a)
a_s = copysign(1.0, a)
x, y, z, t, a_m = sort([x, y, z, t, a_m])
function code(a_s, x, y, z, t, a_m)
	tmp = 0.0
	if (a_m <= 5e+39)
		tmp = Float64(Float64(Float64(x * y) - Float64(z * t)) / a_m);
	else
		tmp = Float64(Float64(x * Float64(y / a_m)) - Float64(z / Float64(a_m / t)));
	end
	return Float64(a_s * tmp)
end
a_m = abs(a);
a_s = sign(a) * abs(1.0);
x, y, z, t, a_m = num2cell(sort([x, y, z, t, a_m])){:}
function tmp_2 = code(a_s, x, y, z, t, a_m)
	tmp = 0.0;
	if (a_m <= 5e+39)
		tmp = ((x * y) - (z * t)) / a_m;
	else
		tmp = (x * (y / a_m)) - (z / (a_m / t));
	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]
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
code[a$95$s_, x_, y_, z_, t_, a$95$m_] := N[(a$95$s * If[LessEqual[a$95$m, 5e+39], N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a$95$m), $MachinePrecision], N[(N[(x * N[(y / a$95$m), $MachinePrecision]), $MachinePrecision] - N[(z / N[(a$95$m / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
a_m = \left|a\right|
\\
a_s = \mathsf{copysign}\left(1, a\right)
\\
[x, y, z, t, a_m] = \mathsf{sort}([x, y, z, t, a_m])\\
\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;a\_m \leq 5 \cdot 10^{+39}:\\
\;\;\;\;\frac{x \cdot y - z \cdot t}{a\_m}\\

\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{a\_m} - \frac{z}{\frac{a\_m}{t}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < 5.00000000000000015e39

    1. Initial program 92.4%

      \[\frac{x \cdot y - z \cdot t}{a} \]
    2. Add Preprocessing

    if 5.00000000000000015e39 < a

    1. Initial program 73.5%

      \[\frac{x \cdot y - z \cdot t}{a} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. div-sub73.5%

        \[\leadsto \color{blue}{\frac{x \cdot y}{a} - \frac{z \cdot t}{a}} \]
      2. associate-/l*78.0%

        \[\leadsto \color{blue}{x \cdot \frac{y}{a}} - \frac{z \cdot t}{a} \]
      3. associate-/l*92.0%

        \[\leadsto x \cdot \frac{y}{a} - \color{blue}{z \cdot \frac{t}{a}} \]
    4. Applied egg-rr92.0%

      \[\leadsto \color{blue}{x \cdot \frac{y}{a} - z \cdot \frac{t}{a}} \]
    5. Step-by-step derivation
      1. clear-num91.9%

        \[\leadsto x \cdot \frac{y}{a} - z \cdot \color{blue}{\frac{1}{\frac{a}{t}}} \]
      2. un-div-inv92.0%

        \[\leadsto x \cdot \frac{y}{a} - \color{blue}{\frac{z}{\frac{a}{t}}} \]
    6. Applied egg-rr92.0%

      \[\leadsto x \cdot \frac{y}{a} - \color{blue}{\frac{z}{\frac{a}{t}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification92.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq 5 \cdot 10^{+39}:\\ \;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{a} - \frac{z}{\frac{a}{t}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 50.9% accurate, 0.9× speedup?

\[\begin{array}{l} a_m = \left|a\right| \\ a_s = \mathsf{copysign}\left(1, a\right) \\ [x, y, z, t, a_m] = \mathsf{sort}([x, y, z, t, a_m])\\ \\ a\_s \cdot \begin{array}{l} \mathbf{if}\;t \leq 1.1 \cdot 10^{-198}:\\ \;\;\;\;y \cdot \frac{x}{a\_m}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{a\_m}\\ \end{array} \end{array} \]
a_m = (fabs.f64 a)
a_s = (copysign.f64 1 a)
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
(FPCore (a_s x y z t a_m)
 :precision binary64
 (* a_s (if (<= t 1.1e-198) (* y (/ x a_m)) (* x (/ y a_m)))))
a_m = fabs(a);
a_s = copysign(1.0, a);
assert(x < y && y < z && z < t && t < a_m);
double code(double a_s, double x, double y, double z, double t, double a_m) {
	double tmp;
	if (t <= 1.1e-198) {
		tmp = y * (x / a_m);
	} else {
		tmp = x * (y / a_m);
	}
	return a_s * tmp;
}
a_m = abs(a)
a_s = copysign(1.0d0, a)
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
real(8) function code(a_s, x, y, z, t, a_m)
    real(8), intent (in) :: a_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a_m
    real(8) :: tmp
    if (t <= 1.1d-198) then
        tmp = y * (x / a_m)
    else
        tmp = x * (y / a_m)
    end if
    code = a_s * tmp
end function
a_m = Math.abs(a);
a_s = Math.copySign(1.0, a);
assert x < y && y < z && z < t && t < a_m;
public static double code(double a_s, double x, double y, double z, double t, double a_m) {
	double tmp;
	if (t <= 1.1e-198) {
		tmp = y * (x / a_m);
	} else {
		tmp = x * (y / a_m);
	}
	return a_s * tmp;
}
a_m = math.fabs(a)
a_s = math.copysign(1.0, a)
[x, y, z, t, a_m] = sort([x, y, z, t, a_m])
def code(a_s, x, y, z, t, a_m):
	tmp = 0
	if t <= 1.1e-198:
		tmp = y * (x / a_m)
	else:
		tmp = x * (y / a_m)
	return a_s * tmp
a_m = abs(a)
a_s = copysign(1.0, a)
x, y, z, t, a_m = sort([x, y, z, t, a_m])
function code(a_s, x, y, z, t, a_m)
	tmp = 0.0
	if (t <= 1.1e-198)
		tmp = Float64(y * Float64(x / a_m));
	else
		tmp = Float64(x * Float64(y / a_m));
	end
	return Float64(a_s * tmp)
end
a_m = abs(a);
a_s = sign(a) * abs(1.0);
x, y, z, t, a_m = num2cell(sort([x, y, z, t, a_m])){:}
function tmp_2 = code(a_s, x, y, z, t, a_m)
	tmp = 0.0;
	if (t <= 1.1e-198)
		tmp = y * (x / a_m);
	else
		tmp = x * (y / 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]
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
code[a$95$s_, x_, y_, z_, t_, a$95$m_] := N[(a$95$s * If[LessEqual[t, 1.1e-198], N[(y * N[(x / a$95$m), $MachinePrecision]), $MachinePrecision], N[(x * N[(y / a$95$m), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
a_m = \left|a\right|
\\
a_s = \mathsf{copysign}\left(1, a\right)
\\
[x, y, z, t, a_m] = \mathsf{sort}([x, y, z, t, a_m])\\
\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;t \leq 1.1 \cdot 10^{-198}:\\
\;\;\;\;y \cdot \frac{x}{a\_m}\\

\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{a\_m}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < 1.1e-198

    1. Initial program 90.2%

      \[\frac{x \cdot y - z \cdot t}{a} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 49.0%

      \[\leadsto \color{blue}{\frac{x \cdot y}{a}} \]
    4. Step-by-step derivation
      1. *-commutative49.0%

        \[\leadsto \frac{\color{blue}{y \cdot x}}{a} \]
      2. associate-*r/49.6%

        \[\leadsto \color{blue}{y \cdot \frac{x}{a}} \]
    5. Simplified49.6%

      \[\leadsto \color{blue}{y \cdot \frac{x}{a}} \]

    if 1.1e-198 < t

    1. Initial program 84.6%

      \[\frac{x \cdot y - z \cdot t}{a} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 42.7%

      \[\leadsto \color{blue}{\frac{x \cdot y}{a}} \]
    4. Step-by-step derivation
      1. associate-*r/47.1%

        \[\leadsto \color{blue}{x \cdot \frac{y}{a}} \]
    5. Simplified47.1%

      \[\leadsto \color{blue}{x \cdot \frac{y}{a}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification48.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq 1.1 \cdot 10^{-198}:\\ \;\;\;\;y \cdot \frac{x}{a}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{a}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 50.9% accurate, 0.9× speedup?

\[\begin{array}{l} a_m = \left|a\right| \\ a_s = \mathsf{copysign}\left(1, a\right) \\ [x, y, z, t, a_m] = \mathsf{sort}([x, y, z, t, a_m])\\ \\ a\_s \cdot \begin{array}{l} \mathbf{if}\;t \leq 7.6 \cdot 10^{-193}:\\ \;\;\;\;\frac{y}{\frac{a\_m}{x}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{a\_m}\\ \end{array} \end{array} \]
a_m = (fabs.f64 a)
a_s = (copysign.f64 1 a)
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
(FPCore (a_s x y z t a_m)
 :precision binary64
 (* a_s (if (<= t 7.6e-193) (/ y (/ a_m x)) (* x (/ y a_m)))))
a_m = fabs(a);
a_s = copysign(1.0, a);
assert(x < y && y < z && z < t && t < a_m);
double code(double a_s, double x, double y, double z, double t, double a_m) {
	double tmp;
	if (t <= 7.6e-193) {
		tmp = y / (a_m / x);
	} else {
		tmp = x * (y / a_m);
	}
	return a_s * tmp;
}
a_m = abs(a)
a_s = copysign(1.0d0, a)
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
real(8) function code(a_s, x, y, z, t, a_m)
    real(8), intent (in) :: a_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a_m
    real(8) :: tmp
    if (t <= 7.6d-193) then
        tmp = y / (a_m / x)
    else
        tmp = x * (y / a_m)
    end if
    code = a_s * tmp
end function
a_m = Math.abs(a);
a_s = Math.copySign(1.0, a);
assert x < y && y < z && z < t && t < a_m;
public static double code(double a_s, double x, double y, double z, double t, double a_m) {
	double tmp;
	if (t <= 7.6e-193) {
		tmp = y / (a_m / x);
	} else {
		tmp = x * (y / a_m);
	}
	return a_s * tmp;
}
a_m = math.fabs(a)
a_s = math.copysign(1.0, a)
[x, y, z, t, a_m] = sort([x, y, z, t, a_m])
def code(a_s, x, y, z, t, a_m):
	tmp = 0
	if t <= 7.6e-193:
		tmp = y / (a_m / x)
	else:
		tmp = x * (y / a_m)
	return a_s * tmp
a_m = abs(a)
a_s = copysign(1.0, a)
x, y, z, t, a_m = sort([x, y, z, t, a_m])
function code(a_s, x, y, z, t, a_m)
	tmp = 0.0
	if (t <= 7.6e-193)
		tmp = Float64(y / Float64(a_m / x));
	else
		tmp = Float64(x * Float64(y / a_m));
	end
	return Float64(a_s * tmp)
end
a_m = abs(a);
a_s = sign(a) * abs(1.0);
x, y, z, t, a_m = num2cell(sort([x, y, z, t, a_m])){:}
function tmp_2 = code(a_s, x, y, z, t, a_m)
	tmp = 0.0;
	if (t <= 7.6e-193)
		tmp = y / (a_m / x);
	else
		tmp = x * (y / 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]
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
code[a$95$s_, x_, y_, z_, t_, a$95$m_] := N[(a$95$s * If[LessEqual[t, 7.6e-193], N[(y / N[(a$95$m / x), $MachinePrecision]), $MachinePrecision], N[(x * N[(y / a$95$m), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
a_m = \left|a\right|
\\
a_s = \mathsf{copysign}\left(1, a\right)
\\
[x, y, z, t, a_m] = \mathsf{sort}([x, y, z, t, a_m])\\
\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;t \leq 7.6 \cdot 10^{-193}:\\
\;\;\;\;\frac{y}{\frac{a\_m}{x}}\\

\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{a\_m}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < 7.60000000000000007e-193

    1. Initial program 90.2%

      \[\frac{x \cdot y - z \cdot t}{a} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 49.0%

      \[\leadsto \color{blue}{\frac{x \cdot y}{a}} \]
    4. Step-by-step derivation
      1. *-commutative49.0%

        \[\leadsto \frac{\color{blue}{y \cdot x}}{a} \]
      2. associate-*r/49.6%

        \[\leadsto \color{blue}{y \cdot \frac{x}{a}} \]
    5. Simplified49.6%

      \[\leadsto \color{blue}{y \cdot \frac{x}{a}} \]
    6. Step-by-step derivation
      1. clear-num49.5%

        \[\leadsto y \cdot \color{blue}{\frac{1}{\frac{a}{x}}} \]
      2. div-inv49.8%

        \[\leadsto \color{blue}{\frac{y}{\frac{a}{x}}} \]
    7. Applied egg-rr49.8%

      \[\leadsto \color{blue}{\frac{y}{\frac{a}{x}}} \]

    if 7.60000000000000007e-193 < t

    1. Initial program 84.6%

      \[\frac{x \cdot y - z \cdot t}{a} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 42.7%

      \[\leadsto \color{blue}{\frac{x \cdot y}{a}} \]
    4. Step-by-step derivation
      1. associate-*r/47.1%

        \[\leadsto \color{blue}{x \cdot \frac{y}{a}} \]
    5. Simplified47.1%

      \[\leadsto \color{blue}{x \cdot \frac{y}{a}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification48.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq 7.6 \cdot 10^{-193}:\\ \;\;\;\;\frac{y}{\frac{a}{x}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{a}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 51.2% accurate, 1.8× speedup?

\[\begin{array}{l} a_m = \left|a\right| \\ a_s = \mathsf{copysign}\left(1, a\right) \\ [x, y, z, t, a_m] = \mathsf{sort}([x, y, z, t, a_m])\\ \\ a\_s \cdot \left(x \cdot \frac{y}{a\_m}\right) \end{array} \]
a_m = (fabs.f64 a)
a_s = (copysign.f64 1 a)
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
(FPCore (a_s x y z t a_m) :precision binary64 (* a_s (* x (/ y a_m))))
a_m = fabs(a);
a_s = copysign(1.0, a);
assert(x < y && y < z && z < t && t < a_m);
double code(double a_s, double x, double y, double z, double t, double a_m) {
	return a_s * (x * (y / a_m));
}
a_m = abs(a)
a_s = copysign(1.0d0, a)
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
real(8) function code(a_s, x, y, z, t, a_m)
    real(8), intent (in) :: a_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a_m
    code = a_s * (x * (y / a_m))
end function
a_m = Math.abs(a);
a_s = Math.copySign(1.0, a);
assert x < y && y < z && z < t && t < a_m;
public static double code(double a_s, double x, double y, double z, double t, double a_m) {
	return a_s * (x * (y / a_m));
}
a_m = math.fabs(a)
a_s = math.copysign(1.0, a)
[x, y, z, t, a_m] = sort([x, y, z, t, a_m])
def code(a_s, x, y, z, t, a_m):
	return a_s * (x * (y / a_m))
a_m = abs(a)
a_s = copysign(1.0, a)
x, y, z, t, a_m = sort([x, y, z, t, a_m])
function code(a_s, x, y, z, t, a_m)
	return Float64(a_s * Float64(x * Float64(y / a_m)))
end
a_m = abs(a);
a_s = sign(a) * abs(1.0);
x, y, z, t, a_m = num2cell(sort([x, y, z, t, a_m])){:}
function tmp = code(a_s, x, y, z, t, a_m)
	tmp = a_s * (x * (y / 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]
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
code[a$95$s_, x_, y_, z_, t_, a$95$m_] := N[(a$95$s * N[(x * N[(y / a$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a_m = \left|a\right|
\\
a_s = \mathsf{copysign}\left(1, a\right)
\\
[x, y, z, t, a_m] = \mathsf{sort}([x, y, z, t, a_m])\\
\\
a\_s \cdot \left(x \cdot \frac{y}{a\_m}\right)
\end{array}
Derivation
  1. Initial program 87.9%

    \[\frac{x \cdot y - z \cdot t}{a} \]
  2. Add Preprocessing
  3. Taylor expanded in x around inf 46.3%

    \[\leadsto \color{blue}{\frac{x \cdot y}{a}} \]
  4. Step-by-step derivation
    1. associate-*r/49.9%

      \[\leadsto \color{blue}{x \cdot \frac{y}{a}} \]
  5. Simplified49.9%

    \[\leadsto \color{blue}{x \cdot \frac{y}{a}} \]
  6. Final simplification49.9%

    \[\leadsto x \cdot \frac{y}{a} \]
  7. Add Preprocessing

Developer target: 91.2% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{y}{a} \cdot x - \frac{t}{a} \cdot z\\ \mathbf{if}\;z < -2.468684968699548 \cdot 10^{+170}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z < 6.309831121978371 \cdot 10^{-71}:\\ \;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (- (* (/ y a) x) (* (/ t a) z))))
   (if (< z -2.468684968699548e+170)
     t_1
     (if (< z 6.309831121978371e-71) (/ (- (* x y) (* z t)) a) t_1))))
double code(double x, double y, double z, double t, double a) {
	double t_1 = ((y / a) * x) - ((t / a) * z);
	double tmp;
	if (z < -2.468684968699548e+170) {
		tmp = t_1;
	} else if (z < 6.309831121978371e-71) {
		tmp = ((x * y) - (z * t)) / a;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(x, y, z, t, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8) :: t_1
    real(8) :: tmp
    t_1 = ((y / a) * x) - ((t / a) * z)
    if (z < (-2.468684968699548d+170)) then
        tmp = t_1
    else if (z < 6.309831121978371d-71) then
        tmp = ((x * y) - (z * t)) / a
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
	double t_1 = ((y / a) * x) - ((t / a) * z);
	double tmp;
	if (z < -2.468684968699548e+170) {
		tmp = t_1;
	} else if (z < 6.309831121978371e-71) {
		tmp = ((x * y) - (z * t)) / a;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t, a):
	t_1 = ((y / a) * x) - ((t / a) * z)
	tmp = 0
	if z < -2.468684968699548e+170:
		tmp = t_1
	elif z < 6.309831121978371e-71:
		tmp = ((x * y) - (z * t)) / a
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t, a)
	t_1 = Float64(Float64(Float64(y / a) * x) - Float64(Float64(t / a) * z))
	tmp = 0.0
	if (z < -2.468684968699548e+170)
		tmp = t_1;
	elseif (z < 6.309831121978371e-71)
		tmp = Float64(Float64(Float64(x * y) - Float64(z * t)) / a);
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a)
	t_1 = ((y / a) * x) - ((t / a) * z);
	tmp = 0.0;
	if (z < -2.468684968699548e+170)
		tmp = t_1;
	elseif (z < 6.309831121978371e-71)
		tmp = ((x * y) - (z * t)) / a;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(y / a), $MachinePrecision] * x), $MachinePrecision] - N[(N[(t / a), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]}, If[Less[z, -2.468684968699548e+170], t$95$1, If[Less[z, 6.309831121978371e-71], N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \frac{y}{a} \cdot x - \frac{t}{a} \cdot z\\
\mathbf{if}\;z < -2.468684968699548 \cdot 10^{+170}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z < 6.309831121978371 \cdot 10^{-71}:\\
\;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\

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


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2024044 
(FPCore (x y z t a)
  :name "Data.Colour.Matrix:inverse from colour-2.3.3, B"
  :precision binary64

  :herbie-target
  (if (< z -2.468684968699548e+170) (- (* (/ y a) x) (* (/ t a) z)) (if (< z 6.309831121978371e-71) (/ (- (* x y) (* z t)) a) (- (* (/ y a) x) (* (/ t a) z))))

  (/ (- (* x y) (* z t)) a))