Numeric.Histogram:binBounds from Chart-1.5.3

Percentage Accurate: 93.0% → 97.8%
Time: 2.6s
Alternatives: 9
Speedup: 1.1×

Specification

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

\\
x + \frac{\left(y - x\right) \cdot z}{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 9 alternatives:

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

Initial Program: 93.0% accurate, 1.0× speedup?

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

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

Alternative 1: 97.8% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\frac{z}{t}, y - x, x\right) \end{array} \]
(FPCore (x y z t) :precision binary64 (fma (/ z t) (- y x) x))
double code(double x, double y, double z, double t) {
	return fma((z / t), (y - x), x);
}
function code(x, y, z, t)
	return fma(Float64(z / t), Float64(y - x), x)
end
code[x_, y_, z_, t_] := N[(N[(z / t), $MachinePrecision] * N[(y - x), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(\frac{z}{t}, y - x, x\right)
\end{array}
Derivation
  1. Initial program 93.0%

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{z}{t}}, y - x, x\right) \]
    10. lift--.f6497.8

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{z}{t}, y - x, x\right)} \]
  4. Add Preprocessing

Alternative 2: 85.4% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x + \frac{\left(y - x\right) \cdot z}{t}\\ \mathbf{if}\;t\_1 \leq -1 \cdot 10^{+300}:\\ \;\;\;\;\frac{y - x}{t} \cdot z\\ \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+285}:\\ \;\;\;\;x + \frac{y \cdot z}{t}\\ \mathbf{else}:\\ \;\;\;\;\left(y - x\right) \cdot \frac{z}{t}\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (+ x (/ (* (- y x) z) t))))
   (if (<= t_1 -1e+300)
     (* (/ (- y x) t) z)
     (if (<= t_1 2e+285) (+ x (/ (* y z) t)) (* (- y x) (/ z t))))))
double code(double x, double y, double z, double t) {
	double t_1 = x + (((y - x) * z) / t);
	double tmp;
	if (t_1 <= -1e+300) {
		tmp = ((y - x) / t) * z;
	} else if (t_1 <= 2e+285) {
		tmp = x + ((y * z) / t);
	} else {
		tmp = (y - x) * (z / t);
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y, z, t)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: t_1
    real(8) :: tmp
    t_1 = x + (((y - x) * z) / t)
    if (t_1 <= (-1d+300)) then
        tmp = ((y - x) / t) * z
    else if (t_1 <= 2d+285) then
        tmp = x + ((y * z) / t)
    else
        tmp = (y - x) * (z / t)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = x + (((y - x) * z) / t);
	double tmp;
	if (t_1 <= -1e+300) {
		tmp = ((y - x) / t) * z;
	} else if (t_1 <= 2e+285) {
		tmp = x + ((y * z) / t);
	} else {
		tmp = (y - x) * (z / t);
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = x + (((y - x) * z) / t)
	tmp = 0
	if t_1 <= -1e+300:
		tmp = ((y - x) / t) * z
	elif t_1 <= 2e+285:
		tmp = x + ((y * z) / t)
	else:
		tmp = (y - x) * (z / t)
	return tmp
function code(x, y, z, t)
	t_1 = Float64(x + Float64(Float64(Float64(y - x) * z) / t))
	tmp = 0.0
	if (t_1 <= -1e+300)
		tmp = Float64(Float64(Float64(y - x) / t) * z);
	elseif (t_1 <= 2e+285)
		tmp = Float64(x + Float64(Float64(y * z) / t));
	else
		tmp = Float64(Float64(y - x) * Float64(z / t));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = x + (((y - x) * z) / t);
	tmp = 0.0;
	if (t_1 <= -1e+300)
		tmp = ((y - x) / t) * z;
	elseif (t_1 <= 2e+285)
		tmp = x + ((y * z) / t);
	else
		tmp = (y - x) * (z / t);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x + N[(N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+300], N[(N[(N[(y - x), $MachinePrecision] / t), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[t$95$1, 2e+285], N[(x + N[(N[(y * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(N[(y - x), $MachinePrecision] * N[(z / t), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x + \frac{\left(y - x\right) \cdot z}{t}\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+300}:\\
\;\;\;\;\frac{y - x}{t} \cdot z\\

\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+285}:\\
\;\;\;\;x + \frac{y \cdot z}{t}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (+.f64 x (/.f64 (*.f64 (-.f64 y x) z) t)) < -1.0000000000000001e300

    1. Initial program 80.1%

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

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

        \[\leadsto z \cdot \frac{y - x}{\color{blue}{t}} \]
      2. associate-/l*N/A

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

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

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

        \[\leadsto \frac{\left(y - x\right) \cdot z}{t} \]
      6. lift-/.f6478.1

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

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

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

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

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

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

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

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

        \[\leadsto z \cdot \color{blue}{\frac{y - x}{t}} \]
      8. sub-divN/A

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

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

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

        \[\leadsto \frac{y - x}{t} \cdot z \]
      12. lower-/.f64N/A

        \[\leadsto \frac{y - x}{t} \cdot z \]
      13. lift--.f6490.5

        \[\leadsto \frac{y - x}{t} \cdot z \]
    6. Applied rewrites90.5%

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

    if -1.0000000000000001e300 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) z) t)) < 2e285

    1. Initial program 98.8%

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

      \[\leadsto x + \frac{\color{blue}{y} \cdot z}{t} \]
    3. Step-by-step derivation
      1. Applied rewrites82.8%

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

      if 2e285 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) z) t))

      1. Initial program 83.3%

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

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

          \[\leadsto z \cdot \frac{y - x}{\color{blue}{t}} \]
        2. associate-/l*N/A

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

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

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

          \[\leadsto \frac{\left(y - x\right) \cdot z}{t} \]
        6. lift-/.f6479.0

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

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

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

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

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

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

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

          \[\leadsto \left(y - x\right) \cdot \frac{\color{blue}{z}}{t} \]
        7. lift-/.f6490.0

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

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

    Alternative 3: 85.2% accurate, 0.7× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{y - x}{t} \cdot z\\ \mathbf{if}\;z \leq -6.5 \cdot 10^{+128}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 7.5 \cdot 10^{-8}:\\ \;\;\;\;\mathsf{fma}\left(y, \frac{z}{t}, x\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
    (FPCore (x y z t)
     :precision binary64
     (let* ((t_1 (* (/ (- y x) t) z)))
       (if (<= z -6.5e+128) t_1 (if (<= z 7.5e-8) (fma y (/ z t) x) t_1))))
    double code(double x, double y, double z, double t) {
    	double t_1 = ((y - x) / t) * z;
    	double tmp;
    	if (z <= -6.5e+128) {
    		tmp = t_1;
    	} else if (z <= 7.5e-8) {
    		tmp = fma(y, (z / t), x);
    	} else {
    		tmp = t_1;
    	}
    	return tmp;
    }
    
    function code(x, y, z, t)
    	t_1 = Float64(Float64(Float64(y - x) / t) * z)
    	tmp = 0.0
    	if (z <= -6.5e+128)
    		tmp = t_1;
    	elseif (z <= 7.5e-8)
    		tmp = fma(y, Float64(z / t), x);
    	else
    		tmp = t_1;
    	end
    	return tmp
    end
    
    code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[(y - x), $MachinePrecision] / t), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -6.5e+128], t$95$1, If[LessEqual[z, 7.5e-8], N[(y * N[(z / t), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_1 := \frac{y - x}{t} \cdot z\\
    \mathbf{if}\;z \leq -6.5 \cdot 10^{+128}:\\
    \;\;\;\;t\_1\\
    
    \mathbf{elif}\;z \leq 7.5 \cdot 10^{-8}:\\
    \;\;\;\;\mathsf{fma}\left(y, \frac{z}{t}, x\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_1\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if z < -6.5000000000000003e128 or 7.4999999999999997e-8 < z

      1. Initial program 86.3%

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

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

          \[\leadsto z \cdot \frac{y - x}{\color{blue}{t}} \]
        2. associate-/l*N/A

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

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

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

          \[\leadsto \frac{\left(y - x\right) \cdot z}{t} \]
        6. lift-/.f6477.2

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

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

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

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

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

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

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

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

          \[\leadsto z \cdot \color{blue}{\frac{y - x}{t}} \]
        8. sub-divN/A

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

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

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

          \[\leadsto \frac{y - x}{t} \cdot z \]
        12. lower-/.f64N/A

          \[\leadsto \frac{y - x}{t} \cdot z \]
        13. lift--.f6485.4

          \[\leadsto \frac{y - x}{t} \cdot z \]
      6. Applied rewrites85.4%

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

      if -6.5000000000000003e128 < z < 7.4999999999999997e-8

      1. Initial program 97.3%

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

        \[\leadsto x + \frac{\color{blue}{y} \cdot z}{t} \]
      3. Step-by-step derivation
        1. Applied rewrites82.6%

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

            \[\leadsto \color{blue}{x + \frac{y \cdot z}{t}} \]
          2. +-commutativeN/A

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

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

            \[\leadsto \frac{\color{blue}{y \cdot z}}{t} + x \]
          5. associate-/l*N/A

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

            \[\leadsto \color{blue}{\mathsf{fma}\left(y, \frac{z}{t}, x\right)} \]
          7. lift-/.f6483.0

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

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

      Alternative 4: 84.5% accurate, 0.3× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_1 := x + \frac{\left(y - x\right) \cdot z}{t}\\ t_2 := \left(y - x\right) \cdot \frac{z}{t}\\ \mathbf{if}\;t\_1 \leq -1 \cdot 10^{+300}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+285}:\\ \;\;\;\;\mathsf{fma}\left(y, \frac{z}{t}, x\right)\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
      (FPCore (x y z t)
       :precision binary64
       (let* ((t_1 (+ x (/ (* (- y x) z) t))) (t_2 (* (- y x) (/ z t))))
         (if (<= t_1 -1e+300) t_2 (if (<= t_1 2e+285) (fma y (/ z t) x) t_2))))
      double code(double x, double y, double z, double t) {
      	double t_1 = x + (((y - x) * z) / t);
      	double t_2 = (y - x) * (z / t);
      	double tmp;
      	if (t_1 <= -1e+300) {
      		tmp = t_2;
      	} else if (t_1 <= 2e+285) {
      		tmp = fma(y, (z / t), x);
      	} else {
      		tmp = t_2;
      	}
      	return tmp;
      }
      
      function code(x, y, z, t)
      	t_1 = Float64(x + Float64(Float64(Float64(y - x) * z) / t))
      	t_2 = Float64(Float64(y - x) * Float64(z / t))
      	tmp = 0.0
      	if (t_1 <= -1e+300)
      		tmp = t_2;
      	elseif (t_1 <= 2e+285)
      		tmp = fma(y, Float64(z / t), x);
      	else
      		tmp = t_2;
      	end
      	return tmp
      end
      
      code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x + N[(N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(y - x), $MachinePrecision] * N[(z / t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+300], t$95$2, If[LessEqual[t$95$1, 2e+285], N[(y * N[(z / t), $MachinePrecision] + x), $MachinePrecision], t$95$2]]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_1 := x + \frac{\left(y - x\right) \cdot z}{t}\\
      t_2 := \left(y - x\right) \cdot \frac{z}{t}\\
      \mathbf{if}\;t\_1 \leq -1 \cdot 10^{+300}:\\
      \;\;\;\;t\_2\\
      
      \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+285}:\\
      \;\;\;\;\mathsf{fma}\left(y, \frac{z}{t}, x\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;t\_2\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if (+.f64 x (/.f64 (*.f64 (-.f64 y x) z) t)) < -1.0000000000000001e300 or 2e285 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) z) t))

        1. Initial program 81.7%

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

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

            \[\leadsto z \cdot \frac{y - x}{\color{blue}{t}} \]
          2. associate-/l*N/A

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

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

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

            \[\leadsto \frac{\left(y - x\right) \cdot z}{t} \]
          6. lift-/.f6478.6

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

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

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

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

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

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

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

            \[\leadsto \left(y - x\right) \cdot \frac{\color{blue}{z}}{t} \]
          7. lift-/.f6490.4

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

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

        if -1.0000000000000001e300 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) z) t)) < 2e285

        1. Initial program 98.8%

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

          \[\leadsto x + \frac{\color{blue}{y} \cdot z}{t} \]
        3. Step-by-step derivation
          1. Applied rewrites82.8%

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

              \[\leadsto \color{blue}{x + \frac{y \cdot z}{t}} \]
            2. +-commutativeN/A

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

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

              \[\leadsto \frac{\color{blue}{y \cdot z}}{t} + x \]
            5. associate-/l*N/A

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

              \[\leadsto \color{blue}{\mathsf{fma}\left(y, \frac{z}{t}, x\right)} \]
            7. lift-/.f6481.4

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

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

        Alternative 5: 84.0% accurate, 0.7× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_1 := \mathsf{fma}\left(y, \frac{z}{t}, x\right)\\ \mathbf{if}\;y \leq -2900000000:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y \leq 1.6 \cdot 10^{-170}:\\ \;\;\;\;\left(1 - \frac{z}{t}\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
        (FPCore (x y z t)
         :precision binary64
         (let* ((t_1 (fma y (/ z t) x)))
           (if (<= y -2900000000.0)
             t_1
             (if (<= y 1.6e-170) (* (- 1.0 (/ z t)) x) t_1))))
        double code(double x, double y, double z, double t) {
        	double t_1 = fma(y, (z / t), x);
        	double tmp;
        	if (y <= -2900000000.0) {
        		tmp = t_1;
        	} else if (y <= 1.6e-170) {
        		tmp = (1.0 - (z / t)) * x;
        	} else {
        		tmp = t_1;
        	}
        	return tmp;
        }
        
        function code(x, y, z, t)
        	t_1 = fma(y, Float64(z / t), x)
        	tmp = 0.0
        	if (y <= -2900000000.0)
        		tmp = t_1;
        	elseif (y <= 1.6e-170)
        		tmp = Float64(Float64(1.0 - Float64(z / t)) * x);
        	else
        		tmp = t_1;
        	end
        	return tmp
        end
        
        code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(z / t), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[y, -2900000000.0], t$95$1, If[LessEqual[y, 1.6e-170], N[(N[(1.0 - N[(z / t), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], t$95$1]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_1 := \mathsf{fma}\left(y, \frac{z}{t}, x\right)\\
        \mathbf{if}\;y \leq -2900000000:\\
        \;\;\;\;t\_1\\
        
        \mathbf{elif}\;y \leq 1.6 \cdot 10^{-170}:\\
        \;\;\;\;\left(1 - \frac{z}{t}\right) \cdot x\\
        
        \mathbf{else}:\\
        \;\;\;\;t\_1\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if y < -2.9e9 or 1.6e-170 < y

          1. Initial program 92.2%

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

            \[\leadsto x + \frac{\color{blue}{y} \cdot z}{t} \]
          3. Step-by-step derivation
            1. Applied rewrites80.6%

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

                \[\leadsto \color{blue}{x + \frac{y \cdot z}{t}} \]
              2. +-commutativeN/A

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

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

                \[\leadsto \frac{\color{blue}{y \cdot z}}{t} + x \]
              5. associate-/l*N/A

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

                \[\leadsto \color{blue}{\mathsf{fma}\left(y, \frac{z}{t}, x\right)} \]
              7. lift-/.f6484.8

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

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

            if -2.9e9 < y < 1.6e-170

            1. Initial program 94.2%

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

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

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

                \[\leadsto \left(1 + -1 \cdot \frac{z}{t}\right) \cdot \color{blue}{x} \]
              3. cancel-sign-subN/A

                \[\leadsto \left(1 - \left(\mathsf{neg}\left(-1\right)\right) \cdot \frac{z}{t}\right) \cdot x \]
              4. metadata-evalN/A

                \[\leadsto \left(1 - 1 \cdot \frac{z}{t}\right) \cdot x \]
              5. *-lft-identityN/A

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

                \[\leadsto \left(1 - \frac{z}{t}\right) \cdot x \]
              7. lower-/.f6485.9

                \[\leadsto \left(1 - \frac{z}{t}\right) \cdot x \]
            4. Applied rewrites85.9%

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

          Alternative 6: 76.2% accurate, 0.7× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_1 := \mathsf{fma}\left(y, \frac{z}{t}, x\right)\\ \mathbf{if}\;t \leq -1.2 \cdot 10^{-237}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t \leq 2.65 \cdot 10^{-229}:\\ \;\;\;\;\frac{-z}{t} \cdot x\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
          (FPCore (x y z t)
           :precision binary64
           (let* ((t_1 (fma y (/ z t) x)))
             (if (<= t -1.2e-237) t_1 (if (<= t 2.65e-229) (* (/ (- z) t) x) t_1))))
          double code(double x, double y, double z, double t) {
          	double t_1 = fma(y, (z / t), x);
          	double tmp;
          	if (t <= -1.2e-237) {
          		tmp = t_1;
          	} else if (t <= 2.65e-229) {
          		tmp = (-z / t) * x;
          	} else {
          		tmp = t_1;
          	}
          	return tmp;
          }
          
          function code(x, y, z, t)
          	t_1 = fma(y, Float64(z / t), x)
          	tmp = 0.0
          	if (t <= -1.2e-237)
          		tmp = t_1;
          	elseif (t <= 2.65e-229)
          		tmp = Float64(Float64(Float64(-z) / t) * x);
          	else
          		tmp = t_1;
          	end
          	return tmp
          end
          
          code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(z / t), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[t, -1.2e-237], t$95$1, If[LessEqual[t, 2.65e-229], N[(N[((-z) / t), $MachinePrecision] * x), $MachinePrecision], t$95$1]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          t_1 := \mathsf{fma}\left(y, \frac{z}{t}, x\right)\\
          \mathbf{if}\;t \leq -1.2 \cdot 10^{-237}:\\
          \;\;\;\;t\_1\\
          
          \mathbf{elif}\;t \leq 2.65 \cdot 10^{-229}:\\
          \;\;\;\;\frac{-z}{t} \cdot x\\
          
          \mathbf{else}:\\
          \;\;\;\;t\_1\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if t < -1.2e-237 or 2.64999999999999999e-229 < t

            1. Initial program 92.5%

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

              \[\leadsto x + \frac{\color{blue}{y} \cdot z}{t} \]
            3. Step-by-step derivation
              1. Applied rewrites75.2%

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

                  \[\leadsto \color{blue}{x + \frac{y \cdot z}{t}} \]
                2. +-commutativeN/A

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

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

                  \[\leadsto \frac{\color{blue}{y \cdot z}}{t} + x \]
                5. associate-/l*N/A

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

                  \[\leadsto \color{blue}{\mathsf{fma}\left(y, \frac{z}{t}, x\right)} \]
                7. lift-/.f6478.6

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

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

              if -1.2e-237 < t < 2.64999999999999999e-229

              1. Initial program 96.4%

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

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

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

                  \[\leadsto \left(1 + -1 \cdot \frac{z}{t}\right) \cdot \color{blue}{x} \]
                3. cancel-sign-subN/A

                  \[\leadsto \left(1 - \left(\mathsf{neg}\left(-1\right)\right) \cdot \frac{z}{t}\right) \cdot x \]
                4. metadata-evalN/A

                  \[\leadsto \left(1 - 1 \cdot \frac{z}{t}\right) \cdot x \]
                5. *-lft-identityN/A

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

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

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

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

                \[\leadsto \left(-1 \cdot \frac{z}{t}\right) \cdot x \]
              6. Step-by-step derivation
                1. associate-*r/N/A

                  \[\leadsto \frac{-1 \cdot z}{t} \cdot x \]
                2. lower-/.f64N/A

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

                  \[\leadsto \frac{\mathsf{neg}\left(z\right)}{t} \cdot x \]
                4. lower-neg.f6457.9

                  \[\leadsto \frac{-z}{t} \cdot x \]
              7. Applied rewrites57.9%

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

            Alternative 7: 55.8% accurate, 0.8× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -4.5 \cdot 10^{+19}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{elif}\;z \leq 5.2 \cdot 10^{-10}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{t} \cdot z\\ \end{array} \end{array} \]
            (FPCore (x y z t)
             :precision binary64
             (if (<= z -4.5e+19) (* y (/ z t)) (if (<= z 5.2e-10) x (* (/ y t) z))))
            double code(double x, double y, double z, double t) {
            	double tmp;
            	if (z <= -4.5e+19) {
            		tmp = y * (z / t);
            	} else if (z <= 5.2e-10) {
            		tmp = x;
            	} else {
            		tmp = (y / t) * z;
            	}
            	return tmp;
            }
            
            module fmin_fmax_functions
                implicit none
                private
                public fmax
                public fmin
            
                interface fmax
                    module procedure fmax88
                    module procedure fmax44
                    module procedure fmax84
                    module procedure fmax48
                end interface
                interface fmin
                    module procedure fmin88
                    module procedure fmin44
                    module procedure fmin84
                    module procedure fmin48
                end interface
            contains
                real(8) function fmax88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(4) function fmax44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(8) function fmax84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmax48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                end function
                real(8) function fmin88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(4) function fmin44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(8) function fmin84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmin48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                end function
            end module
            
            real(8) function code(x, y, z, t)
            use fmin_fmax_functions
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                real(8), intent (in) :: z
                real(8), intent (in) :: t
                real(8) :: tmp
                if (z <= (-4.5d+19)) then
                    tmp = y * (z / t)
                else if (z <= 5.2d-10) then
                    tmp = x
                else
                    tmp = (y / t) * z
                end if
                code = tmp
            end function
            
            public static double code(double x, double y, double z, double t) {
            	double tmp;
            	if (z <= -4.5e+19) {
            		tmp = y * (z / t);
            	} else if (z <= 5.2e-10) {
            		tmp = x;
            	} else {
            		tmp = (y / t) * z;
            	}
            	return tmp;
            }
            
            def code(x, y, z, t):
            	tmp = 0
            	if z <= -4.5e+19:
            		tmp = y * (z / t)
            	elif z <= 5.2e-10:
            		tmp = x
            	else:
            		tmp = (y / t) * z
            	return tmp
            
            function code(x, y, z, t)
            	tmp = 0.0
            	if (z <= -4.5e+19)
            		tmp = Float64(y * Float64(z / t));
            	elseif (z <= 5.2e-10)
            		tmp = x;
            	else
            		tmp = Float64(Float64(y / t) * z);
            	end
            	return tmp
            end
            
            function tmp_2 = code(x, y, z, t)
            	tmp = 0.0;
            	if (z <= -4.5e+19)
            		tmp = y * (z / t);
            	elseif (z <= 5.2e-10)
            		tmp = x;
            	else
            		tmp = (y / t) * z;
            	end
            	tmp_2 = tmp;
            end
            
            code[x_, y_, z_, t_] := If[LessEqual[z, -4.5e+19], N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 5.2e-10], x, N[(N[(y / t), $MachinePrecision] * z), $MachinePrecision]]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            \mathbf{if}\;z \leq -4.5 \cdot 10^{+19}:\\
            \;\;\;\;y \cdot \frac{z}{t}\\
            
            \mathbf{elif}\;z \leq 5.2 \cdot 10^{-10}:\\
            \;\;\;\;x\\
            
            \mathbf{else}:\\
            \;\;\;\;\frac{y}{t} \cdot z\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 3 regimes
            2. if z < -4.5e19

              1. Initial program 86.3%

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

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

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

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

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

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

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

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

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

                  \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{z}{t}}, y - x, x\right) \]
                10. lift--.f6497.2

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

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

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

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

                  \[\leadsto \frac{y \cdot z}{t} \]
                3. +-commutativeN/A

                  \[\leadsto \frac{\color{blue}{y \cdot z}}{t} \]
                4. associate-/l*N/A

                  \[\leadsto y \cdot \color{blue}{\frac{z}{t}} \]
                5. lower-*.f64N/A

                  \[\leadsto y \cdot \color{blue}{\frac{z}{t}} \]
                6. lift-/.f6451.3

                  \[\leadsto y \cdot \frac{z}{\color{blue}{t}} \]
              6. Applied rewrites51.3%

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

              if -4.5e19 < z < 5.19999999999999962e-10

              1. Initial program 98.6%

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

                \[\leadsto \color{blue}{x} \]
              3. Step-by-step derivation
                1. Applied rewrites59.3%

                  \[\leadsto \color{blue}{x} \]

                if 5.19999999999999962e-10 < z

                1. Initial program 87.9%

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

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

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

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

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

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

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

                    \[\leadsto \frac{z \cdot \left(y - \color{blue}{1 \cdot x}\right)}{t} + x \]
                  8. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \color{blue}{\frac{y \cdot z}{t}} \]
                5. Step-by-step derivation
                  1. *-commutativeN/A

                    \[\leadsto \frac{z \cdot y}{t} \]
                  2. associate-*r/N/A

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

                    \[\leadsto \frac{y}{t} \cdot \color{blue}{z} \]
                  4. lower-*.f64N/A

                    \[\leadsto \frac{y}{t} \cdot \color{blue}{z} \]
                  5. lift-/.f6451.4

                    \[\leadsto \frac{y}{t} \cdot z \]
                6. Applied rewrites51.4%

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

              Alternative 8: 55.4% accurate, 0.8× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} t_1 := y \cdot \frac{z}{t}\\ \mathbf{if}\;z \leq -4.5 \cdot 10^{+19}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 5.2 \cdot 10^{-10}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
              (FPCore (x y z t)
               :precision binary64
               (let* ((t_1 (* y (/ z t))))
                 (if (<= z -4.5e+19) t_1 (if (<= z 5.2e-10) x t_1))))
              double code(double x, double y, double z, double t) {
              	double t_1 = y * (z / t);
              	double tmp;
              	if (z <= -4.5e+19) {
              		tmp = t_1;
              	} else if (z <= 5.2e-10) {
              		tmp = x;
              	} else {
              		tmp = t_1;
              	}
              	return tmp;
              }
              
              module fmin_fmax_functions
                  implicit none
                  private
                  public fmax
                  public fmin
              
                  interface fmax
                      module procedure fmax88
                      module procedure fmax44
                      module procedure fmax84
                      module procedure fmax48
                  end interface
                  interface fmin
                      module procedure fmin88
                      module procedure fmin44
                      module procedure fmin84
                      module procedure fmin48
                  end interface
              contains
                  real(8) function fmax88(x, y) result (res)
                      real(8), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                  end function
                  real(4) function fmax44(x, y) result (res)
                      real(4), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                  end function
                  real(8) function fmax84(x, y) result(res)
                      real(8), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                  end function
                  real(8) function fmax48(x, y) result(res)
                      real(4), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                  end function
                  real(8) function fmin88(x, y) result (res)
                      real(8), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                  end function
                  real(4) function fmin44(x, y) result (res)
                      real(4), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                  end function
                  real(8) function fmin84(x, y) result(res)
                      real(8), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                  end function
                  real(8) function fmin48(x, y) result(res)
                      real(4), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                  end function
              end module
              
              real(8) function code(x, y, z, t)
              use fmin_fmax_functions
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  real(8), intent (in) :: z
                  real(8), intent (in) :: t
                  real(8) :: t_1
                  real(8) :: tmp
                  t_1 = y * (z / t)
                  if (z <= (-4.5d+19)) then
                      tmp = t_1
                  else if (z <= 5.2d-10) then
                      tmp = x
                  else
                      tmp = t_1
                  end if
                  code = tmp
              end function
              
              public static double code(double x, double y, double z, double t) {
              	double t_1 = y * (z / t);
              	double tmp;
              	if (z <= -4.5e+19) {
              		tmp = t_1;
              	} else if (z <= 5.2e-10) {
              		tmp = x;
              	} else {
              		tmp = t_1;
              	}
              	return tmp;
              }
              
              def code(x, y, z, t):
              	t_1 = y * (z / t)
              	tmp = 0
              	if z <= -4.5e+19:
              		tmp = t_1
              	elif z <= 5.2e-10:
              		tmp = x
              	else:
              		tmp = t_1
              	return tmp
              
              function code(x, y, z, t)
              	t_1 = Float64(y * Float64(z / t))
              	tmp = 0.0
              	if (z <= -4.5e+19)
              		tmp = t_1;
              	elseif (z <= 5.2e-10)
              		tmp = x;
              	else
              		tmp = t_1;
              	end
              	return tmp
              end
              
              function tmp_2 = code(x, y, z, t)
              	t_1 = y * (z / t);
              	tmp = 0.0;
              	if (z <= -4.5e+19)
              		tmp = t_1;
              	elseif (z <= 5.2e-10)
              		tmp = x;
              	else
              		tmp = t_1;
              	end
              	tmp_2 = tmp;
              end
              
              code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -4.5e+19], t$95$1, If[LessEqual[z, 5.2e-10], x, t$95$1]]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              t_1 := y \cdot \frac{z}{t}\\
              \mathbf{if}\;z \leq -4.5 \cdot 10^{+19}:\\
              \;\;\;\;t\_1\\
              
              \mathbf{elif}\;z \leq 5.2 \cdot 10^{-10}:\\
              \;\;\;\;x\\
              
              \mathbf{else}:\\
              \;\;\;\;t\_1\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if z < -4.5e19 or 5.19999999999999962e-10 < z

                1. Initial program 87.1%

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

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

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

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

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

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{z}{t}}, y - x, x\right) \]
                  10. lift--.f6496.8

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

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

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

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

                    \[\leadsto \frac{y \cdot z}{t} \]
                  3. +-commutativeN/A

                    \[\leadsto \frac{\color{blue}{y \cdot z}}{t} \]
                  4. associate-/l*N/A

                    \[\leadsto y \cdot \color{blue}{\frac{z}{t}} \]
                  5. lower-*.f64N/A

                    \[\leadsto y \cdot \color{blue}{\frac{z}{t}} \]
                  6. lift-/.f6452.2

                    \[\leadsto y \cdot \frac{z}{\color{blue}{t}} \]
                6. Applied rewrites52.2%

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

                if -4.5e19 < z < 5.19999999999999962e-10

                1. Initial program 98.6%

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

                  \[\leadsto \color{blue}{x} \]
                3. Step-by-step derivation
                  1. Applied rewrites59.3%

                    \[\leadsto \color{blue}{x} \]
                4. Recombined 2 regimes into one program.
                5. Add Preprocessing

                Alternative 9: 38.5% accurate, 12.7× speedup?

                \[\begin{array}{l} \\ x \end{array} \]
                (FPCore (x y z t) :precision binary64 x)
                double code(double x, double y, double z, double t) {
                	return x;
                }
                
                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
                end function
                
                public static double code(double x, double y, double z, double t) {
                	return x;
                }
                
                def code(x, y, z, t):
                	return x
                
                function code(x, y, z, t)
                	return x
                end
                
                function tmp = code(x, y, z, t)
                	tmp = x;
                end
                
                code[x_, y_, z_, t_] := x
                
                \begin{array}{l}
                
                \\
                x
                \end{array}
                
                Derivation
                1. Initial program 93.0%

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

                  \[\leadsto \color{blue}{x} \]
                3. Step-by-step derivation
                  1. Applied rewrites38.5%

                    \[\leadsto \color{blue}{x} \]
                  2. Add Preprocessing

                  Reproduce

                  ?
                  herbie shell --seed 2025112 
                  (FPCore (x y z t)
                    :name "Numeric.Histogram:binBounds from Chart-1.5.3"
                    :precision binary64
                    (+ x (/ (* (- y x) z) t)))