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

Percentage Accurate: 91.2% → 97.1%
Time: 11.6s
Alternatives: 7
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 7 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: 97.1% accurate, 0.3× speedup?

\[\begin{array}{l} [x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\\\ [x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\ \\ \begin{array}{l} t_1 := x \cdot y - z \cdot t\\ \mathbf{if}\;t\_1 \leq -2 \cdot 10^{+226}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{a}, y, z \cdot \left(t \cdot \frac{-1}{a}\right)\right)\\ \mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+303}:\\ \;\;\;\;\frac{t\_1}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{a}, y, z \cdot \frac{t}{-a}\right)\\ \end{array} \end{array} \]
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, and a 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 -2e+226)
     (fma (/ x a) y (* z (* t (/ -1.0 a))))
     (if (<= t_1 4e+303) (/ t_1 a) (fma (/ x a) y (* z (/ t (- a))))))))
assert(x < y && y < z && z < t && t < a);
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
	double t_1 = (x * y) - (z * t);
	double tmp;
	if (t_1 <= -2e+226) {
		tmp = fma((x / a), y, (z * (t * (-1.0 / a))));
	} else if (t_1 <= 4e+303) {
		tmp = t_1 / a;
	} else {
		tmp = fma((x / a), y, (z * (t / -a)));
	}
	return tmp;
}
x, y, z, t, a = sort([x, y, z, t, a])
x, y, z, t, a = sort([x, y, z, t, a])
function code(x, y, z, t, a)
	t_1 = Float64(Float64(x * y) - Float64(z * t))
	tmp = 0.0
	if (t_1 <= -2e+226)
		tmp = fma(Float64(x / a), y, Float64(z * Float64(t * Float64(-1.0 / a))));
	elseif (t_1 <= 4e+303)
		tmp = Float64(t_1 / a);
	else
		tmp = fma(Float64(x / a), y, Float64(z * Float64(t / Float64(-a))));
	end
	return tmp
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, and a 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, -2e+226], N[(N[(x / a), $MachinePrecision] * y + N[(z * N[(t * N[(-1.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 4e+303], N[(t$95$1 / a), $MachinePrecision], N[(N[(x / a), $MachinePrecision] * y + N[(z * N[(t / (-a)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\\\
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
t_1 := x \cdot y - z \cdot t\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+226}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{a}, y, z \cdot \left(t \cdot \frac{-1}{a}\right)\right)\\

\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+303}:\\
\;\;\;\;\frac{t\_1}{a}\\

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


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

    1. Initial program 70.3%

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

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

        \[\leadsto \frac{\color{blue}{x \cdot y - z \cdot t}}{a} \]
      3. div-subN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{x}{a}, y, \color{blue}{z \cdot \left(\frac{1}{a} \cdot \left(\mathsf{neg}\left(t\right)\right)\right)}\right) \]
      12. lower-*.f6492.0

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

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

    if -1.99999999999999992e226 < (-.f64 (*.f64 x y) (*.f64 z t)) < 4e303

    1. Initial program 98.1%

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

    if 4e303 < (-.f64 (*.f64 x y) (*.f64 z t))

    1. Initial program 62.6%

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

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

        \[\leadsto \frac{\color{blue}{x \cdot y - z \cdot t}}{a} \]
      3. div-subN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 97.1% accurate, 0.3× speedup?

\[\begin{array}{l} [x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\\\ [x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\ \\ \begin{array}{l} t_1 := x \cdot y - z \cdot t\\ t_2 := \mathsf{fma}\left(\frac{x}{a}, y, z \cdot \frac{t}{-a}\right)\\ \mathbf{if}\;t\_1 \leq -2 \cdot 10^{+226}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+303}:\\ \;\;\;\;\frac{t\_1}{a}\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, and a 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))) (t_2 (fma (/ x a) y (* z (/ t (- a))))))
   (if (<= t_1 -2e+226) t_2 (if (<= t_1 4e+303) (/ t_1 a) t_2))))
assert(x < y && y < z && z < t && t < a);
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
	double t_1 = (x * y) - (z * t);
	double t_2 = fma((x / a), y, (z * (t / -a)));
	double tmp;
	if (t_1 <= -2e+226) {
		tmp = t_2;
	} else if (t_1 <= 4e+303) {
		tmp = t_1 / a;
	} else {
		tmp = t_2;
	}
	return tmp;
}
x, y, z, t, a = sort([x, y, z, t, a])
x, y, z, t, a = sort([x, y, z, t, a])
function code(x, y, z, t, a)
	t_1 = Float64(Float64(x * y) - Float64(z * t))
	t_2 = fma(Float64(x / a), y, Float64(z * Float64(t / Float64(-a))))
	tmp = 0.0
	if (t_1 <= -2e+226)
		tmp = t_2;
	elseif (t_1 <= 4e+303)
		tmp = Float64(t_1 / a);
	else
		tmp = t_2;
	end
	return tmp
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, and a 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]}, Block[{t$95$2 = N[(N[(x / a), $MachinePrecision] * y + N[(z * N[(t / (-a)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e+226], t$95$2, If[LessEqual[t$95$1, 4e+303], N[(t$95$1 / a), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\\\
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
t_1 := x \cdot y - z \cdot t\\
t_2 := \mathsf{fma}\left(\frac{x}{a}, y, z \cdot \frac{t}{-a}\right)\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+226}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+303}:\\
\;\;\;\;\frac{t\_1}{a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (*.f64 x y) (*.f64 z t)) < -1.99999999999999992e226 or 4e303 < (-.f64 (*.f64 x y) (*.f64 z t))

    1. Initial program 67.9%

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

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

        \[\leadsto \frac{\color{blue}{x \cdot y - z \cdot t}}{a} \]
      3. div-subN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.99999999999999992e226 < (-.f64 (*.f64 x y) (*.f64 z t)) < 4e303

    1. Initial program 98.1%

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

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

Alternative 3: 93.1% accurate, 0.5× speedup?

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

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


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

    1. Initial program 90.6%

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

    if 2.59999999999999984e62 < a

    1. Initial program 83.9%

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

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

        \[\leadsto \frac{\color{blue}{x \cdot y - z \cdot t}}{a} \]
      3. div-subN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(t\right), \color{blue}{\frac{z}{a}}, \frac{x \cdot y}{a}\right) \]
      13. lower-/.f6485.9

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(t\right), \frac{z}{a}, \color{blue}{\frac{y}{\frac{a}{x}}}\right) \]
      7. lower-/.f6494.9

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

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

Alternative 4: 93.2% accurate, 0.6× speedup?

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

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


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

    1. Initial program 90.7%

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

    if 2.80000000000000004e-21 < a

    1. Initial program 84.9%

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

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

        \[\leadsto \frac{\color{blue}{x \cdot y - z \cdot t}}{a} \]
      3. div-subN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 73.6% accurate, 0.6× speedup?

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

\mathbf{elif}\;z \cdot t \leq 4 \cdot 10^{+67}:\\
\;\;\;\;\frac{x \cdot y}{a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 z t) < -1e21 or 3.99999999999999993e67 < (*.f64 z t)

    1. Initial program 88.9%

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

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

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

      \[\leadsto \frac{\color{blue}{x \cdot y}}{a} \]
    6. Taylor expanded in x around 0

      \[\leadsto \frac{\color{blue}{-1 \cdot \left(t \cdot z\right)}}{a} \]
    7. Step-by-step derivation
      1. associate-*r*N/A

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

        \[\leadsto \frac{\color{blue}{z \cdot \left(-1 \cdot t\right)}}{a} \]
      3. lower-*.f64N/A

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

        \[\leadsto \frac{z \cdot \color{blue}{\left(\mathsf{neg}\left(t\right)\right)}}{a} \]
      5. lower-neg.f6478.5

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

      \[\leadsto \frac{\color{blue}{z \cdot \left(-t\right)}}{a} \]
    9. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{z \cdot \left(\mathsf{neg}\left(t\right)\right)}{a}} \]
      2. clear-numN/A

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

        \[\leadsto \color{blue}{\frac{1}{\frac{a}{z \cdot \left(\mathsf{neg}\left(t\right)\right)}}} \]
      4. lower-/.f6478.4

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

      \[\leadsto \color{blue}{\frac{1}{\frac{a}{-z \cdot t}}} \]
    11. Taylor expanded in x around 0

      \[\leadsto \color{blue}{-1 \cdot \frac{t \cdot z}{a}} \]
    12. Step-by-step derivation
      1. mul-1-negN/A

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

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

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

        \[\leadsto t \cdot \color{blue}{\left(-1 \cdot \frac{z}{a}\right)} \]
      5. lower-*.f64N/A

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

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

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

        \[\leadsto t \cdot \frac{z}{\color{blue}{-1 \cdot a}} \]
      9. lower-/.f64N/A

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

        \[\leadsto t \cdot \frac{z}{\color{blue}{\mathsf{neg}\left(a\right)}} \]
      11. lower-neg.f6480.5

        \[\leadsto t \cdot \frac{z}{\color{blue}{-a}} \]
    13. Applied rewrites80.5%

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

    if -1e21 < (*.f64 z t) < 3.99999999999999993e67

    1. Initial program 89.7%

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

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

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

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

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

Alternative 6: 92.4% accurate, 0.7× speedup?

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

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


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

    1. Initial program 90.9%

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

    if 5.00000000000000019e200 < (*.f64 z t)

    1. Initial program 77.1%

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

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

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

      \[\leadsto \frac{\color{blue}{x \cdot y}}{a} \]
    6. Taylor expanded in x around 0

      \[\leadsto \frac{\color{blue}{-1 \cdot \left(t \cdot z\right)}}{a} \]
    7. Step-by-step derivation
      1. associate-*r*N/A

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

        \[\leadsto \frac{\color{blue}{z \cdot \left(-1 \cdot t\right)}}{a} \]
      3. lower-*.f64N/A

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

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

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

      \[\leadsto \frac{\color{blue}{z \cdot \left(-t\right)}}{a} \]
    9. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{z \cdot \left(\mathsf{neg}\left(t\right)\right)}{a}} \]
      2. clear-numN/A

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

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

        \[\leadsto \frac{1}{\color{blue}{\frac{a}{z \cdot \left(-t\right)}}} \]
    10. Applied rewrites80.6%

      \[\leadsto \color{blue}{\frac{1}{\frac{a}{-z \cdot t}}} \]
    11. Taylor expanded in x around 0

      \[\leadsto \color{blue}{-1 \cdot \frac{t \cdot z}{a}} \]
    12. Step-by-step derivation
      1. mul-1-negN/A

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

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

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

        \[\leadsto t \cdot \color{blue}{\left(-1 \cdot \frac{z}{a}\right)} \]
      5. lower-*.f64N/A

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

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

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

        \[\leadsto t \cdot \frac{z}{\color{blue}{-1 \cdot a}} \]
      9. lower-/.f64N/A

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

        \[\leadsto t \cdot \frac{z}{\color{blue}{\mathsf{neg}\left(a\right)}} \]
      11. lower-neg.f6493.4

        \[\leadsto t \cdot \frac{z}{\color{blue}{-a}} \]
    13. Applied rewrites93.4%

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

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

Alternative 7: 51.3% accurate, 1.5× speedup?

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

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

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

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

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

Developer Target 1: 91.7% 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 2024220 
(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))