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

Percentage Accurate: 91.8% → 96.6%
Time: 6.6s
Alternatives: 8
Speedup: 0.7×

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 8 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.8% 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: 96.6% accurate, 0.1× speedup?

\[\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ [z, t] = \mathsf{sort}([z, t])\\ \\ \begin{array}{l} t_1 := x \cdot y - z \cdot t\\ \mathbf{if}\;t_1 \leq -1 \cdot 10^{+295}:\\ \;\;\;\;\mathsf{fma}\left(x, \frac{y}{a}, -\frac{z}{\frac{a}{t}}\right)\\ \mathbf{elif}\;t_1 \leq 5 \cdot 10^{+140}:\\ \;\;\;\;\frac{t_1}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, \frac{y}{a}, \frac{-1}{\frac{\frac{a}{t}}{z}}\right)\\ \end{array} \end{array} \]
NOTE: x and y should be sorted in increasing order before calling this function.
NOTE: z and t should be sorted in increasing order before calling this function.
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (- (* x y) (* z t))))
   (if (<= t_1 -1e+295)
     (fma x (/ y a) (- (/ z (/ a t))))
     (if (<= t_1 5e+140) (/ t_1 a) (fma x (/ y a) (/ -1.0 (/ (/ a t) z)))))))
assert(x < y);
assert(z < t);
double code(double x, double y, double z, double t, double a) {
	double t_1 = (x * y) - (z * t);
	double tmp;
	if (t_1 <= -1e+295) {
		tmp = fma(x, (y / a), -(z / (a / t)));
	} else if (t_1 <= 5e+140) {
		tmp = t_1 / a;
	} else {
		tmp = fma(x, (y / a), (-1.0 / ((a / t) / z)));
	}
	return tmp;
}
x, y = sort([x, y])
z, t = sort([z, t])
function code(x, y, z, t, a)
	t_1 = Float64(Float64(x * y) - Float64(z * t))
	tmp = 0.0
	if (t_1 <= -1e+295)
		tmp = fma(x, Float64(y / a), Float64(-Float64(z / Float64(a / t))));
	elseif (t_1 <= 5e+140)
		tmp = Float64(t_1 / a);
	else
		tmp = fma(x, Float64(y / a), Float64(-1.0 / Float64(Float64(a / t) / z)));
	end
	return tmp
end
NOTE: x and y should be sorted in increasing order before calling this function.
NOTE: z and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+295], N[(x * N[(y / a), $MachinePrecision] + (-N[(z / N[(a / t), $MachinePrecision]), $MachinePrecision])), $MachinePrecision], If[LessEqual[t$95$1, 5e+140], N[(t$95$1 / a), $MachinePrecision], N[(x * N[(y / a), $MachinePrecision] + N[(-1.0 / N[(N[(a / t), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
t_1 := x \cdot y - z \cdot t\\
\mathbf{if}\;t_1 \leq -1 \cdot 10^{+295}:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{y}{a}, -\frac{z}{\frac{a}{t}}\right)\\

\mathbf{elif}\;t_1 \leq 5 \cdot 10^{+140}:\\
\;\;\;\;\frac{t_1}{a}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{y}{a}, \frac{-1}{\frac{\frac{a}{t}}{z}}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (-.f64 (*.f64 x y) (*.f64 z t)) < -9.9999999999999998e294

    1. Initial program 72.5%

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

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

        \[\leadsto \frac{x \cdot y}{\color{blue}{1 \cdot a}} - \frac{z \cdot t}{a} \]
      3. times-frac76.9%

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

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

        \[\leadsto \mathsf{fma}\left(\frac{x}{1}, \frac{y}{a}, -\color{blue}{\frac{z}{\frac{a}{t}}}\right) \]
    3. Applied egg-rr88.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{1}, \frac{y}{a}, -\frac{z}{\frac{a}{t}}\right)} \]

    if -9.9999999999999998e294 < (-.f64 (*.f64 x y) (*.f64 z t)) < 5.00000000000000008e140

    1. Initial program 99.0%

      \[\frac{x \cdot y - z \cdot t}{a} \]

    if 5.00000000000000008e140 < (-.f64 (*.f64 x y) (*.f64 z t))

    1. Initial program 85.0%

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

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

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

        \[\leadsto \color{blue}{\frac{x}{1} \cdot \frac{y}{a}} - \frac{z \cdot t}{a} \]
      4. fma-neg89.8%

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

        \[\leadsto \mathsf{fma}\left(\frac{x}{1}, \frac{y}{a}, -\color{blue}{\frac{z}{\frac{a}{t}}}\right) \]
    3. Applied egg-rr97.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{1}, \frac{y}{a}, -\frac{z}{\frac{a}{t}}\right)} \]
    4. Step-by-step derivation
      1. clear-num97.3%

        \[\leadsto \mathsf{fma}\left(\frac{x}{1}, \frac{y}{a}, -\color{blue}{\frac{1}{\frac{\frac{a}{t}}{z}}}\right) \]
      2. inv-pow97.3%

        \[\leadsto \mathsf{fma}\left(\frac{x}{1}, \frac{y}{a}, -\color{blue}{{\left(\frac{\frac{a}{t}}{z}\right)}^{-1}}\right) \]
      3. associate-/l/89.8%

        \[\leadsto \mathsf{fma}\left(\frac{x}{1}, \frac{y}{a}, -{\color{blue}{\left(\frac{a}{z \cdot t}\right)}}^{-1}\right) \]
    5. Applied egg-rr89.8%

      \[\leadsto \mathsf{fma}\left(\frac{x}{1}, \frac{y}{a}, -\color{blue}{{\left(\frac{a}{z \cdot t}\right)}^{-1}}\right) \]
    6. Step-by-step derivation
      1. unpow-189.8%

        \[\leadsto \mathsf{fma}\left(\frac{x}{1}, \frac{y}{a}, -\color{blue}{\frac{1}{\frac{a}{z \cdot t}}}\right) \]
      2. *-commutative89.8%

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

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

      \[\leadsto \mathsf{fma}\left(\frac{x}{1}, \frac{y}{a}, -\color{blue}{\frac{1}{\frac{\frac{a}{t}}{z}}}\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification97.1%

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

Alternative 2: 96.6% accurate, 0.1× speedup?

\[\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ [z, t] = \mathsf{sort}([z, t])\\ \\ \begin{array}{l} t_1 := x \cdot y - z \cdot t\\ \mathbf{if}\;t_1 \leq -1 \cdot 10^{+295} \lor \neg \left(t_1 \leq 5 \cdot 10^{+140}\right):\\ \;\;\;\;\mathsf{fma}\left(x, \frac{y}{a}, -\frac{z}{\frac{a}{t}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{t_1}{a}\\ \end{array} \end{array} \]
NOTE: x and y should be sorted in increasing order before calling this function.
NOTE: z and t should be sorted in increasing order before calling this function.
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (- (* x y) (* z t))))
   (if (or (<= t_1 -1e+295) (not (<= t_1 5e+140)))
     (fma x (/ y a) (- (/ z (/ a t))))
     (/ t_1 a))))
assert(x < y);
assert(z < t);
double code(double x, double y, double z, double t, double a) {
	double t_1 = (x * y) - (z * t);
	double tmp;
	if ((t_1 <= -1e+295) || !(t_1 <= 5e+140)) {
		tmp = fma(x, (y / a), -(z / (a / t)));
	} else {
		tmp = t_1 / a;
	}
	return tmp;
}
x, y = sort([x, y])
z, t = sort([z, t])
function code(x, y, z, t, a)
	t_1 = Float64(Float64(x * y) - Float64(z * t))
	tmp = 0.0
	if ((t_1 <= -1e+295) || !(t_1 <= 5e+140))
		tmp = fma(x, Float64(y / a), Float64(-Float64(z / Float64(a / t))));
	else
		tmp = Float64(t_1 / a);
	end
	return tmp
end
NOTE: x and y should be sorted in increasing order before calling this function.
NOTE: z and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -1e+295], N[Not[LessEqual[t$95$1, 5e+140]], $MachinePrecision]], N[(x * N[(y / a), $MachinePrecision] + (-N[(z / N[(a / t), $MachinePrecision]), $MachinePrecision])), $MachinePrecision], N[(t$95$1 / a), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
t_1 := x \cdot y - z \cdot t\\
\mathbf{if}\;t_1 \leq -1 \cdot 10^{+295} \lor \neg \left(t_1 \leq 5 \cdot 10^{+140}\right):\\
\;\;\;\;\mathsf{fma}\left(x, \frac{y}{a}, -\frac{z}{\frac{a}{t}}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (*.f64 x y) (*.f64 z t)) < -9.9999999999999998e294 or 5.00000000000000008e140 < (-.f64 (*.f64 x y) (*.f64 z t))

    1. Initial program 81.1%

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

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

        \[\leadsto \frac{x \cdot y}{\color{blue}{1 \cdot a}} - \frac{z \cdot t}{a} \]
      3. times-frac84.9%

        \[\leadsto \color{blue}{\frac{x}{1} \cdot \frac{y}{a}} - \frac{z \cdot t}{a} \]
      4. fma-neg85.8%

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{1}, \frac{y}{a}, -\frac{z}{\frac{a}{t}}\right)} \]

    if -9.9999999999999998e294 < (-.f64 (*.f64 x y) (*.f64 z t)) < 5.00000000000000008e140

    1. Initial program 99.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \leq -1 \cdot 10^{+295} \lor \neg \left(x \cdot y - z \cdot t \leq 5 \cdot 10^{+140}\right):\\ \;\;\;\;\mathsf{fma}\left(x, \frac{y}{a}, -\frac{z}{\frac{a}{t}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\ \end{array} \]

Alternative 3: 96.7% accurate, 0.3× speedup?

\[\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ [z, t] = \mathsf{sort}([z, t])\\ \\ \begin{array}{l} t_1 := \frac{x}{\frac{a}{y}}\\ t_2 := x \cdot y - z \cdot t\\ \mathbf{if}\;t_2 \leq -1 \cdot 10^{+295}:\\ \;\;\;\;t_1 - \frac{z}{\frac{a}{t}}\\ \mathbf{elif}\;t_2 \leq 5 \cdot 10^{+188}:\\ \;\;\;\;\frac{t_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{\frac{\frac{a}{t}}{z}} + t_1\\ \end{array} \end{array} \]
NOTE: x and y should be sorted in increasing order before calling this function.
NOTE: z and t should be sorted in increasing order before calling this function.
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (/ x (/ a y))) (t_2 (- (* x y) (* z t))))
   (if (<= t_2 -1e+295)
     (- t_1 (/ z (/ a t)))
     (if (<= t_2 5e+188) (/ t_2 a) (+ (/ -1.0 (/ (/ a t) z)) t_1)))))
assert(x < y);
assert(z < t);
double code(double x, double y, double z, double t, double a) {
	double t_1 = x / (a / y);
	double t_2 = (x * y) - (z * t);
	double tmp;
	if (t_2 <= -1e+295) {
		tmp = t_1 - (z / (a / t));
	} else if (t_2 <= 5e+188) {
		tmp = t_2 / a;
	} else {
		tmp = (-1.0 / ((a / t) / z)) + t_1;
	}
	return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
NOTE: z and t should be sorted in increasing order before calling this function.
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) :: t_2
    real(8) :: tmp
    t_1 = x / (a / y)
    t_2 = (x * y) - (z * t)
    if (t_2 <= (-1d+295)) then
        tmp = t_1 - (z / (a / t))
    else if (t_2 <= 5d+188) then
        tmp = t_2 / a
    else
        tmp = ((-1.0d0) / ((a / t) / z)) + t_1
    end if
    code = tmp
end function
assert x < y;
assert z < t;
public static double code(double x, double y, double z, double t, double a) {
	double t_1 = x / (a / y);
	double t_2 = (x * y) - (z * t);
	double tmp;
	if (t_2 <= -1e+295) {
		tmp = t_1 - (z / (a / t));
	} else if (t_2 <= 5e+188) {
		tmp = t_2 / a;
	} else {
		tmp = (-1.0 / ((a / t) / z)) + t_1;
	}
	return tmp;
}
[x, y] = sort([x, y])
[z, t] = sort([z, t])
def code(x, y, z, t, a):
	t_1 = x / (a / y)
	t_2 = (x * y) - (z * t)
	tmp = 0
	if t_2 <= -1e+295:
		tmp = t_1 - (z / (a / t))
	elif t_2 <= 5e+188:
		tmp = t_2 / a
	else:
		tmp = (-1.0 / ((a / t) / z)) + t_1
	return tmp
x, y = sort([x, y])
z, t = sort([z, t])
function code(x, y, z, t, a)
	t_1 = Float64(x / Float64(a / y))
	t_2 = Float64(Float64(x * y) - Float64(z * t))
	tmp = 0.0
	if (t_2 <= -1e+295)
		tmp = Float64(t_1 - Float64(z / Float64(a / t)));
	elseif (t_2 <= 5e+188)
		tmp = Float64(t_2 / a);
	else
		tmp = Float64(Float64(-1.0 / Float64(Float64(a / t) / z)) + t_1);
	end
	return tmp
end
x, y = num2cell(sort([x, y])){:}
z, t = num2cell(sort([z, t])){:}
function tmp_2 = code(x, y, z, t, a)
	t_1 = x / (a / y);
	t_2 = (x * y) - (z * t);
	tmp = 0.0;
	if (t_2 <= -1e+295)
		tmp = t_1 - (z / (a / t));
	elseif (t_2 <= 5e+188)
		tmp = t_2 / a;
	else
		tmp = (-1.0 / ((a / t) / z)) + t_1;
	end
	tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
NOTE: z and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(x / N[(a / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -1e+295], N[(t$95$1 - N[(z / N[(a / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 5e+188], N[(t$95$2 / a), $MachinePrecision], N[(N[(-1.0 / N[(N[(a / t), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
t_1 := \frac{x}{\frac{a}{y}}\\
t_2 := x \cdot y - z \cdot t\\
\mathbf{if}\;t_2 \leq -1 \cdot 10^{+295}:\\
\;\;\;\;t_1 - \frac{z}{\frac{a}{t}}\\

\mathbf{elif}\;t_2 \leq 5 \cdot 10^{+188}:\\
\;\;\;\;\frac{t_2}{a}\\

\mathbf{else}:\\
\;\;\;\;\frac{-1}{\frac{\frac{a}{t}}{z}} + t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (-.f64 (*.f64 x y) (*.f64 z t)) < -9.9999999999999998e294

    1. Initial program 72.5%

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

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

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

        \[\leadsto \frac{x}{\frac{a}{y}} - \color{blue}{\frac{z}{\frac{a}{t}}} \]
    3. Applied egg-rr88.1%

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

    if -9.9999999999999998e294 < (-.f64 (*.f64 x y) (*.f64 z t)) < 5.0000000000000001e188

    1. Initial program 99.1%

      \[\frac{x \cdot y - z \cdot t}{a} \]

    if 5.0000000000000001e188 < (-.f64 (*.f64 x y) (*.f64 z t))

    1. Initial program 83.0%

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

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

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

        \[\leadsto \frac{x}{\frac{a}{y}} - \color{blue}{\frac{z}{\frac{a}{t}}} \]
    3. Applied egg-rr96.8%

      \[\leadsto \color{blue}{\frac{x}{\frac{a}{y}} - \frac{z}{\frac{a}{t}}} \]
    4. Step-by-step derivation
      1. clear-num98.3%

        \[\leadsto \mathsf{fma}\left(\frac{x}{1}, \frac{y}{a}, -\color{blue}{\frac{1}{\frac{\frac{a}{t}}{z}}}\right) \]
      2. inv-pow98.3%

        \[\leadsto \mathsf{fma}\left(\frac{x}{1}, \frac{y}{a}, -\color{blue}{{\left(\frac{\frac{a}{t}}{z}\right)}^{-1}}\right) \]
      3. associate-/l/88.4%

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

      \[\leadsto \frac{x}{\frac{a}{y}} - \color{blue}{{\left(\frac{a}{z \cdot t}\right)}^{-1}} \]
    6. Step-by-step derivation
      1. unpow-188.4%

        \[\leadsto \mathsf{fma}\left(\frac{x}{1}, \frac{y}{a}, -\color{blue}{\frac{1}{\frac{a}{z \cdot t}}}\right) \]
      2. *-commutative88.4%

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

        \[\leadsto \mathsf{fma}\left(\frac{x}{1}, \frac{y}{a}, -\frac{1}{\color{blue}{\frac{\frac{a}{t}}{z}}}\right) \]
    7. Simplified96.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \leq -1 \cdot 10^{+295}:\\ \;\;\;\;\frac{x}{\frac{a}{y}} - \frac{z}{\frac{a}{t}}\\ \mathbf{elif}\;x \cdot y - z \cdot t \leq 5 \cdot 10^{+188}:\\ \;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{\frac{\frac{a}{t}}{z}} + \frac{x}{\frac{a}{y}}\\ \end{array} \]

Alternative 4: 96.7% accurate, 0.3× speedup?

\[\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ [z, t] = \mathsf{sort}([z, t])\\ \\ \begin{array}{l} t_1 := x \cdot y - z \cdot t\\ \mathbf{if}\;t_1 \leq -1 \cdot 10^{+295} \lor \neg \left(t_1 \leq 5 \cdot 10^{+188}\right):\\ \;\;\;\;\frac{x}{\frac{a}{y}} - \frac{z}{\frac{a}{t}}\\ \mathbf{else}:\\ \;\;\;\;\frac{t_1}{a}\\ \end{array} \end{array} \]
NOTE: x and y should be sorted in increasing order before calling this function.
NOTE: z and t should be sorted in increasing order before calling this function.
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (- (* x y) (* z t))))
   (if (or (<= t_1 -1e+295) (not (<= t_1 5e+188)))
     (- (/ x (/ a y)) (/ z (/ a t)))
     (/ t_1 a))))
assert(x < y);
assert(z < t);
double code(double x, double y, double z, double t, double a) {
	double t_1 = (x * y) - (z * t);
	double tmp;
	if ((t_1 <= -1e+295) || !(t_1 <= 5e+188)) {
		tmp = (x / (a / y)) - (z / (a / t));
	} else {
		tmp = t_1 / a;
	}
	return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
NOTE: z and t should be sorted in increasing order before calling this function.
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 = (x * y) - (z * t)
    if ((t_1 <= (-1d+295)) .or. (.not. (t_1 <= 5d+188))) then
        tmp = (x / (a / y)) - (z / (a / t))
    else
        tmp = t_1 / a
    end if
    code = tmp
end function
assert x < y;
assert z < t;
public static double code(double x, double y, double z, double t, double a) {
	double t_1 = (x * y) - (z * t);
	double tmp;
	if ((t_1 <= -1e+295) || !(t_1 <= 5e+188)) {
		tmp = (x / (a / y)) - (z / (a / t));
	} else {
		tmp = t_1 / a;
	}
	return tmp;
}
[x, y] = sort([x, y])
[z, t] = sort([z, t])
def code(x, y, z, t, a):
	t_1 = (x * y) - (z * t)
	tmp = 0
	if (t_1 <= -1e+295) or not (t_1 <= 5e+188):
		tmp = (x / (a / y)) - (z / (a / t))
	else:
		tmp = t_1 / a
	return tmp
x, y = sort([x, y])
z, t = sort([z, t])
function code(x, y, z, t, a)
	t_1 = Float64(Float64(x * y) - Float64(z * t))
	tmp = 0.0
	if ((t_1 <= -1e+295) || !(t_1 <= 5e+188))
		tmp = Float64(Float64(x / Float64(a / y)) - Float64(z / Float64(a / t)));
	else
		tmp = Float64(t_1 / a);
	end
	return tmp
end
x, y = num2cell(sort([x, y])){:}
z, t = num2cell(sort([z, t])){:}
function tmp_2 = code(x, y, z, t, a)
	t_1 = (x * y) - (z * t);
	tmp = 0.0;
	if ((t_1 <= -1e+295) || ~((t_1 <= 5e+188)))
		tmp = (x / (a / y)) - (z / (a / t));
	else
		tmp = t_1 / a;
	end
	tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
NOTE: z and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -1e+295], N[Not[LessEqual[t$95$1, 5e+188]], $MachinePrecision]], N[(N[(x / N[(a / y), $MachinePrecision]), $MachinePrecision] - N[(z / N[(a / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 / a), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
t_1 := x \cdot y - z \cdot t\\
\mathbf{if}\;t_1 \leq -1 \cdot 10^{+295} \lor \neg \left(t_1 \leq 5 \cdot 10^{+188}\right):\\
\;\;\;\;\frac{x}{\frac{a}{y}} - \frac{z}{\frac{a}{t}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (*.f64 x y) (*.f64 z t)) < -9.9999999999999998e294 or 5.0000000000000001e188 < (-.f64 (*.f64 x y) (*.f64 z t))

    1. Initial program 79.4%

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

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

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

        \[\leadsto \frac{x}{\frac{a}{y}} - \color{blue}{\frac{z}{\frac{a}{t}}} \]
    3. Applied egg-rr93.9%

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

    if -9.9999999999999998e294 < (-.f64 (*.f64 x y) (*.f64 z t)) < 5.0000000000000001e188

    1. Initial program 99.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \leq -1 \cdot 10^{+295} \lor \neg \left(x \cdot y - z \cdot t \leq 5 \cdot 10^{+188}\right):\\ \;\;\;\;\frac{x}{\frac{a}{y}} - \frac{z}{\frac{a}{t}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\ \end{array} \]

Alternative 5: 93.8% accurate, 0.7× speedup?

\[\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ [z, t] = \mathsf{sort}([z, t])\\ \\ \begin{array}{l} \mathbf{if}\;z \cdot t \leq -1 \cdot 10^{+299}:\\ \;\;\;\;z \cdot \frac{-t}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\ \end{array} \end{array} \]
NOTE: x and y should be sorted in increasing order before calling this function.
NOTE: z and t should be sorted in increasing order before calling this function.
(FPCore (x y z t a)
 :precision binary64
 (if (<= (* z t) -1e+299) (* z (/ (- t) a)) (/ (- (* x y) (* z t)) a)))
assert(x < y);
assert(z < t);
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if ((z * t) <= -1e+299) {
		tmp = z * (-t / a);
	} else {
		tmp = ((x * y) - (z * t)) / a;
	}
	return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
NOTE: z and t should be sorted in increasing order before calling this function.
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) :: tmp
    if ((z * t) <= (-1d+299)) then
        tmp = z * (-t / a)
    else
        tmp = ((x * y) - (z * t)) / a
    end if
    code = tmp
end function
assert x < y;
assert z < t;
public static double code(double x, double y, double z, double t, double a) {
	double tmp;
	if ((z * t) <= -1e+299) {
		tmp = z * (-t / a);
	} else {
		tmp = ((x * y) - (z * t)) / a;
	}
	return tmp;
}
[x, y] = sort([x, y])
[z, t] = sort([z, t])
def code(x, y, z, t, a):
	tmp = 0
	if (z * t) <= -1e+299:
		tmp = z * (-t / a)
	else:
		tmp = ((x * y) - (z * t)) / a
	return tmp
x, y = sort([x, y])
z, t = sort([z, t])
function code(x, y, z, t, a)
	tmp = 0.0
	if (Float64(z * t) <= -1e+299)
		tmp = Float64(z * Float64(Float64(-t) / a));
	else
		tmp = Float64(Float64(Float64(x * y) - Float64(z * t)) / a);
	end
	return tmp
end
x, y = num2cell(sort([x, y])){:}
z, t = num2cell(sort([z, t])){:}
function tmp_2 = code(x, y, z, t, a)
	tmp = 0.0;
	if ((z * t) <= -1e+299)
		tmp = z * (-t / a);
	else
		tmp = ((x * y) - (z * t)) / a;
	end
	tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
NOTE: z and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_] := If[LessEqual[N[(z * t), $MachinePrecision], -1e+299], N[(z * N[((-t) / a), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -1 \cdot 10^{+299}:\\
\;\;\;\;z \cdot \frac{-t}{a}\\

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


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

    1. Initial program 69.7%

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

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

        \[\leadsto \frac{x \cdot y}{\color{blue}{1 \cdot a}} - \frac{z \cdot t}{a} \]
      3. times-frac60.6%

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

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

        \[\leadsto \mathsf{fma}\left(\frac{x}{1}, \frac{y}{a}, -\color{blue}{\frac{z}{\frac{a}{t}}}\right) \]
    3. Applied egg-rr95.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{1}, \frac{y}{a}, -\frac{z}{\frac{a}{t}}\right)} \]
    4. Taylor expanded in x around 0 69.7%

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

        \[\leadsto -1 \cdot \color{blue}{\left(\frac{t}{a} \cdot z\right)} \]
      2. associate-*r*99.8%

        \[\leadsto \color{blue}{\left(-1 \cdot \frac{t}{a}\right) \cdot z} \]
      3. neg-mul-199.8%

        \[\leadsto \color{blue}{\left(-\frac{t}{a}\right)} \cdot z \]
      4. *-commutative99.8%

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

        \[\leadsto z \cdot \color{blue}{\frac{-t}{a}} \]
    6. Simplified99.8%

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

    if -1.0000000000000001e299 < (*.f64 z t)

    1. Initial program 93.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \cdot t \leq -1 \cdot 10^{+299}:\\ \;\;\;\;z \cdot \frac{-t}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\ \end{array} \]

Alternative 6: 67.7% accurate, 0.9× speedup?

\[\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ [z, t] = \mathsf{sort}([z, t])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq -1.6 \cdot 10^{-90}:\\ \;\;\;\;\frac{x}{\frac{a}{y}}\\ \mathbf{elif}\;y \leq 6.6 \cdot 10^{+63}:\\ \;\;\;\;z \cdot \frac{-t}{a}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{a}\\ \end{array} \end{array} \]
NOTE: x and y should be sorted in increasing order before calling this function.
NOTE: z and t should be sorted in increasing order before calling this function.
(FPCore (x y z t a)
 :precision binary64
 (if (<= y -1.6e-90)
   (/ x (/ a y))
   (if (<= y 6.6e+63) (* z (/ (- t) a)) (* y (/ x a)))))
assert(x < y);
assert(z < t);
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if (y <= -1.6e-90) {
		tmp = x / (a / y);
	} else if (y <= 6.6e+63) {
		tmp = z * (-t / a);
	} else {
		tmp = y * (x / a);
	}
	return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
NOTE: z and t should be sorted in increasing order before calling this function.
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) :: tmp
    if (y <= (-1.6d-90)) then
        tmp = x / (a / y)
    else if (y <= 6.6d+63) then
        tmp = z * (-t / a)
    else
        tmp = y * (x / a)
    end if
    code = tmp
end function
assert x < y;
assert z < t;
public static double code(double x, double y, double z, double t, double a) {
	double tmp;
	if (y <= -1.6e-90) {
		tmp = x / (a / y);
	} else if (y <= 6.6e+63) {
		tmp = z * (-t / a);
	} else {
		tmp = y * (x / a);
	}
	return tmp;
}
[x, y] = sort([x, y])
[z, t] = sort([z, t])
def code(x, y, z, t, a):
	tmp = 0
	if y <= -1.6e-90:
		tmp = x / (a / y)
	elif y <= 6.6e+63:
		tmp = z * (-t / a)
	else:
		tmp = y * (x / a)
	return tmp
x, y = sort([x, y])
z, t = sort([z, t])
function code(x, y, z, t, a)
	tmp = 0.0
	if (y <= -1.6e-90)
		tmp = Float64(x / Float64(a / y));
	elseif (y <= 6.6e+63)
		tmp = Float64(z * Float64(Float64(-t) / a));
	else
		tmp = Float64(y * Float64(x / a));
	end
	return tmp
end
x, y = num2cell(sort([x, y])){:}
z, t = num2cell(sort([z, t])){:}
function tmp_2 = code(x, y, z, t, a)
	tmp = 0.0;
	if (y <= -1.6e-90)
		tmp = x / (a / y);
	elseif (y <= 6.6e+63)
		tmp = z * (-t / a);
	else
		tmp = y * (x / a);
	end
	tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
NOTE: z and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_] := If[LessEqual[y, -1.6e-90], N[(x / N[(a / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 6.6e+63], N[(z * N[((-t) / a), $MachinePrecision]), $MachinePrecision], N[(y * N[(x / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.6 \cdot 10^{-90}:\\
\;\;\;\;\frac{x}{\frac{a}{y}}\\

\mathbf{elif}\;y \leq 6.6 \cdot 10^{+63}:\\
\;\;\;\;z \cdot \frac{-t}{a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.60000000000000004e-90

    1. Initial program 94.4%

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

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

        \[\leadsto \color{blue}{y \cdot \frac{x}{a}} \]
    4. Simplified56.4%

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

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

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

        \[\leadsto \color{blue}{\frac{x}{\frac{a}{y}}} \]
    6. Applied egg-rr56.2%

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

    if -1.60000000000000004e-90 < y < 6.6000000000000003e63

    1. Initial program 92.2%

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

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

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

        \[\leadsto \color{blue}{\frac{x}{1} \cdot \frac{y}{a}} - \frac{z \cdot t}{a} \]
      4. fma-neg89.4%

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

        \[\leadsto \mathsf{fma}\left(\frac{x}{1}, \frac{y}{a}, -\color{blue}{\frac{z}{\frac{a}{t}}}\right) \]
    3. Applied egg-rr91.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{1}, \frac{y}{a}, -\frac{z}{\frac{a}{t}}\right)} \]
    4. Taylor expanded in x around 0 67.4%

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

        \[\leadsto -1 \cdot \color{blue}{\left(\frac{t}{a} \cdot z\right)} \]
      2. associate-*r*71.3%

        \[\leadsto \color{blue}{\left(-1 \cdot \frac{t}{a}\right) \cdot z} \]
      3. neg-mul-171.3%

        \[\leadsto \color{blue}{\left(-\frac{t}{a}\right)} \cdot z \]
      4. *-commutative71.3%

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

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

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

    if 6.6000000000000003e63 < y

    1. Initial program 84.7%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.6 \cdot 10^{-90}:\\ \;\;\;\;\frac{x}{\frac{a}{y}}\\ \mathbf{elif}\;y \leq 6.6 \cdot 10^{+63}:\\ \;\;\;\;z \cdot \frac{-t}{a}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{a}\\ \end{array} \]

Alternative 7: 67.6% accurate, 0.9× speedup?

\[\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ [z, t] = \mathsf{sort}([z, t])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq -1.7 \cdot 10^{-90}:\\ \;\;\;\;\frac{x}{\frac{a}{y}}\\ \mathbf{elif}\;y \leq 1.4 \cdot 10^{+64}:\\ \;\;\;\;\frac{z}{\frac{-a}{t}}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{a}\\ \end{array} \end{array} \]
NOTE: x and y should be sorted in increasing order before calling this function.
NOTE: z and t should be sorted in increasing order before calling this function.
(FPCore (x y z t a)
 :precision binary64
 (if (<= y -1.7e-90)
   (/ x (/ a y))
   (if (<= y 1.4e+64) (/ z (/ (- a) t)) (* y (/ x a)))))
assert(x < y);
assert(z < t);
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if (y <= -1.7e-90) {
		tmp = x / (a / y);
	} else if (y <= 1.4e+64) {
		tmp = z / (-a / t);
	} else {
		tmp = y * (x / a);
	}
	return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
NOTE: z and t should be sorted in increasing order before calling this function.
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) :: tmp
    if (y <= (-1.7d-90)) then
        tmp = x / (a / y)
    else if (y <= 1.4d+64) then
        tmp = z / (-a / t)
    else
        tmp = y * (x / a)
    end if
    code = tmp
end function
assert x < y;
assert z < t;
public static double code(double x, double y, double z, double t, double a) {
	double tmp;
	if (y <= -1.7e-90) {
		tmp = x / (a / y);
	} else if (y <= 1.4e+64) {
		tmp = z / (-a / t);
	} else {
		tmp = y * (x / a);
	}
	return tmp;
}
[x, y] = sort([x, y])
[z, t] = sort([z, t])
def code(x, y, z, t, a):
	tmp = 0
	if y <= -1.7e-90:
		tmp = x / (a / y)
	elif y <= 1.4e+64:
		tmp = z / (-a / t)
	else:
		tmp = y * (x / a)
	return tmp
x, y = sort([x, y])
z, t = sort([z, t])
function code(x, y, z, t, a)
	tmp = 0.0
	if (y <= -1.7e-90)
		tmp = Float64(x / Float64(a / y));
	elseif (y <= 1.4e+64)
		tmp = Float64(z / Float64(Float64(-a) / t));
	else
		tmp = Float64(y * Float64(x / a));
	end
	return tmp
end
x, y = num2cell(sort([x, y])){:}
z, t = num2cell(sort([z, t])){:}
function tmp_2 = code(x, y, z, t, a)
	tmp = 0.0;
	if (y <= -1.7e-90)
		tmp = x / (a / y);
	elseif (y <= 1.4e+64)
		tmp = z / (-a / t);
	else
		tmp = y * (x / a);
	end
	tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
NOTE: z and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_] := If[LessEqual[y, -1.7e-90], N[(x / N[(a / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.4e+64], N[(z / N[((-a) / t), $MachinePrecision]), $MachinePrecision], N[(y * N[(x / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.7 \cdot 10^{-90}:\\
\;\;\;\;\frac{x}{\frac{a}{y}}\\

\mathbf{elif}\;y \leq 1.4 \cdot 10^{+64}:\\
\;\;\;\;\frac{z}{\frac{-a}{t}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.69999999999999997e-90

    1. Initial program 94.4%

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

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

        \[\leadsto \color{blue}{y \cdot \frac{x}{a}} \]
    4. Simplified56.4%

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

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

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

        \[\leadsto \color{blue}{\frac{x}{\frac{a}{y}}} \]
    6. Applied egg-rr56.2%

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

    if -1.69999999999999997e-90 < y < 1.40000000000000012e64

    1. Initial program 92.2%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-z}{\frac{a}{t}}} \]
      6. associate-/r/70.2%

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

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

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

        \[\leadsto \color{blue}{\frac{-z}{\frac{a}{t}}} \]
      3. add-sqr-sqrt41.7%

        \[\leadsto \frac{\color{blue}{\sqrt{-z} \cdot \sqrt{-z}}}{\frac{a}{t}} \]
      4. sqrt-unprod36.6%

        \[\leadsto \frac{\color{blue}{\sqrt{\left(-z\right) \cdot \left(-z\right)}}}{\frac{a}{t}} \]
      5. sqr-neg36.6%

        \[\leadsto \frac{\sqrt{\color{blue}{z \cdot z}}}{\frac{a}{t}} \]
      6. sqrt-unprod5.1%

        \[\leadsto \frac{\color{blue}{\sqrt{z} \cdot \sqrt{z}}}{\frac{a}{t}} \]
      7. add-sqr-sqrt11.4%

        \[\leadsto \frac{\color{blue}{z}}{\frac{a}{t}} \]
      8. frac-2neg11.4%

        \[\leadsto \color{blue}{\frac{-z}{-\frac{a}{t}}} \]
      9. add-sqr-sqrt6.3%

        \[\leadsto \frac{\color{blue}{\sqrt{-z} \cdot \sqrt{-z}}}{-\frac{a}{t}} \]
      10. sqrt-unprod30.0%

        \[\leadsto \frac{\color{blue}{\sqrt{\left(-z\right) \cdot \left(-z\right)}}}{-\frac{a}{t}} \]
      11. sqr-neg30.0%

        \[\leadsto \frac{\sqrt{\color{blue}{z \cdot z}}}{-\frac{a}{t}} \]
      12. sqrt-unprod28.9%

        \[\leadsto \frac{\color{blue}{\sqrt{z} \cdot \sqrt{z}}}{-\frac{a}{t}} \]
      13. add-sqr-sqrt70.8%

        \[\leadsto \frac{\color{blue}{z}}{-\frac{a}{t}} \]
      14. distribute-neg-frac70.8%

        \[\leadsto \frac{z}{\color{blue}{\frac{-a}{t}}} \]
    6. Applied egg-rr70.8%

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

    if 1.40000000000000012e64 < y

    1. Initial program 84.7%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.7 \cdot 10^{-90}:\\ \;\;\;\;\frac{x}{\frac{a}{y}}\\ \mathbf{elif}\;y \leq 1.4 \cdot 10^{+64}:\\ \;\;\;\;\frac{z}{\frac{-a}{t}}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{a}\\ \end{array} \]

Alternative 8: 51.6% accurate, 1.8× speedup?

\[\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ [z, t] = \mathsf{sort}([z, t])\\ \\ y \cdot \frac{x}{a} \end{array} \]
NOTE: x and y should be sorted in increasing order before calling this function.
NOTE: z and t should be sorted in increasing order before calling this function.
(FPCore (x y z t a) :precision binary64 (* y (/ x a)))
assert(x < y);
assert(z < t);
double code(double x, double y, double z, double t, double a) {
	return y * (x / a);
}
NOTE: x and y should be sorted in increasing order before calling this function.
NOTE: z and t should be sorted in increasing order before calling this function.
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 = y * (x / a)
end function
assert x < y;
assert z < t;
public static double code(double x, double y, double z, double t, double a) {
	return y * (x / a);
}
[x, y] = sort([x, y])
[z, t] = sort([z, t])
def code(x, y, z, t, a):
	return y * (x / a)
x, y = sort([x, y])
z, t = sort([z, t])
function code(x, y, z, t, a)
	return Float64(y * Float64(x / a))
end
x, y = num2cell(sort([x, y])){:}
z, t = num2cell(sort([z, t])){:}
function tmp = code(x, y, z, t, a)
	tmp = y * (x / a);
end
NOTE: x and y should be sorted in increasing order before calling this function.
NOTE: z and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_] := N[(y * N[(x / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
[z, t] = \mathsf{sort}([z, t])\\
\\
y \cdot \frac{x}{a}
\end{array}
Derivation
  1. Initial program 91.3%

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

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

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

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

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

Developer target: 91.8% accurate, 0.6× 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 2023185 
(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))