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

Percentage Accurate: 91.6% → 94.4%
Time: 6.5s
Alternatives: 10
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 10 alternatives:

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

Initial Program: 91.6% accurate, 1.0× speedup?

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

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

Alternative 1: 94.4% accurate, 0.1× speedup?

\[\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ \begin{array}{l} t_1 := x \cdot y - z \cdot t\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;\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.
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (- (* x y) (* z t))))
   (if (<= t_1 (- INFINITY)) (fma x (/ y a) (/ (- z) (/ a t))) (/ t_1 a))))
assert(x < y);
double code(double x, double y, double z, double t, double a) {
	double t_1 = (x * y) - (z * t);
	double tmp;
	if (t_1 <= -((double) INFINITY)) {
		tmp = fma(x, (y / a), (-z / (a / t)));
	} else {
		tmp = t_1 / a;
	}
	return tmp;
}
x, y = sort([x, y])
function code(x, y, z, t, a)
	t_1 = Float64(Float64(x * y) - Float64(z * t))
	tmp = 0.0
	if (t_1 <= Float64(-Inf))
		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.
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, (-Infinity)], 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])\\
\\
\begin{array}{l}
t_1 := x \cdot y - z \cdot t\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;\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)) < -inf.0

    1. Initial program 73.6%

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

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

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

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

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

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

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

    if -inf.0 < (-.f64 (*.f64 x y) (*.f64 z t))

    1. Initial program 97.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \leq -\infty:\\ \;\;\;\;\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 2: 73.8% accurate, 0.3× speedup?

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

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

\mathbf{elif}\;x \cdot y \leq 6.6 \cdot 10^{-23}:\\
\;\;\;\;\frac{x \cdot y}{a}\\

\mathbf{elif}\;x \cdot y \leq 500000000000:\\
\;\;\;\;\frac{-t}{\frac{a}{z}}\\

\mathbf{elif}\;x \cdot y \leq 10^{+32}:\\
\;\;\;\;\left(x \cdot y\right) \cdot \frac{1}{a}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 7 regimes
  2. if (*.f64 x y) < -9.9999999999999997e34

    1. Initial program 89.3%

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

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

        \[\leadsto \color{blue}{\frac{y}{\frac{a}{x}}} \]
    4. Simplified80.8%

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

    if -9.9999999999999997e34 < (*.f64 x y) < 4.99999999999999981e-81

    1. Initial program 98.2%

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

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

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

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

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

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

    if 4.99999999999999981e-81 < (*.f64 x y) < 6.60000000000000041e-23

    1. Initial program 99.7%

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

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

    if 6.60000000000000041e-23 < (*.f64 x y) < 5e11

    1. Initial program 91.9%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-t}{\frac{a}{z}}} \]
      2. distribute-frac-neg73.7%

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

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

    if 5e11 < (*.f64 x y) < 1.00000000000000005e32

    1. Initial program 99.4%

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

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

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

        \[\leadsto \color{blue}{\frac{1}{a} \cdot \left(y \cdot x\right)} \]
      3. *-commutative99.7%

        \[\leadsto \frac{1}{a} \cdot \color{blue}{\left(x \cdot y\right)} \]
    4. Applied egg-rr99.7%

      \[\leadsto \color{blue}{\frac{1}{a} \cdot \left(x \cdot y\right)} \]

    if 1.00000000000000005e32 < (*.f64 x y) < 5.0000000000000001e93

    1. Initial program 87.8%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{y}{a} \cdot x + -1 \cdot \frac{t \cdot z}{a}} \]
      3. mul-1-neg75.3%

        \[\leadsto \frac{y}{a} \cdot x + \color{blue}{\left(-\frac{t \cdot z}{a}\right)} \]
      4. associate-*r/87.3%

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

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

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

        \[\leadsto \color{blue}{\frac{y \cdot x}{a}} - t \cdot \frac{z}{a} \]
      8. associate-*r/99.8%

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

      \[\leadsto \color{blue}{y \cdot \frac{x}{a} - t \cdot \frac{z}{a}} \]
    7. Taylor expanded in y around 0 87.8%

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

        \[\leadsto \color{blue}{-\frac{t \cdot z}{a}} \]
      2. *-commutative87.8%

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

        \[\leadsto -\color{blue}{\frac{z}{\frac{a}{t}}} \]
    9. Simplified88.0%

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

    if 5.0000000000000001e93 < (*.f64 x y)

    1. Initial program 89.9%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \leq -1 \cdot 10^{+35}:\\ \;\;\;\;\frac{y}{\frac{a}{x}}\\ \mathbf{elif}\;x \cdot y \leq 5 \cdot 10^{-81}:\\ \;\;\;\;\frac{z \cdot \left(-t\right)}{a}\\ \mathbf{elif}\;x \cdot y \leq 6.6 \cdot 10^{-23}:\\ \;\;\;\;\frac{x \cdot y}{a}\\ \mathbf{elif}\;x \cdot y \leq 500000000000:\\ \;\;\;\;\frac{-t}{\frac{a}{z}}\\ \mathbf{elif}\;x \cdot y \leq 10^{+32}:\\ \;\;\;\;\left(x \cdot y\right) \cdot \frac{1}{a}\\ \mathbf{elif}\;x \cdot y \leq 5 \cdot 10^{+93}:\\ \;\;\;\;\frac{-z}{\frac{a}{t}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{a}\\ \end{array} \]

Alternative 3: 94.1% accurate, 0.5× speedup?

\[\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ \begin{array}{l} t_1 := x \cdot y - z \cdot t\\ \mathbf{if}\;t_1 \leq -1.5 \cdot 10^{+267}:\\ \;\;\;\;\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.
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (- (* x y) (* z t))))
   (if (<= t_1 -1.5e+267) (- (/ x (/ a y)) (/ z (/ a t))) (/ t_1 a))))
assert(x < y);
double code(double x, double y, double z, double t, double a) {
	double t_1 = (x * y) - (z * t);
	double tmp;
	if (t_1 <= -1.5e+267) {
		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.
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 <= (-1.5d+267)) then
        tmp = (x / (a / y)) - (z / (a / t))
    else
        tmp = t_1 / a
    end if
    code = tmp
end function
assert x < y;
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 <= -1.5e+267) {
		tmp = (x / (a / y)) - (z / (a / t));
	} else {
		tmp = t_1 / a;
	}
	return tmp;
}
[x, y] = sort([x, y])
def code(x, y, z, t, a):
	t_1 = (x * y) - (z * t)
	tmp = 0
	if t_1 <= -1.5e+267:
		tmp = (x / (a / y)) - (z / (a / t))
	else:
		tmp = t_1 / a
	return tmp
x, y = sort([x, y])
function code(x, y, z, t, a)
	t_1 = Float64(Float64(x * y) - Float64(z * t))
	tmp = 0.0
	if (t_1 <= -1.5e+267)
		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])){:}
function tmp_2 = code(x, y, z, t, a)
	t_1 = (x * y) - (z * t);
	tmp = 0.0;
	if (t_1 <= -1.5e+267)
		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.
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, -1.5e+267], 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])\\
\\
\begin{array}{l}
t_1 := x \cdot y - z \cdot t\\
\mathbf{if}\;t_1 \leq -1.5 \cdot 10^{+267}:\\
\;\;\;\;\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)) < -1.5e267

    1. Initial program 76.8%

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

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

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

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

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

    if -1.5e267 < (-.f64 (*.f64 x y) (*.f64 z t))

    1. Initial program 97.5%

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

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

Alternative 4: 93.3% accurate, 0.7× speedup?

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

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


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

    1. Initial program 96.1%

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

    if 1e262 < (*.f64 z t)

    1. Initial program 76.2%

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

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

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

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

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

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

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

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

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

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

Alternative 5: 93.3% accurate, 0.7× speedup?

\[\begin{array}{l} [x, y] = \mathsf{sort}([x, y])\\ \\ \begin{array}{l} \mathbf{if}\;a \leq -11000000000000:\\ \;\;\;\;y \cdot \frac{x}{a} - t \cdot \frac{z}{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.
(FPCore (x y z t a)
 :precision binary64
 (if (<= a -11000000000000.0)
   (- (* y (/ x a)) (* t (/ z a)))
   (/ (- (* x y) (* z t)) a)))
assert(x < y);
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if (a <= -11000000000000.0) {
		tmp = (y * (x / a)) - (t * (z / a));
	} else {
		tmp = ((x * y) - (z * t)) / a;
	}
	return tmp;
}
NOTE: x and y 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 (a <= (-11000000000000.0d0)) then
        tmp = (y * (x / a)) - (t * (z / a))
    else
        tmp = ((x * y) - (z * t)) / a
    end if
    code = tmp
end function
assert x < y;
public static double code(double x, double y, double z, double t, double a) {
	double tmp;
	if (a <= -11000000000000.0) {
		tmp = (y * (x / a)) - (t * (z / a));
	} else {
		tmp = ((x * y) - (z * t)) / a;
	}
	return tmp;
}
[x, y] = sort([x, y])
def code(x, y, z, t, a):
	tmp = 0
	if a <= -11000000000000.0:
		tmp = (y * (x / a)) - (t * (z / a))
	else:
		tmp = ((x * y) - (z * t)) / a
	return tmp
x, y = sort([x, y])
function code(x, y, z, t, a)
	tmp = 0.0
	if (a <= -11000000000000.0)
		tmp = Float64(Float64(y * Float64(x / a)) - Float64(t * Float64(z / a)));
	else
		tmp = Float64(Float64(Float64(x * y) - Float64(z * t)) / a);
	end
	return tmp
end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z, t, a)
	tmp = 0.0;
	if (a <= -11000000000000.0)
		tmp = (y * (x / a)) - (t * (z / 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.
code[x_, y_, z_, t_, a_] := If[LessEqual[a, -11000000000000.0], N[(N[(y * N[(x / a), $MachinePrecision]), $MachinePrecision] - N[(t * N[(z / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -11000000000000:\\
\;\;\;\;y \cdot \frac{x}{a} - t \cdot \frac{z}{a}\\

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


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

    1. Initial program 86.6%

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

        \[\leadsto \color{blue}{\left(x \cdot y - z \cdot t\right) \cdot \frac{1}{a}} \]
      2. fma-neg86.5%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{y}{a} \cdot x + -1 \cdot \frac{t \cdot z}{a}} \]
      3. mul-1-neg93.2%

        \[\leadsto \frac{y}{a} \cdot x + \color{blue}{\left(-\frac{t \cdot z}{a}\right)} \]
      4. associate-*r/93.2%

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

        \[\leadsto \frac{y}{a} \cdot x + \color{blue}{\left(-t\right) \cdot \frac{z}{a}} \]
      6. cancel-sign-sub-inv93.2%

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

        \[\leadsto \color{blue}{\frac{y \cdot x}{a}} - t \cdot \frac{z}{a} \]
      8. associate-*r/95.4%

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

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

    if -1.1e13 < a

    1. Initial program 96.9%

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

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

Alternative 6: 65.5% accurate, 0.9× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -3.15e13 or 6.00000000000000017e-127 < z

    1. Initial program 92.9%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-t}{\frac{a}{z}}} \]
      2. distribute-frac-neg64.0%

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

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

    if -3.15e13 < z < 6.00000000000000017e-127

    1. Initial program 96.7%

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

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

        \[\leadsto \color{blue}{\frac{y}{\frac{a}{x}}} \]
    4. Simplified72.5%

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

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

Alternative 7: 65.6% accurate, 0.9× speedup?

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

\mathbf{elif}\;z \leq 6 \cdot 10^{-127}:\\
\;\;\;\;\frac{y}{\frac{a}{x}}\\

\mathbf{else}:\\
\;\;\;\;\frac{z}{a} \cdot \left(-t\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -5.2e16

    1. Initial program 95.3%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-t}{\frac{a}{z}}} \]
      2. distribute-frac-neg68.5%

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

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

    if -5.2e16 < z < 6.00000000000000017e-127

    1. Initial program 96.7%

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

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

        \[\leadsto \color{blue}{\frac{y}{\frac{a}{x}}} \]
    4. Simplified72.5%

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

    if 6.00000000000000017e-127 < z

    1. Initial program 91.4%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -5.2 \cdot 10^{+16}:\\ \;\;\;\;\frac{-t}{\frac{a}{z}}\\ \mathbf{elif}\;z \leq 6 \cdot 10^{-127}:\\ \;\;\;\;\frac{y}{\frac{a}{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{a} \cdot \left(-t\right)\\ \end{array} \]

Alternative 8: 64.3% accurate, 0.9× speedup?

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

\mathbf{elif}\;z \leq 4.2 \cdot 10^{-127}:\\
\;\;\;\;\frac{y}{\frac{a}{x}}\\

\mathbf{else}:\\
\;\;\;\;\frac{z}{a} \cdot \left(-t\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.48e26

    1. Initial program 95.1%

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

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

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

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

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

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

    if -1.48e26 < z < 4.2000000000000002e-127

    1. Initial program 96.8%

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

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

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

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

    if 4.2000000000000002e-127 < z

    1. Initial program 91.4%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.48 \cdot 10^{+26}:\\ \;\;\;\;\frac{z \cdot \left(-t\right)}{a}\\ \mathbf{elif}\;z \leq 4.2 \cdot 10^{-127}:\\ \;\;\;\;\frac{y}{\frac{a}{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{a} \cdot \left(-t\right)\\ \end{array} \]

Alternative 9: 52.0% accurate, 1.8× speedup?

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

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

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

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

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

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

Alternative 10: 52.1% accurate, 1.8× speedup?

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

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

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

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

    \[\leadsto \color{blue}{\frac{y}{\frac{a}{x}}} \]
  5. Final simplification50.4%

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

Developer target: 91.0% 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 2023230 
(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))