Numeric.SpecFunctions:stirlingError from math-functions-0.1.5.2

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(x - \left(\left(y + \frac{1}{2}\right) \cdot \log y - y\right)\right)} - z \]
    5. lower--.f6499.8

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

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

      \[\leadsto \left(x - \left(\color{blue}{\log y \cdot \left(y + \frac{1}{2}\right)} - y\right)\right) - z \]
    8. lower-*.f6499.8

      \[\leadsto \left(x - \left(\color{blue}{\log y \cdot \left(y + 0.5\right)} - y\right)\right) - z \]
    9. lift-+.f64N/A

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

      \[\leadsto \left(x - \left(\log y \cdot \color{blue}{\left(\frac{1}{2} + y\right)} - y\right)\right) - z \]
    11. lower-+.f6499.8

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

    \[\leadsto \color{blue}{\left(x - \left(\log y \cdot \left(0.5 + y\right) - y\right)\right)} - z \]
  5. Add Preprocessing

Alternative 2: 89.4% accurate, 0.3× speedup?

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

\\
\begin{array}{l}
t_0 := \left(x - \left(y + 0.5\right) \cdot \log y\right) + y\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{+130}:\\
\;\;\;\;\mathsf{fma}\left(-0.5 - y, \log y, y + x\right)\\

\mathbf{elif}\;t\_0 \leq -1 \cdot 10^{+44}:\\
\;\;\;\;\left(1 - \log y\right) \cdot y - z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -2.0000000000000001e130

    1. Initial program 99.7%

      \[\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 rewrites92.6%

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

      if -2.0000000000000001e130 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -1.0000000000000001e44

      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 rewrites87.2%

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

        if -1.0000000000000001e44 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y)

        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 rewrites97.1%

            \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5, \log y, x\right)} - z \]
        5. Recombined 3 regimes into one program.
        6. Final simplification93.5%

          \[\leadsto \begin{array}{l} \mathbf{if}\;\left(x - \left(y + 0.5\right) \cdot \log y\right) + y \leq -2 \cdot 10^{+130}:\\ \;\;\;\;\mathsf{fma}\left(-0.5 - y, \log y, y + x\right)\\ \mathbf{elif}\;\left(x - \left(y + 0.5\right) \cdot \log y\right) + y \leq -1 \cdot 10^{+44}:\\ \;\;\;\;\left(1 - \log y\right) \cdot y - z\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\ \end{array} \]
        7. Add Preprocessing

        Alternative 3: 99.3% accurate, 1.0× speedup?

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

          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.3%

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

            if 0.28000000000000003 < 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. Step-by-step derivation
              1. lift-+.f64N/A

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

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

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

                \[\leadsto \color{blue}{\left(x - \left(\left(y + \frac{1}{2}\right) \cdot \log y - y\right)\right)} - z \]
              5. lower--.f6499.7

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

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

                \[\leadsto \left(x - \left(\color{blue}{\log y \cdot \left(y + \frac{1}{2}\right)} - y\right)\right) - z \]
              8. lower-*.f6499.7

                \[\leadsto \left(x - \left(\color{blue}{\log y \cdot \left(y + 0.5\right)} - y\right)\right) - z \]
              9. lift-+.f64N/A

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

                \[\leadsto \left(x - \left(\log y \cdot \color{blue}{\left(\frac{1}{2} + y\right)} - y\right)\right) - z \]
              11. lower-+.f6499.7

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

              \[\leadsto \color{blue}{\left(x - \left(\log y \cdot \left(0.5 + y\right) - y\right)\right)} - z \]
            5. Taylor expanded in y around inf

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

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

            Alternative 4: 89.7% accurate, 1.0× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 7.5 \cdot 10^{+41}:\\ \;\;\;\;\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 7.5e+41) (- (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 <= 7.5e+41) {
            		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 <= 7.5e+41)
            		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, 7.5e+41], 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 7.5 \cdot 10^{+41}:\\
            \;\;\;\;\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 < 7.50000000000000072e41

              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 rewrites98.0%

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

                if 7.50000000000000072e41 < 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 rewrites80.7%

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

                Alternative 5: 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.8%

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

                Alternative 6: 89.7% accurate, 1.0× speedup?

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

                  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 rewrites98.0%

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

                    if 7.50000000000000072e41 < 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. Step-by-step derivation
                      1. lift-+.f64N/A

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

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

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

                        \[\leadsto \color{blue}{\left(x - \left(\left(y + \frac{1}{2}\right) \cdot \log y - y\right)\right)} - z \]
                      5. lower--.f6499.6

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

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

                        \[\leadsto \left(x - \left(\color{blue}{\log y \cdot \left(y + \frac{1}{2}\right)} - y\right)\right) - z \]
                      8. lower-*.f6499.6

                        \[\leadsto \left(x - \left(\color{blue}{\log y \cdot \left(y + 0.5\right)} - y\right)\right) - z \]
                      9. lift-+.f64N/A

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

                        \[\leadsto \left(x - \left(\log y \cdot \color{blue}{\left(\frac{1}{2} + y\right)} - y\right)\right) - z \]
                      11. lower-+.f6499.6

                        \[\leadsto \left(x - \left(\log y \cdot \color{blue}{\left(0.5 + y\right)} - y\right)\right) - z \]
                    4. Applied rewrites99.6%

                      \[\leadsto \color{blue}{\left(x - \left(\log y \cdot \left(0.5 + y\right) - y\right)\right)} - z \]
                    5. Taylor expanded in y around inf

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

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

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

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

                          \[\leadsto y - \mathsf{fma}\left(y, \log \color{blue}{y}, z\right) \]
                        3. Step-by-step derivation
                          1. Applied rewrites80.6%

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

                        Alternative 7: 77.7% accurate, 1.0× speedup?

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

                          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 \left(\color{blue}{x} + y\right) - z \]
                          4. Step-by-step derivation
                            1. Applied rewrites85.8%

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

                            if 6.49999999999999975e41 < 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. Step-by-step derivation
                              1. lift-+.f64N/A

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

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

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

                                \[\leadsto \color{blue}{\left(x - \left(\left(y + \frac{1}{2}\right) \cdot \log y - y\right)\right)} - z \]
                              5. lower--.f6499.6

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

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

                                \[\leadsto \left(x - \left(\color{blue}{\log y \cdot \left(y + \frac{1}{2}\right)} - y\right)\right) - z \]
                              8. lower-*.f6499.6

                                \[\leadsto \left(x - \left(\color{blue}{\log y \cdot \left(y + 0.5\right)} - y\right)\right) - z \]
                              9. lift-+.f64N/A

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

                                \[\leadsto \left(x - \left(\log y \cdot \color{blue}{\left(\frac{1}{2} + y\right)} - y\right)\right) - z \]
                              11. lower-+.f6499.6

                                \[\leadsto \left(x - \left(\log y \cdot \color{blue}{\left(0.5 + y\right)} - y\right)\right) - z \]
                            4. Applied rewrites99.6%

                              \[\leadsto \color{blue}{\left(x - \left(\log y \cdot \left(0.5 + y\right) - y\right)\right)} - z \]
                            5. Taylor expanded in y around inf

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

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

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

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

                                  \[\leadsto y - \mathsf{fma}\left(y, \log \color{blue}{y}, z\right) \]
                                3. Step-by-step derivation
                                  1. Applied rewrites80.6%

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

                                Alternative 8: 72.3% accurate, 1.0× speedup?

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

                                  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 rewrites77.5%

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

                                    if 1.19999999999999996e153 < y

                                    1. Initial program 99.5%

                                      \[\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 rewrites81.8%

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

                                      \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 1.2 \cdot 10^{+153}:\\ \;\;\;\;x - z\\ \mathbf{else}:\\ \;\;\;\;\left(1 - \log y\right) \cdot y\\ \end{array} \]
                                    7. Add Preprocessing

                                    Alternative 9: 48.5% accurate, 7.9× speedup?

                                    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -700000000:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.4 \cdot 10^{+39}:\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
                                    (FPCore (x y z)
                                     :precision binary64
                                     (if (<= x -700000000.0) x (if (<= x 2.4e+39) (- z) x)))
                                    double code(double x, double y, double z) {
                                    	double tmp;
                                    	if (x <= -700000000.0) {
                                    		tmp = x;
                                    	} else if (x <= 2.4e+39) {
                                    		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 (x <= (-700000000.0d0)) then
                                            tmp = x
                                        else if (x <= 2.4d+39) 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 (x <= -700000000.0) {
                                    		tmp = x;
                                    	} else if (x <= 2.4e+39) {
                                    		tmp = -z;
                                    	} else {
                                    		tmp = x;
                                    	}
                                    	return tmp;
                                    }
                                    
                                    def code(x, y, z):
                                    	tmp = 0
                                    	if x <= -700000000.0:
                                    		tmp = x
                                    	elif x <= 2.4e+39:
                                    		tmp = -z
                                    	else:
                                    		tmp = x
                                    	return tmp
                                    
                                    function code(x, y, z)
                                    	tmp = 0.0
                                    	if (x <= -700000000.0)
                                    		tmp = x;
                                    	elseif (x <= 2.4e+39)
                                    		tmp = Float64(-z);
                                    	else
                                    		tmp = x;
                                    	end
                                    	return tmp
                                    end
                                    
                                    function tmp_2 = code(x, y, z)
                                    	tmp = 0.0;
                                    	if (x <= -700000000.0)
                                    		tmp = x;
                                    	elseif (x <= 2.4e+39)
                                    		tmp = -z;
                                    	else
                                    		tmp = x;
                                    	end
                                    	tmp_2 = tmp;
                                    end
                                    
                                    code[x_, y_, z_] := If[LessEqual[x, -700000000.0], x, If[LessEqual[x, 2.4e+39], (-z), x]]
                                    
                                    \begin{array}{l}
                                    
                                    \\
                                    \begin{array}{l}
                                    \mathbf{if}\;x \leq -700000000:\\
                                    \;\;\;\;x\\
                                    
                                    \mathbf{elif}\;x \leq 2.4 \cdot 10^{+39}:\\
                                    \;\;\;\;-z\\
                                    
                                    \mathbf{else}:\\
                                    \;\;\;\;x\\
                                    
                                    
                                    \end{array}
                                    \end{array}
                                    
                                    Derivation
                                    1. Split input into 2 regimes
                                    2. if x < -7e8 or 2.4000000000000001e39 < x

                                      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 rewrites63.5%

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

                                        if -7e8 < x < 2.4000000000000001e39

                                        1. Initial program 99.7%

                                          \[\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 rewrites43.2%

                                            \[\leadsto \color{blue}{-z} \]
                                        5. Recombined 2 regimes into one program.
                                        6. Final simplification53.4%

                                          \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -700000000:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.4 \cdot 10^{+39}:\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
                                        7. Add Preprocessing

                                        Alternative 10: 58.1% 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.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} - z \]
                                        4. Step-by-step derivation
                                          1. Applied rewrites60.5%

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

                                          Alternative 11: 30.0% 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.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 rewrites33.4%

                                              \[\leadsto \color{blue}{x} \]
                                            2. Final simplification33.4%

                                              \[\leadsto x \]
                                            3. 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 2025023 
                                            (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))