Numeric.SpecFunctions:stirlingError from math-functions-0.1.5.2

Percentage Accurate: 99.8% → 99.8%
Time: 5.7s
Alternatives: 11
Speedup: 1.0×

Specification

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

\\
\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 11 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: 99.8% accurate, 1.0× speedup?

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

\\
\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z
\end{array}

Alternative 1: 99.8% accurate, 1.0× speedup?

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

\\
\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z
\end{array}
Derivation
  1. Initial program 99.9%

    \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
  2. Add Preprocessing
  3. Add Preprocessing

Alternative 2: 89.4% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(1 - \log y\right) \cdot y - z\\ \mathbf{if}\;z \leq -1.75 \cdot 10^{+107}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 2.8 \cdot 10^{+27}:\\ \;\;\;\;\mathsf{fma}\left(-0.5 - y, \log y, y + x\right)\\ \mathbf{elif}\;z \leq 5.4 \cdot 10^{+98}:\\ \;\;\;\;x - z\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (- (* (- 1.0 (log y)) y) z)))
   (if (<= z -1.75e+107)
     t_0
     (if (<= z 2.8e+27)
       (fma (- -0.5 y) (log y) (+ y x))
       (if (<= z 5.4e+98) (- x z) t_0)))))
double code(double x, double y, double z) {
	double t_0 = ((1.0 - log(y)) * y) - z;
	double tmp;
	if (z <= -1.75e+107) {
		tmp = t_0;
	} else if (z <= 2.8e+27) {
		tmp = fma((-0.5 - y), log(y), (y + x));
	} else if (z <= 5.4e+98) {
		tmp = x - z;
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(x, y, z)
	t_0 = Float64(Float64(Float64(1.0 - log(y)) * y) - z)
	tmp = 0.0
	if (z <= -1.75e+107)
		tmp = t_0;
	elseif (z <= 2.8e+27)
		tmp = fma(Float64(-0.5 - y), log(y), Float64(y + x));
	elseif (z <= 5.4e+98)
		tmp = Float64(x - z);
	else
		tmp = t_0;
	end
	return tmp
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision] - z), $MachinePrecision]}, If[LessEqual[z, -1.75e+107], t$95$0, If[LessEqual[z, 2.8e+27], N[(N[(-0.5 - y), $MachinePrecision] * N[Log[y], $MachinePrecision] + N[(y + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 5.4e+98], N[(x - z), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(1 - \log y\right) \cdot y - z\\
\mathbf{if}\;z \leq -1.75 \cdot 10^{+107}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 2.8 \cdot 10^{+27}:\\
\;\;\;\;\mathsf{fma}\left(-0.5 - y, \log y, y + x\right)\\

\mathbf{elif}\;z \leq 5.4 \cdot 10^{+98}:\\
\;\;\;\;x - z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.7499999999999999e107 or 5.4e98 < z

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{y \cdot \left(1 - -1 \cdot \log \left(\frac{1}{y}\right)\right)} - z \]
    4. Step-by-step derivation
      1. Applied rewrites90.6%

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

      if -1.7499999999999999e107 < z < 2.7999999999999999e27

      1. Initial program 99.8%

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

        \[\leadsto \color{blue}{\left(x + y\right) - \log y \cdot \left(\frac{1}{2} + y\right)} \]
      4. Step-by-step derivation
        1. Applied rewrites96.6%

          \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5 - y, \log y, y + x\right)} \]

        if 2.7999999999999999e27 < z < 5.4e98

        1. Initial program 100.0%

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

          \[\leadsto \color{blue}{x} - z \]
        4. Step-by-step derivation
          1. Applied rewrites100.0%

            \[\leadsto \color{blue}{x} - z \]
        5. Recombined 3 regimes into one program.
        6. Add Preprocessing

        Alternative 3: 99.3% accurate, 1.0× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 0.0026:\\ \;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\ \mathbf{else}:\\ \;\;\;\;\left(\left(x - \log y \cdot y\right) + y\right) - z\\ \end{array} \end{array} \]
        (FPCore (x y z)
         :precision binary64
         (if (<= y 0.0026) (- (fma -0.5 (log y) x) z) (- (+ (- x (* (log y) y)) y) z)))
        double code(double x, double y, double z) {
        	double tmp;
        	if (y <= 0.0026) {
        		tmp = fma(-0.5, log(y), x) - z;
        	} else {
        		tmp = ((x - (log(y) * y)) + y) - z;
        	}
        	return tmp;
        }
        
        function code(x, y, z)
        	tmp = 0.0
        	if (y <= 0.0026)
        		tmp = Float64(fma(-0.5, log(y), x) - z);
        	else
        		tmp = Float64(Float64(Float64(x - Float64(log(y) * y)) + y) - z);
        	end
        	return tmp
        end
        
        code[x_, y_, z_] := If[LessEqual[y, 0.0026], N[(N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision] - z), $MachinePrecision], N[(N[(N[(x - N[(N[Log[y], $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;y \leq 0.0026:\\
        \;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\
        
        \mathbf{else}:\\
        \;\;\;\;\left(\left(x - \log y \cdot y\right) + y\right) - z\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if y < 0.0025999999999999999

          1. Initial program 100.0%

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

            \[\leadsto \color{blue}{\left(x - \frac{1}{2} \cdot \log y\right)} - z \]
          4. Step-by-step derivation
            1. Applied rewrites99.7%

              \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5, \log y, x\right)} - z \]

            if 0.0025999999999999999 < y

            1. Initial program 99.8%

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

              \[\leadsto \left(\left(x - \color{blue}{-1 \cdot \left(y \cdot \log \left(\frac{1}{y}\right)\right)}\right) + y\right) - z \]
            4. Step-by-step derivation
              1. Applied rewrites99.1%

                \[\leadsto \left(\left(x - \color{blue}{\log y \cdot y}\right) + y\right) - z \]
            5. Recombined 2 regimes into one program.
            6. Add Preprocessing

            Alternative 4: 69.6% accurate, 1.0× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -370 \lor \neg \left(z \leq 55\right):\\ \;\;\;\;x - z\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right)\\ \end{array} \end{array} \]
            (FPCore (x y z)
             :precision binary64
             (if (or (<= z -370.0) (not (<= z 55.0))) (- x z) (fma -0.5 (log y) x)))
            double code(double x, double y, double z) {
            	double tmp;
            	if ((z <= -370.0) || !(z <= 55.0)) {
            		tmp = x - z;
            	} else {
            		tmp = fma(-0.5, log(y), x);
            	}
            	return tmp;
            }
            
            function code(x, y, z)
            	tmp = 0.0
            	if ((z <= -370.0) || !(z <= 55.0))
            		tmp = Float64(x - z);
            	else
            		tmp = fma(-0.5, log(y), x);
            	end
            	return tmp
            end
            
            code[x_, y_, z_] := If[Or[LessEqual[z, -370.0], N[Not[LessEqual[z, 55.0]], $MachinePrecision]], N[(x - z), $MachinePrecision], N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            \mathbf{if}\;z \leq -370 \lor \neg \left(z \leq 55\right):\\
            \;\;\;\;x - z\\
            
            \mathbf{else}:\\
            \;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right)\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if z < -370 or 55 < z

              1. Initial program 99.9%

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

                \[\leadsto \color{blue}{x} - z \]
              4. Step-by-step derivation
                1. Applied rewrites79.8%

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

                if -370 < z < 55

                1. Initial program 99.8%

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

                  \[\leadsto \color{blue}{\left(x + y\right) - \log y \cdot \left(\frac{1}{2} + y\right)} \]
                4. Step-by-step derivation
                  1. Applied rewrites99.6%

                    \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5 - y, \log y, y + x\right)} \]
                  2. Taylor expanded in x around inf

                    \[\leadsto \mathsf{fma}\left(\frac{-1}{2} - y, \log y, x\right) \]
                  3. Step-by-step derivation
                    1. Applied rewrites77.9%

                      \[\leadsto \mathsf{fma}\left(-0.5 - y, \log y, x\right) \]
                    2. Taylor expanded in y around 0

                      \[\leadsto \mathsf{fma}\left(\frac{-1}{2}, \log \color{blue}{y}, x\right) \]
                    3. Step-by-step derivation
                      1. Applied rewrites70.1%

                        \[\leadsto \mathsf{fma}\left(-0.5, \log \color{blue}{y}, x\right) \]
                    4. Recombined 2 regimes into one program.
                    5. Final simplification74.9%

                      \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -370 \lor \neg \left(z \leq 55\right):\\ \;\;\;\;x - z\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right)\\ \end{array} \]
                    6. Add Preprocessing

                    Alternative 5: 88.2% accurate, 1.0× speedup?

                    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 1.8 \cdot 10^{+126}:\\ \;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\ \mathbf{else}:\\ \;\;\;\;\left(1 - \log y\right) \cdot y - z\\ \end{array} \end{array} \]
                    (FPCore (x y z)
                     :precision binary64
                     (if (<= y 1.8e+126) (- (fma -0.5 (log y) x) z) (- (* (- 1.0 (log y)) y) z)))
                    double code(double x, double y, double z) {
                    	double tmp;
                    	if (y <= 1.8e+126) {
                    		tmp = fma(-0.5, log(y), x) - z;
                    	} else {
                    		tmp = ((1.0 - log(y)) * y) - z;
                    	}
                    	return tmp;
                    }
                    
                    function code(x, y, z)
                    	tmp = 0.0
                    	if (y <= 1.8e+126)
                    		tmp = Float64(fma(-0.5, log(y), x) - z);
                    	else
                    		tmp = Float64(Float64(Float64(1.0 - log(y)) * y) - z);
                    	end
                    	return tmp
                    end
                    
                    code[x_, y_, z_] := If[LessEqual[y, 1.8e+126], N[(N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision] - z), $MachinePrecision], N[(N[(N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision] - z), $MachinePrecision]]
                    
                    \begin{array}{l}
                    
                    \\
                    \begin{array}{l}
                    \mathbf{if}\;y \leq 1.8 \cdot 10^{+126}:\\
                    \;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\
                    
                    \mathbf{else}:\\
                    \;\;\;\;\left(1 - \log y\right) \cdot y - z\\
                    
                    
                    \end{array}
                    \end{array}
                    
                    Derivation
                    1. Split input into 2 regimes
                    2. if y < 1.8e126

                      1. Initial program 99.9%

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

                        \[\leadsto \color{blue}{\left(x - \frac{1}{2} \cdot \log y\right)} - z \]
                      4. Step-by-step derivation
                        1. Applied rewrites92.3%

                          \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5, \log y, x\right)} - z \]

                        if 1.8e126 < y

                        1. Initial program 99.6%

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

                          \[\leadsto \color{blue}{y \cdot \left(1 - -1 \cdot \log \left(\frac{1}{y}\right)\right)} - z \]
                        4. Step-by-step derivation
                          1. Applied rewrites88.3%

                            \[\leadsto \color{blue}{\left(1 - \log y\right) \cdot y} - z \]
                        5. Recombined 2 regimes into one program.
                        6. Add Preprocessing

                        Alternative 6: 87.7% accurate, 1.0× speedup?

                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 1.36 \cdot 10^{+142}:\\ \;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-y, \log y, y + x\right)\\ \end{array} \end{array} \]
                        (FPCore (x y z)
                         :precision binary64
                         (if (<= y 1.36e+142) (- (fma -0.5 (log y) x) z) (fma (- y) (log y) (+ y x))))
                        double code(double x, double y, double z) {
                        	double tmp;
                        	if (y <= 1.36e+142) {
                        		tmp = fma(-0.5, log(y), x) - z;
                        	} else {
                        		tmp = fma(-y, log(y), (y + x));
                        	}
                        	return tmp;
                        }
                        
                        function code(x, y, z)
                        	tmp = 0.0
                        	if (y <= 1.36e+142)
                        		tmp = Float64(fma(-0.5, log(y), x) - z);
                        	else
                        		tmp = fma(Float64(-y), log(y), Float64(y + x));
                        	end
                        	return tmp
                        end
                        
                        code[x_, y_, z_] := If[LessEqual[y, 1.36e+142], N[(N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision] - z), $MachinePrecision], N[((-y) * N[Log[y], $MachinePrecision] + N[(y + x), $MachinePrecision]), $MachinePrecision]]
                        
                        \begin{array}{l}
                        
                        \\
                        \begin{array}{l}
                        \mathbf{if}\;y \leq 1.36 \cdot 10^{+142}:\\
                        \;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\
                        
                        \mathbf{else}:\\
                        \;\;\;\;\mathsf{fma}\left(-y, \log y, y + x\right)\\
                        
                        
                        \end{array}
                        \end{array}
                        
                        Derivation
                        1. Split input into 2 regimes
                        2. if y < 1.3599999999999999e142

                          1. Initial program 99.9%

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

                            \[\leadsto \color{blue}{\left(x - \frac{1}{2} \cdot \log y\right)} - z \]
                          4. Step-by-step derivation
                            1. Applied rewrites91.9%

                              \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5, \log y, x\right)} - z \]

                            if 1.3599999999999999e142 < y

                            1. Initial program 99.6%

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

                              \[\leadsto \color{blue}{\left(x + y\right) - \log y \cdot \left(\frac{1}{2} + y\right)} \]
                            4. Step-by-step derivation
                              1. Applied rewrites86.7%

                                \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5 - y, \log y, y + x\right)} \]
                              2. Taylor expanded in y around inf

                                \[\leadsto \mathsf{fma}\left(-1 \cdot y, \log \color{blue}{y}, y + x\right) \]
                              3. Step-by-step derivation
                                1. Applied rewrites86.7%

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

                              Alternative 7: 84.4% accurate, 1.0× speedup?

                              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 4.4 \cdot 10^{+142}:\\ \;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\ \mathbf{else}:\\ \;\;\;\;\left(1 - \log y\right) \cdot y\\ \end{array} \end{array} \]
                              (FPCore (x y z)
                               :precision binary64
                               (if (<= y 4.4e+142) (- (fma -0.5 (log y) x) z) (* (- 1.0 (log y)) y)))
                              double code(double x, double y, double z) {
                              	double tmp;
                              	if (y <= 4.4e+142) {
                              		tmp = fma(-0.5, log(y), x) - z;
                              	} else {
                              		tmp = (1.0 - log(y)) * y;
                              	}
                              	return tmp;
                              }
                              
                              function code(x, y, z)
                              	tmp = 0.0
                              	if (y <= 4.4e+142)
                              		tmp = Float64(fma(-0.5, log(y), x) - z);
                              	else
                              		tmp = Float64(Float64(1.0 - log(y)) * y);
                              	end
                              	return tmp
                              end
                              
                              code[x_, y_, z_] := If[LessEqual[y, 4.4e+142], N[(N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision] - z), $MachinePrecision], N[(N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]]
                              
                              \begin{array}{l}
                              
                              \\
                              \begin{array}{l}
                              \mathbf{if}\;y \leq 4.4 \cdot 10^{+142}:\\
                              \;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\
                              
                              \mathbf{else}:\\
                              \;\;\;\;\left(1 - \log y\right) \cdot y\\
                              
                              
                              \end{array}
                              \end{array}
                              
                              Derivation
                              1. Split input into 2 regimes
                              2. if y < 4.39999999999999974e142

                                1. Initial program 99.9%

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

                                  \[\leadsto \color{blue}{\left(x - \frac{1}{2} \cdot \log y\right)} - z \]
                                4. Step-by-step derivation
                                  1. Applied rewrites91.9%

                                    \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5, \log y, x\right)} - z \]

                                  if 4.39999999999999974e142 < y

                                  1. Initial program 99.6%

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

                                    \[\leadsto \color{blue}{y \cdot \left(1 - -1 \cdot \log \left(\frac{1}{y}\right)\right)} \]
                                  4. Step-by-step derivation
                                    1. Applied rewrites76.7%

                                      \[\leadsto \color{blue}{\left(1 - \log y\right) \cdot y} \]
                                  5. Recombined 2 regimes into one program.
                                  6. Add Preprocessing

                                  Alternative 8: 71.5% accurate, 1.0× speedup?

                                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 4 \cdot 10^{+142}:\\ \;\;\;\;\left(x + y\right) - z\\ \mathbf{else}:\\ \;\;\;\;\left(1 - \log y\right) \cdot y\\ \end{array} \end{array} \]
                                  (FPCore (x y z)
                                   :precision binary64
                                   (if (<= y 4e+142) (- (+ x y) z) (* (- 1.0 (log y)) y)))
                                  double code(double x, double y, double z) {
                                  	double tmp;
                                  	if (y <= 4e+142) {
                                  		tmp = (x + y) - z;
                                  	} else {
                                  		tmp = (1.0 - log(y)) * y;
                                  	}
                                  	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 <= 4d+142) then
                                          tmp = (x + y) - z
                                      else
                                          tmp = (1.0d0 - log(y)) * y
                                      end if
                                      code = tmp
                                  end function
                                  
                                  public static double code(double x, double y, double z) {
                                  	double tmp;
                                  	if (y <= 4e+142) {
                                  		tmp = (x + y) - z;
                                  	} else {
                                  		tmp = (1.0 - Math.log(y)) * y;
                                  	}
                                  	return tmp;
                                  }
                                  
                                  def code(x, y, z):
                                  	tmp = 0
                                  	if y <= 4e+142:
                                  		tmp = (x + y) - z
                                  	else:
                                  		tmp = (1.0 - math.log(y)) * y
                                  	return tmp
                                  
                                  function code(x, y, z)
                                  	tmp = 0.0
                                  	if (y <= 4e+142)
                                  		tmp = Float64(Float64(x + y) - z);
                                  	else
                                  		tmp = Float64(Float64(1.0 - log(y)) * y);
                                  	end
                                  	return tmp
                                  end
                                  
                                  function tmp_2 = code(x, y, z)
                                  	tmp = 0.0;
                                  	if (y <= 4e+142)
                                  		tmp = (x + y) - z;
                                  	else
                                  		tmp = (1.0 - log(y)) * y;
                                  	end
                                  	tmp_2 = tmp;
                                  end
                                  
                                  code[x_, y_, z_] := If[LessEqual[y, 4e+142], N[(N[(x + y), $MachinePrecision] - z), $MachinePrecision], N[(N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]]
                                  
                                  \begin{array}{l}
                                  
                                  \\
                                  \begin{array}{l}
                                  \mathbf{if}\;y \leq 4 \cdot 10^{+142}:\\
                                  \;\;\;\;\left(x + y\right) - z\\
                                  
                                  \mathbf{else}:\\
                                  \;\;\;\;\left(1 - \log y\right) \cdot y\\
                                  
                                  
                                  \end{array}
                                  \end{array}
                                  
                                  Derivation
                                  1. Split input into 2 regimes
                                  2. if y < 4.0000000000000002e142

                                    1. Initial program 99.9%

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

                                      \[\leadsto \left(\color{blue}{x} + y\right) - z \]
                                    4. Step-by-step derivation
                                      1. Applied rewrites79.9%

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

                                      if 4.0000000000000002e142 < y

                                      1. Initial program 99.6%

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

                                        \[\leadsto \color{blue}{y \cdot \left(1 - -1 \cdot \log \left(\frac{1}{y}\right)\right)} \]
                                      4. Step-by-step derivation
                                        1. Applied rewrites76.7%

                                          \[\leadsto \color{blue}{\left(1 - \log y\right) \cdot y} \]
                                      5. Recombined 2 regimes into one program.
                                      6. Add Preprocessing

                                      Alternative 9: 47.5% accurate, 7.8× speedup?

                                      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -1.75 \cdot 10^{+107} \lor \neg \left(z \leq 9.5 \cdot 10^{+78}\right):\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
                                      (FPCore (x y z)
                                       :precision binary64
                                       (if (or (<= z -1.75e+107) (not (<= z 9.5e+78))) (- z) x))
                                      double code(double x, double y, double z) {
                                      	double tmp;
                                      	if ((z <= -1.75e+107) || !(z <= 9.5e+78)) {
                                      		tmp = -z;
                                      	} 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) :: tmp
                                          if ((z <= (-1.75d+107)) .or. (.not. (z <= 9.5d+78))) then
                                              tmp = -z
                                          else
                                              tmp = x
                                          end if
                                          code = tmp
                                      end function
                                      
                                      public static double code(double x, double y, double z) {
                                      	double tmp;
                                      	if ((z <= -1.75e+107) || !(z <= 9.5e+78)) {
                                      		tmp = -z;
                                      	} else {
                                      		tmp = x;
                                      	}
                                      	return tmp;
                                      }
                                      
                                      def code(x, y, z):
                                      	tmp = 0
                                      	if (z <= -1.75e+107) or not (z <= 9.5e+78):
                                      		tmp = -z
                                      	else:
                                      		tmp = x
                                      	return tmp
                                      
                                      function code(x, y, z)
                                      	tmp = 0.0
                                      	if ((z <= -1.75e+107) || !(z <= 9.5e+78))
                                      		tmp = Float64(-z);
                                      	else
                                      		tmp = x;
                                      	end
                                      	return tmp
                                      end
                                      
                                      function tmp_2 = code(x, y, z)
                                      	tmp = 0.0;
                                      	if ((z <= -1.75e+107) || ~((z <= 9.5e+78)))
                                      		tmp = -z;
                                      	else
                                      		tmp = x;
                                      	end
                                      	tmp_2 = tmp;
                                      end
                                      
                                      code[x_, y_, z_] := If[Or[LessEqual[z, -1.75e+107], N[Not[LessEqual[z, 9.5e+78]], $MachinePrecision]], (-z), x]
                                      
                                      \begin{array}{l}
                                      
                                      \\
                                      \begin{array}{l}
                                      \mathbf{if}\;z \leq -1.75 \cdot 10^{+107} \lor \neg \left(z \leq 9.5 \cdot 10^{+78}\right):\\
                                      \;\;\;\;-z\\
                                      
                                      \mathbf{else}:\\
                                      \;\;\;\;x\\
                                      
                                      
                                      \end{array}
                                      \end{array}
                                      
                                      Derivation
                                      1. Split input into 2 regimes
                                      2. if z < -1.7499999999999999e107 or 9.5000000000000006e78 < z

                                        1. Initial program 99.9%

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

                                          \[\leadsto \color{blue}{-1 \cdot z} \]
                                        4. Step-by-step derivation
                                          1. Applied rewrites71.6%

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

                                          if -1.7499999999999999e107 < z < 9.5000000000000006e78

                                          1. Initial program 99.8%

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

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

                                              \[\leadsto \color{blue}{x} \]
                                          5. Recombined 2 regimes into one program.
                                          6. Final simplification59.1%

                                            \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.75 \cdot 10^{+107} \lor \neg \left(z \leq 9.5 \cdot 10^{+78}\right):\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
                                          7. Add Preprocessing

                                          Alternative 10: 57.3% accurate, 29.5× speedup?

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

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

                                            \[\leadsto \color{blue}{x} - z \]
                                          4. Step-by-step derivation
                                            1. Applied rewrites65.9%

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

                                            Alternative 11: 29.4% accurate, 118.0× 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 99.9%

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

                                              \[\leadsto \color{blue}{x} \]
                                            4. Step-by-step derivation
                                              1. Applied rewrites35.0%

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

                                              Developer Target 1: 99.8% accurate, 1.0× speedup?

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

                                              Reproduce

                                              ?
                                              herbie shell --seed 2025021 
                                              (FPCore (x y z)
                                                :name "Numeric.SpecFunctions:stirlingError from math-functions-0.1.5.2"
                                                :precision binary64
                                              
                                                :alt
                                                (! :herbie-platform default (- (- (+ y x) z) (* (+ y 1/2) (log y))))
                                              
                                                (- (+ (- x (* (+ y 0.5) (log y))) y) z))