Data.Colour.Matrix:determinant from colour-2.3.3, A

Percentage Accurate: 73.2% → 79.9%
Time: 17.4s
Alternatives: 19
Speedup: 0.5×

Specification

?
\[\begin{array}{l} \\ \left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right) + j \cdot \left(c \cdot a - y \cdot i\right) \end{array} \]
(FPCore (x y z t a b c i j)
 :precision binary64
 (+
  (- (* x (- (* y z) (* t a))) (* b (- (* c z) (* t i))))
  (* j (- (* c a) (* y i)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
	return ((x * ((y * z) - (t * a))) - (b * ((c * z) - (t * i)))) + (j * ((c * a) - (y * i)));
}
real(8) function code(x, y, z, t, a, b, c, i, j)
    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), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: i
    real(8), intent (in) :: j
    code = ((x * ((y * z) - (t * a))) - (b * ((c * z) - (t * i)))) + (j * ((c * a) - (y * i)))
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
	return ((x * ((y * z) - (t * a))) - (b * ((c * z) - (t * i)))) + (j * ((c * a) - (y * i)));
}
def code(x, y, z, t, a, b, c, i, j):
	return ((x * ((y * z) - (t * a))) - (b * ((c * z) - (t * i)))) + (j * ((c * a) - (y * i)))
function code(x, y, z, t, a, b, c, i, j)
	return Float64(Float64(Float64(x * Float64(Float64(y * z) - Float64(t * a))) - Float64(b * Float64(Float64(c * z) - Float64(t * i)))) + Float64(j * Float64(Float64(c * a) - Float64(y * i))))
end
function tmp = code(x, y, z, t, a, b, c, i, j)
	tmp = ((x * ((y * z) - (t * a))) - (b * ((c * z) - (t * i)))) + (j * ((c * a) - (y * i)));
end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := N[(N[(N[(x * N[(N[(y * z), $MachinePrecision] - N[(t * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(b * N[(N[(c * z), $MachinePrecision] - N[(t * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(j * N[(N[(c * a), $MachinePrecision] - N[(y * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right) + j \cdot \left(c \cdot a - y \cdot i\right)
\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 19 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: 73.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right) + j \cdot \left(c \cdot a - y \cdot i\right) \end{array} \]
(FPCore (x y z t a b c i j)
 :precision binary64
 (+
  (- (* x (- (* y z) (* t a))) (* b (- (* c z) (* t i))))
  (* j (- (* c a) (* y i)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
	return ((x * ((y * z) - (t * a))) - (b * ((c * z) - (t * i)))) + (j * ((c * a) - (y * i)));
}
real(8) function code(x, y, z, t, a, b, c, i, j)
    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), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: i
    real(8), intent (in) :: j
    code = ((x * ((y * z) - (t * a))) - (b * ((c * z) - (t * i)))) + (j * ((c * a) - (y * i)))
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
	return ((x * ((y * z) - (t * a))) - (b * ((c * z) - (t * i)))) + (j * ((c * a) - (y * i)));
}
def code(x, y, z, t, a, b, c, i, j):
	return ((x * ((y * z) - (t * a))) - (b * ((c * z) - (t * i)))) + (j * ((c * a) - (y * i)))
function code(x, y, z, t, a, b, c, i, j)
	return Float64(Float64(Float64(x * Float64(Float64(y * z) - Float64(t * a))) - Float64(b * Float64(Float64(c * z) - Float64(t * i)))) + Float64(j * Float64(Float64(c * a) - Float64(y * i))))
end
function tmp = code(x, y, z, t, a, b, c, i, j)
	tmp = ((x * ((y * z) - (t * a))) - (b * ((c * z) - (t * i)))) + (j * ((c * a) - (y * i)));
end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := N[(N[(N[(x * N[(N[(y * z), $MachinePrecision] - N[(t * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(b * N[(N[(c * z), $MachinePrecision] - N[(t * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(j * N[(N[(c * a), $MachinePrecision] - N[(y * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right) + j \cdot \left(c \cdot a - y \cdot i\right)
\end{array}

Alternative 1: 79.9% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\left(c \cdot a - i \cdot y\right) \cdot j - \left(\left(a \cdot t - z \cdot y\right) \cdot x - \left(i \cdot t - c \cdot z\right) \cdot b\right) \leq 10^{+268}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-i, y, c \cdot a\right), j, \mathsf{fma}\left(-\mathsf{fma}\left(-t, i, c \cdot z\right), b, \mathsf{fma}\left(-a, t, z \cdot y\right) \cdot x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-x, a, \mathsf{fma}\left(\frac{\mathsf{fma}\left(c, a, \left(-y\right) \cdot i\right)}{t}, j, i \cdot b + \frac{\mathsf{fma}\left(-c, b, y \cdot x\right) \cdot z}{t}\right)\right) \cdot t\\ \end{array} \end{array} \]
(FPCore (x y z t a b c i j)
 :precision binary64
 (if (<=
      (-
       (* (- (* c a) (* i y)) j)
       (- (* (- (* a t) (* z y)) x) (* (- (* i t) (* c z)) b)))
      1e+268)
   (fma
    (fma (- i) y (* c a))
    j
    (fma (- (fma (- t) i (* c z))) b (* (fma (- a) t (* z y)) x)))
   (*
    (fma
     (- x)
     a
     (fma
      (/ (fma c a (* (- y) i)) t)
      j
      (+ (* i b) (/ (* (fma (- c) b (* y x)) z) t))))
    t)))
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
	double tmp;
	if (((((c * a) - (i * y)) * j) - ((((a * t) - (z * y)) * x) - (((i * t) - (c * z)) * b))) <= 1e+268) {
		tmp = fma(fma(-i, y, (c * a)), j, fma(-fma(-t, i, (c * z)), b, (fma(-a, t, (z * y)) * x)));
	} else {
		tmp = fma(-x, a, fma((fma(c, a, (-y * i)) / t), j, ((i * b) + ((fma(-c, b, (y * x)) * z) / t)))) * t;
	}
	return tmp;
}
function code(x, y, z, t, a, b, c, i, j)
	tmp = 0.0
	if (Float64(Float64(Float64(Float64(c * a) - Float64(i * y)) * j) - Float64(Float64(Float64(Float64(a * t) - Float64(z * y)) * x) - Float64(Float64(Float64(i * t) - Float64(c * z)) * b))) <= 1e+268)
		tmp = fma(fma(Float64(-i), y, Float64(c * a)), j, fma(Float64(-fma(Float64(-t), i, Float64(c * z))), b, Float64(fma(Float64(-a), t, Float64(z * y)) * x)));
	else
		tmp = Float64(fma(Float64(-x), a, fma(Float64(fma(c, a, Float64(Float64(-y) * i)) / t), j, Float64(Float64(i * b) + Float64(Float64(fma(Float64(-c), b, Float64(y * x)) * z) / t)))) * t);
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := If[LessEqual[N[(N[(N[(N[(c * a), $MachinePrecision] - N[(i * y), $MachinePrecision]), $MachinePrecision] * j), $MachinePrecision] - N[(N[(N[(N[(a * t), $MachinePrecision] - N[(z * y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] - N[(N[(N[(i * t), $MachinePrecision] - N[(c * z), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e+268], N[(N[((-i) * y + N[(c * a), $MachinePrecision]), $MachinePrecision] * j + N[((-N[((-t) * i + N[(c * z), $MachinePrecision]), $MachinePrecision]) * b + N[(N[((-a) * t + N[(z * y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-x) * a + N[(N[(N[(c * a + N[((-y) * i), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision] * j + N[(N[(i * b), $MachinePrecision] + N[(N[(N[((-c) * b + N[(y * x), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\left(c \cdot a - i \cdot y\right) \cdot j - \left(\left(a \cdot t - z \cdot y\right) \cdot x - \left(i \cdot t - c \cdot z\right) \cdot b\right) \leq 10^{+268}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-i, y, c \cdot a\right), j, \mathsf{fma}\left(-\mathsf{fma}\left(-t, i, c \cdot z\right), b, \mathsf{fma}\left(-a, t, z \cdot y\right) \cdot x\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 (-.f64 (*.f64 x (-.f64 (*.f64 y z) (*.f64 t a))) (*.f64 b (-.f64 (*.f64 c z) (*.f64 t i)))) (*.f64 j (-.f64 (*.f64 c a) (*.f64 y i)))) < 9.9999999999999997e267

    1. Initial program 92.7%

      \[\left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right) + j \cdot \left(c \cdot a - y \cdot i\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \color{blue}{\left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right) + j \cdot \left(c \cdot a - y \cdot i\right)} \]
      2. +-commutativeN/A

        \[\leadsto \color{blue}{j \cdot \left(c \cdot a - y \cdot i\right) + \left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right)} \]
      3. lift-*.f64N/A

        \[\leadsto \color{blue}{j \cdot \left(c \cdot a - y \cdot i\right)} + \left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right) \]
      4. *-commutativeN/A

        \[\leadsto \color{blue}{\left(c \cdot a - y \cdot i\right) \cdot j} + \left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right) \]
      5. lower-fma.f6492.7

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{c \cdot a - y \cdot i}, j, x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right) \]
      7. sub-negN/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{c \cdot a + \left(\mathsf{neg}\left(y \cdot i\right)\right)}, j, x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right) \]
      8. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(y \cdot i\right)\right) + c \cdot a}, j, x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right) \]
      9. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\mathsf{neg}\left(\color{blue}{y \cdot i}\right)\right) + c \cdot a, j, x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right) \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\left(\mathsf{neg}\left(\color{blue}{i \cdot y}\right)\right) + c \cdot a, j, x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right) \]
      11. distribute-lft-neg-inN/A

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(i\right), y, c \cdot a\right)}, j, x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right) \]
      13. lower-neg.f6492.7

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{-i}, y, c \cdot a\right), j, x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right) \]
      14. lift--.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{neg}\left(i\right), y, c \cdot a\right), j, \color{blue}{x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)}\right) \]
      15. sub-negN/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{neg}\left(i\right), y, c \cdot a\right), j, \color{blue}{x \cdot \left(y \cdot z - t \cdot a\right) + \left(\mathsf{neg}\left(b \cdot \left(c \cdot z - t \cdot i\right)\right)\right)}\right) \]
      16. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{neg}\left(i\right), y, c \cdot a\right), j, \color{blue}{\left(\mathsf{neg}\left(b \cdot \left(c \cdot z - t \cdot i\right)\right)\right) + x \cdot \left(y \cdot z - t \cdot a\right)}\right) \]
    4. Applied rewrites92.7%

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

    if 9.9999999999999997e267 < (+.f64 (-.f64 (*.f64 x (-.f64 (*.f64 y z) (*.f64 t a))) (*.f64 b (-.f64 (*.f64 c z) (*.f64 t i)))) (*.f64 j (-.f64 (*.f64 c a) (*.f64 y i))))

    1. Initial program 40.0%

      \[\left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right) + j \cdot \left(c \cdot a - y \cdot i\right) \]
    2. Add Preprocessing
    3. Taylor expanded in t around inf

      \[\leadsto \color{blue}{t \cdot \left(\left(-1 \cdot \left(a \cdot x\right) + \left(\frac{j \cdot \left(a \cdot c - i \cdot y\right)}{t} + \frac{x \cdot \left(y \cdot z\right)}{t}\right)\right) - \left(-1 \cdot \left(b \cdot i\right) + \frac{b \cdot \left(c \cdot z\right)}{t}\right)\right)} \]
    4. Applied rewrites70.0%

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

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

Alternative 2: 82.2% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\left(c \cdot a - i \cdot y\right) \cdot j - \left(\left(a \cdot t - z \cdot y\right) \cdot x - \left(i \cdot t - c \cdot z\right) \cdot b\right) \leq \infty:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-i, y, c \cdot a\right), j, \mathsf{fma}\left(-\mathsf{fma}\left(-t, i, c \cdot z\right), b, \mathsf{fma}\left(-a, t, z \cdot y\right) \cdot x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\mathsf{fma}\left(-j, \frac{y}{b}, t\right) \cdot b\right) \cdot i\\ \end{array} \end{array} \]
(FPCore (x y z t a b c i j)
 :precision binary64
 (if (<=
      (-
       (* (- (* c a) (* i y)) j)
       (- (* (- (* a t) (* z y)) x) (* (- (* i t) (* c z)) b)))
      INFINITY)
   (fma
    (fma (- i) y (* c a))
    j
    (fma (- (fma (- t) i (* c z))) b (* (fma (- a) t (* z y)) x)))
   (* (* (fma (- j) (/ y b) t) b) i)))
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
	double tmp;
	if (((((c * a) - (i * y)) * j) - ((((a * t) - (z * y)) * x) - (((i * t) - (c * z)) * b))) <= ((double) INFINITY)) {
		tmp = fma(fma(-i, y, (c * a)), j, fma(-fma(-t, i, (c * z)), b, (fma(-a, t, (z * y)) * x)));
	} else {
		tmp = (fma(-j, (y / b), t) * b) * i;
	}
	return tmp;
}
function code(x, y, z, t, a, b, c, i, j)
	tmp = 0.0
	if (Float64(Float64(Float64(Float64(c * a) - Float64(i * y)) * j) - Float64(Float64(Float64(Float64(a * t) - Float64(z * y)) * x) - Float64(Float64(Float64(i * t) - Float64(c * z)) * b))) <= Inf)
		tmp = fma(fma(Float64(-i), y, Float64(c * a)), j, fma(Float64(-fma(Float64(-t), i, Float64(c * z))), b, Float64(fma(Float64(-a), t, Float64(z * y)) * x)));
	else
		tmp = Float64(Float64(fma(Float64(-j), Float64(y / b), t) * b) * i);
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := If[LessEqual[N[(N[(N[(N[(c * a), $MachinePrecision] - N[(i * y), $MachinePrecision]), $MachinePrecision] * j), $MachinePrecision] - N[(N[(N[(N[(a * t), $MachinePrecision] - N[(z * y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] - N[(N[(N[(i * t), $MachinePrecision] - N[(c * z), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[((-i) * y + N[(c * a), $MachinePrecision]), $MachinePrecision] * j + N[((-N[((-t) * i + N[(c * z), $MachinePrecision]), $MachinePrecision]) * b + N[(N[((-a) * t + N[(z * y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[((-j) * N[(y / b), $MachinePrecision] + t), $MachinePrecision] * b), $MachinePrecision] * i), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\left(c \cdot a - i \cdot y\right) \cdot j - \left(\left(a \cdot t - z \cdot y\right) \cdot x - \left(i \cdot t - c \cdot z\right) \cdot b\right) \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-i, y, c \cdot a\right), j, \mathsf{fma}\left(-\mathsf{fma}\left(-t, i, c \cdot z\right), b, \mathsf{fma}\left(-a, t, z \cdot y\right) \cdot x\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(-j, \frac{y}{b}, t\right) \cdot b\right) \cdot i\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 (-.f64 (*.f64 x (-.f64 (*.f64 y z) (*.f64 t a))) (*.f64 b (-.f64 (*.f64 c z) (*.f64 t i)))) (*.f64 j (-.f64 (*.f64 c a) (*.f64 y i)))) < +inf.0

    1. Initial program 90.7%

      \[\left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right) + j \cdot \left(c \cdot a - y \cdot i\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \color{blue}{\left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right) + j \cdot \left(c \cdot a - y \cdot i\right)} \]
      2. +-commutativeN/A

        \[\leadsto \color{blue}{j \cdot \left(c \cdot a - y \cdot i\right) + \left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right)} \]
      3. lift-*.f64N/A

        \[\leadsto \color{blue}{j \cdot \left(c \cdot a - y \cdot i\right)} + \left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right) \]
      4. *-commutativeN/A

        \[\leadsto \color{blue}{\left(c \cdot a - y \cdot i\right) \cdot j} + \left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right) \]
      5. lower-fma.f6490.7

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{c \cdot a - y \cdot i}, j, x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right) \]
      7. sub-negN/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{c \cdot a + \left(\mathsf{neg}\left(y \cdot i\right)\right)}, j, x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right) \]
      8. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(y \cdot i\right)\right) + c \cdot a}, j, x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right) \]
      9. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\mathsf{neg}\left(\color{blue}{y \cdot i}\right)\right) + c \cdot a, j, x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right) \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\left(\mathsf{neg}\left(\color{blue}{i \cdot y}\right)\right) + c \cdot a, j, x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right) \]
      11. distribute-lft-neg-inN/A

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(i\right), y, c \cdot a\right)}, j, x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right) \]
      13. lower-neg.f6490.7

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{-i}, y, c \cdot a\right), j, x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right) \]
      14. lift--.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{neg}\left(i\right), y, c \cdot a\right), j, \color{blue}{x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)}\right) \]
      15. sub-negN/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{neg}\left(i\right), y, c \cdot a\right), j, \color{blue}{x \cdot \left(y \cdot z - t \cdot a\right) + \left(\mathsf{neg}\left(b \cdot \left(c \cdot z - t \cdot i\right)\right)\right)}\right) \]
      16. +-commutativeN/A

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

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

    if +inf.0 < (+.f64 (-.f64 (*.f64 x (-.f64 (*.f64 y z) (*.f64 t a))) (*.f64 b (-.f64 (*.f64 c z) (*.f64 t i)))) (*.f64 j (-.f64 (*.f64 c a) (*.f64 y i))))

    1. Initial program 0.0%

      \[\left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right) + j \cdot \left(c \cdot a - y \cdot i\right) \]
    2. Add Preprocessing
    3. Taylor expanded in i around inf

      \[\leadsto \color{blue}{i \cdot \left(-1 \cdot \left(j \cdot y\right) - -1 \cdot \left(b \cdot t\right)\right)} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{\left(-1 \cdot \left(j \cdot y\right) - -1 \cdot \left(b \cdot t\right)\right) \cdot i} \]
      2. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(-1 \cdot \left(j \cdot y\right) - -1 \cdot \left(b \cdot t\right)\right) \cdot i} \]
      3. sub-negN/A

        \[\leadsto \color{blue}{\left(-1 \cdot \left(j \cdot y\right) + \left(\mathsf{neg}\left(-1 \cdot \left(b \cdot t\right)\right)\right)\right)} \cdot i \]
      4. associate-*r*N/A

        \[\leadsto \left(\color{blue}{\left(-1 \cdot j\right) \cdot y} + \left(\mathsf{neg}\left(-1 \cdot \left(b \cdot t\right)\right)\right)\right) \cdot i \]
      5. mul-1-negN/A

        \[\leadsto \left(\left(-1 \cdot j\right) \cdot y + \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(b \cdot t\right)\right)}\right)\right)\right) \cdot i \]
      6. remove-double-negN/A

        \[\leadsto \left(\left(-1 \cdot j\right) \cdot y + \color{blue}{b \cdot t}\right) \cdot i \]
      7. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(-1 \cdot j, y, b \cdot t\right)} \cdot i \]
      8. mul-1-negN/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{neg}\left(j\right)}, y, b \cdot t\right) \cdot i \]
      9. lower-neg.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{neg}\left(j\right)}, y, b \cdot t\right) \cdot i \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(j\right), y, \color{blue}{t \cdot b}\right) \cdot i \]
      11. lower-*.f6443.5

        \[\leadsto \mathsf{fma}\left(-j, y, \color{blue}{t \cdot b}\right) \cdot i \]
    5. Applied rewrites43.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-j, y, t \cdot b\right) \cdot i} \]
    6. Taylor expanded in b around inf

      \[\leadsto \left(b \cdot \left(t + -1 \cdot \frac{j \cdot y}{b}\right)\right) \cdot i \]
    7. Step-by-step derivation
      1. Applied rewrites46.2%

        \[\leadsto \left(\mathsf{fma}\left(-j, \frac{y}{b}, t\right) \cdot b\right) \cdot i \]
    8. Recombined 2 regimes into one program.
    9. Final simplification82.2%

      \[\leadsto \begin{array}{l} \mathbf{if}\;\left(c \cdot a - i \cdot y\right) \cdot j - \left(\left(a \cdot t - z \cdot y\right) \cdot x - \left(i \cdot t - c \cdot z\right) \cdot b\right) \leq \infty:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-i, y, c \cdot a\right), j, \mathsf{fma}\left(-\mathsf{fma}\left(-t, i, c \cdot z\right), b, \mathsf{fma}\left(-a, t, z \cdot y\right) \cdot x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\mathsf{fma}\left(-j, \frac{y}{b}, t\right) \cdot b\right) \cdot i\\ \end{array} \]
    10. Add Preprocessing

    Developer Target 1: 59.6% accurate, 0.2× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_1 := j \cdot \left(c \cdot a - y \cdot i\right)\\ t_2 := \left(x \cdot \left(y \cdot z - t \cdot a\right) - \frac{b \cdot \left({\left(c \cdot z\right)}^{2} - {\left(t \cdot i\right)}^{2}\right)}{c \cdot z + t \cdot i}\right) + t\_1\\ \mathbf{if}\;x < -1.469694296777705 \cdot 10^{-64}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;x < 3.2113527362226803 \cdot 10^{-147}:\\ \;\;\;\;\left(b \cdot i - x \cdot a\right) \cdot t - \left(z \cdot \left(c \cdot b\right) - t\_1\right)\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
    (FPCore (x y z t a b c i j)
     :precision binary64
     (let* ((t_1 (* j (- (* c a) (* y i))))
            (t_2
             (+
              (-
               (* x (- (* y z) (* t a)))
               (/
                (* b (- (pow (* c z) 2.0) (pow (* t i) 2.0)))
                (+ (* c z) (* t i))))
              t_1)))
       (if (< x -1.469694296777705e-64)
         t_2
         (if (< x 3.2113527362226803e-147)
           (- (* (- (* b i) (* x a)) t) (- (* z (* c b)) t_1))
           t_2))))
    double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
    	double t_1 = j * ((c * a) - (y * i));
    	double t_2 = ((x * ((y * z) - (t * a))) - ((b * (pow((c * z), 2.0) - pow((t * i), 2.0))) / ((c * z) + (t * i)))) + t_1;
    	double tmp;
    	if (x < -1.469694296777705e-64) {
    		tmp = t_2;
    	} else if (x < 3.2113527362226803e-147) {
    		tmp = (((b * i) - (x * a)) * t) - ((z * (c * b)) - t_1);
    	} else {
    		tmp = t_2;
    	}
    	return tmp;
    }
    
    real(8) function code(x, y, z, t, a, b, c, i, j)
        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), intent (in) :: b
        real(8), intent (in) :: c
        real(8), intent (in) :: i
        real(8), intent (in) :: j
        real(8) :: t_1
        real(8) :: t_2
        real(8) :: tmp
        t_1 = j * ((c * a) - (y * i))
        t_2 = ((x * ((y * z) - (t * a))) - ((b * (((c * z) ** 2.0d0) - ((t * i) ** 2.0d0))) / ((c * z) + (t * i)))) + t_1
        if (x < (-1.469694296777705d-64)) then
            tmp = t_2
        else if (x < 3.2113527362226803d-147) then
            tmp = (((b * i) - (x * a)) * t) - ((z * (c * b)) - t_1)
        else
            tmp = t_2
        end if
        code = tmp
    end function
    
    public static double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
    	double t_1 = j * ((c * a) - (y * i));
    	double t_2 = ((x * ((y * z) - (t * a))) - ((b * (Math.pow((c * z), 2.0) - Math.pow((t * i), 2.0))) / ((c * z) + (t * i)))) + t_1;
    	double tmp;
    	if (x < -1.469694296777705e-64) {
    		tmp = t_2;
    	} else if (x < 3.2113527362226803e-147) {
    		tmp = (((b * i) - (x * a)) * t) - ((z * (c * b)) - t_1);
    	} else {
    		tmp = t_2;
    	}
    	return tmp;
    }
    
    def code(x, y, z, t, a, b, c, i, j):
    	t_1 = j * ((c * a) - (y * i))
    	t_2 = ((x * ((y * z) - (t * a))) - ((b * (math.pow((c * z), 2.0) - math.pow((t * i), 2.0))) / ((c * z) + (t * i)))) + t_1
    	tmp = 0
    	if x < -1.469694296777705e-64:
    		tmp = t_2
    	elif x < 3.2113527362226803e-147:
    		tmp = (((b * i) - (x * a)) * t) - ((z * (c * b)) - t_1)
    	else:
    		tmp = t_2
    	return tmp
    
    function code(x, y, z, t, a, b, c, i, j)
    	t_1 = Float64(j * Float64(Float64(c * a) - Float64(y * i)))
    	t_2 = Float64(Float64(Float64(x * Float64(Float64(y * z) - Float64(t * a))) - Float64(Float64(b * Float64((Float64(c * z) ^ 2.0) - (Float64(t * i) ^ 2.0))) / Float64(Float64(c * z) + Float64(t * i)))) + t_1)
    	tmp = 0.0
    	if (x < -1.469694296777705e-64)
    		tmp = t_2;
    	elseif (x < 3.2113527362226803e-147)
    		tmp = Float64(Float64(Float64(Float64(b * i) - Float64(x * a)) * t) - Float64(Float64(z * Float64(c * b)) - t_1));
    	else
    		tmp = t_2;
    	end
    	return tmp
    end
    
    function tmp_2 = code(x, y, z, t, a, b, c, i, j)
    	t_1 = j * ((c * a) - (y * i));
    	t_2 = ((x * ((y * z) - (t * a))) - ((b * (((c * z) ^ 2.0) - ((t * i) ^ 2.0))) / ((c * z) + (t * i)))) + t_1;
    	tmp = 0.0;
    	if (x < -1.469694296777705e-64)
    		tmp = t_2;
    	elseif (x < 3.2113527362226803e-147)
    		tmp = (((b * i) - (x * a)) * t) - ((z * (c * b)) - t_1);
    	else
    		tmp = t_2;
    	end
    	tmp_2 = tmp;
    end
    
    code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := Block[{t$95$1 = N[(j * N[(N[(c * a), $MachinePrecision] - N[(y * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(x * N[(N[(y * z), $MachinePrecision] - N[(t * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(b * N[(N[Power[N[(c * z), $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[(t * i), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(c * z), $MachinePrecision] + N[(t * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]}, If[Less[x, -1.469694296777705e-64], t$95$2, If[Less[x, 3.2113527362226803e-147], N[(N[(N[(N[(b * i), $MachinePrecision] - N[(x * a), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision] - N[(N[(z * N[(c * b), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision]), $MachinePrecision], t$95$2]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_1 := j \cdot \left(c \cdot a - y \cdot i\right)\\
    t_2 := \left(x \cdot \left(y \cdot z - t \cdot a\right) - \frac{b \cdot \left({\left(c \cdot z\right)}^{2} - {\left(t \cdot i\right)}^{2}\right)}{c \cdot z + t \cdot i}\right) + t\_1\\
    \mathbf{if}\;x < -1.469694296777705 \cdot 10^{-64}:\\
    \;\;\;\;t\_2\\
    
    \mathbf{elif}\;x < 3.2113527362226803 \cdot 10^{-147}:\\
    \;\;\;\;\left(b \cdot i - x \cdot a\right) \cdot t - \left(z \cdot \left(c \cdot b\right) - t\_1\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_2\\
    
    
    \end{array}
    \end{array}
    

    Reproduce

    ?
    herbie shell --seed 2024230 
    (FPCore (x y z t a b c i j)
      :name "Data.Colour.Matrix:determinant from colour-2.3.3, A"
      :precision binary64
    
      :alt
      (! :herbie-platform default (if (< x -293938859355541/2000000000000000000000000000000000000000000000000000000000000000000000000000000) (+ (- (* x (- (* y z) (* t a))) (/ (* b (- (pow (* c z) 2) (pow (* t i) 2))) (+ (* c z) (* t i)))) (* j (- (* c a) (* y i)))) (if (< x 32113527362226803/10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (- (* (- (* b i) (* x a)) t) (- (* z (* c b)) (* j (- (* c a) (* y i))))) (+ (- (* x (- (* y z) (* t a))) (/ (* b (- (pow (* c z) 2) (pow (* t i) 2))) (+ (* c z) (* t i)))) (* j (- (* c a) (* y i)))))))
    
      (+ (- (* x (- (* y z) (* t a))) (* b (- (* c z) (* t i)))) (* j (- (* c a) (* y i)))))