Linear.Projection:inverseInfinitePerspective from linear-1.19.1.3

Percentage Accurate: 96.3% → 96.9%
Time: 4.5s
Alternatives: 8
Speedup: 1.3×

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}

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: 96.9% accurate, 1.3× speedup?

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

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

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

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

      \[\leadsto \color{blue}{\left(x \cdot y - 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. sub-flipN/A

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

      \[\leadsto \left(y \cdot \left(x + \color{blue}{-1 \cdot z}\right)\right) \cdot t \]
    7. add-flipN/A

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

      \[\leadsto \left(y \cdot \left(\mathsf{neg}\left(\left(\color{blue}{-1 \cdot x} - -1 \cdot z\right)\right)\right)\right) \cdot t \]
    9. distribute-rgt-neg-outN/A

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\left(z - x\right) \cdot \color{blue}{\left(\mathsf{neg}\left(y\right)\right)}\right) \cdot t \]
    19. lower-neg.f6496.9

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(\left(z - x\right)\right)\right) \cdot y\right)} \cdot t \]
    6. sub-negateN/A

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

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

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

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

Alternative 2: 88.9% accurate, 0.7× speedup?

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

\mathbf{elif}\;x \leq 4.2 \cdot 10^{+92}:\\
\;\;\;\;\left(\left(x - z\right) \cdot t\_m\right) \cdot y\_m\\

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


\end{array}\right)
\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.6e99 or 4.19999999999999972e92 < x

    1. Initial program 98.2%

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

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

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

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

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

    if -2.6e99 < x < 4.19999999999999972e92

    1. Initial program 95.3%

      \[\left(x \cdot y - z \cdot y\right) \cdot t \]
    2. 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. lift--.f64N/A

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

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

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

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

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

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

        \[\leadsto t \cdot \left(y \cdot \left(\mathsf{neg}\left(\left(\color{blue}{-1 \cdot x} - -1 \cdot z\right)\right)\right)\right) \]
      11. distribute-rgt-neg-outN/A

        \[\leadsto t \cdot \color{blue}{\left(\mathsf{neg}\left(y \cdot \left(-1 \cdot x - -1 \cdot z\right)\right)\right)} \]
      12. distribute-rgt-neg-outN/A

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(\left(z - x\right)\right)\right) \cdot t\right)} \cdot y \]
      7. sub-negateN/A

        \[\leadsto \left(\color{blue}{\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--.f6491.3

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

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

Alternative 3: 76.8% accurate, 0.8× speedup?

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

\mathbf{elif}\;x \leq 3.1 \cdot 10^{-69}:\\
\;\;\;\;\left(\left(-z\right) \cdot y\_m\right) \cdot t\_m\\

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


\end{array}\right)
\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -9.5999999999999997e55 or 3.0999999999999999e-69 < x

    1. Initial program 98.4%

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

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

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

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

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

    if -9.5999999999999997e55 < x < 3.0999999999999999e-69

    1. Initial program 94.1%

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

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

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

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

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

        \[\leadsto \left(\left(\mathsf{neg}\left(z\right)\right) \cdot y\right) \cdot t \]
      5. lower-neg.f6477.0

        \[\leadsto \left(\left(-z\right) \cdot y\right) \cdot t \]
    4. Applied rewrites77.0%

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

Alternative 4: 76.2% accurate, 0.8× speedup?

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

\mathbf{elif}\;x \leq 3.5 \cdot 10^{-70}:\\
\;\;\;\;\left(-z\right) \cdot \left(t\_m \cdot y\_m\right)\\

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


\end{array}\right)
\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.8000000000000001e55 or 3.49999999999999974e-70 < x

    1. Initial program 98.4%

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

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

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

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

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

    if -2.8000000000000001e55 < x < 3.49999999999999974e-70

    1. Initial program 94.1%

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

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

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

        \[\leadsto \color{blue}{\left(x \cdot y - 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. sub-flipN/A

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

        \[\leadsto \left(y \cdot \left(x + \color{blue}{-1 \cdot z}\right)\right) \cdot t \]
      7. add-flipN/A

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

        \[\leadsto \left(y \cdot \left(\mathsf{neg}\left(\left(\color{blue}{-1 \cdot x} - -1 \cdot z\right)\right)\right)\right) \cdot t \]
      9. distribute-rgt-neg-outN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto t \cdot \left(\mathsf{neg}\left(\color{blue}{y \cdot \left(z - x\right)}\right)\right) \]
      8. distribute-rgt-neg-outN/A

        \[\leadsto t \cdot \color{blue}{\left(y \cdot \left(\mathsf{neg}\left(\left(z - x\right)\right)\right)\right)} \]
      9. sub-negateN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-z\right) \cdot \left(t \cdot y\right) \]
    8. Applied rewrites75.7%

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

Alternative 5: 74.8% accurate, 0.8× speedup?

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

\mathbf{elif}\;x \leq 2.6 \cdot 10^{-69}:\\
\;\;\;\;\left(z \cdot \left(-t\_m\right)\right) \cdot y\_m\\

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


\end{array}\right)
\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.1799999999999999e55 or 2.6000000000000002e-69 < x

    1. Initial program 98.4%

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

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

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

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

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

    if -1.1799999999999999e55 < x < 2.6000000000000002e-69

    1. Initial program 94.1%

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

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

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

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

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

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

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

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

        \[\leadsto \left(z \cdot \left(-1 \cdot t\right)\right) \cdot y \]
      8. mul-1-negN/A

        \[\leadsto \left(z \cdot \left(\mathsf{neg}\left(t\right)\right)\right) \cdot y \]
      9. lower-neg.f6472.7

        \[\leadsto \left(z \cdot \left(-t\right)\right) \cdot y \]
    4. Applied rewrites72.7%

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

Alternative 6: 57.9% accurate, 1.2× speedup?

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

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


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

    1. Initial program 98.8%

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

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

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

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

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

    if 2.6999999999999999e73 < t

    1. Initial program 94.8%

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

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

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

        \[\leadsto \color{blue}{\left(x \cdot y - 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. sub-flipN/A

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

        \[\leadsto \left(y \cdot \left(x + \color{blue}{-1 \cdot z}\right)\right) \cdot t \]
      7. add-flipN/A

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

        \[\leadsto \left(y \cdot \left(\mathsf{neg}\left(\left(\color{blue}{-1 \cdot x} - -1 \cdot z\right)\right)\right)\right) \cdot t \]
      9. distribute-rgt-neg-outN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto t \cdot \left(\mathsf{neg}\left(\color{blue}{y \cdot \left(z - x\right)}\right)\right) \]
      8. distribute-rgt-neg-outN/A

        \[\leadsto t \cdot \color{blue}{\left(y \cdot \left(\mathsf{neg}\left(\left(z - x\right)\right)\right)\right)} \]
      9. sub-negateN/A

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

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

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

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

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

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

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

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

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

    Alternative 7: 57.7% accurate, 1.2× speedup?

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

      1. Initial program 99.7%

        \[\left(x \cdot y - z \cdot y\right) \cdot t \]
      2. 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. lift--.f64N/A

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

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

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

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

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

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

          \[\leadsto t \cdot \left(y \cdot \left(\mathsf{neg}\left(\left(\color{blue}{-1 \cdot x} - -1 \cdot z\right)\right)\right)\right) \]
        11. distribute-rgt-neg-outN/A

          \[\leadsto t \cdot \color{blue}{\left(\mathsf{neg}\left(y \cdot \left(-1 \cdot x - -1 \cdot z\right)\right)\right)} \]
        12. distribute-rgt-neg-outN/A

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(t \cdot x\right)} \cdot y \]
      5. Step-by-step derivation
        1. lower-*.f6464.9

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

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

      if 1e8 < t

      1. Initial program 95.1%

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

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

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

          \[\leadsto \color{blue}{\left(x \cdot y - 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. sub-flipN/A

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

          \[\leadsto \left(y \cdot \left(x + \color{blue}{-1 \cdot z}\right)\right) \cdot t \]
        7. add-flipN/A

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

          \[\leadsto \left(y \cdot \left(\mathsf{neg}\left(\left(\color{blue}{-1 \cdot x} - -1 \cdot z\right)\right)\right)\right) \cdot t \]
        9. distribute-rgt-neg-outN/A

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

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

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

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

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

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

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

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

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

          \[\leadsto \left(\left(z - x\right) \cdot \color{blue}{\left(\mathsf{neg}\left(y\right)\right)}\right) \cdot t \]
        19. lower-neg.f6495.9

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

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

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

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

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

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

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

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

          \[\leadsto t \cdot \left(\mathsf{neg}\left(\color{blue}{y \cdot \left(z - x\right)}\right)\right) \]
        8. distribute-rgt-neg-outN/A

          \[\leadsto t \cdot \color{blue}{\left(y \cdot \left(\mathsf{neg}\left(\left(z - x\right)\right)\right)\right)} \]
        9. sub-negateN/A

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

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

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

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

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

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

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

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

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

      Alternative 8: 51.3% accurate, 1.8× speedup?

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

        \[\left(x \cdot y - z \cdot y\right) \cdot t \]
      2. 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. lift--.f64N/A

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

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

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

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

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

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

          \[\leadsto t \cdot \left(y \cdot \left(\mathsf{neg}\left(\left(\color{blue}{-1 \cdot x} - -1 \cdot z\right)\right)\right)\right) \]
        11. distribute-rgt-neg-outN/A

          \[\leadsto t \cdot \color{blue}{\left(\mathsf{neg}\left(y \cdot \left(-1 \cdot x - -1 \cdot z\right)\right)\right)} \]
        12. distribute-rgt-neg-outN/A

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(t \cdot x\right)} \cdot y \]
      5. Step-by-step derivation
        1. lower-*.f6451.3

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

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

      Reproduce

      ?
      herbie shell --seed 2025122 
      (FPCore (x y z t)
        :name "Linear.Projection:inverseInfinitePerspective from linear-1.19.1.3"
        :precision binary64
        (* (- (* x y) (* z y)) t))