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

Percentage Accurate: 91.1% → 96.7%
Time: 7.0s
Alternatives: 7
Speedup: 0.5×

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.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: 96.7% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot y - z \cdot t\\ \mathbf{if}\;t_1 \leq -\infty \lor \neg \left(t_1 \leq 2 \cdot 10^{+287}\right):\\ \;\;\;\;\mathsf{fma}\left(-1, \frac{t}{\frac{a}{z}}, \frac{y}{\frac{a}{x}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{t_1}{a}\\ \end{array} \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (- (* x y) (* z t))))
   (if (or (<= t_1 (- INFINITY)) (not (<= t_1 2e+287)))
     (fma -1.0 (/ t (/ a z)) (/ y (/ a x)))
     (/ t_1 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 <= -((double) INFINITY)) || !(t_1 <= 2e+287)) {
		tmp = fma(-1.0, (t / (a / z)), (y / (a / x)));
	} else {
		tmp = t_1 / a;
	}
	return tmp;
}
function code(x, y, z, t, a)
	t_1 = Float64(Float64(x * y) - Float64(z * t))
	tmp = 0.0
	if ((t_1 <= Float64(-Inf)) || !(t_1 <= 2e+287))
		tmp = fma(-1.0, Float64(t / Float64(a / z)), Float64(y / Float64(a / x)));
	else
		tmp = Float64(t_1 / a);
	end
	return tmp
end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, (-Infinity)], N[Not[LessEqual[t$95$1, 2e+287]], $MachinePrecision]], N[(-1.0 * N[(t / N[(a / z), $MachinePrecision]), $MachinePrecision] + N[(y / N[(a / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 / a), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x \cdot y - z \cdot t\\
\mathbf{if}\;t_1 \leq -\infty \lor \neg \left(t_1 \leq 2 \cdot 10^{+287}\right):\\
\;\;\;\;\mathsf{fma}\left(-1, \frac{t}{\frac{a}{z}}, \frac{y}{\frac{a}{x}}\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{t_1}{a}\\


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

    1. Initial program 59.3%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{t \cdot z}{a} + \frac{y \cdot x}{a}} \]
    3. Step-by-step derivation
      1. fma-def56.0%

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

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

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

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

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

    1. Initial program 97.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \leq -\infty \lor \neg \left(x \cdot y - z \cdot t \leq 2 \cdot 10^{+287}\right):\\ \;\;\;\;\mathsf{fma}\left(-1, \frac{t}{\frac{a}{z}}, \frac{y}{\frac{a}{x}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\ \end{array} \]

Alternative 2: 96.9% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot y - z \cdot t\\ \mathbf{if}\;t_1 \leq -\infty \lor \neg \left(t_1 \leq 2 \cdot 10^{+287}\right):\\ \;\;\;\;\frac{x}{\frac{a}{y}} - \frac{z}{\frac{a}{t}}\\ \mathbf{else}:\\ \;\;\;\;\frac{t_1}{a}\\ \end{array} \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (- (* x y) (* z t))))
   (if (or (<= t_1 (- INFINITY)) (not (<= t_1 2e+287)))
     (- (/ x (/ a y)) (/ z (/ a t)))
     (/ t_1 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 <= -((double) INFINITY)) || !(t_1 <= 2e+287)) {
		tmp = (x / (a / y)) - (z / (a / t));
	} else {
		tmp = t_1 / a;
	}
	return tmp;
}
public static double code(double x, double y, double z, double t, double a) {
	double t_1 = (x * y) - (z * t);
	double tmp;
	if ((t_1 <= -Double.POSITIVE_INFINITY) || !(t_1 <= 2e+287)) {
		tmp = (x / (a / y)) - (z / (a / t));
	} else {
		tmp = t_1 / a;
	}
	return tmp;
}
def code(x, y, z, t, a):
	t_1 = (x * y) - (z * t)
	tmp = 0
	if (t_1 <= -math.inf) or not (t_1 <= 2e+287):
		tmp = (x / (a / y)) - (z / (a / t))
	else:
		tmp = t_1 / a
	return tmp
function code(x, y, z, t, a)
	t_1 = Float64(Float64(x * y) - Float64(z * t))
	tmp = 0.0
	if ((t_1 <= Float64(-Inf)) || !(t_1 <= 2e+287))
		tmp = Float64(Float64(x / Float64(a / y)) - Float64(z / Float64(a / t)));
	else
		tmp = Float64(t_1 / a);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a)
	t_1 = (x * y) - (z * t);
	tmp = 0.0;
	if ((t_1 <= -Inf) || ~((t_1 <= 2e+287)))
		tmp = (x / (a / y)) - (z / (a / t));
	else
		tmp = t_1 / a;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, (-Infinity)], N[Not[LessEqual[t$95$1, 2e+287]], $MachinePrecision]], N[(N[(x / N[(a / y), $MachinePrecision]), $MachinePrecision] - N[(z / N[(a / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 / a), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x \cdot y - z \cdot t\\
\mathbf{if}\;t_1 \leq -\infty \lor \neg \left(t_1 \leq 2 \cdot 10^{+287}\right):\\
\;\;\;\;\frac{x}{\frac{a}{y}} - \frac{z}{\frac{a}{t}}\\

\mathbf{else}:\\
\;\;\;\;\frac{t_1}{a}\\


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

    1. Initial program 59.3%

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

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

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

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

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

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

    1. Initial program 97.7%

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

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

Alternative 3: 72.9% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
t_1 := \frac{z \cdot \left(-t\right)}{a}\\
\mathbf{if}\;x \cdot y \leq -2 \cdot 10^{+86}:\\
\;\;\;\;y \cdot \frac{x}{a}\\

\mathbf{elif}\;x \cdot y \leq -1 \cdot 10^{+33}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;x \cdot y \leq 4000000000:\\
\;\;\;\;t_1\\

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


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

    1. Initial program 85.5%

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

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

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

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

    if -2e86 < (*.f64 x y) < -9.9999999999999995e32 or -4.9999999999999999e-67 < (*.f64 x y) < 4e9

    1. Initial program 93.0%

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

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

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

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

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

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

    if -9.9999999999999995e32 < (*.f64 x y) < -4.9999999999999999e-67

    1. Initial program 95.7%

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

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

    if 4e9 < (*.f64 x y)

    1. Initial program 79.2%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \leq -2 \cdot 10^{+86}:\\ \;\;\;\;y \cdot \frac{x}{a}\\ \mathbf{elif}\;x \cdot y \leq -1 \cdot 10^{+33}:\\ \;\;\;\;\frac{z \cdot \left(-t\right)}{a}\\ \mathbf{elif}\;x \cdot y \leq -5 \cdot 10^{-67}:\\ \;\;\;\;\frac{x \cdot y}{a}\\ \mathbf{elif}\;x \cdot y \leq 4000000000:\\ \;\;\;\;\frac{z \cdot \left(-t\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{a}{x}}\\ \end{array} \]

Alternative 4: 94.8% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \cdot t \leq -\infty:\\ \;\;\;\;t \cdot \frac{-z}{a}\\ \mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+295}:\\ \;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\ \mathbf{else}:\\ \;\;\;\;z \cdot \frac{-t}{a}\\ \end{array} \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (if (<= (* z t) (- INFINITY))
   (* t (/ (- z) a))
   (if (<= (* z t) 2e+295) (/ (- (* x y) (* z t)) a) (* z (/ (- t) a)))))
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if ((z * t) <= -((double) INFINITY)) {
		tmp = t * (-z / a);
	} else if ((z * t) <= 2e+295) {
		tmp = ((x * y) - (z * t)) / a;
	} else {
		tmp = z * (-t / a);
	}
	return tmp;
}
public static double code(double x, double y, double z, double t, double a) {
	double tmp;
	if ((z * t) <= -Double.POSITIVE_INFINITY) {
		tmp = t * (-z / a);
	} else if ((z * t) <= 2e+295) {
		tmp = ((x * y) - (z * t)) / a;
	} else {
		tmp = z * (-t / a);
	}
	return tmp;
}
def code(x, y, z, t, a):
	tmp = 0
	if (z * t) <= -math.inf:
		tmp = t * (-z / a)
	elif (z * t) <= 2e+295:
		tmp = ((x * y) - (z * t)) / a
	else:
		tmp = z * (-t / a)
	return tmp
function code(x, y, z, t, a)
	tmp = 0.0
	if (Float64(z * t) <= Float64(-Inf))
		tmp = Float64(t * Float64(Float64(-z) / a));
	elseif (Float64(z * t) <= 2e+295)
		tmp = Float64(Float64(Float64(x * y) - Float64(z * t)) / a);
	else
		tmp = Float64(z * Float64(Float64(-t) / a));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a)
	tmp = 0.0;
	if ((z * t) <= -Inf)
		tmp = t * (-z / a);
	elseif ((z * t) <= 2e+295)
		tmp = ((x * y) - (z * t)) / a;
	else
		tmp = z * (-t / a);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_] := If[LessEqual[N[(z * t), $MachinePrecision], (-Infinity)], N[(t * N[((-z) / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 2e+295], N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(z * N[((-t) / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -\infty:\\
\;\;\;\;t \cdot \frac{-z}{a}\\

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

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


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

    1. Initial program 49.7%

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

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

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

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

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

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

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

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

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

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

    1. Initial program 94.1%

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

    if 2e295 < (*.f64 z t)

    1. Initial program 56.5%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 65.5% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1.4 \cdot 10^{-97}:\\ \;\;\;\;\frac{y}{\frac{a}{x}}\\ \mathbf{elif}\;y \leq 1.1 \cdot 10^{-15}:\\ \;\;\;\;-\frac{t}{\frac{a}{z}}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{a}\\ \end{array} \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (if (<= y -1.4e-97)
   (/ y (/ a x))
   (if (<= y 1.1e-15) (- (/ t (/ a z))) (* y (/ x a)))))
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if (y <= -1.4e-97) {
		tmp = y / (a / x);
	} else if (y <= 1.1e-15) {
		tmp = -(t / (a / z));
	} else {
		tmp = y * (x / a);
	}
	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) :: tmp
    if (y <= (-1.4d-97)) then
        tmp = y / (a / x)
    else if (y <= 1.1d-15) then
        tmp = -(t / (a / z))
    else
        tmp = y * (x / a)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
	double tmp;
	if (y <= -1.4e-97) {
		tmp = y / (a / x);
	} else if (y <= 1.1e-15) {
		tmp = -(t / (a / z));
	} else {
		tmp = y * (x / a);
	}
	return tmp;
}
def code(x, y, z, t, a):
	tmp = 0
	if y <= -1.4e-97:
		tmp = y / (a / x)
	elif y <= 1.1e-15:
		tmp = -(t / (a / z))
	else:
		tmp = y * (x / a)
	return tmp
function code(x, y, z, t, a)
	tmp = 0.0
	if (y <= -1.4e-97)
		tmp = Float64(y / Float64(a / x));
	elseif (y <= 1.1e-15)
		tmp = Float64(-Float64(t / Float64(a / z)));
	else
		tmp = Float64(y * Float64(x / a));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a)
	tmp = 0.0;
	if (y <= -1.4e-97)
		tmp = y / (a / x);
	elseif (y <= 1.1e-15)
		tmp = -(t / (a / z));
	else
		tmp = y * (x / a);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_] := If[LessEqual[y, -1.4e-97], N[(y / N[(a / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.1e-15], (-N[(t / N[(a / z), $MachinePrecision]), $MachinePrecision]), N[(y * N[(x / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.4 \cdot 10^{-97}:\\
\;\;\;\;\frac{y}{\frac{a}{x}}\\

\mathbf{elif}\;y \leq 1.1 \cdot 10^{-15}:\\
\;\;\;\;-\frac{t}{\frac{a}{z}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.4000000000000001e-97

    1. Initial program 86.9%

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

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

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

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

    if -1.4000000000000001e-97 < y < 1.09999999999999993e-15

    1. Initial program 92.6%

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

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

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

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

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

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

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

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

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

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

    if 1.09999999999999993e-15 < y

    1. Initial program 83.6%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.4 \cdot 10^{-97}:\\ \;\;\;\;\frac{y}{\frac{a}{x}}\\ \mathbf{elif}\;y \leq 1.1 \cdot 10^{-15}:\\ \;\;\;\;-\frac{t}{\frac{a}{z}}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{a}\\ \end{array} \]

Alternative 6: 65.6% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1.45 \cdot 10^{-94}:\\ \;\;\;\;\frac{y}{\frac{a}{x}}\\ \mathbf{elif}\;y \leq 8 \cdot 10^{-16}:\\ \;\;\;\;t \cdot \frac{-z}{a}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{a}\\ \end{array} \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (if (<= y -1.45e-94)
   (/ y (/ a x))
   (if (<= y 8e-16) (* t (/ (- z) a)) (* y (/ x a)))))
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if (y <= -1.45e-94) {
		tmp = y / (a / x);
	} else if (y <= 8e-16) {
		tmp = t * (-z / a);
	} else {
		tmp = y * (x / a);
	}
	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) :: tmp
    if (y <= (-1.45d-94)) then
        tmp = y / (a / x)
    else if (y <= 8d-16) then
        tmp = t * (-z / a)
    else
        tmp = y * (x / a)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
	double tmp;
	if (y <= -1.45e-94) {
		tmp = y / (a / x);
	} else if (y <= 8e-16) {
		tmp = t * (-z / a);
	} else {
		tmp = y * (x / a);
	}
	return tmp;
}
def code(x, y, z, t, a):
	tmp = 0
	if y <= -1.45e-94:
		tmp = y / (a / x)
	elif y <= 8e-16:
		tmp = t * (-z / a)
	else:
		tmp = y * (x / a)
	return tmp
function code(x, y, z, t, a)
	tmp = 0.0
	if (y <= -1.45e-94)
		tmp = Float64(y / Float64(a / x));
	elseif (y <= 8e-16)
		tmp = Float64(t * Float64(Float64(-z) / a));
	else
		tmp = Float64(y * Float64(x / a));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a)
	tmp = 0.0;
	if (y <= -1.45e-94)
		tmp = y / (a / x);
	elseif (y <= 8e-16)
		tmp = t * (-z / a);
	else
		tmp = y * (x / a);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_] := If[LessEqual[y, -1.45e-94], N[(y / N[(a / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 8e-16], N[(t * N[((-z) / a), $MachinePrecision]), $MachinePrecision], N[(y * N[(x / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.45 \cdot 10^{-94}:\\
\;\;\;\;\frac{y}{\frac{a}{x}}\\

\mathbf{elif}\;y \leq 8 \cdot 10^{-16}:\\
\;\;\;\;t \cdot \frac{-z}{a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.44999999999999998e-94

    1. Initial program 86.6%

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

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

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

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

    if -1.44999999999999998e-94 < y < 7.9999999999999998e-16

    1. Initial program 92.7%

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

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

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

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

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

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

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

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

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

    if 7.9999999999999998e-16 < y

    1. Initial program 83.6%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.45 \cdot 10^{-94}:\\ \;\;\;\;\frac{y}{\frac{a}{x}}\\ \mathbf{elif}\;y \leq 8 \cdot 10^{-16}:\\ \;\;\;\;t \cdot \frac{-z}{a}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{a}\\ \end{array} \]

Alternative 7: 51.3% accurate, 1.8× speedup?

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

\\
y \cdot \frac{x}{a}
\end{array}
Derivation
  1. Initial program 88.5%

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

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

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

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

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

Developer target: 90.6% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{y}{a} \cdot x - \frac{t}{a} \cdot z\\ \mathbf{if}\;z < -2.468684968699548 \cdot 10^{+170}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z < 6.309831121978371 \cdot 10^{-71}:\\ \;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (- (* (/ y a) x) (* (/ t a) z))))
   (if (< z -2.468684968699548e+170)
     t_1
     (if (< z 6.309831121978371e-71) (/ (- (* x y) (* z t)) a) t_1))))
double code(double x, double y, double z, double t, double a) {
	double t_1 = ((y / a) * x) - ((t / a) * z);
	double tmp;
	if (z < -2.468684968699548e+170) {
		tmp = t_1;
	} else if (z < 6.309831121978371e-71) {
		tmp = ((x * y) - (z * t)) / a;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(x, y, z, t, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8) :: t_1
    real(8) :: tmp
    t_1 = ((y / a) * x) - ((t / a) * z)
    if (z < (-2.468684968699548d+170)) then
        tmp = t_1
    else if (z < 6.309831121978371d-71) then
        tmp = ((x * y) - (z * t)) / a
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
	double t_1 = ((y / a) * x) - ((t / a) * z);
	double tmp;
	if (z < -2.468684968699548e+170) {
		tmp = t_1;
	} else if (z < 6.309831121978371e-71) {
		tmp = ((x * y) - (z * t)) / a;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t, a):
	t_1 = ((y / a) * x) - ((t / a) * z)
	tmp = 0
	if z < -2.468684968699548e+170:
		tmp = t_1
	elif z < 6.309831121978371e-71:
		tmp = ((x * y) - (z * t)) / a
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t, a)
	t_1 = Float64(Float64(Float64(y / a) * x) - Float64(Float64(t / a) * z))
	tmp = 0.0
	if (z < -2.468684968699548e+170)
		tmp = t_1;
	elseif (z < 6.309831121978371e-71)
		tmp = Float64(Float64(Float64(x * y) - Float64(z * t)) / a);
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a)
	t_1 = ((y / a) * x) - ((t / a) * z);
	tmp = 0.0;
	if (z < -2.468684968699548e+170)
		tmp = t_1;
	elseif (z < 6.309831121978371e-71)
		tmp = ((x * y) - (z * t)) / a;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(y / a), $MachinePrecision] * x), $MachinePrecision] - N[(N[(t / a), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]}, If[Less[z, -2.468684968699548e+170], t$95$1, If[Less[z, 6.309831121978371e-71], N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \frac{y}{a} \cdot x - \frac{t}{a} \cdot z\\
\mathbf{if}\;z < -2.468684968699548 \cdot 10^{+170}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;z < 6.309831121978371 \cdot 10^{-71}:\\
\;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2023173 
(FPCore (x y z t a)
  :name "Data.Colour.Matrix:inverse from colour-2.3.3, B"
  :precision binary64

  :herbie-target
  (if (< z -2.468684968699548e+170) (- (* (/ y a) x) (* (/ t a) z)) (if (< z 6.309831121978371e-71) (/ (- (* x y) (* z t)) a) (- (* (/ y a) x) (* (/ t a) z))))

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