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

Percentage Accurate: 91.1% → 93.9%
Time: 10.7s
Alternatives: 9
Speedup: 1.0×

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 9 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.1% 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: 93.9% accurate, 0.4× speedup?

\[\begin{array}{l} [x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\ \\ \begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \leq 4 \cdot 10^{+191}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-z, t, x \cdot y\right)}{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.
(FPCore (x y z t a)
 :precision binary64
 (if (<= (- (* x y) (* z t)) 4e+191)
   (/ (fma (- z) t (* x y)) a)
   (fma (- t) (/ z a) (/ y (/ a x)))))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if (((x * y) - (z * t)) <= 4e+191) {
		tmp = fma(-z, t, (x * y)) / a;
	} else {
		tmp = fma(-t, (z / a), (y / (a / x)));
	}
	return tmp;
}
x, y, z, t, a = sort([x, y, z, t, a])
function code(x, y, z, t, a)
	tmp = 0.0
	if (Float64(Float64(x * y) - Float64(z * t)) <= 4e+191)
		tmp = Float64(fma(Float64(-z), t, Float64(x * y)) / 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.
code[x_, y_, z_, t_, a_] := If[LessEqual[N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision], 4e+191], N[(N[((-z) * t + N[(x * y), $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])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y - z \cdot t \leq 4 \cdot 10^{+191}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-z, t, x \cdot y\right)}{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 (-.f64 (*.f64 x y) (*.f64 z t)) < 4.00000000000000029e191

    1. Initial program 96.5%

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

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

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

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

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

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

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

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

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

    if 4.00000000000000029e191 < (-.f64 (*.f64 x y) (*.f64 z t))

    1. Initial program 77.1%

      \[\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-/.f6490.7

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

      \[\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-/.f6492.4

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

      \[\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 2: 92.5% accurate, 0.5× speedup?

\[\begin{array}{l} [x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\ \\ \begin{array}{l} \mathbf{if}\;z \cdot t \leq -4 \cdot 10^{+161}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{a}, y, z \cdot \left(t \cdot \frac{-1}{a}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-z, t, x \cdot y\right)}{a}\\ \end{array} \end{array} \]
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) -4e+161)
   (fma (/ x a) y (* z (* t (/ -1.0 a))))
   (/ (fma (- z) t (* x y)) 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) <= -4e+161) {
		tmp = fma((x / a), y, (z * (t * (-1.0 / a))));
	} else {
		tmp = fma(-z, t, (x * y)) / a;
	}
	return tmp;
}
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) <= -4e+161)
		tmp = fma(Float64(x / a), y, Float64(z * Float64(t * Float64(-1.0 / a))));
	else
		tmp = Float64(fma(Float64(-z), t, Float64(x * y)) / a);
	end
	return tmp
end
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], -4e+161], N[(N[(x / a), $MachinePrecision] * y + N[(z * N[(t * N[(-1.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-z) * t + N[(x * y), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -4 \cdot 10^{+161}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{a}, y, z \cdot \left(t \cdot \frac{-1}{a}\right)\right)\\

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


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

    1. Initial program 72.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-/.f6469.9

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

      \[\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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.0000000000000002e161 < (*.f64 z t)

    1. Initial program 95.8%

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

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

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

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

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

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

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

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

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

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

Alternative 3: 92.5% accurate, 0.5× speedup?

\[\begin{array}{l} [x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\ \\ \begin{array}{l} \mathbf{if}\;z \cdot t \leq -4 \cdot 10^{+161}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{a}, y, -z \cdot \frac{t}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-z, t, x \cdot y\right)}{a}\\ \end{array} \end{array} \]
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) -4e+161)
   (fma (/ x a) y (- (* z (/ t a))))
   (/ (fma (- z) t (* x y)) 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) <= -4e+161) {
		tmp = fma((x / a), y, -(z * (t / a)));
	} else {
		tmp = fma(-z, t, (x * y)) / a;
	}
	return tmp;
}
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) <= -4e+161)
		tmp = fma(Float64(x / a), y, Float64(-Float64(z * Float64(t / a))));
	else
		tmp = Float64(fma(Float64(-z), t, Float64(x * y)) / a);
	end
	return tmp
end
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], -4e+161], N[(N[(x / a), $MachinePrecision] * y + (-N[(z * N[(t / a), $MachinePrecision]), $MachinePrecision])), $MachinePrecision], N[(N[((-z) * t + N[(x * y), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -4 \cdot 10^{+161}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{a}, y, -z \cdot \frac{t}{a}\right)\\

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


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

    1. Initial program 72.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-/.f6469.9

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

      \[\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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.0000000000000002e161 < (*.f64 z t)

    1. Initial program 95.8%

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

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

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

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

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

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

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

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

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

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

Alternative 4: 92.7% accurate, 0.5× speedup?

\[\begin{array}{l} [x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\ \\ \begin{array}{l} \mathbf{if}\;z \cdot t \leq -\infty:\\ \;\;\;\;\mathsf{fma}\left(-t, \frac{z}{a}, \frac{x \cdot y}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-z, t, x \cdot y\right)}{a}\\ \end{array} \end{array} \]
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) (- INFINITY))
   (fma (- t) (/ z a) (/ (* x y) a))
   (/ (fma (- z) t (* x y)) 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) <= -((double) INFINITY)) {
		tmp = fma(-t, (z / a), ((x * y) / a));
	} else {
		tmp = fma(-z, t, (x * y)) / a;
	}
	return tmp;
}
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) <= Float64(-Inf))
		tmp = fma(Float64(-t), Float64(z / a), Float64(Float64(x * y) / a));
	else
		tmp = Float64(fma(Float64(-z), t, Float64(x * y)) / a);
	end
	return tmp
end
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], (-Infinity)], N[((-t) * N[(z / a), $MachinePrecision] + N[(N[(x * y), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[((-z) * t + N[(x * y), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(-t, \frac{z}{a}, \frac{x \cdot y}{a}\right)\\

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


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

    1. Initial program 55.7%

      \[\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-/.f6494.4

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

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

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

    1. Initial program 95.3%

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

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

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

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

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

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

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

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

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

Alternative 5: 91.7% accurate, 0.6× speedup?

\[\begin{array}{l} [x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\ \\ \begin{array}{l} \mathbf{if}\;a \leq 8.2 \cdot 10^{-111}:\\ \;\;\;\;\frac{1}{\frac{a}{\mathsf{fma}\left(-z, t, x \cdot y\right)}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-z, \frac{t}{a}, \frac{x \cdot y}{a}\right)\\ \end{array} \end{array} \]
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 8.2e-111)
   (/ 1.0 (/ a (fma (- z) t (* x y))))
   (fma (- z) (/ t a) (/ (* x y) 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 <= 8.2e-111) {
		tmp = 1.0 / (a / fma(-z, t, (x * y)));
	} else {
		tmp = fma(-z, (t / a), ((x * y) / a));
	}
	return tmp;
}
x, y, z, t, a = sort([x, y, z, t, a])
function code(x, y, z, t, a)
	tmp = 0.0
	if (a <= 8.2e-111)
		tmp = Float64(1.0 / Float64(a / fma(Float64(-z), t, Float64(x * y))));
	else
		tmp = fma(Float64(-z), Float64(t / a), Float64(Float64(x * y) / a));
	end
	return tmp
end
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, 8.2e-111], N[(1.0 / N[(a / N[((-z) * t + N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-z) * N[(t / a), $MachinePrecision] + N[(N[(x * y), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq 8.2 \cdot 10^{-111}:\\
\;\;\;\;\frac{1}{\frac{a}{\mathsf{fma}\left(-z, t, x \cdot y\right)}}\\

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


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

    1. Initial program 93.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 8.19999999999999936e-111 < a

    1. Initial program 91.1%

      \[\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. associate-/l*N/A

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

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

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

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

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

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

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

Alternative 6: 72.6% accurate, 0.6× speedup?

\[\begin{array}{l} [x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\ \\ \begin{array}{l} t_1 := \frac{x \cdot y}{a}\\ \mathbf{if}\;x \cdot y \leq -8.8 \cdot 10^{-13}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \cdot y \leq 0.0019:\\ \;\;\;\;\frac{z \cdot \left(-t\right)}{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.
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (/ (* x y) a)))
   (if (<= (* x y) -8.8e-13)
     t_1
     (if (<= (* x y) 0.0019) (/ (* z (- t)) a) t_1))))
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) / a;
	double tmp;
	if ((x * y) <= -8.8e-13) {
		tmp = t_1;
	} else if ((x * y) <= 0.0019) {
		tmp = (z * -t) / a;
	} else {
		tmp = t_1;
	}
	return tmp;
}
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 = (x * y) / a
    if ((x * y) <= (-8.8d-13)) then
        tmp = t_1
    else if ((x * y) <= 0.0019d0) then
        tmp = (z * -t) / a
    else
        tmp = t_1
    end if
    code = tmp
end function
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 = (x * y) / a;
	double tmp;
	if ((x * y) <= -8.8e-13) {
		tmp = t_1;
	} else if ((x * y) <= 0.0019) {
		tmp = (z * -t) / a;
	} else {
		tmp = t_1;
	}
	return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a])
def code(x, y, z, t, a):
	t_1 = (x * y) / a
	tmp = 0
	if (x * y) <= -8.8e-13:
		tmp = t_1
	elif (x * y) <= 0.0019:
		tmp = (z * -t) / a
	else:
		tmp = t_1
	return tmp
x, y, z, t, a = sort([x, y, z, t, a])
function code(x, y, z, t, a)
	t_1 = Float64(Float64(x * y) / a)
	tmp = 0.0
	if (Float64(x * y) <= -8.8e-13)
		tmp = t_1;
	elseif (Float64(x * y) <= 0.0019)
		tmp = Float64(Float64(z * Float64(-t)) / a);
	else
		tmp = t_1;
	end
	return tmp
end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp_2 = code(x, y, z, t, a)
	t_1 = (x * y) / a;
	tmp = 0.0;
	if ((x * y) <= -8.8e-13)
		tmp = t_1;
	elseif ((x * y) <= 0.0019)
		tmp = (z * -t) / 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.
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(x * y), $MachinePrecision] / a), $MachinePrecision]}, If[LessEqual[N[(x * y), $MachinePrecision], -8.8e-13], t$95$1, If[LessEqual[N[(x * y), $MachinePrecision], 0.0019], N[(N[(z * (-t)), $MachinePrecision] / a), $MachinePrecision], t$95$1]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
t_1 := \frac{x \cdot y}{a}\\
\mathbf{if}\;x \cdot y \leq -8.8 \cdot 10^{-13}:\\
\;\;\;\;t\_1\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x y) < -8.79999999999999986e-13 or 0.0019 < (*.f64 x y)

    1. Initial program 90.5%

      \[\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-*.f6479.8

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

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

    if -8.79999999999999986e-13 < (*.f64 x y) < 0.0019

    1. Initial program 94.4%

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

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

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

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

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

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

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

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

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

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

Alternative 7: 91.4% accurate, 1.0× speedup?

\[\begin{array}{l} [x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\ \\ \frac{\mathsf{fma}\left(-z, t, x \cdot y\right)}{a} \end{array} \]
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 (/ (fma (- z) t (* x y)) a))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
	return fma(-z, t, (x * y)) / a;
}
x, y, z, t, a = sort([x, y, z, t, a])
function code(x, y, z, t, a)
	return Float64(fma(Float64(-z), t, Float64(x * y)) / a)
end
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[((-z) * t + N[(x * y), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\frac{\mathsf{fma}\left(-z, t, x \cdot y\right)}{a}
\end{array}
Derivation
  1. Initial program 92.4%

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

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

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

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

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

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

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

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

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

Alternative 8: 91.1% accurate, 1.0× speedup?

\[\begin{array}{l} [x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\ \\ \frac{x \cdot y - z \cdot t}{a} \end{array} \]
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) (* z 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) - (z * t)) / a;
}
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) - (z * t)) / a
end function
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) - (z * t)) / a;
}
[x, y, z, t, a] = sort([x, y, z, t, a])
def code(x, y, z, t, a):
	return ((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(Float64(x * y) - Float64(z * t)) / a)
end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp = code(x, y, z, t, a)
	tmp = ((x * y) - (z * t)) / a;
end
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[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\frac{x \cdot y - z \cdot t}{a}
\end{array}
Derivation
  1. Initial program 92.4%

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

Alternative 9: 50.5% accurate, 1.5× speedup?

\[\begin{array}{l} [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.
(FPCore (x y z t a) :precision binary64 (/ (* x y) 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.
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;
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])
def code(x, y, z, t, a):
	return (x * y) / 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])){:}
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.
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])\\
\\
\frac{x \cdot y}{a}
\end{array}
Derivation
  1. Initial program 92.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-*.f6458.0

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

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

Developer Target 1: 91.1% 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 2024233 
(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))