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

Percentage Accurate: 91.2% → 95.2%
Time: 10.4s
Alternatives: 6
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 6 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.2% 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: 95.2% 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 10^{-13}:\\ \;\;\;\;\frac{x \cdot y - z \cdot t}{a\_m}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{a\_m}, y, 0 - z \cdot \frac{t}{a\_m}\right)\\ \end{array} \end{array} \]
a\_m = (fabs.f64 a)
a\_s = (copysign.f64 #s(literal 1 binary64) 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 1e-13)
    (/ (- (* x y) (* z t)) a_m)
    (fma (/ x a_m) y (- 0.0 (* 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 <= 1e-13) {
		tmp = ((x * y) - (z * t)) / a_m;
	} else {
		tmp = fma((x / a_m), y, (0.0 - (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 <= 1e-13)
		tmp = Float64(Float64(Float64(x * y) - Float64(z * t)) / a_m);
	else
		tmp = fma(Float64(x / a_m), y, Float64(0.0 - Float64(z * Float64(t / 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, 1e-13], N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a$95$m), $MachinePrecision], N[(N[(x / a$95$m), $MachinePrecision] * y + N[(0.0 - N[(z * N[(t / a$95$m), $MachinePrecision]), $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 10^{-13}:\\
\;\;\;\;\frac{x \cdot y - z \cdot t}{a\_m}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < 1e-13

    1. Initial program 95.1%

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

    if 1e-13 < a

    1. Initial program 83.5%

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

        \[\leadsto \color{blue}{\frac{x \cdot y}{a} - \frac{z \cdot t}{a}} \]
      2. sub-negN/A

        \[\leadsto \color{blue}{\frac{x \cdot y}{a} + \left(\mathsf{neg}\left(\frac{z \cdot t}{a}\right)\right)} \]
      3. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{y \cdot x}}{a} + \left(\mathsf{neg}\left(\frac{z \cdot t}{a}\right)\right) \]
      4. associate-/l*N/A

        \[\leadsto \color{blue}{y \cdot \frac{x}{a}} + \left(\mathsf{neg}\left(\frac{z \cdot t}{a}\right)\right) \]
      5. *-commutativeN/A

        \[\leadsto \color{blue}{\frac{x}{a} \cdot y} + \left(\mathsf{neg}\left(\frac{z \cdot t}{a}\right)\right) \]
      6. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{a}, y, \mathsf{neg}\left(\frac{z \cdot t}{a}\right)\right)} \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{x}{a}}, y, \mathsf{neg}\left(\frac{z \cdot t}{a}\right)\right) \]
      8. neg-sub0N/A

        \[\leadsto \mathsf{fma}\left(\frac{x}{a}, y, \color{blue}{0 - \frac{z \cdot t}{a}}\right) \]
      9. --lowering--.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{x}{a}, y, \color{blue}{0 - \frac{z \cdot t}{a}}\right) \]
      10. /-lowering-/.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{x}{a}, y, 0 - \color{blue}{\frac{z \cdot t}{a}}\right) \]
      11. *-lowering-*.f6488.2

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{a}, y, 0 - \frac{z \cdot t}{a}\right)} \]
    5. Step-by-step derivation
      1. sub0-negN/A

        \[\leadsto \mathsf{fma}\left(\frac{x}{a}, y, \color{blue}{\mathsf{neg}\left(\frac{z \cdot t}{a}\right)}\right) \]
      2. associate-/l*N/A

        \[\leadsto \mathsf{fma}\left(\frac{x}{a}, y, \mathsf{neg}\left(\color{blue}{z \cdot \frac{t}{a}}\right)\right) \]
      3. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma}\left(\frac{x}{a}, y, \color{blue}{z \cdot \left(\mathsf{neg}\left(\frac{t}{a}\right)\right)}\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{x}{a}, y, \color{blue}{z \cdot \left(\mathsf{neg}\left(\frac{t}{a}\right)\right)}\right) \]
      5. neg-lowering-neg.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{x}{a}, y, z \cdot \color{blue}{\left(\mathsf{neg}\left(\frac{t}{a}\right)\right)}\right) \]
      6. /-lowering-/.f6491.0

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

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

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

Alternative 2: 73.7% 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])\\ \\ \begin{array}{l} t_1 := 0 - z \cdot \frac{t}{a\_m}\\ a\_s \cdot \begin{array}{l} \mathbf{if}\;z \cdot t \leq -5 \cdot 10^{+23}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+43}:\\ \;\;\;\;x \cdot \frac{y}{a\_m}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \end{array} \]
a\_m = (fabs.f64 a)
a\_s = (copysign.f64 #s(literal 1 binary64) 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 (- 0.0 (* z (/ t a_m)))))
   (*
    a_s
    (if (<= (* z t) -5e+23) t_1 (if (<= (* z t) 2e+43) (* x (/ y a_m)) 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 = 0.0 - (z * (t / a_m));
	double tmp;
	if ((z * t) <= -5e+23) {
		tmp = t_1;
	} else if ((z * t) <= 2e+43) {
		tmp = x * (y / a_m);
	} 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 = 0.0d0 - (z * (t / a_m))
    if ((z * t) <= (-5d+23)) then
        tmp = t_1
    else if ((z * t) <= 2d+43) then
        tmp = x * (y / a_m)
    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 = 0.0 - (z * (t / a_m));
	double tmp;
	if ((z * t) <= -5e+23) {
		tmp = t_1;
	} else if ((z * t) <= 2e+43) {
		tmp = x * (y / a_m);
	} 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 = 0.0 - (z * (t / a_m))
	tmp = 0
	if (z * t) <= -5e+23:
		tmp = t_1
	elif (z * t) <= 2e+43:
		tmp = x * (y / a_m)
	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(0.0 - Float64(z * Float64(t / a_m)))
	tmp = 0.0
	if (Float64(z * t) <= -5e+23)
		tmp = t_1;
	elseif (Float64(z * t) <= 2e+43)
		tmp = Float64(x * Float64(y / a_m));
	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 = 0.0 - (z * (t / a_m));
	tmp = 0.0;
	if ((z * t) <= -5e+23)
		tmp = t_1;
	elseif ((z * t) <= 2e+43)
		tmp = x * (y / a_m);
	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[(0.0 - N[(z * N[(t / a$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(a$95$s * If[LessEqual[N[(z * t), $MachinePrecision], -5e+23], t$95$1, If[LessEqual[N[(z * t), $MachinePrecision], 2e+43], N[(x * N[(y / a$95$m), $MachinePrecision]), $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 := 0 - z \cdot \frac{t}{a\_m}\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;z \cdot t \leq -5 \cdot 10^{+23}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+43}:\\
\;\;\;\;x \cdot \frac{y}{a\_m}\\

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 z t) < -4.9999999999999999e23 or 2.00000000000000003e43 < (*.f64 z t)

    1. Initial program 89.4%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{t \cdot z}{a}} \]
    4. Step-by-step derivation
      1. +-lft-identityN/A

        \[\leadsto \color{blue}{0 + -1 \cdot \frac{t \cdot z}{a}} \]
      2. +-commutativeN/A

        \[\leadsto \color{blue}{-1 \cdot \frac{t \cdot z}{a} + 0} \]
      3. mul-1-negN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\frac{t \cdot z}{a}\right)\right)} + 0 \]
      4. associate-/l*N/A

        \[\leadsto \left(\mathsf{neg}\left(\color{blue}{t \cdot \frac{z}{a}}\right)\right) + 0 \]
      5. distribute-rgt-neg-inN/A

        \[\leadsto \color{blue}{t \cdot \left(\mathsf{neg}\left(\frac{z}{a}\right)\right)} + 0 \]
      6. mul-1-negN/A

        \[\leadsto t \cdot \color{blue}{\left(-1 \cdot \frac{z}{a}\right)} + 0 \]
      7. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(t, -1 \cdot \frac{z}{a}, 0\right)} \]
      8. mul-1-negN/A

        \[\leadsto \mathsf{fma}\left(t, \color{blue}{\mathsf{neg}\left(\frac{z}{a}\right)}, 0\right) \]
      9. neg-sub0N/A

        \[\leadsto \mathsf{fma}\left(t, \color{blue}{0 - \frac{z}{a}}, 0\right) \]
      10. --lowering--.f64N/A

        \[\leadsto \mathsf{fma}\left(t, \color{blue}{0 - \frac{z}{a}}, 0\right) \]
      11. /-lowering-/.f6481.5

        \[\leadsto \mathsf{fma}\left(t, 0 - \color{blue}{\frac{z}{a}}, 0\right) \]
    5. Simplified81.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(t, 0 - \frac{z}{a}, 0\right)} \]
    6. Step-by-step derivation
      1. +-rgt-identityN/A

        \[\leadsto \color{blue}{t \cdot \left(0 - \frac{z}{a}\right)} \]
      2. sub0-negN/A

        \[\leadsto t \cdot \color{blue}{\left(\mathsf{neg}\left(\frac{z}{a}\right)\right)} \]
      3. distribute-rgt-neg-outN/A

        \[\leadsto \color{blue}{\mathsf{neg}\left(t \cdot \frac{z}{a}\right)} \]
      4. div-invN/A

        \[\leadsto \mathsf{neg}\left(t \cdot \color{blue}{\left(z \cdot \frac{1}{a}\right)}\right) \]
      5. associate-*l*N/A

        \[\leadsto \mathsf{neg}\left(\color{blue}{\left(t \cdot z\right) \cdot \frac{1}{a}}\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{neg}\left(\color{blue}{\left(z \cdot t\right)} \cdot \frac{1}{a}\right) \]
      7. div-invN/A

        \[\leadsto \mathsf{neg}\left(\color{blue}{\frac{z \cdot t}{a}}\right) \]
      8. associate-/l*N/A

        \[\leadsto \mathsf{neg}\left(\color{blue}{z \cdot \frac{t}{a}}\right) \]
      9. distribute-rgt-neg-inN/A

        \[\leadsto \color{blue}{z \cdot \left(\mathsf{neg}\left(\frac{t}{a}\right)\right)} \]
      10. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{z \cdot \left(\mathsf{neg}\left(\frac{t}{a}\right)\right)} \]
      11. neg-lowering-neg.f64N/A

        \[\leadsto z \cdot \color{blue}{\left(\mathsf{neg}\left(\frac{t}{a}\right)\right)} \]
      12. /-lowering-/.f6480.7

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

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

    if -4.9999999999999999e23 < (*.f64 z t) < 2.00000000000000003e43

    1. Initial program 93.9%

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{a}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot y}{a}} \]
      2. +-rgt-identityN/A

        \[\leadsto \frac{\color{blue}{x \cdot y + 0}}{a} \]
      3. accelerator-lowering-fma.f6475.2

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(x, y, 0\right)}}{a} \]
    5. Simplified75.2%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x, y, 0\right)}{a}} \]
    6. Step-by-step derivation
      1. +-rgt-identityN/A

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

        \[\leadsto \color{blue}{x \cdot \frac{y}{a}} \]
      3. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{x \cdot \frac{y}{a}} \]
      4. /-lowering-/.f6476.5

        \[\leadsto x \cdot \color{blue}{\frac{y}{a}} \]
    7. Applied egg-rr76.5%

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

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

Alternative 3: 74.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])\\ \\ \begin{array}{l} t_1 := 0 - t \cdot \frac{z}{a\_m}\\ a\_s \cdot \begin{array}{l} \mathbf{if}\;z \cdot t \leq -5 \cdot 10^{+23}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+43}:\\ \;\;\;\;x \cdot \frac{y}{a\_m}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \end{array} \]
a\_m = (fabs.f64 a)
a\_s = (copysign.f64 #s(literal 1 binary64) 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 (- 0.0 (* t (/ z a_m)))))
   (*
    a_s
    (if (<= (* z t) -5e+23) t_1 (if (<= (* z t) 2e+43) (* x (/ y a_m)) 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 = 0.0 - (t * (z / a_m));
	double tmp;
	if ((z * t) <= -5e+23) {
		tmp = t_1;
	} else if ((z * t) <= 2e+43) {
		tmp = x * (y / a_m);
	} 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 = 0.0d0 - (t * (z / a_m))
    if ((z * t) <= (-5d+23)) then
        tmp = t_1
    else if ((z * t) <= 2d+43) then
        tmp = x * (y / a_m)
    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 = 0.0 - (t * (z / a_m));
	double tmp;
	if ((z * t) <= -5e+23) {
		tmp = t_1;
	} else if ((z * t) <= 2e+43) {
		tmp = x * (y / a_m);
	} 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 = 0.0 - (t * (z / a_m))
	tmp = 0
	if (z * t) <= -5e+23:
		tmp = t_1
	elif (z * t) <= 2e+43:
		tmp = x * (y / a_m)
	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(0.0 - Float64(t * Float64(z / a_m)))
	tmp = 0.0
	if (Float64(z * t) <= -5e+23)
		tmp = t_1;
	elseif (Float64(z * t) <= 2e+43)
		tmp = Float64(x * Float64(y / a_m));
	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 = 0.0 - (t * (z / a_m));
	tmp = 0.0;
	if ((z * t) <= -5e+23)
		tmp = t_1;
	elseif ((z * t) <= 2e+43)
		tmp = x * (y / a_m);
	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[(0.0 - N[(t * N[(z / a$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(a$95$s * If[LessEqual[N[(z * t), $MachinePrecision], -5e+23], t$95$1, If[LessEqual[N[(z * t), $MachinePrecision], 2e+43], N[(x * N[(y / a$95$m), $MachinePrecision]), $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 := 0 - t \cdot \frac{z}{a\_m}\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;z \cdot t \leq -5 \cdot 10^{+23}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+43}:\\
\;\;\;\;x \cdot \frac{y}{a\_m}\\

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 z t) < -4.9999999999999999e23 or 2.00000000000000003e43 < (*.f64 z t)

    1. Initial program 89.4%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{t \cdot z}{a}} \]
    4. Step-by-step derivation
      1. +-lft-identityN/A

        \[\leadsto \color{blue}{0 + -1 \cdot \frac{t \cdot z}{a}} \]
      2. +-commutativeN/A

        \[\leadsto \color{blue}{-1 \cdot \frac{t \cdot z}{a} + 0} \]
      3. mul-1-negN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\frac{t \cdot z}{a}\right)\right)} + 0 \]
      4. associate-/l*N/A

        \[\leadsto \left(\mathsf{neg}\left(\color{blue}{t \cdot \frac{z}{a}}\right)\right) + 0 \]
      5. distribute-rgt-neg-inN/A

        \[\leadsto \color{blue}{t \cdot \left(\mathsf{neg}\left(\frac{z}{a}\right)\right)} + 0 \]
      6. mul-1-negN/A

        \[\leadsto t \cdot \color{blue}{\left(-1 \cdot \frac{z}{a}\right)} + 0 \]
      7. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(t, -1 \cdot \frac{z}{a}, 0\right)} \]
      8. mul-1-negN/A

        \[\leadsto \mathsf{fma}\left(t, \color{blue}{\mathsf{neg}\left(\frac{z}{a}\right)}, 0\right) \]
      9. neg-sub0N/A

        \[\leadsto \mathsf{fma}\left(t, \color{blue}{0 - \frac{z}{a}}, 0\right) \]
      10. --lowering--.f64N/A

        \[\leadsto \mathsf{fma}\left(t, \color{blue}{0 - \frac{z}{a}}, 0\right) \]
      11. /-lowering-/.f6481.5

        \[\leadsto \mathsf{fma}\left(t, 0 - \color{blue}{\frac{z}{a}}, 0\right) \]
    5. Simplified81.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(t, 0 - \frac{z}{a}, 0\right)} \]
    6. Step-by-step derivation
      1. +-rgt-identityN/A

        \[\leadsto \color{blue}{t \cdot \left(0 - \frac{z}{a}\right)} \]
      2. *-commutativeN/A

        \[\leadsto \color{blue}{\left(0 - \frac{z}{a}\right) \cdot t} \]
      3. sub0-negN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\frac{z}{a}\right)\right)} \cdot t \]
      4. distribute-lft-neg-outN/A

        \[\leadsto \color{blue}{\mathsf{neg}\left(\frac{z}{a} \cdot t\right)} \]
      5. neg-lowering-neg.f64N/A

        \[\leadsto \color{blue}{\mathsf{neg}\left(\frac{z}{a} \cdot t\right)} \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{neg}\left(\color{blue}{\frac{z}{a} \cdot t}\right) \]
      7. /-lowering-/.f6481.5

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

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

    if -4.9999999999999999e23 < (*.f64 z t) < 2.00000000000000003e43

    1. Initial program 93.9%

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{a}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot y}{a}} \]
      2. +-rgt-identityN/A

        \[\leadsto \frac{\color{blue}{x \cdot y + 0}}{a} \]
      3. accelerator-lowering-fma.f6475.2

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(x, y, 0\right)}}{a} \]
    5. Simplified75.2%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x, y, 0\right)}{a}} \]
    6. Step-by-step derivation
      1. +-rgt-identityN/A

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

        \[\leadsto \color{blue}{x \cdot \frac{y}{a}} \]
      3. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{x \cdot \frac{y}{a}} \]
      4. /-lowering-/.f6476.5

        \[\leadsto x \cdot \color{blue}{\frac{y}{a}} \]
    7. Applied egg-rr76.5%

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

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

Alternative 4: 93.1% accurate, 0.7× 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^{+302}:\\ \;\;\;\;\frac{x \cdot y - z \cdot t}{a\_m}\\ \mathbf{else}:\\ \;\;\;\;0 - z \cdot \frac{t}{a\_m}\\ \end{array} \end{array} \]
a\_m = (fabs.f64 a)
a\_s = (copysign.f64 #s(literal 1 binary64) 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+302)
    (/ (- (* x y) (* z t)) a_m)
    (- 0.0 (* 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 ((z * t) <= 4e+302) {
		tmp = ((x * y) - (z * t)) / a_m;
	} else {
		tmp = 0.0 - (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 ((z * t) <= 4d+302) then
        tmp = ((x * y) - (z * t)) / a_m
    else
        tmp = 0.0d0 - (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 ((z * t) <= 4e+302) {
		tmp = ((x * y) - (z * t)) / a_m;
	} else {
		tmp = 0.0 - (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 (z * t) <= 4e+302:
		tmp = ((x * y) - (z * t)) / a_m
	else:
		tmp = 0.0 - (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 (Float64(z * t) <= 4e+302)
		tmp = Float64(Float64(Float64(x * y) - Float64(z * t)) / a_m);
	else
		tmp = Float64(0.0 - 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 ((z * t) <= 4e+302)
		tmp = ((x * y) - (z * t)) / a_m;
	else
		tmp = 0.0 - (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[N[(z * t), $MachinePrecision], 4e+302], N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a$95$m), $MachinePrecision], N[(0.0 - 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}\;z \cdot t \leq 4 \cdot 10^{+302}:\\
\;\;\;\;\frac{x \cdot y - z \cdot t}{a\_m}\\

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


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

    1. Initial program 94.5%

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

    if 4.0000000000000003e302 < (*.f64 z t)

    1. Initial program 65.6%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{t \cdot z}{a}} \]
    4. Step-by-step derivation
      1. +-lft-identityN/A

        \[\leadsto \color{blue}{0 + -1 \cdot \frac{t \cdot z}{a}} \]
      2. +-commutativeN/A

        \[\leadsto \color{blue}{-1 \cdot \frac{t \cdot z}{a} + 0} \]
      3. mul-1-negN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\frac{t \cdot z}{a}\right)\right)} + 0 \]
      4. associate-/l*N/A

        \[\leadsto \left(\mathsf{neg}\left(\color{blue}{t \cdot \frac{z}{a}}\right)\right) + 0 \]
      5. distribute-rgt-neg-inN/A

        \[\leadsto \color{blue}{t \cdot \left(\mathsf{neg}\left(\frac{z}{a}\right)\right)} + 0 \]
      6. mul-1-negN/A

        \[\leadsto t \cdot \color{blue}{\left(-1 \cdot \frac{z}{a}\right)} + 0 \]
      7. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(t, -1 \cdot \frac{z}{a}, 0\right)} \]
      8. mul-1-negN/A

        \[\leadsto \mathsf{fma}\left(t, \color{blue}{\mathsf{neg}\left(\frac{z}{a}\right)}, 0\right) \]
      9. neg-sub0N/A

        \[\leadsto \mathsf{fma}\left(t, \color{blue}{0 - \frac{z}{a}}, 0\right) \]
      10. --lowering--.f64N/A

        \[\leadsto \mathsf{fma}\left(t, \color{blue}{0 - \frac{z}{a}}, 0\right) \]
      11. /-lowering-/.f6496.0

        \[\leadsto \mathsf{fma}\left(t, 0 - \color{blue}{\frac{z}{a}}, 0\right) \]
    5. Simplified96.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(t, 0 - \frac{z}{a}, 0\right)} \]
    6. Step-by-step derivation
      1. +-rgt-identityN/A

        \[\leadsto \color{blue}{t \cdot \left(0 - \frac{z}{a}\right)} \]
      2. sub0-negN/A

        \[\leadsto t \cdot \color{blue}{\left(\mathsf{neg}\left(\frac{z}{a}\right)\right)} \]
      3. distribute-rgt-neg-outN/A

        \[\leadsto \color{blue}{\mathsf{neg}\left(t \cdot \frac{z}{a}\right)} \]
      4. div-invN/A

        \[\leadsto \mathsf{neg}\left(t \cdot \color{blue}{\left(z \cdot \frac{1}{a}\right)}\right) \]
      5. associate-*l*N/A

        \[\leadsto \mathsf{neg}\left(\color{blue}{\left(t \cdot z\right) \cdot \frac{1}{a}}\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{neg}\left(\color{blue}{\left(z \cdot t\right)} \cdot \frac{1}{a}\right) \]
      7. div-invN/A

        \[\leadsto \mathsf{neg}\left(\color{blue}{\frac{z \cdot t}{a}}\right) \]
      8. associate-/l*N/A

        \[\leadsto \mathsf{neg}\left(\color{blue}{z \cdot \frac{t}{a}}\right) \]
      9. distribute-rgt-neg-inN/A

        \[\leadsto \color{blue}{z \cdot \left(\mathsf{neg}\left(\frac{t}{a}\right)\right)} \]
      10. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{z \cdot \left(\mathsf{neg}\left(\frac{t}{a}\right)\right)} \]
      11. neg-lowering-neg.f64N/A

        \[\leadsto z \cdot \color{blue}{\left(\mathsf{neg}\left(\frac{t}{a}\right)\right)} \]
      12. /-lowering-/.f6495.8

        \[\leadsto z \cdot \left(-\color{blue}{\frac{t}{a}}\right) \]
    7. Applied egg-rr95.8%

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

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

Alternative 5: 52.3% accurate, 1.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}\;t \leq 2.2 \cdot 10^{+30}:\\ \;\;\;\;x \cdot \frac{y}{a\_m}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{a\_m}\\ \end{array} \end{array} \]
a\_m = (fabs.f64 a)
a\_s = (copysign.f64 #s(literal 1 binary64) 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 2.2e+30) (* x (/ y a_m)) (* y (/ x 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 <= 2.2e+30) {
		tmp = x * (y / a_m);
	} else {
		tmp = y * (x / 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 <= 2.2d+30) then
        tmp = x * (y / a_m)
    else
        tmp = y * (x / 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 <= 2.2e+30) {
		tmp = x * (y / a_m);
	} else {
		tmp = y * (x / 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 <= 2.2e+30:
		tmp = x * (y / a_m)
	else:
		tmp = y * (x / 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 <= 2.2e+30)
		tmp = Float64(x * Float64(y / a_m));
	else
		tmp = Float64(y * Float64(x / 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 <= 2.2e+30)
		tmp = x * (y / a_m);
	else
		tmp = y * (x / 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, 2.2e+30], N[(x * N[(y / a$95$m), $MachinePrecision]), $MachinePrecision], N[(y * N[(x / 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 2.2 \cdot 10^{+30}:\\
\;\;\;\;x \cdot \frac{y}{a\_m}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < 2.2e30

    1. Initial program 92.4%

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{a}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot y}{a}} \]
      2. +-rgt-identityN/A

        \[\leadsto \frac{\color{blue}{x \cdot y + 0}}{a} \]
      3. accelerator-lowering-fma.f6451.9

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(x, y, 0\right)}}{a} \]
    5. Simplified51.9%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x, y, 0\right)}{a}} \]
    6. Step-by-step derivation
      1. +-rgt-identityN/A

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

        \[\leadsto \color{blue}{x \cdot \frac{y}{a}} \]
      3. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{x \cdot \frac{y}{a}} \]
      4. /-lowering-/.f6455.3

        \[\leadsto x \cdot \color{blue}{\frac{y}{a}} \]
    7. Applied egg-rr55.3%

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

    if 2.2e30 < t

    1. Initial program 89.0%

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{a}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot y}{a}} \]
      2. +-rgt-identityN/A

        \[\leadsto \frac{\color{blue}{x \cdot y + 0}}{a} \]
      3. accelerator-lowering-fma.f6437.3

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(x, y, 0\right)}}{a} \]
    5. Simplified37.3%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x, y, 0\right)}{a}} \]
    6. Step-by-step derivation
      1. +-rgt-identityN/A

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

        \[\leadsto \color{blue}{\frac{x}{a} \cdot y} \]
      3. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{\frac{x}{a} \cdot y} \]
      4. /-lowering-/.f6439.5

        \[\leadsto \color{blue}{\frac{x}{a}} \cdot y \]
    7. Applied egg-rr39.5%

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

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

Alternative 6: 52.4% accurate, 1.5× 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 #s(literal 1 binary64) 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 91.7%

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

    \[\leadsto \color{blue}{\frac{x \cdot y}{a}} \]
  4. Step-by-step derivation
    1. /-lowering-/.f64N/A

      \[\leadsto \color{blue}{\frac{x \cdot y}{a}} \]
    2. +-rgt-identityN/A

      \[\leadsto \frac{\color{blue}{x \cdot y + 0}}{a} \]
    3. accelerator-lowering-fma.f6448.9

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(x, y, 0\right)}}{a} \]
  5. Simplified48.9%

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x, y, 0\right)}{a}} \]
  6. Step-by-step derivation
    1. +-rgt-identityN/A

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

      \[\leadsto \color{blue}{x \cdot \frac{y}{a}} \]
    3. *-lowering-*.f64N/A

      \[\leadsto \color{blue}{x \cdot \frac{y}{a}} \]
    4. /-lowering-/.f6451.7

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

    \[\leadsto \color{blue}{x \cdot \frac{y}{a}} \]
  8. Add Preprocessing

Developer Target 1: 92.0% accurate, 0.5× 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 2024195 
(FPCore (x y z t a)
  :name "Data.Colour.Matrix:inverse from colour-2.3.3, B"
  :precision binary64

  :alt
  (! :herbie-platform default (if (< z -246868496869954800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (- (* (/ y a) x) (* (/ t a) z)) (if (< z 6309831121978371/100000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (/ (- (* x y) (* z t)) a) (- (* (/ y a) x) (* (/ t a) z)))))

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