Linear.Projection:inverseInfinitePerspective from linear-1.19.1.3

Percentage Accurate: 96.3% → 99.3%
Time: 6.3s
Alternatives: 8
Speedup: 0.9×

Specification

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

\\
\left(x \cdot y - z \cdot y\right) \cdot t
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 8 alternatives:

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

Initial Program: 96.3% accurate, 1.0× speedup?

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

\\
\left(x \cdot y - z \cdot y\right) \cdot t
\end{array}

Alternative 1: 99.3% accurate, 0.4× speedup?

\[\begin{array}{l} t\_m = \left|t\right| \\ t\_s = \mathsf{copysign}\left(1, t\right) \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ [x, y_m, z, t_m] = \mathsf{sort}([x, y_m, z, t_m])\\ \\ \begin{array}{l} t_2 := x \cdot y\_m - z \cdot y\_m\\ y\_s \cdot \left(t\_s \cdot \begin{array}{l} \mathbf{if}\;t\_2 \leq -5 \cdot 10^{-273} \lor \neg \left(t\_2 \leq 2 \cdot 10^{-129}\right):\\ \;\;\;\;\left(\left(x - z\right) \cdot y\_m\right) \cdot t\_m\\ \mathbf{else}:\\ \;\;\;\;\left(\left(x - z\right) \cdot t\_m\right) \cdot y\_m\\ \end{array}\right) \end{array} \end{array} \]
t\_m = (fabs.f64 t)
t\_s = (copysign.f64 #s(literal 1 binary64) t)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function.
(FPCore (y_s t_s x y_m z t_m)
 :precision binary64
 (let* ((t_2 (- (* x y_m) (* z y_m))))
   (*
    y_s
    (*
     t_s
     (if (or (<= t_2 -5e-273) (not (<= t_2 2e-129)))
       (* (* (- x z) y_m) t_m)
       (* (* (- x z) t_m) y_m))))))
t\_m = fabs(t);
t\_s = copysign(1.0, t);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z && z < t_m);
double code(double y_s, double t_s, double x, double y_m, double z, double t_m) {
	double t_2 = (x * y_m) - (z * y_m);
	double tmp;
	if ((t_2 <= -5e-273) || !(t_2 <= 2e-129)) {
		tmp = ((x - z) * y_m) * t_m;
	} else {
		tmp = ((x - z) * t_m) * y_m;
	}
	return y_s * (t_s * tmp);
}
t\_m =     private
t\_s =     private
y\_m =     private
y\_s =     private
NOTE: x, y_m, z, and t_m 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(y_s, t_s, x, y_m, z, t_m)
use fmin_fmax_functions
    real(8), intent (in) :: y_s
    real(8), intent (in) :: t_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8), intent (in) :: t_m
    real(8) :: t_2
    real(8) :: tmp
    t_2 = (x * y_m) - (z * y_m)
    if ((t_2 <= (-5d-273)) .or. (.not. (t_2 <= 2d-129))) then
        tmp = ((x - z) * y_m) * t_m
    else
        tmp = ((x - z) * t_m) * y_m
    end if
    code = y_s * (t_s * tmp)
end function
t\_m = Math.abs(t);
t\_s = Math.copySign(1.0, t);
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x < y_m && y_m < z && z < t_m;
public static double code(double y_s, double t_s, double x, double y_m, double z, double t_m) {
	double t_2 = (x * y_m) - (z * y_m);
	double tmp;
	if ((t_2 <= -5e-273) || !(t_2 <= 2e-129)) {
		tmp = ((x - z) * y_m) * t_m;
	} else {
		tmp = ((x - z) * t_m) * y_m;
	}
	return y_s * (t_s * tmp);
}
t\_m = math.fabs(t)
t\_s = math.copysign(1.0, t)
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
[x, y_m, z, t_m] = sort([x, y_m, z, t_m])
def code(y_s, t_s, x, y_m, z, t_m):
	t_2 = (x * y_m) - (z * y_m)
	tmp = 0
	if (t_2 <= -5e-273) or not (t_2 <= 2e-129):
		tmp = ((x - z) * y_m) * t_m
	else:
		tmp = ((x - z) * t_m) * y_m
	return y_s * (t_s * tmp)
t\_m = abs(t)
t\_s = copysign(1.0, t)
y\_m = abs(y)
y\_s = copysign(1.0, y)
x, y_m, z, t_m = sort([x, y_m, z, t_m])
function code(y_s, t_s, x, y_m, z, t_m)
	t_2 = Float64(Float64(x * y_m) - Float64(z * y_m))
	tmp = 0.0
	if ((t_2 <= -5e-273) || !(t_2 <= 2e-129))
		tmp = Float64(Float64(Float64(x - z) * y_m) * t_m);
	else
		tmp = Float64(Float64(Float64(x - z) * t_m) * y_m);
	end
	return Float64(y_s * Float64(t_s * tmp))
end
t\_m = abs(t);
t\_s = sign(t) * abs(1.0);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x, y_m, z, t_m = num2cell(sort([x, y_m, z, t_m])){:}
function tmp_2 = code(y_s, t_s, x, y_m, z, t_m)
	t_2 = (x * y_m) - (z * y_m);
	tmp = 0.0;
	if ((t_2 <= -5e-273) || ~((t_2 <= 2e-129)))
		tmp = ((x - z) * y_m) * t_m;
	else
		tmp = ((x - z) * t_m) * y_m;
	end
	tmp_2 = y_s * (t_s * tmp);
end
t\_m = N[Abs[t], $MachinePrecision]
t\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function.
code[y$95$s_, t$95$s_, x_, y$95$m_, z_, t$95$m_] := Block[{t$95$2 = N[(N[(x * y$95$m), $MachinePrecision] - N[(z * y$95$m), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * N[(t$95$s * If[Or[LessEqual[t$95$2, -5e-273], N[Not[LessEqual[t$95$2, 2e-129]], $MachinePrecision]], N[(N[(N[(x - z), $MachinePrecision] * y$95$m), $MachinePrecision] * t$95$m), $MachinePrecision], N[(N[(N[(x - z), $MachinePrecision] * t$95$m), $MachinePrecision] * y$95$m), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t\_m = \left|t\right|
\\
t\_s = \mathsf{copysign}\left(1, t\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z, t_m] = \mathsf{sort}([x, y_m, z, t_m])\\
\\
\begin{array}{l}
t_2 := x \cdot y\_m - z \cdot y\_m\\
y\_s \cdot \left(t\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_2 \leq -5 \cdot 10^{-273} \lor \neg \left(t\_2 \leq 2 \cdot 10^{-129}\right):\\
\;\;\;\;\left(\left(x - z\right) \cdot y\_m\right) \cdot t\_m\\

\mathbf{else}:\\
\;\;\;\;\left(\left(x - z\right) \cdot t\_m\right) \cdot y\_m\\


\end{array}\right)
\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (*.f64 x y) (*.f64 z y)) < -4.99999999999999965e-273 or 1.9999999999999999e-129 < (-.f64 (*.f64 x y) (*.f64 z y))

    1. Initial program 90.0%

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

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

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

        \[\leadsto \left(x \cdot y - \color{blue}{z \cdot y}\right) \cdot t \]
      4. distribute-rgt-out--N/A

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

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

        \[\leadsto \color{blue}{\left(\left(x - z\right) \cdot y\right)} \cdot t \]
      7. lower--.f6493.2

        \[\leadsto \left(\color{blue}{\left(x - z\right)} \cdot y\right) \cdot t \]
    4. Applied rewrites93.2%

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

    if -4.99999999999999965e-273 < (-.f64 (*.f64 x y) (*.f64 z y)) < 1.9999999999999999e-129

    1. Initial program 77.6%

      \[\left(x \cdot y - z \cdot y\right) \cdot t \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f64N/A

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

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

        \[\leadsto \left(\color{blue}{x \cdot y} - z \cdot y\right) \cdot t \]
      4. lift-*.f64N/A

        \[\leadsto \left(x \cdot y - \color{blue}{z \cdot y}\right) \cdot t \]
      5. distribute-rgt-out--N/A

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

        \[\leadsto \color{blue}{y \cdot \left(\left(x - z\right) \cdot t\right)} \]
      7. *-commutativeN/A

        \[\leadsto \color{blue}{\left(\left(x - z\right) \cdot t\right) \cdot y} \]
      8. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(\left(x - z\right) \cdot t\right) \cdot y} \]
      9. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(\left(x - z\right) \cdot t\right)} \cdot y \]
      10. lower--.f6499.7

        \[\leadsto \left(\color{blue}{\left(x - z\right)} \cdot t\right) \cdot y \]
    4. Applied rewrites99.7%

      \[\leadsto \color{blue}{\left(\left(x - z\right) \cdot t\right) \cdot y} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification93.9%

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

Alternative 2: 89.8% accurate, 0.7× speedup?

\[\begin{array}{l} t\_m = \left|t\right| \\ t\_s = \mathsf{copysign}\left(1, t\right) \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ [x, y_m, z, t_m] = \mathsf{sort}([x, y_m, z, t_m])\\ \\ y\_s \cdot \left(t\_s \cdot \begin{array}{l} \mathbf{if}\;z \leq -5.8 \cdot 10^{+203} \lor \neg \left(z \leq 1.35 \cdot 10^{+201}\right):\\ \;\;\;\;\left(\left(-z\right) \cdot y\_m\right) \cdot t\_m\\ \mathbf{else}:\\ \;\;\;\;\left(\left(x - z\right) \cdot t\_m\right) \cdot y\_m\\ \end{array}\right) \end{array} \]
t\_m = (fabs.f64 t)
t\_s = (copysign.f64 #s(literal 1 binary64) t)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function.
(FPCore (y_s t_s x y_m z t_m)
 :precision binary64
 (*
  y_s
  (*
   t_s
   (if (or (<= z -5.8e+203) (not (<= z 1.35e+201)))
     (* (* (- z) y_m) t_m)
     (* (* (- x z) t_m) y_m)))))
t\_m = fabs(t);
t\_s = copysign(1.0, t);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z && z < t_m);
double code(double y_s, double t_s, double x, double y_m, double z, double t_m) {
	double tmp;
	if ((z <= -5.8e+203) || !(z <= 1.35e+201)) {
		tmp = (-z * y_m) * t_m;
	} else {
		tmp = ((x - z) * t_m) * y_m;
	}
	return y_s * (t_s * tmp);
}
t\_m =     private
t\_s =     private
y\_m =     private
y\_s =     private
NOTE: x, y_m, z, and t_m 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(y_s, t_s, x, y_m, z, t_m)
use fmin_fmax_functions
    real(8), intent (in) :: y_s
    real(8), intent (in) :: t_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8), intent (in) :: t_m
    real(8) :: tmp
    if ((z <= (-5.8d+203)) .or. (.not. (z <= 1.35d+201))) then
        tmp = (-z * y_m) * t_m
    else
        tmp = ((x - z) * t_m) * y_m
    end if
    code = y_s * (t_s * tmp)
end function
t\_m = Math.abs(t);
t\_s = Math.copySign(1.0, t);
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x < y_m && y_m < z && z < t_m;
public static double code(double y_s, double t_s, double x, double y_m, double z, double t_m) {
	double tmp;
	if ((z <= -5.8e+203) || !(z <= 1.35e+201)) {
		tmp = (-z * y_m) * t_m;
	} else {
		tmp = ((x - z) * t_m) * y_m;
	}
	return y_s * (t_s * tmp);
}
t\_m = math.fabs(t)
t\_s = math.copysign(1.0, t)
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
[x, y_m, z, t_m] = sort([x, y_m, z, t_m])
def code(y_s, t_s, x, y_m, z, t_m):
	tmp = 0
	if (z <= -5.8e+203) or not (z <= 1.35e+201):
		tmp = (-z * y_m) * t_m
	else:
		tmp = ((x - z) * t_m) * y_m
	return y_s * (t_s * tmp)
t\_m = abs(t)
t\_s = copysign(1.0, t)
y\_m = abs(y)
y\_s = copysign(1.0, y)
x, y_m, z, t_m = sort([x, y_m, z, t_m])
function code(y_s, t_s, x, y_m, z, t_m)
	tmp = 0.0
	if ((z <= -5.8e+203) || !(z <= 1.35e+201))
		tmp = Float64(Float64(Float64(-z) * y_m) * t_m);
	else
		tmp = Float64(Float64(Float64(x - z) * t_m) * y_m);
	end
	return Float64(y_s * Float64(t_s * tmp))
end
t\_m = abs(t);
t\_s = sign(t) * abs(1.0);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x, y_m, z, t_m = num2cell(sort([x, y_m, z, t_m])){:}
function tmp_2 = code(y_s, t_s, x, y_m, z, t_m)
	tmp = 0.0;
	if ((z <= -5.8e+203) || ~((z <= 1.35e+201)))
		tmp = (-z * y_m) * t_m;
	else
		tmp = ((x - z) * t_m) * y_m;
	end
	tmp_2 = y_s * (t_s * tmp);
end
t\_m = N[Abs[t], $MachinePrecision]
t\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function.
code[y$95$s_, t$95$s_, x_, y$95$m_, z_, t$95$m_] := N[(y$95$s * N[(t$95$s * If[Or[LessEqual[z, -5.8e+203], N[Not[LessEqual[z, 1.35e+201]], $MachinePrecision]], N[(N[((-z) * y$95$m), $MachinePrecision] * t$95$m), $MachinePrecision], N[(N[(N[(x - z), $MachinePrecision] * t$95$m), $MachinePrecision] * y$95$m), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
t\_m = \left|t\right|
\\
t\_s = \mathsf{copysign}\left(1, t\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z, t_m] = \mathsf{sort}([x, y_m, z, t_m])\\
\\
y\_s \cdot \left(t\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -5.8 \cdot 10^{+203} \lor \neg \left(z \leq 1.35 \cdot 10^{+201}\right):\\
\;\;\;\;\left(\left(-z\right) \cdot y\_m\right) \cdot t\_m\\

\mathbf{else}:\\
\;\;\;\;\left(\left(x - z\right) \cdot t\_m\right) \cdot y\_m\\


\end{array}\right)
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -5.80000000000000021e203 or 1.35e201 < z

    1. Initial program 84.5%

      \[\left(x \cdot y - z \cdot y\right) \cdot t \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

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

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

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

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

        \[\leadsto \left(\color{blue}{\left(\mathsf{neg}\left(z\right)\right)} \cdot y\right) \cdot t \]
      5. lower-neg.f6486.1

        \[\leadsto \left(\color{blue}{\left(-z\right)} \cdot y\right) \cdot t \]
    5. Applied rewrites86.1%

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

    if -5.80000000000000021e203 < z < 1.35e201

    1. Initial program 89.3%

      \[\left(x \cdot y - z \cdot y\right) \cdot t \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f64N/A

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

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

        \[\leadsto \left(\color{blue}{x \cdot y} - z \cdot y\right) \cdot t \]
      4. lift-*.f64N/A

        \[\leadsto \left(x \cdot y - \color{blue}{z \cdot y}\right) \cdot t \]
      5. distribute-rgt-out--N/A

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

        \[\leadsto \color{blue}{y \cdot \left(\left(x - z\right) \cdot t\right)} \]
      7. *-commutativeN/A

        \[\leadsto \color{blue}{\left(\left(x - z\right) \cdot t\right) \cdot y} \]
      8. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(\left(x - z\right) \cdot t\right) \cdot y} \]
      9. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(\left(x - z\right) \cdot t\right)} \cdot y \]
      10. lower--.f6493.7

        \[\leadsto \left(\color{blue}{\left(x - z\right)} \cdot t\right) \cdot y \]
    4. Applied rewrites93.7%

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

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

Alternative 3: 75.6% accurate, 0.8× speedup?

\[\begin{array}{l} t\_m = \left|t\right| \\ t\_s = \mathsf{copysign}\left(1, t\right) \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ [x, y_m, z, t_m] = \mathsf{sort}([x, y_m, z, t_m])\\ \\ y\_s \cdot \left(t\_s \cdot \begin{array}{l} \mathbf{if}\;x \leq -1.6 \cdot 10^{+107} \lor \neg \left(x \leq 3.15 \cdot 10^{-43}\right):\\ \;\;\;\;\left(y\_m \cdot x\right) \cdot t\_m\\ \mathbf{else}:\\ \;\;\;\;\left(t\_m \cdot y\_m\right) \cdot \left(-z\right)\\ \end{array}\right) \end{array} \]
t\_m = (fabs.f64 t)
t\_s = (copysign.f64 #s(literal 1 binary64) t)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function.
(FPCore (y_s t_s x y_m z t_m)
 :precision binary64
 (*
  y_s
  (*
   t_s
   (if (or (<= x -1.6e+107) (not (<= x 3.15e-43)))
     (* (* y_m x) t_m)
     (* (* t_m y_m) (- z))))))
t\_m = fabs(t);
t\_s = copysign(1.0, t);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z && z < t_m);
double code(double y_s, double t_s, double x, double y_m, double z, double t_m) {
	double tmp;
	if ((x <= -1.6e+107) || !(x <= 3.15e-43)) {
		tmp = (y_m * x) * t_m;
	} else {
		tmp = (t_m * y_m) * -z;
	}
	return y_s * (t_s * tmp);
}
t\_m =     private
t\_s =     private
y\_m =     private
y\_s =     private
NOTE: x, y_m, z, and t_m 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(y_s, t_s, x, y_m, z, t_m)
use fmin_fmax_functions
    real(8), intent (in) :: y_s
    real(8), intent (in) :: t_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8), intent (in) :: t_m
    real(8) :: tmp
    if ((x <= (-1.6d+107)) .or. (.not. (x <= 3.15d-43))) then
        tmp = (y_m * x) * t_m
    else
        tmp = (t_m * y_m) * -z
    end if
    code = y_s * (t_s * tmp)
end function
t\_m = Math.abs(t);
t\_s = Math.copySign(1.0, t);
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x < y_m && y_m < z && z < t_m;
public static double code(double y_s, double t_s, double x, double y_m, double z, double t_m) {
	double tmp;
	if ((x <= -1.6e+107) || !(x <= 3.15e-43)) {
		tmp = (y_m * x) * t_m;
	} else {
		tmp = (t_m * y_m) * -z;
	}
	return y_s * (t_s * tmp);
}
t\_m = math.fabs(t)
t\_s = math.copysign(1.0, t)
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
[x, y_m, z, t_m] = sort([x, y_m, z, t_m])
def code(y_s, t_s, x, y_m, z, t_m):
	tmp = 0
	if (x <= -1.6e+107) or not (x <= 3.15e-43):
		tmp = (y_m * x) * t_m
	else:
		tmp = (t_m * y_m) * -z
	return y_s * (t_s * tmp)
t\_m = abs(t)
t\_s = copysign(1.0, t)
y\_m = abs(y)
y\_s = copysign(1.0, y)
x, y_m, z, t_m = sort([x, y_m, z, t_m])
function code(y_s, t_s, x, y_m, z, t_m)
	tmp = 0.0
	if ((x <= -1.6e+107) || !(x <= 3.15e-43))
		tmp = Float64(Float64(y_m * x) * t_m);
	else
		tmp = Float64(Float64(t_m * y_m) * Float64(-z));
	end
	return Float64(y_s * Float64(t_s * tmp))
end
t\_m = abs(t);
t\_s = sign(t) * abs(1.0);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x, y_m, z, t_m = num2cell(sort([x, y_m, z, t_m])){:}
function tmp_2 = code(y_s, t_s, x, y_m, z, t_m)
	tmp = 0.0;
	if ((x <= -1.6e+107) || ~((x <= 3.15e-43)))
		tmp = (y_m * x) * t_m;
	else
		tmp = (t_m * y_m) * -z;
	end
	tmp_2 = y_s * (t_s * tmp);
end
t\_m = N[Abs[t], $MachinePrecision]
t\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function.
code[y$95$s_, t$95$s_, x_, y$95$m_, z_, t$95$m_] := N[(y$95$s * N[(t$95$s * If[Or[LessEqual[x, -1.6e+107], N[Not[LessEqual[x, 3.15e-43]], $MachinePrecision]], N[(N[(y$95$m * x), $MachinePrecision] * t$95$m), $MachinePrecision], N[(N[(t$95$m * y$95$m), $MachinePrecision] * (-z)), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
t\_m = \left|t\right|
\\
t\_s = \mathsf{copysign}\left(1, t\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z, t_m] = \mathsf{sort}([x, y_m, z, t_m])\\
\\
y\_s \cdot \left(t\_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq -1.6 \cdot 10^{+107} \lor \neg \left(x \leq 3.15 \cdot 10^{-43}\right):\\
\;\;\;\;\left(y\_m \cdot x\right) \cdot t\_m\\

\mathbf{else}:\\
\;\;\;\;\left(t\_m \cdot y\_m\right) \cdot \left(-z\right)\\


\end{array}\right)
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.60000000000000015e107 or 3.1500000000000001e-43 < x

    1. Initial program 83.9%

      \[\left(x \cdot y - z \cdot y\right) \cdot t \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf

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

        \[\leadsto \color{blue}{\left(x \cdot y\right) \cdot t} \]
      2. associate-*r*N/A

        \[\leadsto \color{blue}{x \cdot \left(y \cdot t\right)} \]
      3. *-commutativeN/A

        \[\leadsto x \cdot \color{blue}{\left(t \cdot y\right)} \]
      4. remove-double-negN/A

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

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

        \[\leadsto \color{blue}{\left(-1 \cdot \left(-1 \cdot x\right)\right)} \cdot \left(t \cdot y\right) \]
      7. *-commutativeN/A

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

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

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

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

        \[\leadsto \color{blue}{\left(\left(-1 \cdot x\right) \cdot \left(-1 \cdot y\right)\right) \cdot t} \]
      12. lower-*.f64N/A

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

        \[\leadsto \color{blue}{\left(\left(\left(-1 \cdot x\right) \cdot -1\right) \cdot y\right)} \cdot t \]
      14. *-commutativeN/A

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

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

        \[\leadsto \left(\left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right)\right) \cdot y\right) \cdot t \]
      17. remove-double-negN/A

        \[\leadsto \left(\color{blue}{x} \cdot y\right) \cdot t \]
      18. *-commutativeN/A

        \[\leadsto \color{blue}{\left(y \cdot x\right)} \cdot t \]
      19. lower-*.f6475.2

        \[\leadsto \color{blue}{\left(y \cdot x\right)} \cdot t \]
    5. Applied rewrites75.2%

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

    if -1.60000000000000015e107 < x < 3.1500000000000001e-43

    1. Initial program 91.9%

      \[\left(x \cdot y - z \cdot y\right) \cdot t \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f64N/A

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

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

        \[\leadsto \left(\color{blue}{x \cdot y} - z \cdot y\right) \cdot t \]
      4. lift-*.f64N/A

        \[\leadsto \left(x \cdot y - \color{blue}{z \cdot y}\right) \cdot t \]
      5. distribute-rgt-out--N/A

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

        \[\leadsto \color{blue}{y \cdot \left(\left(x - z\right) \cdot t\right)} \]
      7. *-commutativeN/A

        \[\leadsto \color{blue}{\left(\left(x - z\right) \cdot t\right) \cdot y} \]
      8. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(\left(x - z\right) \cdot t\right) \cdot y} \]
      9. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(\left(x - z\right) \cdot t\right)} \cdot y \]
      10. lower--.f6491.0

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

      \[\leadsto \color{blue}{\left(\left(x - z\right) \cdot t\right) \cdot y} \]
    5. Taylor expanded in x around 0

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

        \[\leadsto \left(\color{blue}{\left(\mathsf{neg}\left(z\right)\right)} \cdot t\right) \cdot y \]
      2. lower-neg.f6471.2

        \[\leadsto \left(\color{blue}{\left(-z\right)} \cdot t\right) \cdot y \]
    7. Applied rewrites71.2%

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

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

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

        \[\leadsto \color{blue}{\left(-z\right) \cdot \left(t \cdot y\right)} \]
      4. lift-*.f64N/A

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

        \[\leadsto \color{blue}{\left(t \cdot y\right) \cdot \left(-z\right)} \]
      6. lower-*.f6476.8

        \[\leadsto \color{blue}{\left(t \cdot y\right) \cdot \left(-z\right)} \]
    9. Applied rewrites76.8%

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

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

Alternative 4: 77.8% accurate, 0.8× speedup?

\[\begin{array}{l} t\_m = \left|t\right| \\ t\_s = \mathsf{copysign}\left(1, t\right) \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ [x, y_m, z, t_m] = \mathsf{sort}([x, y_m, z, t_m])\\ \\ y\_s \cdot \left(t\_s \cdot \begin{array}{l} \mathbf{if}\;z \leq -1.28 \cdot 10^{+20} \lor \neg \left(z \leq 1.3 \cdot 10^{-37}\right):\\ \;\;\;\;\left(\left(-z\right) \cdot y\_m\right) \cdot t\_m\\ \mathbf{else}:\\ \;\;\;\;\left(y\_m \cdot x\right) \cdot t\_m\\ \end{array}\right) \end{array} \]
t\_m = (fabs.f64 t)
t\_s = (copysign.f64 #s(literal 1 binary64) t)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function.
(FPCore (y_s t_s x y_m z t_m)
 :precision binary64
 (*
  y_s
  (*
   t_s
   (if (or (<= z -1.28e+20) (not (<= z 1.3e-37)))
     (* (* (- z) y_m) t_m)
     (* (* y_m x) t_m)))))
t\_m = fabs(t);
t\_s = copysign(1.0, t);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z && z < t_m);
double code(double y_s, double t_s, double x, double y_m, double z, double t_m) {
	double tmp;
	if ((z <= -1.28e+20) || !(z <= 1.3e-37)) {
		tmp = (-z * y_m) * t_m;
	} else {
		tmp = (y_m * x) * t_m;
	}
	return y_s * (t_s * tmp);
}
t\_m =     private
t\_s =     private
y\_m =     private
y\_s =     private
NOTE: x, y_m, z, and t_m 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(y_s, t_s, x, y_m, z, t_m)
use fmin_fmax_functions
    real(8), intent (in) :: y_s
    real(8), intent (in) :: t_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8), intent (in) :: t_m
    real(8) :: tmp
    if ((z <= (-1.28d+20)) .or. (.not. (z <= 1.3d-37))) then
        tmp = (-z * y_m) * t_m
    else
        tmp = (y_m * x) * t_m
    end if
    code = y_s * (t_s * tmp)
end function
t\_m = Math.abs(t);
t\_s = Math.copySign(1.0, t);
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x < y_m && y_m < z && z < t_m;
public static double code(double y_s, double t_s, double x, double y_m, double z, double t_m) {
	double tmp;
	if ((z <= -1.28e+20) || !(z <= 1.3e-37)) {
		tmp = (-z * y_m) * t_m;
	} else {
		tmp = (y_m * x) * t_m;
	}
	return y_s * (t_s * tmp);
}
t\_m = math.fabs(t)
t\_s = math.copysign(1.0, t)
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
[x, y_m, z, t_m] = sort([x, y_m, z, t_m])
def code(y_s, t_s, x, y_m, z, t_m):
	tmp = 0
	if (z <= -1.28e+20) or not (z <= 1.3e-37):
		tmp = (-z * y_m) * t_m
	else:
		tmp = (y_m * x) * t_m
	return y_s * (t_s * tmp)
t\_m = abs(t)
t\_s = copysign(1.0, t)
y\_m = abs(y)
y\_s = copysign(1.0, y)
x, y_m, z, t_m = sort([x, y_m, z, t_m])
function code(y_s, t_s, x, y_m, z, t_m)
	tmp = 0.0
	if ((z <= -1.28e+20) || !(z <= 1.3e-37))
		tmp = Float64(Float64(Float64(-z) * y_m) * t_m);
	else
		tmp = Float64(Float64(y_m * x) * t_m);
	end
	return Float64(y_s * Float64(t_s * tmp))
end
t\_m = abs(t);
t\_s = sign(t) * abs(1.0);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x, y_m, z, t_m = num2cell(sort([x, y_m, z, t_m])){:}
function tmp_2 = code(y_s, t_s, x, y_m, z, t_m)
	tmp = 0.0;
	if ((z <= -1.28e+20) || ~((z <= 1.3e-37)))
		tmp = (-z * y_m) * t_m;
	else
		tmp = (y_m * x) * t_m;
	end
	tmp_2 = y_s * (t_s * tmp);
end
t\_m = N[Abs[t], $MachinePrecision]
t\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function.
code[y$95$s_, t$95$s_, x_, y$95$m_, z_, t$95$m_] := N[(y$95$s * N[(t$95$s * If[Or[LessEqual[z, -1.28e+20], N[Not[LessEqual[z, 1.3e-37]], $MachinePrecision]], N[(N[((-z) * y$95$m), $MachinePrecision] * t$95$m), $MachinePrecision], N[(N[(y$95$m * x), $MachinePrecision] * t$95$m), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
t\_m = \left|t\right|
\\
t\_s = \mathsf{copysign}\left(1, t\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z, t_m] = \mathsf{sort}([x, y_m, z, t_m])\\
\\
y\_s \cdot \left(t\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -1.28 \cdot 10^{+20} \lor \neg \left(z \leq 1.3 \cdot 10^{-37}\right):\\
\;\;\;\;\left(\left(-z\right) \cdot y\_m\right) \cdot t\_m\\

\mathbf{else}:\\
\;\;\;\;\left(y\_m \cdot x\right) \cdot t\_m\\


\end{array}\right)
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.28e20 or 1.2999999999999999e-37 < z

    1. Initial program 87.6%

      \[\left(x \cdot y - z \cdot y\right) \cdot t \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

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

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

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

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

        \[\leadsto \left(\color{blue}{\left(\mathsf{neg}\left(z\right)\right)} \cdot y\right) \cdot t \]
      5. lower-neg.f6476.6

        \[\leadsto \left(\color{blue}{\left(-z\right)} \cdot y\right) \cdot t \]
    5. Applied rewrites76.6%

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

    if -1.28e20 < z < 1.2999999999999999e-37

    1. Initial program 89.5%

      \[\left(x \cdot y - z \cdot y\right) \cdot t \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf

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

        \[\leadsto \color{blue}{\left(x \cdot y\right) \cdot t} \]
      2. associate-*r*N/A

        \[\leadsto \color{blue}{x \cdot \left(y \cdot t\right)} \]
      3. *-commutativeN/A

        \[\leadsto x \cdot \color{blue}{\left(t \cdot y\right)} \]
      4. remove-double-negN/A

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

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

        \[\leadsto \color{blue}{\left(-1 \cdot \left(-1 \cdot x\right)\right)} \cdot \left(t \cdot y\right) \]
      7. *-commutativeN/A

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

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

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

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

        \[\leadsto \color{blue}{\left(\left(-1 \cdot x\right) \cdot \left(-1 \cdot y\right)\right) \cdot t} \]
      12. lower-*.f64N/A

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

        \[\leadsto \color{blue}{\left(\left(\left(-1 \cdot x\right) \cdot -1\right) \cdot y\right)} \cdot t \]
      14. *-commutativeN/A

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

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

        \[\leadsto \left(\left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right)\right) \cdot y\right) \cdot t \]
      17. remove-double-negN/A

        \[\leadsto \left(\color{blue}{x} \cdot y\right) \cdot t \]
      18. *-commutativeN/A

        \[\leadsto \color{blue}{\left(y \cdot x\right)} \cdot t \]
      19. lower-*.f6472.8

        \[\leadsto \color{blue}{\left(y \cdot x\right)} \cdot t \]
    5. Applied rewrites72.8%

      \[\leadsto \color{blue}{\left(y \cdot x\right) \cdot t} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification74.8%

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

Alternative 5: 75.0% accurate, 0.8× speedup?

\[\begin{array}{l} t\_m = \left|t\right| \\ t\_s = \mathsf{copysign}\left(1, t\right) \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ [x, y_m, z, t_m] = \mathsf{sort}([x, y_m, z, t_m])\\ \\ y\_s \cdot \left(t\_s \cdot \begin{array}{l} \mathbf{if}\;x \leq -2.8 \cdot 10^{+25} \lor \neg \left(x \leq 1.7 \cdot 10^{-45}\right):\\ \;\;\;\;\left(y\_m \cdot x\right) \cdot t\_m\\ \mathbf{else}:\\ \;\;\;\;\left(\left(-t\_m\right) \cdot z\right) \cdot y\_m\\ \end{array}\right) \end{array} \]
t\_m = (fabs.f64 t)
t\_s = (copysign.f64 #s(literal 1 binary64) t)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function.
(FPCore (y_s t_s x y_m z t_m)
 :precision binary64
 (*
  y_s
  (*
   t_s
   (if (or (<= x -2.8e+25) (not (<= x 1.7e-45)))
     (* (* y_m x) t_m)
     (* (* (- t_m) z) y_m)))))
t\_m = fabs(t);
t\_s = copysign(1.0, t);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z && z < t_m);
double code(double y_s, double t_s, double x, double y_m, double z, double t_m) {
	double tmp;
	if ((x <= -2.8e+25) || !(x <= 1.7e-45)) {
		tmp = (y_m * x) * t_m;
	} else {
		tmp = (-t_m * z) * y_m;
	}
	return y_s * (t_s * tmp);
}
t\_m =     private
t\_s =     private
y\_m =     private
y\_s =     private
NOTE: x, y_m, z, and t_m 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(y_s, t_s, x, y_m, z, t_m)
use fmin_fmax_functions
    real(8), intent (in) :: y_s
    real(8), intent (in) :: t_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8), intent (in) :: t_m
    real(8) :: tmp
    if ((x <= (-2.8d+25)) .or. (.not. (x <= 1.7d-45))) then
        tmp = (y_m * x) * t_m
    else
        tmp = (-t_m * z) * y_m
    end if
    code = y_s * (t_s * tmp)
end function
t\_m = Math.abs(t);
t\_s = Math.copySign(1.0, t);
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x < y_m && y_m < z && z < t_m;
public static double code(double y_s, double t_s, double x, double y_m, double z, double t_m) {
	double tmp;
	if ((x <= -2.8e+25) || !(x <= 1.7e-45)) {
		tmp = (y_m * x) * t_m;
	} else {
		tmp = (-t_m * z) * y_m;
	}
	return y_s * (t_s * tmp);
}
t\_m = math.fabs(t)
t\_s = math.copysign(1.0, t)
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
[x, y_m, z, t_m] = sort([x, y_m, z, t_m])
def code(y_s, t_s, x, y_m, z, t_m):
	tmp = 0
	if (x <= -2.8e+25) or not (x <= 1.7e-45):
		tmp = (y_m * x) * t_m
	else:
		tmp = (-t_m * z) * y_m
	return y_s * (t_s * tmp)
t\_m = abs(t)
t\_s = copysign(1.0, t)
y\_m = abs(y)
y\_s = copysign(1.0, y)
x, y_m, z, t_m = sort([x, y_m, z, t_m])
function code(y_s, t_s, x, y_m, z, t_m)
	tmp = 0.0
	if ((x <= -2.8e+25) || !(x <= 1.7e-45))
		tmp = Float64(Float64(y_m * x) * t_m);
	else
		tmp = Float64(Float64(Float64(-t_m) * z) * y_m);
	end
	return Float64(y_s * Float64(t_s * tmp))
end
t\_m = abs(t);
t\_s = sign(t) * abs(1.0);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x, y_m, z, t_m = num2cell(sort([x, y_m, z, t_m])){:}
function tmp_2 = code(y_s, t_s, x, y_m, z, t_m)
	tmp = 0.0;
	if ((x <= -2.8e+25) || ~((x <= 1.7e-45)))
		tmp = (y_m * x) * t_m;
	else
		tmp = (-t_m * z) * y_m;
	end
	tmp_2 = y_s * (t_s * tmp);
end
t\_m = N[Abs[t], $MachinePrecision]
t\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function.
code[y$95$s_, t$95$s_, x_, y$95$m_, z_, t$95$m_] := N[(y$95$s * N[(t$95$s * If[Or[LessEqual[x, -2.8e+25], N[Not[LessEqual[x, 1.7e-45]], $MachinePrecision]], N[(N[(y$95$m * x), $MachinePrecision] * t$95$m), $MachinePrecision], N[(N[((-t$95$m) * z), $MachinePrecision] * y$95$m), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
t\_m = \left|t\right|
\\
t\_s = \mathsf{copysign}\left(1, t\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z, t_m] = \mathsf{sort}([x, y_m, z, t_m])\\
\\
y\_s \cdot \left(t\_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq -2.8 \cdot 10^{+25} \lor \neg \left(x \leq 1.7 \cdot 10^{-45}\right):\\
\;\;\;\;\left(y\_m \cdot x\right) \cdot t\_m\\

\mathbf{else}:\\
\;\;\;\;\left(\left(-t\_m\right) \cdot z\right) \cdot y\_m\\


\end{array}\right)
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.8000000000000002e25 or 1.70000000000000002e-45 < x

    1. Initial program 85.3%

      \[\left(x \cdot y - z \cdot y\right) \cdot t \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf

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

        \[\leadsto \color{blue}{\left(x \cdot y\right) \cdot t} \]
      2. associate-*r*N/A

        \[\leadsto \color{blue}{x \cdot \left(y \cdot t\right)} \]
      3. *-commutativeN/A

        \[\leadsto x \cdot \color{blue}{\left(t \cdot y\right)} \]
      4. remove-double-negN/A

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

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

        \[\leadsto \color{blue}{\left(-1 \cdot \left(-1 \cdot x\right)\right)} \cdot \left(t \cdot y\right) \]
      7. *-commutativeN/A

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

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

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

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

        \[\leadsto \color{blue}{\left(\left(-1 \cdot x\right) \cdot \left(-1 \cdot y\right)\right) \cdot t} \]
      12. lower-*.f64N/A

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

        \[\leadsto \color{blue}{\left(\left(\left(-1 \cdot x\right) \cdot -1\right) \cdot y\right)} \cdot t \]
      14. *-commutativeN/A

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

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

        \[\leadsto \left(\left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right)\right) \cdot y\right) \cdot t \]
      17. remove-double-negN/A

        \[\leadsto \left(\color{blue}{x} \cdot y\right) \cdot t \]
      18. *-commutativeN/A

        \[\leadsto \color{blue}{\left(y \cdot x\right)} \cdot t \]
      19. lower-*.f6471.6

        \[\leadsto \color{blue}{\left(y \cdot x\right)} \cdot t \]
    5. Applied rewrites71.6%

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

    if -2.8000000000000002e25 < x < 1.70000000000000002e-45

    1. Initial program 91.9%

      \[\left(x \cdot y - z \cdot y\right) \cdot t \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

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

        \[\leadsto \color{blue}{\mathsf{neg}\left(t \cdot \left(y \cdot z\right)\right)} \]
      2. distribute-lft-neg-inN/A

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

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

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

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

        \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(t\right)\right) \cdot z\right)} \cdot y \]
      7. lower-neg.f6475.3

        \[\leadsto \left(\color{blue}{\left(-t\right)} \cdot z\right) \cdot y \]
    5. Applied rewrites75.3%

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

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

Alternative 6: 98.4% accurate, 0.9× speedup?

\[\begin{array}{l} t\_m = \left|t\right| \\ t\_s = \mathsf{copysign}\left(1, t\right) \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ [x, y_m, z, t_m] = \mathsf{sort}([x, y_m, z, t_m])\\ \\ y\_s \cdot \left(t\_s \cdot \begin{array}{l} \mathbf{if}\;t\_m \leq 3.35:\\ \;\;\;\;\left(\left(x - z\right) \cdot y\_m\right) \cdot t\_m\\ \mathbf{else}:\\ \;\;\;\;\left(x - z\right) \cdot \left(t\_m \cdot y\_m\right)\\ \end{array}\right) \end{array} \]
t\_m = (fabs.f64 t)
t\_s = (copysign.f64 #s(literal 1 binary64) t)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function.
(FPCore (y_s t_s x y_m z t_m)
 :precision binary64
 (*
  y_s
  (* t_s (if (<= t_m 3.35) (* (* (- x z) y_m) t_m) (* (- x z) (* t_m y_m))))))
t\_m = fabs(t);
t\_s = copysign(1.0, t);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z && z < t_m);
double code(double y_s, double t_s, double x, double y_m, double z, double t_m) {
	double tmp;
	if (t_m <= 3.35) {
		tmp = ((x - z) * y_m) * t_m;
	} else {
		tmp = (x - z) * (t_m * y_m);
	}
	return y_s * (t_s * tmp);
}
t\_m =     private
t\_s =     private
y\_m =     private
y\_s =     private
NOTE: x, y_m, z, and t_m 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(y_s, t_s, x, y_m, z, t_m)
use fmin_fmax_functions
    real(8), intent (in) :: y_s
    real(8), intent (in) :: t_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8), intent (in) :: t_m
    real(8) :: tmp
    if (t_m <= 3.35d0) then
        tmp = ((x - z) * y_m) * t_m
    else
        tmp = (x - z) * (t_m * y_m)
    end if
    code = y_s * (t_s * tmp)
end function
t\_m = Math.abs(t);
t\_s = Math.copySign(1.0, t);
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x < y_m && y_m < z && z < t_m;
public static double code(double y_s, double t_s, double x, double y_m, double z, double t_m) {
	double tmp;
	if (t_m <= 3.35) {
		tmp = ((x - z) * y_m) * t_m;
	} else {
		tmp = (x - z) * (t_m * y_m);
	}
	return y_s * (t_s * tmp);
}
t\_m = math.fabs(t)
t\_s = math.copysign(1.0, t)
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
[x, y_m, z, t_m] = sort([x, y_m, z, t_m])
def code(y_s, t_s, x, y_m, z, t_m):
	tmp = 0
	if t_m <= 3.35:
		tmp = ((x - z) * y_m) * t_m
	else:
		tmp = (x - z) * (t_m * y_m)
	return y_s * (t_s * tmp)
t\_m = abs(t)
t\_s = copysign(1.0, t)
y\_m = abs(y)
y\_s = copysign(1.0, y)
x, y_m, z, t_m = sort([x, y_m, z, t_m])
function code(y_s, t_s, x, y_m, z, t_m)
	tmp = 0.0
	if (t_m <= 3.35)
		tmp = Float64(Float64(Float64(x - z) * y_m) * t_m);
	else
		tmp = Float64(Float64(x - z) * Float64(t_m * y_m));
	end
	return Float64(y_s * Float64(t_s * tmp))
end
t\_m = abs(t);
t\_s = sign(t) * abs(1.0);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x, y_m, z, t_m = num2cell(sort([x, y_m, z, t_m])){:}
function tmp_2 = code(y_s, t_s, x, y_m, z, t_m)
	tmp = 0.0;
	if (t_m <= 3.35)
		tmp = ((x - z) * y_m) * t_m;
	else
		tmp = (x - z) * (t_m * y_m);
	end
	tmp_2 = y_s * (t_s * tmp);
end
t\_m = N[Abs[t], $MachinePrecision]
t\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function.
code[y$95$s_, t$95$s_, x_, y$95$m_, z_, t$95$m_] := N[(y$95$s * N[(t$95$s * If[LessEqual[t$95$m, 3.35], N[(N[(N[(x - z), $MachinePrecision] * y$95$m), $MachinePrecision] * t$95$m), $MachinePrecision], N[(N[(x - z), $MachinePrecision] * N[(t$95$m * y$95$m), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
t\_m = \left|t\right|
\\
t\_s = \mathsf{copysign}\left(1, t\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z, t_m] = \mathsf{sort}([x, y_m, z, t_m])\\
\\
y\_s \cdot \left(t\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_m \leq 3.35:\\
\;\;\;\;\left(\left(x - z\right) \cdot y\_m\right) \cdot t\_m\\

\mathbf{else}:\\
\;\;\;\;\left(x - z\right) \cdot \left(t\_m \cdot y\_m\right)\\


\end{array}\right)
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < 3.35000000000000009

    1. Initial program 88.7%

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

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

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

        \[\leadsto \left(x \cdot y - \color{blue}{z \cdot y}\right) \cdot t \]
      4. distribute-rgt-out--N/A

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

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

        \[\leadsto \color{blue}{\left(\left(x - z\right) \cdot y\right)} \cdot t \]
      7. lower--.f6491.0

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

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

    if 3.35000000000000009 < t

    1. Initial program 87.8%

      \[\left(x \cdot y - z \cdot y\right) \cdot t \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\left(x \cdot y - z \cdot y\right) \cdot t} \]
      2. *-commutativeN/A

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

        \[\leadsto t \cdot \color{blue}{\left(x \cdot y - z \cdot y\right)} \]
      4. lift-*.f64N/A

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

        \[\leadsto t \cdot \left(x \cdot y - \color{blue}{z \cdot y}\right) \]
      6. distribute-rgt-out--N/A

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

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

        \[\leadsto \color{blue}{\left(x - z\right) \cdot \left(t \cdot y\right)} \]
      9. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(x - z\right) \cdot \left(t \cdot y\right)} \]
      10. lower--.f64N/A

        \[\leadsto \color{blue}{\left(x - z\right)} \cdot \left(t \cdot y\right) \]
      11. lower-*.f6499.8

        \[\leadsto \left(x - z\right) \cdot \color{blue}{\left(t \cdot y\right)} \]
    4. Applied rewrites99.8%

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

Alternative 7: 56.6% accurate, 1.1× speedup?

\[\begin{array}{l} t\_m = \left|t\right| \\ t\_s = \mathsf{copysign}\left(1, t\right) \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ [x, y_m, z, t_m] = \mathsf{sort}([x, y_m, z, t_m])\\ \\ y\_s \cdot \left(t\_s \cdot \begin{array}{l} \mathbf{if}\;t\_m \leq 5:\\ \;\;\;\;\left(y\_m \cdot x\right) \cdot t\_m\\ \mathbf{else}:\\ \;\;\;\;\left(t\_m \cdot y\_m\right) \cdot x\\ \end{array}\right) \end{array} \]
t\_m = (fabs.f64 t)
t\_s = (copysign.f64 #s(literal 1 binary64) t)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function.
(FPCore (y_s t_s x y_m z t_m)
 :precision binary64
 (* y_s (* t_s (if (<= t_m 5.0) (* (* y_m x) t_m) (* (* t_m y_m) x)))))
t\_m = fabs(t);
t\_s = copysign(1.0, t);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z && z < t_m);
double code(double y_s, double t_s, double x, double y_m, double z, double t_m) {
	double tmp;
	if (t_m <= 5.0) {
		tmp = (y_m * x) * t_m;
	} else {
		tmp = (t_m * y_m) * x;
	}
	return y_s * (t_s * tmp);
}
t\_m =     private
t\_s =     private
y\_m =     private
y\_s =     private
NOTE: x, y_m, z, and t_m 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(y_s, t_s, x, y_m, z, t_m)
use fmin_fmax_functions
    real(8), intent (in) :: y_s
    real(8), intent (in) :: t_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8), intent (in) :: t_m
    real(8) :: tmp
    if (t_m <= 5.0d0) then
        tmp = (y_m * x) * t_m
    else
        tmp = (t_m * y_m) * x
    end if
    code = y_s * (t_s * tmp)
end function
t\_m = Math.abs(t);
t\_s = Math.copySign(1.0, t);
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x < y_m && y_m < z && z < t_m;
public static double code(double y_s, double t_s, double x, double y_m, double z, double t_m) {
	double tmp;
	if (t_m <= 5.0) {
		tmp = (y_m * x) * t_m;
	} else {
		tmp = (t_m * y_m) * x;
	}
	return y_s * (t_s * tmp);
}
t\_m = math.fabs(t)
t\_s = math.copysign(1.0, t)
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
[x, y_m, z, t_m] = sort([x, y_m, z, t_m])
def code(y_s, t_s, x, y_m, z, t_m):
	tmp = 0
	if t_m <= 5.0:
		tmp = (y_m * x) * t_m
	else:
		tmp = (t_m * y_m) * x
	return y_s * (t_s * tmp)
t\_m = abs(t)
t\_s = copysign(1.0, t)
y\_m = abs(y)
y\_s = copysign(1.0, y)
x, y_m, z, t_m = sort([x, y_m, z, t_m])
function code(y_s, t_s, x, y_m, z, t_m)
	tmp = 0.0
	if (t_m <= 5.0)
		tmp = Float64(Float64(y_m * x) * t_m);
	else
		tmp = Float64(Float64(t_m * y_m) * x);
	end
	return Float64(y_s * Float64(t_s * tmp))
end
t\_m = abs(t);
t\_s = sign(t) * abs(1.0);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x, y_m, z, t_m = num2cell(sort([x, y_m, z, t_m])){:}
function tmp_2 = code(y_s, t_s, x, y_m, z, t_m)
	tmp = 0.0;
	if (t_m <= 5.0)
		tmp = (y_m * x) * t_m;
	else
		tmp = (t_m * y_m) * x;
	end
	tmp_2 = y_s * (t_s * tmp);
end
t\_m = N[Abs[t], $MachinePrecision]
t\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function.
code[y$95$s_, t$95$s_, x_, y$95$m_, z_, t$95$m_] := N[(y$95$s * N[(t$95$s * If[LessEqual[t$95$m, 5.0], N[(N[(y$95$m * x), $MachinePrecision] * t$95$m), $MachinePrecision], N[(N[(t$95$m * y$95$m), $MachinePrecision] * x), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
t\_m = \left|t\right|
\\
t\_s = \mathsf{copysign}\left(1, t\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z, t_m] = \mathsf{sort}([x, y_m, z, t_m])\\
\\
y\_s \cdot \left(t\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_m \leq 5:\\
\;\;\;\;\left(y\_m \cdot x\right) \cdot t\_m\\

\mathbf{else}:\\
\;\;\;\;\left(t\_m \cdot y\_m\right) \cdot x\\


\end{array}\right)
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < 5

    1. Initial program 88.7%

      \[\left(x \cdot y - z \cdot y\right) \cdot t \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf

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

        \[\leadsto \color{blue}{\left(x \cdot y\right) \cdot t} \]
      2. associate-*r*N/A

        \[\leadsto \color{blue}{x \cdot \left(y \cdot t\right)} \]
      3. *-commutativeN/A

        \[\leadsto x \cdot \color{blue}{\left(t \cdot y\right)} \]
      4. remove-double-negN/A

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

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

        \[\leadsto \color{blue}{\left(-1 \cdot \left(-1 \cdot x\right)\right)} \cdot \left(t \cdot y\right) \]
      7. *-commutativeN/A

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

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

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

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

        \[\leadsto \color{blue}{\left(\left(-1 \cdot x\right) \cdot \left(-1 \cdot y\right)\right) \cdot t} \]
      12. lower-*.f64N/A

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

        \[\leadsto \color{blue}{\left(\left(\left(-1 \cdot x\right) \cdot -1\right) \cdot y\right)} \cdot t \]
      14. *-commutativeN/A

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

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

        \[\leadsto \left(\left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right)\right) \cdot y\right) \cdot t \]
      17. remove-double-negN/A

        \[\leadsto \left(\color{blue}{x} \cdot y\right) \cdot t \]
      18. *-commutativeN/A

        \[\leadsto \color{blue}{\left(y \cdot x\right)} \cdot t \]
      19. lower-*.f6451.1

        \[\leadsto \color{blue}{\left(y \cdot x\right)} \cdot t \]
    5. Applied rewrites51.1%

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

    if 5 < t

    1. Initial program 87.8%

      \[\left(x \cdot y - z \cdot y\right) \cdot t \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf

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

        \[\leadsto \color{blue}{\left(x \cdot y\right) \cdot t} \]
      2. associate-*r*N/A

        \[\leadsto \color{blue}{x \cdot \left(y \cdot t\right)} \]
      3. *-commutativeN/A

        \[\leadsto x \cdot \color{blue}{\left(t \cdot y\right)} \]
      4. remove-double-negN/A

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

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

        \[\leadsto \color{blue}{\left(-1 \cdot \left(-1 \cdot x\right)\right)} \cdot \left(t \cdot y\right) \]
      7. *-commutativeN/A

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

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

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

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

        \[\leadsto \color{blue}{\left(\left(-1 \cdot x\right) \cdot \left(-1 \cdot y\right)\right) \cdot t} \]
      12. lower-*.f64N/A

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

        \[\leadsto \color{blue}{\left(\left(\left(-1 \cdot x\right) \cdot -1\right) \cdot y\right)} \cdot t \]
      14. *-commutativeN/A

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

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

        \[\leadsto \left(\left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right)\right) \cdot y\right) \cdot t \]
      17. remove-double-negN/A

        \[\leadsto \left(\color{blue}{x} \cdot y\right) \cdot t \]
      18. *-commutativeN/A

        \[\leadsto \color{blue}{\left(y \cdot x\right)} \cdot t \]
      19. lower-*.f6451.8

        \[\leadsto \color{blue}{\left(y \cdot x\right)} \cdot t \]
    5. Applied rewrites51.8%

      \[\leadsto \color{blue}{\left(y \cdot x\right) \cdot t} \]
    6. Step-by-step derivation
      1. Applied rewrites58.2%

        \[\leadsto \left(t \cdot y\right) \cdot \color{blue}{x} \]
    7. Recombined 2 regimes into one program.
    8. Add Preprocessing

    Alternative 8: 53.7% accurate, 1.7× speedup?

    \[\begin{array}{l} t\_m = \left|t\right| \\ t\_s = \mathsf{copysign}\left(1, t\right) \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ [x, y_m, z, t_m] = \mathsf{sort}([x, y_m, z, t_m])\\ \\ y\_s \cdot \left(t\_s \cdot \left(\left(t\_m \cdot y\_m\right) \cdot x\right)\right) \end{array} \]
    t\_m = (fabs.f64 t)
    t\_s = (copysign.f64 #s(literal 1 binary64) t)
    y\_m = (fabs.f64 y)
    y\_s = (copysign.f64 #s(literal 1 binary64) y)
    NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function.
    (FPCore (y_s t_s x y_m z t_m)
     :precision binary64
     (* y_s (* t_s (* (* t_m y_m) x))))
    t\_m = fabs(t);
    t\_s = copysign(1.0, t);
    y\_m = fabs(y);
    y\_s = copysign(1.0, y);
    assert(x < y_m && y_m < z && z < t_m);
    double code(double y_s, double t_s, double x, double y_m, double z, double t_m) {
    	return y_s * (t_s * ((t_m * y_m) * x));
    }
    
    t\_m =     private
    t\_s =     private
    y\_m =     private
    y\_s =     private
    NOTE: x, y_m, z, and t_m 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(y_s, t_s, x, y_m, z, t_m)
    use fmin_fmax_functions
        real(8), intent (in) :: y_s
        real(8), intent (in) :: t_s
        real(8), intent (in) :: x
        real(8), intent (in) :: y_m
        real(8), intent (in) :: z
        real(8), intent (in) :: t_m
        code = y_s * (t_s * ((t_m * y_m) * x))
    end function
    
    t\_m = Math.abs(t);
    t\_s = Math.copySign(1.0, t);
    y\_m = Math.abs(y);
    y\_s = Math.copySign(1.0, y);
    assert x < y_m && y_m < z && z < t_m;
    public static double code(double y_s, double t_s, double x, double y_m, double z, double t_m) {
    	return y_s * (t_s * ((t_m * y_m) * x));
    }
    
    t\_m = math.fabs(t)
    t\_s = math.copysign(1.0, t)
    y\_m = math.fabs(y)
    y\_s = math.copysign(1.0, y)
    [x, y_m, z, t_m] = sort([x, y_m, z, t_m])
    def code(y_s, t_s, x, y_m, z, t_m):
    	return y_s * (t_s * ((t_m * y_m) * x))
    
    t\_m = abs(t)
    t\_s = copysign(1.0, t)
    y\_m = abs(y)
    y\_s = copysign(1.0, y)
    x, y_m, z, t_m = sort([x, y_m, z, t_m])
    function code(y_s, t_s, x, y_m, z, t_m)
    	return Float64(y_s * Float64(t_s * Float64(Float64(t_m * y_m) * x)))
    end
    
    t\_m = abs(t);
    t\_s = sign(t) * abs(1.0);
    y\_m = abs(y);
    y\_s = sign(y) * abs(1.0);
    x, y_m, z, t_m = num2cell(sort([x, y_m, z, t_m])){:}
    function tmp = code(y_s, t_s, x, y_m, z, t_m)
    	tmp = y_s * (t_s * ((t_m * y_m) * x));
    end
    
    t\_m = N[Abs[t], $MachinePrecision]
    t\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
    y\_m = N[Abs[y], $MachinePrecision]
    y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
    NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function.
    code[y$95$s_, t$95$s_, x_, y$95$m_, z_, t$95$m_] := N[(y$95$s * N[(t$95$s * N[(N[(t$95$m * y$95$m), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
    
    \begin{array}{l}
    t\_m = \left|t\right|
    \\
    t\_s = \mathsf{copysign}\left(1, t\right)
    \\
    y\_m = \left|y\right|
    \\
    y\_s = \mathsf{copysign}\left(1, y\right)
    \\
    [x, y_m, z, t_m] = \mathsf{sort}([x, y_m, z, t_m])\\
    \\
    y\_s \cdot \left(t\_s \cdot \left(\left(t\_m \cdot y\_m\right) \cdot x\right)\right)
    \end{array}
    
    Derivation
    1. Initial program 88.5%

      \[\left(x \cdot y - z \cdot y\right) \cdot t \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf

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

        \[\leadsto \color{blue}{\left(x \cdot y\right) \cdot t} \]
      2. associate-*r*N/A

        \[\leadsto \color{blue}{x \cdot \left(y \cdot t\right)} \]
      3. *-commutativeN/A

        \[\leadsto x \cdot \color{blue}{\left(t \cdot y\right)} \]
      4. remove-double-negN/A

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

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

        \[\leadsto \color{blue}{\left(-1 \cdot \left(-1 \cdot x\right)\right)} \cdot \left(t \cdot y\right) \]
      7. *-commutativeN/A

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

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

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

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

        \[\leadsto \color{blue}{\left(\left(-1 \cdot x\right) \cdot \left(-1 \cdot y\right)\right) \cdot t} \]
      12. lower-*.f64N/A

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

        \[\leadsto \color{blue}{\left(\left(\left(-1 \cdot x\right) \cdot -1\right) \cdot y\right)} \cdot t \]
      14. *-commutativeN/A

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

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

        \[\leadsto \left(\left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right)\right) \cdot y\right) \cdot t \]
      17. remove-double-negN/A

        \[\leadsto \left(\color{blue}{x} \cdot y\right) \cdot t \]
      18. *-commutativeN/A

        \[\leadsto \color{blue}{\left(y \cdot x\right)} \cdot t \]
      19. lower-*.f6451.3

        \[\leadsto \color{blue}{\left(y \cdot x\right)} \cdot t \]
    5. Applied rewrites51.3%

      \[\leadsto \color{blue}{\left(y \cdot x\right) \cdot t} \]
    6. Step-by-step derivation
      1. Applied rewrites54.2%

        \[\leadsto \left(t \cdot y\right) \cdot \color{blue}{x} \]
      2. Add Preprocessing

      Developer Target 1: 95.4% accurate, 0.7× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;t < -9.231879582886777 \cdot 10^{-80}:\\ \;\;\;\;\left(y \cdot t\right) \cdot \left(x - z\right)\\ \mathbf{elif}\;t < 2.543067051564877 \cdot 10^{+83}:\\ \;\;\;\;y \cdot \left(t \cdot \left(x - z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(y \cdot \left(x - z\right)\right) \cdot t\\ \end{array} \end{array} \]
      (FPCore (x y z t)
       :precision binary64
       (if (< t -9.231879582886777e-80)
         (* (* y t) (- x z))
         (if (< t 2.543067051564877e+83) (* y (* t (- x z))) (* (* y (- x z)) t))))
      double code(double x, double y, double z, double t) {
      	double tmp;
      	if (t < -9.231879582886777e-80) {
      		tmp = (y * t) * (x - z);
      	} else if (t < 2.543067051564877e+83) {
      		tmp = y * (t * (x - z));
      	} else {
      		tmp = (y * (x - z)) * t;
      	}
      	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)
      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) :: tmp
          if (t < (-9.231879582886777d-80)) then
              tmp = (y * t) * (x - z)
          else if (t < 2.543067051564877d+83) then
              tmp = y * (t * (x - z))
          else
              tmp = (y * (x - z)) * t
          end if
          code = tmp
      end function
      
      public static double code(double x, double y, double z, double t) {
      	double tmp;
      	if (t < -9.231879582886777e-80) {
      		tmp = (y * t) * (x - z);
      	} else if (t < 2.543067051564877e+83) {
      		tmp = y * (t * (x - z));
      	} else {
      		tmp = (y * (x - z)) * t;
      	}
      	return tmp;
      }
      
      def code(x, y, z, t):
      	tmp = 0
      	if t < -9.231879582886777e-80:
      		tmp = (y * t) * (x - z)
      	elif t < 2.543067051564877e+83:
      		tmp = y * (t * (x - z))
      	else:
      		tmp = (y * (x - z)) * t
      	return tmp
      
      function code(x, y, z, t)
      	tmp = 0.0
      	if (t < -9.231879582886777e-80)
      		tmp = Float64(Float64(y * t) * Float64(x - z));
      	elseif (t < 2.543067051564877e+83)
      		tmp = Float64(y * Float64(t * Float64(x - z)));
      	else
      		tmp = Float64(Float64(y * Float64(x - z)) * t);
      	end
      	return tmp
      end
      
      function tmp_2 = code(x, y, z, t)
      	tmp = 0.0;
      	if (t < -9.231879582886777e-80)
      		tmp = (y * t) * (x - z);
      	elseif (t < 2.543067051564877e+83)
      		tmp = y * (t * (x - z));
      	else
      		tmp = (y * (x - z)) * t;
      	end
      	tmp_2 = tmp;
      end
      
      code[x_, y_, z_, t_] := If[Less[t, -9.231879582886777e-80], N[(N[(y * t), $MachinePrecision] * N[(x - z), $MachinePrecision]), $MachinePrecision], If[Less[t, 2.543067051564877e+83], N[(y * N[(t * N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y * N[(x - z), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;t < -9.231879582886777 \cdot 10^{-80}:\\
      \;\;\;\;\left(y \cdot t\right) \cdot \left(x - z\right)\\
      
      \mathbf{elif}\;t < 2.543067051564877 \cdot 10^{+83}:\\
      \;\;\;\;y \cdot \left(t \cdot \left(x - z\right)\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;\left(y \cdot \left(x - z\right)\right) \cdot t\\
      
      
      \end{array}
      \end{array}
      

      Reproduce

      ?
      herbie shell --seed 2025015 
      (FPCore (x y z t)
        :name "Linear.Projection:inverseInfinitePerspective from linear-1.19.1.3"
        :precision binary64
      
        :alt
        (! :herbie-platform default (if (< t -9231879582886777/100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (* (* y t) (- x z)) (if (< t 254306705156487700000000000000000000000000000000000000000000000000000000000000000000) (* y (* t (- x z))) (* (* y (- x z)) t))))
      
        (* (- (* x y) (* z y)) t))