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

Percentage Accurate: 91.7% → 95.9%
Time: 6.1s
Alternatives: 8
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;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
    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}

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.7% 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;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
    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: 95.9% accurate, 0.3× speedup?

\[\begin{array}{l} [x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\ \\ \begin{array}{l} t_1 := \frac{t}{a} \cdot \left(\frac{x}{t} \cdot y - z\right)\\ t_2 := \frac{x \cdot y - z \cdot t}{a}\\ \mathbf{if}\;t\_2 \leq -\infty:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+281}:\\ \;\;\;\;t\_2\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (* (/ t a) (- (* (/ x t) y) z))) (t_2 (/ (- (* x y) (* z t)) a)))
   (if (<= t_2 (- INFINITY)) t_1 (if (<= t_2 5e+281) t_2 t_1))))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
	double t_1 = (t / a) * (((x / t) * y) - z);
	double t_2 = ((x * y) - (z * t)) / a;
	double tmp;
	if (t_2 <= -((double) INFINITY)) {
		tmp = t_1;
	} else if (t_2 <= 5e+281) {
		tmp = t_2;
	} else {
		tmp = t_1;
	}
	return tmp;
}
assert x < y && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
	double t_1 = (t / a) * (((x / t) * y) - z);
	double t_2 = ((x * y) - (z * t)) / a;
	double tmp;
	if (t_2 <= -Double.POSITIVE_INFINITY) {
		tmp = t_1;
	} else if (t_2 <= 5e+281) {
		tmp = t_2;
	} else {
		tmp = t_1;
	}
	return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a])
def code(x, y, z, t, a):
	t_1 = (t / a) * (((x / t) * y) - z)
	t_2 = ((x * y) - (z * t)) / a
	tmp = 0
	if t_2 <= -math.inf:
		tmp = t_1
	elif t_2 <= 5e+281:
		tmp = t_2
	else:
		tmp = t_1
	return tmp
x, y, z, t, a = sort([x, y, z, t, a])
function code(x, y, z, t, a)
	t_1 = Float64(Float64(t / a) * Float64(Float64(Float64(x / t) * y) - z))
	t_2 = Float64(Float64(Float64(x * y) - Float64(z * t)) / a)
	tmp = 0.0
	if (t_2 <= Float64(-Inf))
		tmp = t_1;
	elseif (t_2 <= 5e+281)
		tmp = t_2;
	else
		tmp = t_1;
	end
	return tmp
end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp_2 = code(x, y, z, t, a)
	t_1 = (t / a) * (((x / t) * y) - z);
	t_2 = ((x * y) - (z * t)) / a;
	tmp = 0.0;
	if (t_2 <= -Inf)
		tmp = t_1;
	elseif (t_2 <= 5e+281)
		tmp = t_2;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(t / a), $MachinePrecision] * N[(N[(N[(x / t), $MachinePrecision] * y), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], t$95$1, If[LessEqual[t$95$2, 5e+281], t$95$2, t$95$1]]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
t_1 := \frac{t}{a} \cdot \left(\frac{x}{t} \cdot y - z\right)\\
t_2 := \frac{x \cdot y - z \cdot t}{a}\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+281}:\\
\;\;\;\;t\_2\\

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


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

    1. Initial program 79.3%

      \[\frac{x \cdot y - z \cdot t}{a} \]
    2. Applied rewrites90.8%

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

    if -inf.0 < (/.f64 (-.f64 (*.f64 x y) (*.f64 z t)) a) < 5.00000000000000016e281

    1. Initial program 98.8%

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

Alternative 2: 94.4% accurate, 0.5× speedup?

\[\begin{array}{l} [x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\ \\ \begin{array}{l} t_1 := \frac{-z}{a} \cdot t\\ \mathbf{if}\;z \cdot t \leq -\infty:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+190}:\\ \;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (* (/ (- z) a) t)))
   (if (<= (* z t) (- INFINITY))
     t_1
     (if (<= (* z t) 2e+190) (/ (- (* x y) (* z t)) a) t_1))))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
	double t_1 = (-z / a) * t;
	double tmp;
	if ((z * t) <= -((double) INFINITY)) {
		tmp = t_1;
	} else if ((z * t) <= 2e+190) {
		tmp = ((x * y) - (z * t)) / a;
	} else {
		tmp = t_1;
	}
	return tmp;
}
assert x < y && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
	double t_1 = (-z / a) * t;
	double tmp;
	if ((z * t) <= -Double.POSITIVE_INFINITY) {
		tmp = t_1;
	} else if ((z * t) <= 2e+190) {
		tmp = ((x * y) - (z * t)) / a;
	} else {
		tmp = t_1;
	}
	return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a])
def code(x, y, z, t, a):
	t_1 = (-z / a) * t
	tmp = 0
	if (z * t) <= -math.inf:
		tmp = t_1
	elif (z * t) <= 2e+190:
		tmp = ((x * y) - (z * t)) / a
	else:
		tmp = t_1
	return tmp
x, y, z, t, a = sort([x, y, z, t, a])
function code(x, y, z, t, a)
	t_1 = Float64(Float64(Float64(-z) / a) * t)
	tmp = 0.0
	if (Float64(z * t) <= Float64(-Inf))
		tmp = t_1;
	elseif (Float64(z * t) <= 2e+190)
		tmp = Float64(Float64(Float64(x * y) - Float64(z * t)) / a);
	else
		tmp = t_1;
	end
	return tmp
end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp_2 = code(x, y, z, t, a)
	t_1 = (-z / a) * t;
	tmp = 0.0;
	if ((z * t) <= -Inf)
		tmp = t_1;
	elseif ((z * t) <= 2e+190)
		tmp = ((x * y) - (z * t)) / a;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[((-z) / a), $MachinePrecision] * t), $MachinePrecision]}, If[LessEqual[N[(z * t), $MachinePrecision], (-Infinity)], t$95$1, If[LessEqual[N[(z * t), $MachinePrecision], 2e+190], N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], t$95$1]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
t_1 := \frac{-z}{a} \cdot t\\
\mathbf{if}\;z \cdot t \leq -\infty:\\
\;\;\;\;t\_1\\

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

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


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

    1. Initial program 75.9%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-z\right) \cdot \frac{\color{blue}{t}}{a} \]
      12. lower-/.f6491.4

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

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

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

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

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

        \[\leadsto \frac{-z}{a} \cdot \color{blue}{t} \]
      5. lift-neg.f64N/A

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

        \[\leadsto \frac{-1 \cdot z}{a} \cdot t \]
      7. associate-*r/N/A

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

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

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

        \[\leadsto \frac{\mathsf{neg}\left(z\right)}{a} \cdot t \]
      11. lift-neg.f64N/A

        \[\leadsto \frac{-z}{a} \cdot t \]
      12. lower-/.f6491.3

        \[\leadsto \frac{-z}{a} \cdot t \]
    6. Applied rewrites91.3%

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

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

    1. Initial program 95.1%

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

Alternative 3: 73.4% accurate, 0.6× speedup?

\[\begin{array}{l} [x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\ \\ \begin{array}{l} t_1 := \frac{y \cdot x}{a}\\ \mathbf{if}\;x \cdot y \leq -100000000000:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \cdot y \leq 5 \cdot 10^{-123}:\\ \;\;\;\;\frac{\left(-z\right) \cdot t}{a}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (/ (* y x) a)))
   (if (<= (* x y) -100000000000.0)
     t_1
     (if (<= (* x y) 5e-123) (/ (* (- z) t) a) t_1))))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
	double t_1 = (y * x) / a;
	double tmp;
	if ((x * y) <= -100000000000.0) {
		tmp = t_1;
	} else if ((x * y) <= 5e-123) {
		tmp = (-z * t) / a;
	} else {
		tmp = t_1;
	}
	return tmp;
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

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

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

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


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

    1. Initial program 89.4%

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

      \[\leadsto \frac{\color{blue}{x \cdot y}}{a} \]
    3. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \frac{y \cdot \color{blue}{x}}{a} \]
      2. lower-*.f6467.1

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

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

    if -1e11 < (*.f64 x y) < 5.0000000000000003e-123

    1. Initial program 94.9%

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

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

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

        \[\leadsto \frac{\mathsf{neg}\left(z \cdot t\right)}{a} \]
      3. distribute-lft-neg-outN/A

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

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

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

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

Alternative 4: 73.3% accurate, 0.6× speedup?

\[\begin{array}{l} [x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\ \\ \begin{array}{l} \mathbf{if}\;z \cdot t \leq -2 \cdot 10^{+57}:\\ \;\;\;\;\left(-z\right) \cdot \frac{t}{a}\\ \mathbf{elif}\;z \cdot t \leq 10^{+92}:\\ \;\;\;\;\frac{y \cdot x}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-z}{a} \cdot t\\ \end{array} \end{array} \]
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
(FPCore (x y z t a)
 :precision binary64
 (if (<= (* z t) -2e+57)
   (* (- z) (/ t a))
   (if (<= (* z t) 1e+92) (/ (* y x) a) (* (/ (- z) a) t))))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if ((z * t) <= -2e+57) {
		tmp = -z * (t / a);
	} else if ((z * t) <= 1e+92) {
		tmp = (y * x) / a;
	} else {
		tmp = (-z / a) * t;
	}
	return tmp;
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8) :: tmp
    if ((z * t) <= (-2d+57)) then
        tmp = -z * (t / a)
    else if ((z * t) <= 1d+92) then
        tmp = (y * x) / a
    else
        tmp = (-z / a) * t
    end if
    code = tmp
end function
assert x < y && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
	double tmp;
	if ((z * t) <= -2e+57) {
		tmp = -z * (t / a);
	} else if ((z * t) <= 1e+92) {
		tmp = (y * x) / a;
	} else {
		tmp = (-z / a) * t;
	}
	return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a])
def code(x, y, z, t, a):
	tmp = 0
	if (z * t) <= -2e+57:
		tmp = -z * (t / a)
	elif (z * t) <= 1e+92:
		tmp = (y * x) / a
	else:
		tmp = (-z / a) * t
	return tmp
x, y, z, t, a = sort([x, y, z, t, a])
function code(x, y, z, t, a)
	tmp = 0.0
	if (Float64(z * t) <= -2e+57)
		tmp = Float64(Float64(-z) * Float64(t / a));
	elseif (Float64(z * t) <= 1e+92)
		tmp = Float64(Float64(y * x) / a);
	else
		tmp = Float64(Float64(Float64(-z) / a) * t);
	end
	return tmp
end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp_2 = code(x, y, z, t, a)
	tmp = 0.0;
	if ((z * t) <= -2e+57)
		tmp = -z * (t / a);
	elseif ((z * t) <= 1e+92)
		tmp = (y * x) / a;
	else
		tmp = (-z / a) * t;
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_] := If[LessEqual[N[(z * t), $MachinePrecision], -2e+57], N[((-z) * N[(t / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 1e+92], N[(N[(y * x), $MachinePrecision] / a), $MachinePrecision], N[(N[((-z) / a), $MachinePrecision] * t), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -2 \cdot 10^{+57}:\\
\;\;\;\;\left(-z\right) \cdot \frac{t}{a}\\

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

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


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

    1. Initial program 86.1%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-z\right) \cdot \frac{\color{blue}{t}}{a} \]
      12. lower-/.f6478.6

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

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

    if -2.0000000000000001e57 < (*.f64 z t) < 1e92

    1. Initial program 95.1%

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

      \[\leadsto \frac{\color{blue}{x \cdot y}}{a} \]
    3. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \frac{y \cdot \color{blue}{x}}{a} \]
      2. lower-*.f6469.1

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

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

    if 1e92 < (*.f64 z t)

    1. Initial program 86.7%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-z\right) \cdot \frac{\color{blue}{t}}{a} \]
      12. lower-/.f6481.5

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

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

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

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

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

        \[\leadsto \frac{-z}{a} \cdot \color{blue}{t} \]
      5. lift-neg.f64N/A

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

        \[\leadsto \frac{-1 \cdot z}{a} \cdot t \]
      7. associate-*r/N/A

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

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

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

        \[\leadsto \frac{\mathsf{neg}\left(z\right)}{a} \cdot t \]
      11. lift-neg.f64N/A

        \[\leadsto \frac{-z}{a} \cdot t \]
      12. lower-/.f6482.1

        \[\leadsto \frac{-z}{a} \cdot t \]
    6. Applied rewrites82.1%

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

Alternative 5: 72.0% accurate, 0.6× speedup?

\[\begin{array}{l} [x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\ \\ \begin{array}{l} t_1 := \left(-z\right) \cdot \frac{t}{a}\\ \mathbf{if}\;z \cdot t \leq -2 \cdot 10^{+57}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \cdot t \leq 10^{+92}:\\ \;\;\;\;\frac{y \cdot x}{a}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (* (- z) (/ t a))))
   (if (<= (* z t) -2e+57) t_1 (if (<= (* z t) 1e+92) (/ (* y x) a) t_1))))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
	double t_1 = -z * (t / a);
	double tmp;
	if ((z * t) <= -2e+57) {
		tmp = t_1;
	} else if ((z * t) <= 1e+92) {
		tmp = (y * x) / a;
	} else {
		tmp = t_1;
	}
	return tmp;
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 z t) < -2.0000000000000001e57 or 1e92 < (*.f64 z t)

    1. Initial program 86.4%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-z\right) \cdot \frac{\color{blue}{t}}{a} \]
      12. lower-/.f6480.0

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

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

    if -2.0000000000000001e57 < (*.f64 z t) < 1e92

    1. Initial program 95.1%

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

      \[\leadsto \frac{\color{blue}{x \cdot y}}{a} \]
    3. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \frac{y \cdot \color{blue}{x}}{a} \]
      2. lower-*.f6469.1

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

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

Alternative 6: 52.0% accurate, 1.2× speedup?

\[\begin{array}{l} [x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq 8 \cdot 10^{+191}:\\ \;\;\;\;\frac{x}{a} \cdot y\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{a} \cdot x\\ \end{array} \end{array} \]
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
(FPCore (x y z t a)
 :precision binary64
 (if (<= y 8e+191) (* (/ x a) y) (* (/ y a) x)))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if (y <= 8e+191) {
		tmp = (x / a) * y;
	} else {
		tmp = (y / a) * x;
	}
	return tmp;
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 8.00000000000000058e191

    1. Initial program 92.6%

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

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

        \[\leadsto \frac{x}{a} \cdot \color{blue}{y} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{x}{a} \cdot \color{blue}{y} \]
      3. lower-/.f6449.6

        \[\leadsto \frac{x}{a} \cdot y \]
    4. Applied rewrites49.6%

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

    if 8.00000000000000058e191 < y

    1. Initial program 83.1%

      \[\frac{x \cdot y - z \cdot t}{a} \]
    2. Applied rewrites84.4%

      \[\leadsto \color{blue}{\frac{y - \frac{t \cdot z}{x}}{a} \cdot x} \]
    3. Taylor expanded in x around inf

      \[\leadsto \frac{\color{blue}{y}}{a} \cdot x \]
    4. Step-by-step derivation
      1. Applied rewrites76.3%

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

    Alternative 7: 51.8% accurate, 1.8× speedup?

    \[\begin{array}{l} [x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\ \\ \frac{y \cdot x}{a} \end{array} \]
    NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
    (FPCore (x y z t a) :precision binary64 (/ (* y x) a))
    assert(x < y && y < z && z < t && t < a);
    double code(double x, double y, double z, double t, double a) {
    	return (y * x) / a;
    }
    
    NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
    module fmin_fmax_functions
        implicit none
        private
        public fmax
        public fmin
    
        interface fmax
            module procedure fmax88
            module procedure fmax44
            module procedure fmax84
            module procedure fmax48
        end interface
        interface fmin
            module procedure fmin88
            module procedure fmin44
            module procedure fmin84
            module procedure fmin48
        end interface
    contains
        real(8) function fmax88(x, y) result (res)
            real(8), intent (in) :: x
            real(8), intent (in) :: y
            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
        end function
        real(4) function fmax44(x, y) result (res)
            real(4), intent (in) :: x
            real(4), intent (in) :: y
            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
        end function
        real(8) function fmax84(x, y) result(res)
            real(8), intent (in) :: x
            real(4), intent (in) :: y
            res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
        end function
        real(8) function fmax48(x, y) result(res)
            real(4), intent (in) :: x
            real(8), intent (in) :: y
            res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
        end function
        real(8) function fmin88(x, y) result (res)
            real(8), intent (in) :: x
            real(8), intent (in) :: y
            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
        end function
        real(4) function fmin44(x, y) result (res)
            real(4), intent (in) :: x
            real(4), intent (in) :: y
            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
        end function
        real(8) function fmin84(x, y) result(res)
            real(8), intent (in) :: x
            real(4), intent (in) :: y
            res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
        end function
        real(8) function fmin48(x, y) result(res)
            real(4), intent (in) :: x
            real(8), intent (in) :: y
            res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
        end function
    end module
    
    real(8) function code(x, y, z, t, a)
    use fmin_fmax_functions
        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
    
    assert x < y && y < z && z < t && t < a;
    public static double code(double x, double y, double z, double t, double a) {
    	return (y * x) / a;
    }
    
    [x, y, z, t, a] = sort([x, y, z, t, a])
    def code(x, y, z, t, a):
    	return (y * x) / a
    
    x, y, z, t, a = sort([x, y, z, t, a])
    function code(x, y, z, t, a)
    	return Float64(Float64(y * x) / a)
    end
    
    x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
    function tmp = code(x, y, z, t, a)
    	tmp = (y * x) / a;
    end
    
    NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
    code[x_, y_, z_, t_, a_] := N[(N[(y * x), $MachinePrecision] / a), $MachinePrecision]
    
    \begin{array}{l}
    [x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
    \\
    \frac{y \cdot x}{a}
    \end{array}
    
    Derivation
    1. Initial program 91.7%

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

      \[\leadsto \frac{\color{blue}{x \cdot y}}{a} \]
    3. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \frac{y \cdot \color{blue}{x}}{a} \]
      2. lower-*.f6451.0

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

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

    Alternative 8: 51.0% accurate, 1.8× speedup?

    \[\begin{array}{l} [x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\ \\ \frac{x}{a} \cdot y \end{array} \]
    NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
    (FPCore (x y z t a) :precision binary64 (* (/ x a) y))
    assert(x < y && y < z && z < t && t < a);
    double code(double x, double y, double z, double t, double a) {
    	return (x / a) * y;
    }
    
    NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
    module fmin_fmax_functions
        implicit none
        private
        public fmax
        public fmin
    
        interface fmax
            module procedure fmax88
            module procedure fmax44
            module procedure fmax84
            module procedure fmax48
        end interface
        interface fmin
            module procedure fmin88
            module procedure fmin44
            module procedure fmin84
            module procedure fmin48
        end interface
    contains
        real(8) function fmax88(x, y) result (res)
            real(8), intent (in) :: x
            real(8), intent (in) :: y
            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
        end function
        real(4) function fmax44(x, y) result (res)
            real(4), intent (in) :: x
            real(4), intent (in) :: y
            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
        end function
        real(8) function fmax84(x, y) result(res)
            real(8), intent (in) :: x
            real(4), intent (in) :: y
            res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
        end function
        real(8) function fmax48(x, y) result(res)
            real(4), intent (in) :: x
            real(8), intent (in) :: y
            res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
        end function
        real(8) function fmin88(x, y) result (res)
            real(8), intent (in) :: x
            real(8), intent (in) :: y
            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
        end function
        real(4) function fmin44(x, y) result (res)
            real(4), intent (in) :: x
            real(4), intent (in) :: y
            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
        end function
        real(8) function fmin84(x, y) result(res)
            real(8), intent (in) :: x
            real(4), intent (in) :: y
            res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
        end function
        real(8) function fmin48(x, y) result(res)
            real(4), intent (in) :: x
            real(8), intent (in) :: y
            res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
        end function
    end module
    
    real(8) function code(x, y, z, t, a)
    use fmin_fmax_functions
        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
    
    assert x < y && y < z && z < t && t < a;
    public static double code(double x, double y, double z, double t, double a) {
    	return (x / a) * y;
    }
    
    [x, y, z, t, a] = sort([x, y, z, t, a])
    def code(x, y, z, t, a):
    	return (x / a) * y
    
    x, y, z, t, a = sort([x, y, z, t, a])
    function code(x, y, z, t, a)
    	return Float64(Float64(x / a) * y)
    end
    
    x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
    function tmp = code(x, y, z, t, a)
    	tmp = (x / a) * y;
    end
    
    NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
    code[x_, y_, z_, t_, a_] := N[(N[(x / a), $MachinePrecision] * y), $MachinePrecision]
    
    \begin{array}{l}
    [x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
    \\
    \frac{x}{a} \cdot y
    \end{array}
    
    Derivation
    1. Initial program 91.7%

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

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

        \[\leadsto \frac{x}{a} \cdot \color{blue}{y} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{x}{a} \cdot \color{blue}{y} \]
      3. lower-/.f6451.8

        \[\leadsto \frac{x}{a} \cdot y \]
    4. Applied rewrites51.8%

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

    Reproduce

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