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

Percentage Accurate: 91.4% → 96.5%
Time: 7.9s
Alternatives: 8
Speedup: 0.4×

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 8 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.4% 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.5% 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 5 \cdot 10^{+303}\right):\\ \;\;\;\;y \cdot \frac{x - t \cdot \frac{z}{y}}{a}\\ \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 5e+303)))
     (* y (/ (- x (* t (/ z y))) a))
     (/ 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 <= 5e+303)) {
		tmp = y * ((x - (t * (z / y))) / a);
	} 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 <= 5e+303)) {
		tmp = y * ((x - (t * (z / y))) / a);
	} 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 <= 5e+303):
		tmp = y * ((x - (t * (z / y))) / a)
	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 <= 5e+303))
		tmp = Float64(y * Float64(Float64(x - Float64(t * Float64(z / y))) / a));
	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 <= 5e+303)))
		tmp = y * ((x - (t * (z / y))) / a);
	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, 5e+303]], $MachinePrecision]], N[(y * N[(N[(x - N[(t * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $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 5 \cdot 10^{+303}\right):\\
\;\;\;\;y \cdot \frac{x - t \cdot \frac{z}{y}}{a}\\

\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 4.9999999999999997e303 < (-.f64 (*.f64 x y) (*.f64 z t))

    1. Initial program 79.0%

      \[\frac{x \cdot y - z \cdot t}{a} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-num79.0%

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

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

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

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

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

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

      \[\leadsto \color{blue}{y \cdot \left(-1 \cdot \frac{t \cdot z}{a \cdot y} + \frac{x}{a}\right)} \]
    6. Step-by-step derivation
      1. +-commutative88.4%

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

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

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

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

        \[\leadsto y \cdot \left(\frac{x}{a} - \color{blue}{\frac{\frac{t \cdot z}{y}}{a}}\right) \]
      6. div-sub91.6%

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

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

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

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

    1. Initial program 99.1%

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

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

Alternative 2: 95.0% accurate, 0.4× speedup?

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

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

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

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


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

    1. Initial program 77.7%

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

      \[\leadsto \color{blue}{y \cdot \left(-1 \cdot \frac{t \cdot z}{a \cdot y} + \frac{x}{a}\right)} \]
    4. Step-by-step derivation
      1. +-commutative95.2%

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

        \[\leadsto y \cdot \left(\frac{x}{a} + \color{blue}{\left(-\frac{t \cdot z}{a \cdot y}\right)}\right) \]
      3. unsub-neg95.2%

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

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

      \[\leadsto \color{blue}{y \cdot \left(\frac{x}{a} - \frac{t}{a} \cdot \frac{z}{y}\right)} \]
    6. Taylor expanded in x around inf 99.9%

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

        \[\leadsto y \cdot \color{blue}{\frac{1}{\frac{a}{x}}} \]
      2. un-div-inv99.9%

        \[\leadsto \color{blue}{\frac{y}{\frac{a}{x}}} \]
    8. Applied egg-rr99.9%

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

    if -inf.0 < (*.f64 x y) < 1.00000000000000003e282

    1. Initial program 97.1%

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

    if 1.00000000000000003e282 < (*.f64 x y)

    1. Initial program 66.3%

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

      \[\leadsto \color{blue}{y \cdot \left(-1 \cdot \frac{t \cdot z}{a \cdot y} + \frac{x}{a}\right)} \]
    4. Step-by-step derivation
      1. +-commutative100.0%

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

        \[\leadsto y \cdot \left(\frac{x}{a} + \color{blue}{\left(-\frac{t \cdot z}{a \cdot y}\right)}\right) \]
      3. unsub-neg100.0%

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

        \[\leadsto y \cdot \left(\frac{x}{a} - \color{blue}{\frac{t}{a} \cdot \frac{z}{y}}\right) \]
    5. Simplified85.7%

      \[\leadsto \color{blue}{y \cdot \left(\frac{x}{a} - \frac{t}{a} \cdot \frac{z}{y}\right)} \]
    6. Taylor expanded in x around inf 100.0%

      \[\leadsto y \cdot \color{blue}{\frac{x}{a}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 3: 72.3% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+19} \lor \neg \left(x \cdot y \leq 5 \cdot 10^{+134}\right):\\ \;\;\;\;x \cdot \frac{y}{a}\\ \mathbf{else}:\\ \;\;\;\;\left(z \cdot t\right) \cdot \frac{-1}{a}\\ \end{array} \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (if (or (<= (* x y) -5e+19) (not (<= (* x y) 5e+134)))
   (* x (/ y a))
   (* (* z t) (/ -1.0 a))))
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if (((x * y) <= -5e+19) || !((x * y) <= 5e+134)) {
		tmp = x * (y / a);
	} else {
		tmp = (z * t) * (-1.0 / 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 (((x * y) <= (-5d+19)) .or. (.not. ((x * y) <= 5d+134))) then
        tmp = x * (y / a)
    else
        tmp = (z * t) * ((-1.0d0) / a)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
	double tmp;
	if (((x * y) <= -5e+19) || !((x * y) <= 5e+134)) {
		tmp = x * (y / a);
	} else {
		tmp = (z * t) * (-1.0 / a);
	}
	return tmp;
}
def code(x, y, z, t, a):
	tmp = 0
	if ((x * y) <= -5e+19) or not ((x * y) <= 5e+134):
		tmp = x * (y / a)
	else:
		tmp = (z * t) * (-1.0 / a)
	return tmp
function code(x, y, z, t, a)
	tmp = 0.0
	if ((Float64(x * y) <= -5e+19) || !(Float64(x * y) <= 5e+134))
		tmp = Float64(x * Float64(y / a));
	else
		tmp = Float64(Float64(z * t) * Float64(-1.0 / a));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a)
	tmp = 0.0;
	if (((x * y) <= -5e+19) || ~(((x * y) <= 5e+134)))
		tmp = x * (y / a);
	else
		tmp = (z * t) * (-1.0 / a);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[N[(x * y), $MachinePrecision], -5e+19], N[Not[LessEqual[N[(x * y), $MachinePrecision], 5e+134]], $MachinePrecision]], N[(x * N[(y / a), $MachinePrecision]), $MachinePrecision], N[(N[(z * t), $MachinePrecision] * N[(-1.0 / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+19} \lor \neg \left(x \cdot y \leq 5 \cdot 10^{+134}\right):\\
\;\;\;\;x \cdot \frac{y}{a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x y) < -5e19 or 4.99999999999999981e134 < (*.f64 x y)

    1. Initial program 88.4%

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

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

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

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

    if -5e19 < (*.f64 x y) < 4.99999999999999981e134

    1. Initial program 97.7%

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \left(t \cdot z\right)}}{a} \]
    4. Step-by-step derivation
      1. associate-*r*78.2%

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

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

      \[\leadsto \frac{\color{blue}{\left(-t\right) \cdot z}}{a} \]
    6. Step-by-step derivation
      1. frac-2neg78.2%

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

        \[\leadsto \color{blue}{\left(-\left(-t\right) \cdot z\right) \cdot \frac{1}{-a}} \]
      3. distribute-lft-neg-out78.2%

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

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

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

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

Alternative 4: 72.3% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+19} \lor \neg \left(x \cdot y \leq 5 \cdot 10^{+134}\right):\\ \;\;\;\;x \cdot \frac{y}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{z \cdot t}{-a}\\ \end{array} \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (if (or (<= (* x y) -5e+19) (not (<= (* x y) 5e+134)))
   (* x (/ y a))
   (/ (* z t) (- a))))
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if (((x * y) <= -5e+19) || !((x * y) <= 5e+134)) {
		tmp = x * (y / a);
	} else {
		tmp = (z * t) / -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 (((x * y) <= (-5d+19)) .or. (.not. ((x * y) <= 5d+134))) then
        tmp = x * (y / a)
    else
        tmp = (z * t) / -a
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
	double tmp;
	if (((x * y) <= -5e+19) || !((x * y) <= 5e+134)) {
		tmp = x * (y / a);
	} else {
		tmp = (z * t) / -a;
	}
	return tmp;
}
def code(x, y, z, t, a):
	tmp = 0
	if ((x * y) <= -5e+19) or not ((x * y) <= 5e+134):
		tmp = x * (y / a)
	else:
		tmp = (z * t) / -a
	return tmp
function code(x, y, z, t, a)
	tmp = 0.0
	if ((Float64(x * y) <= -5e+19) || !(Float64(x * y) <= 5e+134))
		tmp = Float64(x * Float64(y / a));
	else
		tmp = Float64(Float64(z * t) / Float64(-a));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a)
	tmp = 0.0;
	if (((x * y) <= -5e+19) || ~(((x * y) <= 5e+134)))
		tmp = x * (y / a);
	else
		tmp = (z * t) / -a;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[N[(x * y), $MachinePrecision], -5e+19], N[Not[LessEqual[N[(x * y), $MachinePrecision], 5e+134]], $MachinePrecision]], N[(x * N[(y / a), $MachinePrecision]), $MachinePrecision], N[(N[(z * t), $MachinePrecision] / (-a)), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+19} \lor \neg \left(x \cdot y \leq 5 \cdot 10^{+134}\right):\\
\;\;\;\;x \cdot \frac{y}{a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x y) < -5e19 or 4.99999999999999981e134 < (*.f64 x y)

    1. Initial program 88.4%

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

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

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

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

    if -5e19 < (*.f64 x y) < 4.99999999999999981e134

    1. Initial program 97.7%

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \left(t \cdot z\right)}}{a} \]
    4. Step-by-step derivation
      1. associate-*r*78.2%

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

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

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

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

Alternative 5: 71.8% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+19} \lor \neg \left(x \cdot y \leq 5 \cdot 10^{+134}\right):\\ \;\;\;\;x \cdot \frac{y}{a}\\ \mathbf{else}:\\ \;\;\;\;t \cdot \frac{z}{-a}\\ \end{array} \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (if (or (<= (* x y) -5e+19) (not (<= (* x y) 5e+134)))
   (* x (/ y a))
   (* t (/ z (- a)))))
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if (((x * y) <= -5e+19) || !((x * y) <= 5e+134)) {
		tmp = x * (y / a);
	} else {
		tmp = t * (z / -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 (((x * y) <= (-5d+19)) .or. (.not. ((x * y) <= 5d+134))) then
        tmp = x * (y / a)
    else
        tmp = t * (z / -a)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
	double tmp;
	if (((x * y) <= -5e+19) || !((x * y) <= 5e+134)) {
		tmp = x * (y / a);
	} else {
		tmp = t * (z / -a);
	}
	return tmp;
}
def code(x, y, z, t, a):
	tmp = 0
	if ((x * y) <= -5e+19) or not ((x * y) <= 5e+134):
		tmp = x * (y / a)
	else:
		tmp = t * (z / -a)
	return tmp
function code(x, y, z, t, a)
	tmp = 0.0
	if ((Float64(x * y) <= -5e+19) || !(Float64(x * y) <= 5e+134))
		tmp = Float64(x * Float64(y / a));
	else
		tmp = Float64(t * Float64(z / Float64(-a)));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a)
	tmp = 0.0;
	if (((x * y) <= -5e+19) || ~(((x * y) <= 5e+134)))
		tmp = x * (y / a);
	else
		tmp = t * (z / -a);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[N[(x * y), $MachinePrecision], -5e+19], N[Not[LessEqual[N[(x * y), $MachinePrecision], 5e+134]], $MachinePrecision]], N[(x * N[(y / a), $MachinePrecision]), $MachinePrecision], N[(t * N[(z / (-a)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+19} \lor \neg \left(x \cdot y \leq 5 \cdot 10^{+134}\right):\\
\;\;\;\;x \cdot \frac{y}{a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x y) < -5e19 or 4.99999999999999981e134 < (*.f64 x y)

    1. Initial program 88.4%

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

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

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

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

    if -5e19 < (*.f64 x y) < 4.99999999999999981e134

    1. Initial program 97.7%

      \[\frac{x \cdot y - z \cdot t}{a} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-num97.5%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto t \cdot \color{blue}{\frac{-1 \cdot z}{a}} \]
      6. mul-1-neg75.9%

        \[\leadsto t \cdot \frac{\color{blue}{-z}}{a} \]
    7. Simplified75.9%

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

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

Alternative 6: 51.7% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq 5.1 \cdot 10^{+168}:\\
\;\;\;\;\frac{x \cdot y}{a}\\

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


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

    1. Initial program 94.7%

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

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

    if 5.10000000000000025e168 < a

    1. Initial program 87.1%

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

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

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

      \[\leadsto \color{blue}{x \cdot \frac{y}{a}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 7: 51.6% accurate, 1.8× speedup?

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

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

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

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

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

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

      \[\leadsto x \cdot \color{blue}{\frac{1}{\frac{a}{y}}} \]
    2. un-div-inv49.8%

      \[\leadsto \color{blue}{\frac{x}{\frac{a}{y}}} \]
  7. Applied egg-rr49.8%

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

Alternative 8: 51.8% accurate, 1.8× speedup?

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

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

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

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

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

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

Developer target: 91.5% accurate, 0.4× 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 2024086 
(FPCore (x y z t a)
  :name "Data.Colour.Matrix:inverse from colour-2.3.3, B"
  :precision binary64

  :alt
  (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))