Diagrams.TwoD.Segment.Bernstein:evaluateBernstein from diagrams-lib-1.3.0.3

Percentage Accurate: 88.2% → 99.8%
Time: 4.8s
Alternatives: 13
Speedup: 0.8×

Specification

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

\\
\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}
\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 13 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: 88.2% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y - \left(z - 1\right)\\ t_1 := \frac{t\_0}{z} \cdot x\\ \mathbf{if}\;z \leq -9.6 \cdot 10^{+28}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 2 \cdot 10^{-39}:\\ \;\;\;\;t\_0 \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (- y (- z 1.0))) (t_1 (* (/ t_0 z) x)))
   (if (<= z -9.6e+28) t_1 (if (<= z 2e-39) (* t_0 (/ x z)) t_1))))
double code(double x, double y, double z) {
	double t_0 = y - (z - 1.0);
	double t_1 = (t_0 / z) * x;
	double tmp;
	if (z <= -9.6e+28) {
		tmp = t_1;
	} else if (z <= 2e-39) {
		tmp = t_0 * (x / z);
	} 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)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = y - (z - 1.0d0)
    t_1 = (t_0 / z) * x
    if (z <= (-9.6d+28)) then
        tmp = t_1
    else if (z <= 2d-39) then
        tmp = t_0 * (x / z)
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = y - (z - 1.0);
	double t_1 = (t_0 / z) * x;
	double tmp;
	if (z <= -9.6e+28) {
		tmp = t_1;
	} else if (z <= 2e-39) {
		tmp = t_0 * (x / z);
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y - (z - 1.0)
	t_1 = (t_0 / z) * x
	tmp = 0
	if z <= -9.6e+28:
		tmp = t_1
	elif z <= 2e-39:
		tmp = t_0 * (x / z)
	else:
		tmp = t_1
	return tmp
function code(x, y, z)
	t_0 = Float64(y - Float64(z - 1.0))
	t_1 = Float64(Float64(t_0 / z) * x)
	tmp = 0.0
	if (z <= -9.6e+28)
		tmp = t_1;
	elseif (z <= 2e-39)
		tmp = Float64(t_0 * Float64(x / z));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = y - (z - 1.0);
	t_1 = (t_0 / z) * x;
	tmp = 0.0;
	if (z <= -9.6e+28)
		tmp = t_1;
	elseif (z <= 2e-39)
		tmp = t_0 * (x / z);
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(y - N[(z - 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 / z), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[z, -9.6e+28], t$95$1, If[LessEqual[z, 2e-39], N[(t$95$0 * N[(x / z), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq 2 \cdot 10^{-39}:\\
\;\;\;\;t\_0 \cdot \frac{x}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -9.59999999999999925e28 or 1.99999999999999986e-39 < z

    1. Initial program 88.2%

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]
    2. Applied rewrites96.0%

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

      \[\leadsto \frac{y - \color{blue}{-1}}{z} \cdot x \]
    4. Applied rewrites58.9%

      \[\leadsto \frac{y - \color{blue}{-1}}{z} \cdot x \]
    5. Taylor expanded in z around 0

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

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

    if -9.59999999999999925e28 < z < 1.99999999999999986e-39

    1. Initial program 88.2%

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]
    2. Applied rewrites88.8%

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

Alternative 2: 98.0% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 5 \cdot 10^{-22}:\\ \;\;\;\;\mathsf{fma}\left(-1, x, \frac{x \cdot \left(1 + y\right)}{z}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(y - \left(z - 1\right)\right) \cdot \frac{x}{z}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x 5e-22)
   (fma -1.0 x (/ (* x (+ 1.0 y)) z))
   (* (- y (- z 1.0)) (/ x z))))
double code(double x, double y, double z) {
	double tmp;
	if (x <= 5e-22) {
		tmp = fma(-1.0, x, ((x * (1.0 + y)) / z));
	} else {
		tmp = (y - (z - 1.0)) * (x / z);
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if (x <= 5e-22)
		tmp = fma(-1.0, x, Float64(Float64(x * Float64(1.0 + y)) / z));
	else
		tmp = Float64(Float64(y - Float64(z - 1.0)) * Float64(x / z));
	end
	return tmp
end
code[x_, y_, z_] := If[LessEqual[x, 5e-22], N[(-1.0 * x + N[(N[(x * N[(1.0 + y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(N[(y - N[(z - 1.0), $MachinePrecision]), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 5 \cdot 10^{-22}:\\
\;\;\;\;\mathsf{fma}\left(-1, x, \frac{x \cdot \left(1 + y\right)}{z}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 4.99999999999999954e-22

    1. Initial program 88.2%

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

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

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

    if 4.99999999999999954e-22 < x

    1. Initial program 88.2%

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]
    2. Applied rewrites88.8%

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

Alternative 3: 97.8% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 4.8 \cdot 10^{-22}:\\ \;\;\;\;\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;\left(y - \left(z - 1\right)\right) \cdot \frac{x}{z}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x 4.8e-22) (/ (* x (+ (- y z) 1.0)) z) (* (- y (- z 1.0)) (/ x z))))
double code(double x, double y, double z) {
	double tmp;
	if (x <= 4.8e-22) {
		tmp = (x * ((y - z) + 1.0)) / z;
	} else {
		tmp = (y - (z - 1.0)) * (x / 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)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= 4.8d-22) then
        tmp = (x * ((y - z) + 1.0d0)) / z
    else
        tmp = (y - (z - 1.0d0)) * (x / z)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= 4.8e-22) {
		tmp = (x * ((y - z) + 1.0)) / z;
	} else {
		tmp = (y - (z - 1.0)) * (x / z);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= 4.8e-22:
		tmp = (x * ((y - z) + 1.0)) / z
	else:
		tmp = (y - (z - 1.0)) * (x / z)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= 4.8e-22)
		tmp = Float64(Float64(x * Float64(Float64(y - z) + 1.0)) / z);
	else
		tmp = Float64(Float64(y - Float64(z - 1.0)) * Float64(x / z));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= 4.8e-22)
		tmp = (x * ((y - z) + 1.0)) / z;
	else
		tmp = (y - (z - 1.0)) * (x / z);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, 4.8e-22], N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(N[(y - N[(z - 1.0), $MachinePrecision]), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.8 \cdot 10^{-22}:\\
\;\;\;\;\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 4.80000000000000005e-22

    1. Initial program 88.2%

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]

    if 4.80000000000000005e-22 < x

    1. Initial program 88.2%

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]
    2. Applied rewrites88.8%

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

Alternative 4: 97.3% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x}{z} \cdot \left(y - 1\right) - x\\ \mathbf{if}\;z \leq -3.4 \cdot 10^{+47}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 9.5 \cdot 10^{+15}:\\ \;\;\;\;\left(y - \left(z - 1\right)\right) \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (- (* (/ x z) (- y 1.0)) x)))
   (if (<= z -3.4e+47)
     t_0
     (if (<= z 9.5e+15) (* (- y (- z 1.0)) (/ x z)) t_0))))
double code(double x, double y, double z) {
	double t_0 = ((x / z) * (y - 1.0)) - x;
	double tmp;
	if (z <= -3.4e+47) {
		tmp = t_0;
	} else if (z <= 9.5e+15) {
		tmp = (y - (z - 1.0)) * (x / z);
	} else {
		tmp = t_0;
	}
	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)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = ((x / z) * (y - 1.0d0)) - x
    if (z <= (-3.4d+47)) then
        tmp = t_0
    else if (z <= 9.5d+15) then
        tmp = (y - (z - 1.0d0)) * (x / z)
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = ((x / z) * (y - 1.0)) - x;
	double tmp;
	if (z <= -3.4e+47) {
		tmp = t_0;
	} else if (z <= 9.5e+15) {
		tmp = (y - (z - 1.0)) * (x / z);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = ((x / z) * (y - 1.0)) - x
	tmp = 0
	if z <= -3.4e+47:
		tmp = t_0
	elif z <= 9.5e+15:
		tmp = (y - (z - 1.0)) * (x / z)
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(Float64(x / z) * Float64(y - 1.0)) - x)
	tmp = 0.0
	if (z <= -3.4e+47)
		tmp = t_0;
	elseif (z <= 9.5e+15)
		tmp = Float64(Float64(y - Float64(z - 1.0)) * Float64(x / z));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = ((x / z) * (y - 1.0)) - x;
	tmp = 0.0;
	if (z <= -3.4e+47)
		tmp = t_0;
	elseif (z <= 9.5e+15)
		tmp = (y - (z - 1.0)) * (x / z);
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(x / z), $MachinePrecision] * N[(y - 1.0), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]}, If[LessEqual[z, -3.4e+47], t$95$0, If[LessEqual[z, 9.5e+15], N[(N[(y - N[(z - 1.0), $MachinePrecision]), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{x}{z} \cdot \left(y - 1\right) - x\\
\mathbf{if}\;z \leq -3.4 \cdot 10^{+47}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 9.5 \cdot 10^{+15}:\\
\;\;\;\;\left(y - \left(z - 1\right)\right) \cdot \frac{x}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -3.3999999999999998e47 or 9.5e15 < z

    1. Initial program 88.2%

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(-1, x, \frac{x \cdot \left(1 + y\right)}{z}\right)} \]
    4. Applied rewrites72.2%

      \[\leadsto \mathsf{fma}\left(-1, x, \frac{x}{z} \cdot \left(y - 1\right)\right) \]
    5. Applied rewrites72.2%

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

    if -3.3999999999999998e47 < z < 9.5e15

    1. Initial program 88.2%

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]
    2. Applied rewrites88.8%

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

Alternative 5: 93.8% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x}{z} \cdot \left(y - 1\right) - x\\ \mathbf{if}\;y \leq -1:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 2:\\ \;\;\;\;\mathsf{fma}\left(-1, x, \frac{x}{z}\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (- (* (/ x z) (- y 1.0)) x)))
   (if (<= y -1.0) t_0 (if (<= y 2.0) (fma -1.0 x (/ x z)) t_0))))
double code(double x, double y, double z) {
	double t_0 = ((x / z) * (y - 1.0)) - x;
	double tmp;
	if (y <= -1.0) {
		tmp = t_0;
	} else if (y <= 2.0) {
		tmp = fma(-1.0, x, (x / z));
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(x, y, z)
	t_0 = Float64(Float64(Float64(x / z) * Float64(y - 1.0)) - x)
	tmp = 0.0
	if (y <= -1.0)
		tmp = t_0;
	elseif (y <= 2.0)
		tmp = fma(-1.0, x, Float64(x / z));
	else
		tmp = t_0;
	end
	return tmp
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(x / z), $MachinePrecision] * N[(y - 1.0), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]}, If[LessEqual[y, -1.0], t$95$0, If[LessEqual[y, 2.0], N[(-1.0 * x + N[(x / z), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{x}{z} \cdot \left(y - 1\right) - x\\
\mathbf{if}\;y \leq -1:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq 2:\\
\;\;\;\;\mathsf{fma}\left(-1, x, \frac{x}{z}\right)\\

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


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

    1. Initial program 88.2%

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(-1, x, \frac{x \cdot \left(1 + y\right)}{z}\right)} \]
    4. Applied rewrites72.2%

      \[\leadsto \mathsf{fma}\left(-1, x, \frac{x}{z} \cdot \left(y - 1\right)\right) \]
    5. Applied rewrites72.2%

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

    if -1 < y < 2

    1. Initial program 88.2%

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

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

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

      \[\leadsto \mathsf{fma}\left(-1, x, \frac{x}{z}\right) \]
    5. Applied rewrites66.4%

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

Alternative 6: 84.7% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -5.5 \cdot 10^{+28}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;y \leq 42000:\\ \;\;\;\;\mathsf{fma}\left(-1, x, \frac{x}{z}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y - 1, \frac{x}{z}, x\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -5.5e+28)
   (/ (* x y) z)
   (if (<= y 42000.0) (fma -1.0 x (/ x z)) (fma (- y 1.0) (/ x z) x))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -5.5e+28) {
		tmp = (x * y) / z;
	} else if (y <= 42000.0) {
		tmp = fma(-1.0, x, (x / z));
	} else {
		tmp = fma((y - 1.0), (x / z), x);
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if (y <= -5.5e+28)
		tmp = Float64(Float64(x * y) / z);
	elseif (y <= 42000.0)
		tmp = fma(-1.0, x, Float64(x / z));
	else
		tmp = fma(Float64(y - 1.0), Float64(x / z), x);
	end
	return tmp
end
code[x_, y_, z_] := If[LessEqual[y, -5.5e+28], N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[y, 42000.0], N[(-1.0 * x + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(N[(y - 1.0), $MachinePrecision] * N[(x / z), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.5 \cdot 10^{+28}:\\
\;\;\;\;\frac{x \cdot y}{z}\\

\mathbf{elif}\;y \leq 42000:\\
\;\;\;\;\mathsf{fma}\left(-1, x, \frac{x}{z}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -5.5000000000000003e28

    1. Initial program 88.2%

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

      \[\leadsto \frac{\color{blue}{x \cdot y}}{z} \]
    3. Applied rewrites37.7%

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

    if -5.5000000000000003e28 < y < 42000

    1. Initial program 88.2%

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

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

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

      \[\leadsto \mathsf{fma}\left(-1, x, \frac{x}{z}\right) \]
    5. Applied rewrites66.4%

      \[\leadsto \mathsf{fma}\left(-1, x, \frac{x}{z}\right) \]

    if 42000 < y

    1. Initial program 88.2%

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(-1, x, \frac{x \cdot \left(1 + y\right)}{z}\right)} \]
    4. Applied rewrites35.5%

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

Alternative 7: 83.9% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -5.5 \cdot 10^{+28}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;y \leq 2.6 \cdot 10^{-19}:\\ \;\;\;\;\mathsf{fma}\left(-1, x, \frac{x}{z}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{y - -1}{z} \cdot x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -5.5e+28)
   (/ (* x y) z)
   (if (<= y 2.6e-19) (fma -1.0 x (/ x z)) (* (/ (- y -1.0) z) x))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -5.5e+28) {
		tmp = (x * y) / z;
	} else if (y <= 2.6e-19) {
		tmp = fma(-1.0, x, (x / z));
	} else {
		tmp = ((y - -1.0) / z) * x;
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if (y <= -5.5e+28)
		tmp = Float64(Float64(x * y) / z);
	elseif (y <= 2.6e-19)
		tmp = fma(-1.0, x, Float64(x / z));
	else
		tmp = Float64(Float64(Float64(y - -1.0) / z) * x);
	end
	return tmp
end
code[x_, y_, z_] := If[LessEqual[y, -5.5e+28], N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[y, 2.6e-19], N[(-1.0 * x + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y - -1.0), $MachinePrecision] / z), $MachinePrecision] * x), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.5 \cdot 10^{+28}:\\
\;\;\;\;\frac{x \cdot y}{z}\\

\mathbf{elif}\;y \leq 2.6 \cdot 10^{-19}:\\
\;\;\;\;\mathsf{fma}\left(-1, x, \frac{x}{z}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -5.5000000000000003e28

    1. Initial program 88.2%

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

      \[\leadsto \frac{\color{blue}{x \cdot y}}{z} \]
    3. Applied rewrites37.7%

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

    if -5.5000000000000003e28 < y < 2.60000000000000013e-19

    1. Initial program 88.2%

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

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

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

      \[\leadsto \mathsf{fma}\left(-1, x, \frac{x}{z}\right) \]
    5. Applied rewrites66.4%

      \[\leadsto \mathsf{fma}\left(-1, x, \frac{x}{z}\right) \]

    if 2.60000000000000013e-19 < y

    1. Initial program 88.2%

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]
    2. Applied rewrites96.0%

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

      \[\leadsto \frac{y - \color{blue}{-1}}{z} \cdot x \]
    4. Applied rewrites58.9%

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

Alternative 8: 83.2% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -5.5 \cdot 10^{+28}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;y \leq 42000:\\ \;\;\;\;\mathsf{fma}\left(-1, x, \frac{x}{z}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -5.5e+28)
   (/ (* x y) z)
   (if (<= y 42000.0) (fma -1.0 x (/ x z)) (* (/ y z) x))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -5.5e+28) {
		tmp = (x * y) / z;
	} else if (y <= 42000.0) {
		tmp = fma(-1.0, x, (x / z));
	} else {
		tmp = (y / z) * x;
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if (y <= -5.5e+28)
		tmp = Float64(Float64(x * y) / z);
	elseif (y <= 42000.0)
		tmp = fma(-1.0, x, Float64(x / z));
	else
		tmp = Float64(Float64(y / z) * x);
	end
	return tmp
end
code[x_, y_, z_] := If[LessEqual[y, -5.5e+28], N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[y, 42000.0], N[(-1.0 * x + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(N[(y / z), $MachinePrecision] * x), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.5 \cdot 10^{+28}:\\
\;\;\;\;\frac{x \cdot y}{z}\\

\mathbf{elif}\;y \leq 42000:\\
\;\;\;\;\mathsf{fma}\left(-1, x, \frac{x}{z}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -5.5000000000000003e28

    1. Initial program 88.2%

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

      \[\leadsto \frac{\color{blue}{x \cdot y}}{z} \]
    3. Applied rewrites37.7%

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

    if -5.5000000000000003e28 < y < 42000

    1. Initial program 88.2%

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

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

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

      \[\leadsto \mathsf{fma}\left(-1, x, \frac{x}{z}\right) \]
    5. Applied rewrites66.4%

      \[\leadsto \mathsf{fma}\left(-1, x, \frac{x}{z}\right) \]

    if 42000 < y

    1. Initial program 88.2%

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]
    2. Applied rewrites96.0%

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

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

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

Alternative 9: 61.8% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x \cdot y}{z}\\ t_1 := \frac{x \cdot 1}{z}\\ \mathbf{if}\;z \leq -1:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq -1.7 \cdot 10^{-179}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 1.42 \cdot 10^{-185}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 2.1 \cdot 10^{-134}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 1.25 \cdot 10^{+136}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (/ (* x y) z)) (t_1 (/ (* x 1.0) z)))
   (if (<= z -1.0)
     (- x)
     (if (<= z -1.7e-179)
       t_1
       (if (<= z 1.42e-185)
         t_0
         (if (<= z 2.1e-134) t_1 (if (<= z 1.25e+136) t_0 (- x))))))))
double code(double x, double y, double z) {
	double t_0 = (x * y) / z;
	double t_1 = (x * 1.0) / z;
	double tmp;
	if (z <= -1.0) {
		tmp = -x;
	} else if (z <= -1.7e-179) {
		tmp = t_1;
	} else if (z <= 1.42e-185) {
		tmp = t_0;
	} else if (z <= 2.1e-134) {
		tmp = t_1;
	} else if (z <= 1.25e+136) {
		tmp = t_0;
	} else {
		tmp = -x;
	}
	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)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (x * y) / z
    t_1 = (x * 1.0d0) / z
    if (z <= (-1.0d0)) then
        tmp = -x
    else if (z <= (-1.7d-179)) then
        tmp = t_1
    else if (z <= 1.42d-185) then
        tmp = t_0
    else if (z <= 2.1d-134) then
        tmp = t_1
    else if (z <= 1.25d+136) then
        tmp = t_0
    else
        tmp = -x
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = (x * y) / z;
	double t_1 = (x * 1.0) / z;
	double tmp;
	if (z <= -1.0) {
		tmp = -x;
	} else if (z <= -1.7e-179) {
		tmp = t_1;
	} else if (z <= 1.42e-185) {
		tmp = t_0;
	} else if (z <= 2.1e-134) {
		tmp = t_1;
	} else if (z <= 1.25e+136) {
		tmp = t_0;
	} else {
		tmp = -x;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = (x * y) / z
	t_1 = (x * 1.0) / z
	tmp = 0
	if z <= -1.0:
		tmp = -x
	elif z <= -1.7e-179:
		tmp = t_1
	elif z <= 1.42e-185:
		tmp = t_0
	elif z <= 2.1e-134:
		tmp = t_1
	elif z <= 1.25e+136:
		tmp = t_0
	else:
		tmp = -x
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(x * y) / z)
	t_1 = Float64(Float64(x * 1.0) / z)
	tmp = 0.0
	if (z <= -1.0)
		tmp = Float64(-x);
	elseif (z <= -1.7e-179)
		tmp = t_1;
	elseif (z <= 1.42e-185)
		tmp = t_0;
	elseif (z <= 2.1e-134)
		tmp = t_1;
	elseif (z <= 1.25e+136)
		tmp = t_0;
	else
		tmp = Float64(-x);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = (x * y) / z;
	t_1 = (x * 1.0) / z;
	tmp = 0.0;
	if (z <= -1.0)
		tmp = -x;
	elseif (z <= -1.7e-179)
		tmp = t_1;
	elseif (z <= 1.42e-185)
		tmp = t_0;
	elseif (z <= 2.1e-134)
		tmp = t_1;
	elseif (z <= 1.25e+136)
		tmp = t_0;
	else
		tmp = -x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * 1.0), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[z, -1.0], (-x), If[LessEqual[z, -1.7e-179], t$95$1, If[LessEqual[z, 1.42e-185], t$95$0, If[LessEqual[z, 2.1e-134], t$95$1, If[LessEqual[z, 1.25e+136], t$95$0, (-x)]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{x \cdot y}{z}\\
t_1 := \frac{x \cdot 1}{z}\\
\mathbf{if}\;z \leq -1:\\
\;\;\;\;-x\\

\mathbf{elif}\;z \leq -1.7 \cdot 10^{-179}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \leq 1.42 \cdot 10^{-185}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 2.1 \cdot 10^{-134}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \leq 1.25 \cdot 10^{+136}:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;-x\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1 or 1.25e136 < z

    1. Initial program 88.2%

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

      \[\leadsto \color{blue}{-1 \cdot x} \]
    3. Applied rewrites38.9%

      \[\leadsto \color{blue}{-1 \cdot x} \]
    4. Applied rewrites38.9%

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

    if -1 < z < -1.6999999999999999e-179 or 1.42000000000000003e-185 < z < 2.0999999999999999e-134

    1. Initial program 88.2%

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

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

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

      \[\leadsto \frac{x \cdot 1}{z} \]
    5. Applied rewrites30.1%

      \[\leadsto \frac{x \cdot 1}{z} \]

    if -1.6999999999999999e-179 < z < 1.42000000000000003e-185 or 2.0999999999999999e-134 < z < 1.25e136

    1. Initial program 88.2%

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

      \[\leadsto \frac{\color{blue}{x \cdot y}}{z} \]
    3. Applied rewrites37.7%

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

Alternative 10: 58.7% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -5.5 \cdot 10^{+28}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;y \leq 8.5 \cdot 10^{-20}:\\ \;\;\;\;-x\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -5.5e+28) (/ (* x y) z) (if (<= y 8.5e-20) (- x) (* (/ y z) x))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -5.5e+28) {
		tmp = (x * y) / z;
	} else if (y <= 8.5e-20) {
		tmp = -x;
	} else {
		tmp = (y / z) * x;
	}
	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)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (y <= (-5.5d+28)) then
        tmp = (x * y) / z
    else if (y <= 8.5d-20) then
        tmp = -x
    else
        tmp = (y / z) * x
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -5.5e+28) {
		tmp = (x * y) / z;
	} else if (y <= 8.5e-20) {
		tmp = -x;
	} else {
		tmp = (y / z) * x;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= -5.5e+28:
		tmp = (x * y) / z
	elif y <= 8.5e-20:
		tmp = -x
	else:
		tmp = (y / z) * x
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= -5.5e+28)
		tmp = Float64(Float64(x * y) / z);
	elseif (y <= 8.5e-20)
		tmp = Float64(-x);
	else
		tmp = Float64(Float64(y / z) * x);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -5.5e+28)
		tmp = (x * y) / z;
	elseif (y <= 8.5e-20)
		tmp = -x;
	else
		tmp = (y / z) * x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, -5.5e+28], N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[y, 8.5e-20], (-x), N[(N[(y / z), $MachinePrecision] * x), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.5 \cdot 10^{+28}:\\
\;\;\;\;\frac{x \cdot y}{z}\\

\mathbf{elif}\;y \leq 8.5 \cdot 10^{-20}:\\
\;\;\;\;-x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -5.5000000000000003e28

    1. Initial program 88.2%

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

      \[\leadsto \frac{\color{blue}{x \cdot y}}{z} \]
    3. Applied rewrites37.7%

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

    if -5.5000000000000003e28 < y < 8.5000000000000005e-20

    1. Initial program 88.2%

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

      \[\leadsto \color{blue}{-1 \cdot x} \]
    3. Applied rewrites38.9%

      \[\leadsto \color{blue}{-1 \cdot x} \]
    4. Applied rewrites38.9%

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

    if 8.5000000000000005e-20 < y

    1. Initial program 88.2%

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]
    2. Applied rewrites96.0%

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

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

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

Alternative 11: 57.6% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{y}{z} \cdot x\\ \mathbf{if}\;y \leq -3.7 \cdot 10^{+29}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 8.5 \cdot 10^{-20}:\\ \;\;\;\;-x\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* (/ y z) x)))
   (if (<= y -3.7e+29) t_0 (if (<= y 8.5e-20) (- x) t_0))))
double code(double x, double y, double z) {
	double t_0 = (y / z) * x;
	double tmp;
	if (y <= -3.7e+29) {
		tmp = t_0;
	} else if (y <= 8.5e-20) {
		tmp = -x;
	} else {
		tmp = t_0;
	}
	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)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (y / z) * x
    if (y <= (-3.7d+29)) then
        tmp = t_0
    else if (y <= 8.5d-20) then
        tmp = -x
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = (y / z) * x;
	double tmp;
	if (y <= -3.7e+29) {
		tmp = t_0;
	} else if (y <= 8.5e-20) {
		tmp = -x;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = (y / z) * x
	tmp = 0
	if y <= -3.7e+29:
		tmp = t_0
	elif y <= 8.5e-20:
		tmp = -x
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(y / z) * x)
	tmp = 0.0
	if (y <= -3.7e+29)
		tmp = t_0;
	elseif (y <= 8.5e-20)
		tmp = Float64(-x);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = (y / z) * x;
	tmp = 0.0;
	if (y <= -3.7e+29)
		tmp = t_0;
	elseif (y <= 8.5e-20)
		tmp = -x;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y / z), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[y, -3.7e+29], t$95$0, If[LessEqual[y, 8.5e-20], (-x), t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{y}{z} \cdot x\\
\mathbf{if}\;y \leq -3.7 \cdot 10^{+29}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq 8.5 \cdot 10^{-20}:\\
\;\;\;\;-x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -3.69999999999999974e29 or 8.5000000000000005e-20 < y

    1. Initial program 88.2%

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]
    2. Applied rewrites96.0%

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

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

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

    if -3.69999999999999974e29 < y < 8.5000000000000005e-20

    1. Initial program 88.2%

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

      \[\leadsto \color{blue}{-1 \cdot x} \]
    3. Applied rewrites38.9%

      \[\leadsto \color{blue}{-1 \cdot x} \]
    4. Applied rewrites38.9%

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

Alternative 12: 38.9% accurate, 6.4× speedup?

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

\\
-x
\end{array}
Derivation
  1. Initial program 88.2%

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

    \[\leadsto \color{blue}{-1 \cdot x} \]
  3. Applied rewrites38.9%

    \[\leadsto \color{blue}{-1 \cdot x} \]
  4. Applied rewrites38.9%

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

Alternative 13: 3.0% accurate, 12.7× speedup?

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

\\
x
\end{array}
Derivation
  1. Initial program 88.2%

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

    \[\leadsto \color{blue}{-1 \cdot x} \]
  3. Applied rewrites38.9%

    \[\leadsto \color{blue}{-1 \cdot x} \]
  4. Applied rewrites38.9%

    \[\leadsto \color{blue}{-x} \]
  5. Applied rewrites3.0%

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

Reproduce

?
herbie shell --seed 2025159 
(FPCore (x y z)
  :name "Diagrams.TwoD.Segment.Bernstein:evaluateBernstein from diagrams-lib-1.3.0.3"
  :precision binary64
  (/ (* x (+ (- y z) 1.0)) z))