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

Percentage Accurate: 91.2% → 97.4%
Time: 3.3s
Alternatives: 9
Speedup: 0.7×

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 9 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 91.2% 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: 97.4% accurate, 0.3× speedup?

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

\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+304}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-z, t, y \cdot x\right)}{a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (*.f64 x y) (*.f64 z t)) < -4.99999999999999991e295 or 4.9999999999999997e304 < (-.f64 (*.f64 x y) (*.f64 z t))

    1. Initial program 67.7%

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

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

        \[\leadsto \frac{\color{blue}{x \cdot y} - z \cdot t}{a} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{x \cdot y - \color{blue}{z \cdot t}}{a} \]
      4. *-commutativeN/A

        \[\leadsto \frac{x \cdot y - \color{blue}{t \cdot z}}{a} \]
      5. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x \cdot y + \color{blue}{-1 \cdot \left(t \cdot z\right)}}{a} \]
      10. div-add-revN/A

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

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

        \[\leadsto x \cdot \frac{y}{a} + \color{blue}{-1 \cdot \frac{t \cdot z}{a}} \]
      13. lower-fma.f64N/A

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

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

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

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

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

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

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

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

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

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

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

    if -4.99999999999999991e295 < (-.f64 (*.f64 x y) (*.f64 z t)) < 4.9999999999999997e304

    1. Initial program 98.9%

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

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

        \[\leadsto \frac{\color{blue}{x \cdot y} - z \cdot t}{a} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{x \cdot y - \color{blue}{z \cdot t}}{a} \]
      4. *-commutativeN/A

        \[\leadsto \frac{x \cdot y - \color{blue}{t \cdot z}}{a} \]
      5. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(-z, t, \color{blue}{y \cdot x}\right)}{a} \]
      15. lower-*.f6498.9

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

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

Alternative 2: 96.4% 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{\frac{y}{z} \cdot x - t}{a} \cdot z\\ t_2 := x \cdot y - z \cdot t\\ \mathbf{if}\;t\_2 \leq -\infty:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_2 \leq 10^{+271}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-z, t, y \cdot x\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (* (/ (- (* (/ y z) x) t) a) z)) (t_2 (- (* x y) (* z t))))
   (if (<= t_2 (- INFINITY))
     t_1
     (if (<= t_2 1e+271) (/ (fma (- z) t (* 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 = ((((y / z) * x) - t) / a) * z;
	double t_2 = (x * y) - (z * t);
	double tmp;
	if (t_2 <= -((double) INFINITY)) {
		tmp = t_1;
	} else if (t_2 <= 1e+271) {
		tmp = fma(-z, t, (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(Float64(Float64(Float64(y / z) * x) - t) / a) * z)
	t_2 = Float64(Float64(x * y) - Float64(z * t))
	tmp = 0.0
	if (t_2 <= Float64(-Inf))
		tmp = t_1;
	elseif (t_2 <= 1e+271)
		tmp = Float64(fma(Float64(-z), t, Float64(y * x)) / a);
	else
		tmp = t_1;
	end
	return tmp
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(N[(N[(y / z), $MachinePrecision] * x), $MachinePrecision] - t), $MachinePrecision] / a), $MachinePrecision] * z), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], t$95$1, If[LessEqual[t$95$2, 1e+271], N[(N[((-z) * t + N[(y * x), $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{\frac{y}{z} \cdot x - t}{a} \cdot z\\
t_2 := x \cdot y - z \cdot t\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_2 \leq 10^{+271}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-z, t, y \cdot x\right)}{a}\\

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


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

    1. Initial program 69.7%

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

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

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

      \[\leadsto -1 \cdot \color{blue}{\frac{t \cdot z}{a}} \]
    5. 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-lft-neg-inN/A

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

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

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

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

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

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

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

      \[\leadsto z \cdot \color{blue}{\left(-1 \cdot \frac{t}{a} + \frac{x \cdot y}{a \cdot z}\right)} \]
    8. Step-by-step derivation
      1. *-commutativeN/A

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

        \[\leadsto \left(-1 \cdot \frac{t}{a} + \frac{x \cdot y}{a \cdot z}\right) \cdot z \]
    9. Applied rewrites89.3%

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

    if -inf.0 < (-.f64 (*.f64 x y) (*.f64 z t)) < 9.99999999999999953e270

    1. Initial program 98.9%

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

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

        \[\leadsto \frac{\color{blue}{x \cdot y} - z \cdot t}{a} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{x \cdot y - \color{blue}{z \cdot t}}{a} \]
      4. *-commutativeN/A

        \[\leadsto \frac{x \cdot y - \color{blue}{t \cdot z}}{a} \]
      5. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(-z, t, \color{blue}{y \cdot x}\right)}{a} \]
      15. lower-*.f6498.9

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

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

Alternative 3: 73.4% accurate, 0.5× speedup?

\[\begin{array}{l} [x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\ \\ \begin{array}{l} \mathbf{if}\;x \cdot y \leq -2 \cdot 10^{+45}:\\ \;\;\;\;\frac{y}{a} \cdot x\\ \mathbf{elif}\;x \cdot y \leq -4 \cdot 10^{-161}:\\ \;\;\;\;\left(-t\right) \cdot \frac{z}{a}\\ \mathbf{elif}\;x \cdot y \leq 2000000:\\ \;\;\;\;\frac{\left(-z\right) \cdot t}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x}{a}\\ \end{array} \end{array} \]
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
(FPCore (x y z t a)
 :precision binary64
 (if (<= (* x y) -2e+45)
   (* (/ y a) x)
   (if (<= (* x y) -4e-161)
     (* (- t) (/ z a))
     (if (<= (* x y) 2000000.0) (/ (* (- z) t) a) (/ (* y x) a)))))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if ((x * y) <= -2e+45) {
		tmp = (y / a) * x;
	} else if ((x * y) <= -4e-161) {
		tmp = -t * (z / a);
	} else if ((x * y) <= 2000000.0) {
		tmp = (-z * t) / a;
	} else {
		tmp = (y * x) / a;
	}
	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 ((x * y) <= (-2d+45)) then
        tmp = (y / a) * x
    else if ((x * y) <= (-4d-161)) then
        tmp = -t * (z / a)
    else if ((x * y) <= 2000000.0d0) then
        tmp = (-z * t) / a
    else
        tmp = (y * x) / a
    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 ((x * y) <= -2e+45) {
		tmp = (y / a) * x;
	} else if ((x * y) <= -4e-161) {
		tmp = -t * (z / a);
	} else if ((x * y) <= 2000000.0) {
		tmp = (-z * t) / a;
	} else {
		tmp = (y * x) / a;
	}
	return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a])
def code(x, y, z, t, a):
	tmp = 0
	if (x * y) <= -2e+45:
		tmp = (y / a) * x
	elif (x * y) <= -4e-161:
		tmp = -t * (z / a)
	elif (x * y) <= 2000000.0:
		tmp = (-z * t) / a
	else:
		tmp = (y * x) / a
	return tmp
x, y, z, t, a = sort([x, y, z, t, a])
function code(x, y, z, t, a)
	tmp = 0.0
	if (Float64(x * y) <= -2e+45)
		tmp = Float64(Float64(y / a) * x);
	elseif (Float64(x * y) <= -4e-161)
		tmp = Float64(Float64(-t) * Float64(z / a));
	elseif (Float64(x * y) <= 2000000.0)
		tmp = Float64(Float64(Float64(-z) * t) / a);
	else
		tmp = Float64(Float64(y * x) / a);
	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 ((x * y) <= -2e+45)
		tmp = (y / a) * x;
	elseif ((x * y) <= -4e-161)
		tmp = -t * (z / a);
	elseif ((x * y) <= 2000000.0)
		tmp = (-z * t) / a;
	else
		tmp = (y * x) / a;
	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[(x * y), $MachinePrecision], -2e+45], N[(N[(y / a), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], -4e-161], N[((-t) * N[(z / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 2000000.0], N[(N[((-z) * t), $MachinePrecision] / a), $MachinePrecision], N[(N[(y * x), $MachinePrecision] / a), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -2 \cdot 10^{+45}:\\
\;\;\;\;\frac{y}{a} \cdot x\\

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

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

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


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

    1. Initial program 86.9%

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

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

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

      \[\leadsto -1 \cdot \color{blue}{\frac{t \cdot z}{a}} \]
    5. 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-lft-neg-inN/A

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

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

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

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

        \[\leadsto \left(-t\right) \cdot \frac{z}{a} \]
      8. lower-/.f6426.7

        \[\leadsto \left(-t\right) \cdot \frac{z}{a} \]
    6. Applied rewrites26.7%

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

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

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

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

        \[\leadsto \frac{y}{a} \cdot x \]
      4. lift-/.f6477.9

        \[\leadsto \frac{y}{a} \cdot x \]
    9. Applied rewrites77.9%

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

    if -1.9999999999999999e45 < (*.f64 x y) < -4.00000000000000011e-161

    1. Initial program 96.1%

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

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

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

      \[\leadsto -1 \cdot \color{blue}{\frac{t \cdot z}{a}} \]
    5. 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-lft-neg-inN/A

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

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

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

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

        \[\leadsto \left(-t\right) \cdot \frac{z}{a} \]
      8. lower-/.f6457.0

        \[\leadsto \left(-t\right) \cdot \frac{z}{a} \]
    6. Applied rewrites57.0%

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

    if -4.00000000000000011e-161 < (*.f64 x y) < 2e6

    1. Initial program 94.0%

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

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

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

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

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

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

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

    if 2e6 < (*.f64 x y)

    1. Initial program 87.9%

      \[\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-*.f6470.6

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

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

Alternative 4: 74.7% 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 -5 \cdot 10^{+46}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \cdot t \leq 10^{+55}:\\ \;\;\;\;\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) -5e+46) t_1 (if (<= (* z t) 1e+55) (/ (* 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) <= -5e+46) {
		tmp = t_1;
	} else if ((z * t) <= 1e+55) {
		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) <= (-5d+46)) then
        tmp = t_1
    else if ((z * t) <= 1d+55) 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) <= -5e+46) {
		tmp = t_1;
	} else if ((z * t) <= 1e+55) {
		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) <= -5e+46:
		tmp = t_1
	elif (z * t) <= 1e+55:
		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) <= -5e+46)
		tmp = t_1;
	elseif (Float64(z * t) <= 1e+55)
		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) <= -5e+46)
		tmp = t_1;
	elseif ((z * t) <= 1e+55)
		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], -5e+46], t$95$1, If[LessEqual[N[(z * t), $MachinePrecision], 1e+55], 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 -5 \cdot 10^{+46}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \cdot t \leq 10^{+55}:\\
\;\;\;\;\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) < -5.0000000000000002e46 or 1.00000000000000001e55 < (*.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. associate-*l/N/A

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

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

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

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

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

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

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

        \[\leadsto \left(-z\right) \cdot \frac{\color{blue}{t}}{a} \]
      9. lower-/.f6479.3

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

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

    if -5.0000000000000002e46 < (*.f64 z t) < 1.00000000000000001e55

    1. Initial program 94.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-*.f6471.3

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

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

Alternative 5: 74.8% 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(-t\right) \cdot \frac{z}{a}\\ \mathbf{if}\;z \cdot t \leq -5 \cdot 10^{+41}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \cdot t \leq 10^{+55}:\\ \;\;\;\;\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 (* (- t) (/ z a))))
   (if (<= (* z t) -5e+41) t_1 (if (<= (* z t) 1e+55) (/ (* 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 = -t * (z / a);
	double tmp;
	if ((z * t) <= -5e+41) {
		tmp = t_1;
	} else if ((z * t) <= 1e+55) {
		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 = -t * (z / a)
    if ((z * t) <= (-5d+41)) then
        tmp = t_1
    else if ((z * t) <= 1d+55) 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 = -t * (z / a);
	double tmp;
	if ((z * t) <= -5e+41) {
		tmp = t_1;
	} else if ((z * t) <= 1e+55) {
		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 = -t * (z / a)
	tmp = 0
	if (z * t) <= -5e+41:
		tmp = t_1
	elif (z * t) <= 1e+55:
		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(-t) * Float64(z / a))
	tmp = 0.0
	if (Float64(z * t) <= -5e+41)
		tmp = t_1;
	elseif (Float64(z * t) <= 1e+55)
		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 = -t * (z / a);
	tmp = 0.0;
	if ((z * t) <= -5e+41)
		tmp = t_1;
	elseif ((z * t) <= 1e+55)
		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[((-t) * N[(z / a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(z * t), $MachinePrecision], -5e+41], t$95$1, If[LessEqual[N[(z * t), $MachinePrecision], 1e+55], 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(-t\right) \cdot \frac{z}{a}\\
\mathbf{if}\;z \cdot t \leq -5 \cdot 10^{+41}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \cdot t \leq 10^{+55}:\\
\;\;\;\;\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) < -5.00000000000000022e41 or 1.00000000000000001e55 < (*.f64 z t)

    1. Initial program 86.4%

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

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

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

      \[\leadsto -1 \cdot \color{blue}{\frac{t \cdot z}{a}} \]
    5. 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-lft-neg-inN/A

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

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

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

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

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

        \[\leadsto \left(-t\right) \cdot \frac{z}{a} \]
    6. Applied rewrites79.1%

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

    if -5.00000000000000022e41 < (*.f64 z t) < 1.00000000000000001e55

    1. Initial program 94.8%

      \[\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-*.f6471.6

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

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

Alternative 6: 93.4% accurate, 0.7× 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 -1 \cdot 10^{+307}:\\ \;\;\;\;\left(-t\right) \cdot \frac{z}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-z, t, y \cdot x\right)}{a}\\ \end{array} \end{array} \]
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
(FPCore (x y z t a)
 :precision binary64
 (if (<= (* z t) -1e+307) (* (- t) (/ z a)) (/ (fma (- z) t (* y x)) a)))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if ((z * t) <= -1e+307) {
		tmp = -t * (z / a);
	} else {
		tmp = fma(-z, t, (y * x)) / a;
	}
	return tmp;
}
x, y, z, t, a = sort([x, y, z, t, a])
function code(x, y, z, t, a)
	tmp = 0.0
	if (Float64(z * t) <= -1e+307)
		tmp = Float64(Float64(-t) * Float64(z / a));
	else
		tmp = Float64(fma(Float64(-z), t, Float64(y * x)) / a);
	end
	return tmp
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_] := If[LessEqual[N[(z * t), $MachinePrecision], -1e+307], N[((-t) * N[(z / a), $MachinePrecision]), $MachinePrecision], N[(N[((-z) * t + N[(y * x), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -1 \cdot 10^{+307}:\\
\;\;\;\;\left(-t\right) \cdot \frac{z}{a}\\

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


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

    1. Initial program 63.5%

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

      \[\leadsto \color{blue}{z \cdot \left(-1 \cdot \frac{t}{a} + \frac{x \cdot y}{a \cdot z}\right)} \]
    3. Applied rewrites91.9%

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

      \[\leadsto -1 \cdot \color{blue}{\frac{t \cdot z}{a}} \]
    5. 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-lft-neg-inN/A

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

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

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

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

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

        \[\leadsto \left(-t\right) \cdot \frac{z}{a} \]
    6. Applied rewrites95.1%

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

    if -9.99999999999999986e306 < (*.f64 z t)

    1. Initial program 93.1%

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

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

        \[\leadsto \frac{\color{blue}{x \cdot y} - z \cdot t}{a} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{x \cdot y - \color{blue}{z \cdot t}}{a} \]
      4. *-commutativeN/A

        \[\leadsto \frac{x \cdot y - \color{blue}{t \cdot z}}{a} \]
      5. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 93.2% accurate, 0.7× 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 -1 \cdot 10^{+307}:\\ \;\;\;\;\left(-t\right) \cdot \frac{z}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\ \end{array} \end{array} \]
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
(FPCore (x y z t a)
 :precision binary64
 (if (<= (* z t) -1e+307) (* (- t) (/ z a)) (/ (- (* x y) (* z t)) a)))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if ((z * t) <= -1e+307) {
		tmp = -t * (z / a);
	} else {
		tmp = ((x * y) - (z * t)) / a;
	}
	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) <= (-1d+307)) then
        tmp = -t * (z / a)
    else
        tmp = ((x * y) - (z * t)) / a
    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) <= -1e+307) {
		tmp = -t * (z / a);
	} else {
		tmp = ((x * y) - (z * t)) / a;
	}
	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) <= -1e+307:
		tmp = -t * (z / a)
	else:
		tmp = ((x * y) - (z * t)) / a
	return tmp
x, y, z, t, a = sort([x, y, z, t, a])
function code(x, y, z, t, a)
	tmp = 0.0
	if (Float64(z * t) <= -1e+307)
		tmp = Float64(Float64(-t) * Float64(z / a));
	else
		tmp = Float64(Float64(Float64(x * y) - Float64(z * t)) / a);
	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) <= -1e+307)
		tmp = -t * (z / a);
	else
		tmp = ((x * y) - (z * t)) / a;
	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], -1e+307], N[((-t) * N[(z / a), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -1 \cdot 10^{+307}:\\
\;\;\;\;\left(-t\right) \cdot \frac{z}{a}\\

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


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

    1. Initial program 63.5%

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

      \[\leadsto \color{blue}{z \cdot \left(-1 \cdot \frac{t}{a} + \frac{x \cdot y}{a \cdot z}\right)} \]
    3. Applied rewrites91.9%

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

      \[\leadsto -1 \cdot \color{blue}{\frac{t \cdot z}{a}} \]
    5. 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-lft-neg-inN/A

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

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

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

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

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

        \[\leadsto \left(-t\right) \cdot \frac{z}{a} \]
    6. Applied rewrites95.1%

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

    if -9.99999999999999986e306 < (*.f64 z t)

    1. Initial program 93.1%

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

Alternative 8: 50.9% accurate, 1.5× 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.2%

    \[\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-*.f6450.9

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

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

Alternative 9: 51.6% accurate, 1.5× speedup?

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

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

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

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

    \[\leadsto -1 \cdot \color{blue}{\frac{t \cdot z}{a}} \]
  5. 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-lft-neg-inN/A

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

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

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

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

      \[\leadsto \left(-t\right) \cdot \frac{z}{a} \]
    8. lower-/.f6451.3

      \[\leadsto \left(-t\right) \cdot \frac{z}{a} \]
  6. Applied rewrites51.3%

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

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

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

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

      \[\leadsto \frac{y}{a} \cdot x \]
    4. lift-/.f6451.6

      \[\leadsto \frac{y}{a} \cdot x \]
  9. Applied rewrites51.6%

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

Developer Target 1: 91.4% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{y}{a} \cdot x - \frac{t}{a} \cdot z\\ \mathbf{if}\;z < -2.468684968699548 \cdot 10^{+170}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z < 6.309831121978371 \cdot 10^{-71}:\\ \;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (- (* (/ y a) x) (* (/ t a) z))))
   (if (< z -2.468684968699548e+170)
     t_1
     (if (< z 6.309831121978371e-71) (/ (- (* x y) (* z t)) a) t_1))))
double code(double x, double y, double z, double t, double a) {
	double t_1 = ((y / a) * x) - ((t / a) * z);
	double tmp;
	if (z < -2.468684968699548e+170) {
		tmp = t_1;
	} else if (z < 6.309831121978371e-71) {
		tmp = ((x * y) - (z * t)) / a;
	} else {
		tmp = t_1;
	}
	return tmp;
}
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 / 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 2025093 
(FPCore (x y z t a)
  :name "Data.Colour.Matrix:inverse from colour-2.3.3, B"
  :precision binary64

  :alt
  (! :herbie-platform default (if (< z -246868496869954800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (- (* (/ y a) x) (* (/ t a) z)) (if (< z 6309831121978371/100000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (/ (- (* x y) (* z t)) a) (- (* (/ y a) x) (* (/ t a) z)))))

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