Numeric.SpecFunctions:stirlingError from math-functions-0.1.5.2

Percentage Accurate: 99.8% → 99.8%
Time: 36.7s
Alternatives: 10
Speedup: 1.0×

Specification

?
\[\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z \]
(FPCore (x y z)
  :precision binary64
  (- (+ (- x (* (+ y 1/2) (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 + 1/2), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]
\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z

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 10 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?

\[\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z \]
(FPCore (x y z)
  :precision binary64
  (- (+ (- x (* (+ y 1/2) (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 + 1/2), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]
\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z

Alternative 1: 99.8% accurate, 1.0× speedup?

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

    \[\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z \]
  2. 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 \color{blue}{\left(\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(y + \frac{1}{2}\right) \cdot \log y\right) + \left(y - z\right)} \]
    4. +-commutativeN/A

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(\left(\left(\mathsf{neg}\left(z\right)\right) + x\right) + y\right)} - \left(y + \frac{1}{2}\right) \cdot \log y \]
    13. remove-double-negN/A

      \[\leadsto \left(\left(\left(\mathsf{neg}\left(z\right)\right) + \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)}\right) + y\right) - \left(y + \frac{1}{2}\right) \cdot \log y \]
    14. distribute-neg-inN/A

      \[\leadsto \left(\color{blue}{\left(\mathsf{neg}\left(\left(z + \left(\mathsf{neg}\left(x\right)\right)\right)\right)\right)} + y\right) - \left(y + \frac{1}{2}\right) \cdot \log y \]
    15. sub-flipN/A

      \[\leadsto \left(\left(\mathsf{neg}\left(\color{blue}{\left(z - x\right)}\right)\right) + y\right) - \left(y + \frac{1}{2}\right) \cdot \log y \]
    16. sub-negate-revN/A

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

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

      \[\leadsto \color{blue}{\left(x + \left(\mathsf{neg}\left(\left(z - y\right)\right)\right)\right)} - \left(y + \frac{1}{2}\right) \cdot \log y \]
    19. sub-negate-revN/A

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

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

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

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

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

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

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

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

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

Alternative 2: 89.3% accurate, 0.9× speedup?

\[\begin{array}{l} \mathbf{if}\;z \leq -47999999999999996524089971390543551186526799180673510009045877937386533124740660945353317548032:\\ \;\;\;\;\left(y - z\right) - \log y \cdot \left(y - \frac{-1}{2}\right)\\ \mathbf{elif}\;z \leq 12000000000000000092156844732391635628802393190991881159827561381888:\\ \;\;\;\;\left(x + y\right) - \log y \cdot \left(\frac{1}{2} + y\right)\\ \mathbf{else}:\\ \;\;\;\;x - \left(z + \frac{1}{2} \cdot \log y\right)\\ \end{array} \]
(FPCore (x y z)
  :precision binary64
  (if (<=
     z
     -47999999999999996524089971390543551186526799180673510009045877937386533124740660945353317548032)
  (- (- y z) (* (log y) (- y -1/2)))
  (if (<=
       z
       12000000000000000092156844732391635628802393190991881159827561381888)
    (- (+ x y) (* (log y) (+ 1/2 y)))
    (- x (+ z (* 1/2 (log y)))))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -4.8e+94) {
		tmp = (y - z) - (log(y) * (y - -0.5));
	} else if (z <= 1.2e+67) {
		tmp = (x + y) - (log(y) * (0.5 + y));
	} else {
		tmp = x - (z + (0.5 * log(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 (z <= (-4.8d+94)) then
        tmp = (y - z) - (log(y) * (y - (-0.5d0)))
    else if (z <= 1.2d+67) then
        tmp = (x + y) - (log(y) * (0.5d0 + y))
    else
        tmp = x - (z + (0.5d0 * log(y)))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (z <= -4.8e+94) {
		tmp = (y - z) - (Math.log(y) * (y - -0.5));
	} else if (z <= 1.2e+67) {
		tmp = (x + y) - (Math.log(y) * (0.5 + y));
	} else {
		tmp = x - (z + (0.5 * Math.log(y)));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z <= -4.8e+94:
		tmp = (y - z) - (math.log(y) * (y - -0.5))
	elif z <= 1.2e+67:
		tmp = (x + y) - (math.log(y) * (0.5 + y))
	else:
		tmp = x - (z + (0.5 * math.log(y)))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z <= -4.8e+94)
		tmp = Float64(Float64(y - z) - Float64(log(y) * Float64(y - -0.5)));
	elseif (z <= 1.2e+67)
		tmp = Float64(Float64(x + y) - Float64(log(y) * Float64(0.5 + y)));
	else
		tmp = Float64(x - Float64(z + Float64(0.5 * log(y))));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (z <= -4.8e+94)
		tmp = (y - z) - (log(y) * (y - -0.5));
	elseif (z <= 1.2e+67)
		tmp = (x + y) - (log(y) * (0.5 + y));
	else
		tmp = x - (z + (0.5 * log(y)));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[z, -47999999999999996524089971390543551186526799180673510009045877937386533124740660945353317548032], N[(N[(y - z), $MachinePrecision] - N[(N[Log[y], $MachinePrecision] * N[(y - -1/2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 12000000000000000092156844732391635628802393190991881159827561381888], N[(N[(x + y), $MachinePrecision] - N[(N[Log[y], $MachinePrecision] * N[(1/2 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(z + N[(1/2 * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;z \leq -47999999999999996524089971390543551186526799180673510009045877937386533124740660945353317548032:\\
\;\;\;\;\left(y - z\right) - \log y \cdot \left(y - \frac{-1}{2}\right)\\

\mathbf{elif}\;z \leq 12000000000000000092156844732391635628802393190991881159827561381888:\\
\;\;\;\;\left(x + y\right) - \log y \cdot \left(\frac{1}{2} + y\right)\\

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


\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -4.7999999999999997e94

    1. Initial program 99.8%

      \[\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z \]
    2. 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 \color{blue}{\left(\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(y + \frac{1}{2}\right) \cdot \log y\right) + \left(y - z\right)} \]
      4. +-commutativeN/A

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(\left(\left(\mathsf{neg}\left(z\right)\right) + x\right) + y\right)} - \left(y + \frac{1}{2}\right) \cdot \log y \]
      13. remove-double-negN/A

        \[\leadsto \left(\left(\left(\mathsf{neg}\left(z\right)\right) + \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)}\right) + y\right) - \left(y + \frac{1}{2}\right) \cdot \log y \]
      14. distribute-neg-inN/A

        \[\leadsto \left(\color{blue}{\left(\mathsf{neg}\left(\left(z + \left(\mathsf{neg}\left(x\right)\right)\right)\right)\right)} + y\right) - \left(y + \frac{1}{2}\right) \cdot \log y \]
      15. sub-flipN/A

        \[\leadsto \left(\left(\mathsf{neg}\left(\color{blue}{\left(z - x\right)}\right)\right) + y\right) - \left(y + \frac{1}{2}\right) \cdot \log y \]
      16. sub-negate-revN/A

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

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

        \[\leadsto \color{blue}{\left(x + \left(\mathsf{neg}\left(\left(z - y\right)\right)\right)\right)} - \left(y + \frac{1}{2}\right) \cdot \log y \]
      19. sub-negate-revN/A

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

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

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

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

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

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

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

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

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

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

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

      if -4.7999999999999997e94 < z < 1.2e67

      1. Initial program 99.8%

        \[\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z \]
      2. 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 \color{blue}{\left(\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(y + \frac{1}{2}\right) \cdot \log y\right) + \left(y - z\right)} \]
        4. +-commutativeN/A

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

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{\left(\left(\left(\mathsf{neg}\left(z\right)\right) + x\right) + y\right)} - \left(y + \frac{1}{2}\right) \cdot \log y \]
        13. remove-double-negN/A

          \[\leadsto \left(\left(\left(\mathsf{neg}\left(z\right)\right) + \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)}\right) + y\right) - \left(y + \frac{1}{2}\right) \cdot \log y \]
        14. distribute-neg-inN/A

          \[\leadsto \left(\color{blue}{\left(\mathsf{neg}\left(\left(z + \left(\mathsf{neg}\left(x\right)\right)\right)\right)\right)} + y\right) - \left(y + \frac{1}{2}\right) \cdot \log y \]
        15. sub-flipN/A

          \[\leadsto \left(\left(\mathsf{neg}\left(\color{blue}{\left(z - x\right)}\right)\right) + y\right) - \left(y + \frac{1}{2}\right) \cdot \log y \]
        16. sub-negate-revN/A

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

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

          \[\leadsto \color{blue}{\left(x + \left(\mathsf{neg}\left(\left(z - y\right)\right)\right)\right)} - \left(y + \frac{1}{2}\right) \cdot \log y \]
        19. sub-negate-revN/A

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{\left(x + y\right) - \log y \cdot \left(\frac{1}{2} + y\right)} \]
        3. Step-by-step derivation
          1. lower--.f64N/A

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

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

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

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

            \[\leadsto \left(x + y\right) - \log y \cdot \left(\frac{1}{2} + \color{blue}{y}\right) \]
        4. Applied rewrites71.0%

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

        if 1.2e67 < z

        1. Initial program 99.8%

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

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

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

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

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

            \[\leadsto x - \left(z + \frac{1}{2} \cdot \log y\right) \]
        4. Applied rewrites69.6%

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

      Alternative 3: 89.3% accurate, 0.9× speedup?

      \[\begin{array}{l} t_0 := \log y \cdot \left(\frac{1}{2} + y\right)\\ \mathbf{if}\;z \leq -47999999999999996524089971390543551186526799180673510009045877937386533124740660945353317548032:\\ \;\;\;\;\left(y - t\_0\right) - z\\ \mathbf{elif}\;z \leq 12000000000000000092156844732391635628802393190991881159827561381888:\\ \;\;\;\;\left(x + y\right) - t\_0\\ \mathbf{else}:\\ \;\;\;\;x - \left(z + \frac{1}{2} \cdot \log y\right)\\ \end{array} \]
      (FPCore (x y z)
        :precision binary64
        (let* ((t_0 (* (log y) (+ 1/2 y))))
        (if (<=
             z
             -47999999999999996524089971390543551186526799180673510009045877937386533124740660945353317548032)
          (- (- y t_0) z)
          (if (<=
               z
               12000000000000000092156844732391635628802393190991881159827561381888)
            (- (+ x y) t_0)
            (- x (+ z (* 1/2 (log y))))))))
      double code(double x, double y, double z) {
      	double t_0 = log(y) * (0.5 + y);
      	double tmp;
      	if (z <= -4.8e+94) {
      		tmp = (y - t_0) - z;
      	} else if (z <= 1.2e+67) {
      		tmp = (x + y) - t_0;
      	} else {
      		tmp = x - (z + (0.5 * log(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) :: t_0
          real(8) :: tmp
          t_0 = log(y) * (0.5d0 + y)
          if (z <= (-4.8d+94)) then
              tmp = (y - t_0) - z
          else if (z <= 1.2d+67) then
              tmp = (x + y) - t_0
          else
              tmp = x - (z + (0.5d0 * log(y)))
          end if
          code = tmp
      end function
      
      public static double code(double x, double y, double z) {
      	double t_0 = Math.log(y) * (0.5 + y);
      	double tmp;
      	if (z <= -4.8e+94) {
      		tmp = (y - t_0) - z;
      	} else if (z <= 1.2e+67) {
      		tmp = (x + y) - t_0;
      	} else {
      		tmp = x - (z + (0.5 * Math.log(y)));
      	}
      	return tmp;
      }
      
      def code(x, y, z):
      	t_0 = math.log(y) * (0.5 + y)
      	tmp = 0
      	if z <= -4.8e+94:
      		tmp = (y - t_0) - z
      	elif z <= 1.2e+67:
      		tmp = (x + y) - t_0
      	else:
      		tmp = x - (z + (0.5 * math.log(y)))
      	return tmp
      
      function code(x, y, z)
      	t_0 = Float64(log(y) * Float64(0.5 + y))
      	tmp = 0.0
      	if (z <= -4.8e+94)
      		tmp = Float64(Float64(y - t_0) - z);
      	elseif (z <= 1.2e+67)
      		tmp = Float64(Float64(x + y) - t_0);
      	else
      		tmp = Float64(x - Float64(z + Float64(0.5 * log(y))));
      	end
      	return tmp
      end
      
      function tmp_2 = code(x, y, z)
      	t_0 = log(y) * (0.5 + y);
      	tmp = 0.0;
      	if (z <= -4.8e+94)
      		tmp = (y - t_0) - z;
      	elseif (z <= 1.2e+67)
      		tmp = (x + y) - t_0;
      	else
      		tmp = x - (z + (0.5 * log(y)));
      	end
      	tmp_2 = tmp;
      end
      
      code[x_, y_, z_] := Block[{t$95$0 = N[(N[Log[y], $MachinePrecision] * N[(1/2 + y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -47999999999999996524089971390543551186526799180673510009045877937386533124740660945353317548032], N[(N[(y - t$95$0), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[z, 12000000000000000092156844732391635628802393190991881159827561381888], N[(N[(x + y), $MachinePrecision] - t$95$0), $MachinePrecision], N[(x - N[(z + N[(1/2 * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
      
      \begin{array}{l}
      t_0 := \log y \cdot \left(\frac{1}{2} + y\right)\\
      \mathbf{if}\;z \leq -47999999999999996524089971390543551186526799180673510009045877937386533124740660945353317548032:\\
      \;\;\;\;\left(y - t\_0\right) - z\\
      
      \mathbf{elif}\;z \leq 12000000000000000092156844732391635628802393190991881159827561381888:\\
      \;\;\;\;\left(x + y\right) - t\_0\\
      
      \mathbf{else}:\\
      \;\;\;\;x - \left(z + \frac{1}{2} \cdot \log y\right)\\
      
      
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if z < -4.7999999999999997e94

        1. Initial program 99.8%

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

          \[\leadsto \color{blue}{\left(y - \log y \cdot \left(\frac{1}{2} + y\right)\right)} - z \]
        3. Step-by-step derivation
          1. lower--.f64N/A

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

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

            \[\leadsto \left(y - \log y \cdot \left(\color{blue}{\frac{1}{2}} + y\right)\right) - z \]
          4. lower-+.f6471.9%

            \[\leadsto \left(y - \log y \cdot \left(\frac{1}{2} + \color{blue}{y}\right)\right) - z \]
        4. Applied rewrites71.9%

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

        if -4.7999999999999997e94 < z < 1.2e67

        1. Initial program 99.8%

          \[\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z \]
        2. 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 \color{blue}{\left(\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(y + \frac{1}{2}\right) \cdot \log y\right) + \left(y - z\right)} \]
          4. +-commutativeN/A

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

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

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

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

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

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

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

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

            \[\leadsto \color{blue}{\left(\left(\left(\mathsf{neg}\left(z\right)\right) + x\right) + y\right)} - \left(y + \frac{1}{2}\right) \cdot \log y \]
          13. remove-double-negN/A

            \[\leadsto \left(\left(\left(\mathsf{neg}\left(z\right)\right) + \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)}\right) + y\right) - \left(y + \frac{1}{2}\right) \cdot \log y \]
          14. distribute-neg-inN/A

            \[\leadsto \left(\color{blue}{\left(\mathsf{neg}\left(\left(z + \left(\mathsf{neg}\left(x\right)\right)\right)\right)\right)} + y\right) - \left(y + \frac{1}{2}\right) \cdot \log y \]
          15. sub-flipN/A

            \[\leadsto \left(\left(\mathsf{neg}\left(\color{blue}{\left(z - x\right)}\right)\right) + y\right) - \left(y + \frac{1}{2}\right) \cdot \log y \]
          16. sub-negate-revN/A

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

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

            \[\leadsto \color{blue}{\left(x + \left(\mathsf{neg}\left(\left(z - y\right)\right)\right)\right)} - \left(y + \frac{1}{2}\right) \cdot \log y \]
          19. sub-negate-revN/A

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \color{blue}{\left(x + y\right) - \log y \cdot \left(\frac{1}{2} + y\right)} \]
          3. Step-by-step derivation
            1. lower--.f64N/A

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

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

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

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

              \[\leadsto \left(x + y\right) - \log y \cdot \left(\frac{1}{2} + \color{blue}{y}\right) \]
          4. Applied rewrites71.0%

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

          if 1.2e67 < z

          1. Initial program 99.8%

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

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

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

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

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

              \[\leadsto x - \left(z + \frac{1}{2} \cdot \log y\right) \]
          4. Applied rewrites69.6%

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

        Alternative 4: 88.8% accurate, 0.9× speedup?

        \[\begin{array}{l} t_0 := x - \left(z + \frac{1}{2} \cdot \log y\right)\\ \mathbf{if}\;z \leq -800000000000000024645330584772205526216201632061146770768717952555311882330651492352:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 12000000000000000092156844732391635628802393190991881159827561381888:\\ \;\;\;\;\left(x + y\right) - \log y \cdot \left(\frac{1}{2} + y\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
        (FPCore (x y z)
          :precision binary64
          (let* ((t_0 (- x (+ z (* 1/2 (log y))))))
          (if (<=
               z
               -800000000000000024645330584772205526216201632061146770768717952555311882330651492352)
            t_0
            (if (<=
                 z
                 12000000000000000092156844732391635628802393190991881159827561381888)
              (- (+ x y) (* (log y) (+ 1/2 y)))
              t_0))))
        double code(double x, double y, double z) {
        	double t_0 = x - (z + (0.5 * log(y)));
        	double tmp;
        	if (z <= -8e+83) {
        		tmp = t_0;
        	} else if (z <= 1.2e+67) {
        		tmp = (x + y) - (log(y) * (0.5 + y));
        	} else {
        		tmp = t_0;
        	}
        	return tmp;
        }
        
        module fmin_fmax_functions
            implicit none
            private
            public fmax
            public fmin
        
            interface fmax
                module procedure fmax88
                module procedure fmax44
                module procedure fmax84
                module procedure fmax48
            end interface
            interface fmin
                module procedure fmin88
                module procedure fmin44
                module procedure fmin84
                module procedure fmin48
            end interface
        contains
            real(8) function fmax88(x, y) result (res)
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
            end function
            real(4) function fmax44(x, y) result (res)
                real(4), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
            end function
            real(8) function fmax84(x, y) result(res)
                real(8), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
            end function
            real(8) function fmax48(x, y) result(res)
                real(4), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
            end function
            real(8) function fmin88(x, y) result (res)
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
            end function
            real(4) function fmin44(x, y) result (res)
                real(4), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
            end function
            real(8) function fmin84(x, y) result(res)
                real(8), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
            end function
            real(8) function fmin48(x, y) result(res)
                real(4), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
            end function
        end module
        
        real(8) function code(x, y, z)
        use fmin_fmax_functions
            real(8), intent (in) :: x
            real(8), intent (in) :: y
            real(8), intent (in) :: z
            real(8) :: t_0
            real(8) :: tmp
            t_0 = x - (z + (0.5d0 * log(y)))
            if (z <= (-8d+83)) then
                tmp = t_0
            else if (z <= 1.2d+67) then
                tmp = (x + y) - (log(y) * (0.5d0 + y))
            else
                tmp = t_0
            end if
            code = tmp
        end function
        
        public static double code(double x, double y, double z) {
        	double t_0 = x - (z + (0.5 * Math.log(y)));
        	double tmp;
        	if (z <= -8e+83) {
        		tmp = t_0;
        	} else if (z <= 1.2e+67) {
        		tmp = (x + y) - (Math.log(y) * (0.5 + y));
        	} else {
        		tmp = t_0;
        	}
        	return tmp;
        }
        
        def code(x, y, z):
        	t_0 = x - (z + (0.5 * math.log(y)))
        	tmp = 0
        	if z <= -8e+83:
        		tmp = t_0
        	elif z <= 1.2e+67:
        		tmp = (x + y) - (math.log(y) * (0.5 + y))
        	else:
        		tmp = t_0
        	return tmp
        
        function code(x, y, z)
        	t_0 = Float64(x - Float64(z + Float64(0.5 * log(y))))
        	tmp = 0.0
        	if (z <= -8e+83)
        		tmp = t_0;
        	elseif (z <= 1.2e+67)
        		tmp = Float64(Float64(x + y) - Float64(log(y) * Float64(0.5 + y)));
        	else
        		tmp = t_0;
        	end
        	return tmp
        end
        
        function tmp_2 = code(x, y, z)
        	t_0 = x - (z + (0.5 * log(y)));
        	tmp = 0.0;
        	if (z <= -8e+83)
        		tmp = t_0;
        	elseif (z <= 1.2e+67)
        		tmp = (x + y) - (log(y) * (0.5 + y));
        	else
        		tmp = t_0;
        	end
        	tmp_2 = tmp;
        end
        
        code[x_, y_, z_] := Block[{t$95$0 = N[(x - N[(z + N[(1/2 * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -800000000000000024645330584772205526216201632061146770768717952555311882330651492352], t$95$0, If[LessEqual[z, 12000000000000000092156844732391635628802393190991881159827561381888], N[(N[(x + y), $MachinePrecision] - N[(N[Log[y], $MachinePrecision] * N[(1/2 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
        
        \begin{array}{l}
        t_0 := x - \left(z + \frac{1}{2} \cdot \log y\right)\\
        \mathbf{if}\;z \leq -800000000000000024645330584772205526216201632061146770768717952555311882330651492352:\\
        \;\;\;\;t\_0\\
        
        \mathbf{elif}\;z \leq 12000000000000000092156844732391635628802393190991881159827561381888:\\
        \;\;\;\;\left(x + y\right) - \log y \cdot \left(\frac{1}{2} + y\right)\\
        
        \mathbf{else}:\\
        \;\;\;\;t\_0\\
        
        
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if z < -8.0000000000000002e83 or 1.2e67 < z

          1. Initial program 99.8%

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

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

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

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

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

              \[\leadsto x - \left(z + \frac{1}{2} \cdot \log y\right) \]
          4. Applied rewrites69.6%

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

          if -8.0000000000000002e83 < z < 1.2e67

          1. Initial program 99.8%

            \[\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z \]
          2. 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 \color{blue}{\left(\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(y + \frac{1}{2}\right) \cdot \log y\right) + \left(y - z\right)} \]
            4. +-commutativeN/A

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

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

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

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

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

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

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

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

              \[\leadsto \color{blue}{\left(\left(\left(\mathsf{neg}\left(z\right)\right) + x\right) + y\right)} - \left(y + \frac{1}{2}\right) \cdot \log y \]
            13. remove-double-negN/A

              \[\leadsto \left(\left(\left(\mathsf{neg}\left(z\right)\right) + \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)}\right) + y\right) - \left(y + \frac{1}{2}\right) \cdot \log y \]
            14. distribute-neg-inN/A

              \[\leadsto \left(\color{blue}{\left(\mathsf{neg}\left(\left(z + \left(\mathsf{neg}\left(x\right)\right)\right)\right)\right)} + y\right) - \left(y + \frac{1}{2}\right) \cdot \log y \]
            15. sub-flipN/A

              \[\leadsto \left(\left(\mathsf{neg}\left(\color{blue}{\left(z - x\right)}\right)\right) + y\right) - \left(y + \frac{1}{2}\right) \cdot \log y \]
            16. sub-negate-revN/A

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

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

              \[\leadsto \color{blue}{\left(x + \left(\mathsf{neg}\left(\left(z - y\right)\right)\right)\right)} - \left(y + \frac{1}{2}\right) \cdot \log y \]
            19. sub-negate-revN/A

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \color{blue}{\left(x + y\right) - \log y \cdot \left(\frac{1}{2} + y\right)} \]
            3. Step-by-step derivation
              1. lower--.f64N/A

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

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

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

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

                \[\leadsto \left(x + y\right) - \log y \cdot \left(\frac{1}{2} + \color{blue}{y}\right) \]
            4. Applied rewrites71.0%

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

          Alternative 5: 69.6% accurate, 1.1× speedup?

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

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

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

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

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

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

              \[\leadsto x - \left(z + \frac{1}{2} \cdot \log y\right) \]
          4. Applied rewrites69.6%

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

          Alternative 6: 69.0% accurate, 1.0× speedup?

          \[\begin{array}{l} t_0 := \left(1 - \frac{z}{x}\right) \cdot x\\ \mathbf{if}\;x \leq -780000000:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq \frac{3602879701896397}{281474976710656}:\\ \;\;\;\;\frac{-1}{2} \cdot \log y - z\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
          (FPCore (x y z)
            :precision binary64
            (let* ((t_0 (* (- 1 (/ z x)) x)))
            (if (<= x -780000000)
              t_0
              (if (<= x 3602879701896397/281474976710656)
                (- (* -1/2 (log y)) z)
                t_0))))
          double code(double x, double y, double z) {
          	double t_0 = (1.0 - (z / x)) * x;
          	double tmp;
          	if (x <= -780000000.0) {
          		tmp = t_0;
          	} else if (x <= 12.8) {
          		tmp = (-0.5 * log(y)) - z;
          	} else {
          		tmp = t_0;
          	}
          	return tmp;
          }
          
          module fmin_fmax_functions
              implicit none
              private
              public fmax
              public fmin
          
              interface fmax
                  module procedure fmax88
                  module procedure fmax44
                  module procedure fmax84
                  module procedure fmax48
              end interface
              interface fmin
                  module procedure fmin88
                  module procedure fmin44
                  module procedure fmin84
                  module procedure fmin48
              end interface
          contains
              real(8) function fmax88(x, y) result (res)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
              end function
              real(4) function fmax44(x, y) result (res)
                  real(4), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
              end function
              real(8) function fmax84(x, y) result(res)
                  real(8), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
              end function
              real(8) function fmax48(x, y) result(res)
                  real(4), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
              end function
              real(8) function fmin88(x, y) result (res)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
              end function
              real(4) function fmin44(x, y) result (res)
                  real(4), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
              end function
              real(8) function fmin84(x, y) result(res)
                  real(8), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
              end function
              real(8) function fmin48(x, y) result(res)
                  real(4), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
              end function
          end module
          
          real(8) function code(x, y, z)
          use fmin_fmax_functions
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              real(8), intent (in) :: z
              real(8) :: t_0
              real(8) :: tmp
              t_0 = (1.0d0 - (z / x)) * x
              if (x <= (-780000000.0d0)) then
                  tmp = t_0
              else if (x <= 12.8d0) then
                  tmp = ((-0.5d0) * log(y)) - z
              else
                  tmp = t_0
              end if
              code = tmp
          end function
          
          public static double code(double x, double y, double z) {
          	double t_0 = (1.0 - (z / x)) * x;
          	double tmp;
          	if (x <= -780000000.0) {
          		tmp = t_0;
          	} else if (x <= 12.8) {
          		tmp = (-0.5 * Math.log(y)) - z;
          	} else {
          		tmp = t_0;
          	}
          	return tmp;
          }
          
          def code(x, y, z):
          	t_0 = (1.0 - (z / x)) * x
          	tmp = 0
          	if x <= -780000000.0:
          		tmp = t_0
          	elif x <= 12.8:
          		tmp = (-0.5 * math.log(y)) - z
          	else:
          		tmp = t_0
          	return tmp
          
          function code(x, y, z)
          	t_0 = Float64(Float64(1.0 - Float64(z / x)) * x)
          	tmp = 0.0
          	if (x <= -780000000.0)
          		tmp = t_0;
          	elseif (x <= 12.8)
          		tmp = Float64(Float64(-0.5 * log(y)) - z);
          	else
          		tmp = t_0;
          	end
          	return tmp
          end
          
          function tmp_2 = code(x, y, z)
          	t_0 = (1.0 - (z / x)) * x;
          	tmp = 0.0;
          	if (x <= -780000000.0)
          		tmp = t_0;
          	elseif (x <= 12.8)
          		tmp = (-0.5 * log(y)) - z;
          	else
          		tmp = t_0;
          	end
          	tmp_2 = tmp;
          end
          
          code[x_, y_, z_] := Block[{t$95$0 = N[(N[(1 - N[(z / x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[x, -780000000], t$95$0, If[LessEqual[x, 3602879701896397/281474976710656], N[(N[(-1/2 * N[Log[y], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], t$95$0]]]
          
          \begin{array}{l}
          t_0 := \left(1 - \frac{z}{x}\right) \cdot x\\
          \mathbf{if}\;x \leq -780000000:\\
          \;\;\;\;t\_0\\
          
          \mathbf{elif}\;x \leq \frac{3602879701896397}{281474976710656}:\\
          \;\;\;\;\frac{-1}{2} \cdot \log y - z\\
          
          \mathbf{else}:\\
          \;\;\;\;t\_0\\
          
          
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if x < -7.8e8 or 12.800000000000001 < x

            1. Initial program 99.8%

              \[\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z \]
            2. 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. sub-flipN/A

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

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

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

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

                \[\leadsto \color{blue}{x - \left(\left(\left(y + \frac{1}{2}\right) \cdot \log y - y\right) - \left(\mathsf{neg}\left(z\right)\right)\right)} \]
              7. sub-to-multN/A

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

                \[\leadsto \color{blue}{\left(1 - \frac{\left(\left(y + \frac{1}{2}\right) \cdot \log y - y\right) - \left(\mathsf{neg}\left(z\right)\right)}{x}\right) \cdot x} \]
            3. Applied rewrites79.2%

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

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

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

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

                \[\leadsto \left(1 - \frac{z - \frac{-1}{2} \cdot \log y}{x}\right) \cdot x \]
            6. Applied rewrites59.7%

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

              \[\leadsto \left(1 - \color{blue}{\frac{z}{x}}\right) \cdot x \]
            8. Step-by-step derivation
              1. lower-/.f6447.2%

                \[\leadsto \left(1 - \frac{z}{\color{blue}{x}}\right) \cdot x \]
            9. Applied rewrites47.2%

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

            if -7.8e8 < x < 12.800000000000001

            1. Initial program 99.8%

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

              \[\leadsto \color{blue}{\left(y - \log y \cdot \left(\frac{1}{2} + y\right)\right)} - z \]
            3. Step-by-step derivation
              1. lower--.f64N/A

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

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

                \[\leadsto \left(y - \log y \cdot \left(\color{blue}{\frac{1}{2}} + y\right)\right) - z \]
              4. lower-+.f6471.9%

                \[\leadsto \left(y - \log y \cdot \left(\frac{1}{2} + \color{blue}{y}\right)\right) - z \]
            4. Applied rewrites71.9%

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

              \[\leadsto \frac{-1}{2} \cdot \color{blue}{\log y} - z \]
            6. Step-by-step derivation
              1. lower-*.f64N/A

                \[\leadsto \frac{-1}{2} \cdot \log y - z \]
              2. lower-log.f6442.4%

                \[\leadsto \frac{-1}{2} \cdot \log y - z \]
            7. Applied rewrites42.4%

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

          Alternative 7: 56.8% accurate, 3.7× speedup?

          \[\begin{array}{l} t_0 := \left(1 - \frac{z}{x}\right) \cdot x\\ \mathbf{if}\;x \leq -115000000:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq \frac{616761790044201}{21267647932558653966460912964485513216}:\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
          (FPCore (x y z)
            :precision binary64
            (let* ((t_0 (* (- 1 (/ z x)) x)))
            (if (<= x -115000000)
              t_0
              (if (<= x 616761790044201/21267647932558653966460912964485513216)
                (- z)
                t_0))))
          double code(double x, double y, double z) {
          	double t_0 = (1.0 - (z / x)) * x;
          	double tmp;
          	if (x <= -115000000.0) {
          		tmp = t_0;
          	} else if (x <= 2.9e-23) {
          		tmp = -z;
          	} else {
          		tmp = t_0;
          	}
          	return tmp;
          }
          
          module fmin_fmax_functions
              implicit none
              private
              public fmax
              public fmin
          
              interface fmax
                  module procedure fmax88
                  module procedure fmax44
                  module procedure fmax84
                  module procedure fmax48
              end interface
              interface fmin
                  module procedure fmin88
                  module procedure fmin44
                  module procedure fmin84
                  module procedure fmin48
              end interface
          contains
              real(8) function fmax88(x, y) result (res)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
              end function
              real(4) function fmax44(x, y) result (res)
                  real(4), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
              end function
              real(8) function fmax84(x, y) result(res)
                  real(8), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
              end function
              real(8) function fmax48(x, y) result(res)
                  real(4), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
              end function
              real(8) function fmin88(x, y) result (res)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
              end function
              real(4) function fmin44(x, y) result (res)
                  real(4), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
              end function
              real(8) function fmin84(x, y) result(res)
                  real(8), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
              end function
              real(8) function fmin48(x, y) result(res)
                  real(4), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
              end function
          end module
          
          real(8) function code(x, y, z)
          use fmin_fmax_functions
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              real(8), intent (in) :: z
              real(8) :: t_0
              real(8) :: tmp
              t_0 = (1.0d0 - (z / x)) * x
              if (x <= (-115000000.0d0)) then
                  tmp = t_0
              else if (x <= 2.9d-23) then
                  tmp = -z
              else
                  tmp = t_0
              end if
              code = tmp
          end function
          
          public static double code(double x, double y, double z) {
          	double t_0 = (1.0 - (z / x)) * x;
          	double tmp;
          	if (x <= -115000000.0) {
          		tmp = t_0;
          	} else if (x <= 2.9e-23) {
          		tmp = -z;
          	} else {
          		tmp = t_0;
          	}
          	return tmp;
          }
          
          def code(x, y, z):
          	t_0 = (1.0 - (z / x)) * x
          	tmp = 0
          	if x <= -115000000.0:
          		tmp = t_0
          	elif x <= 2.9e-23:
          		tmp = -z
          	else:
          		tmp = t_0
          	return tmp
          
          function code(x, y, z)
          	t_0 = Float64(Float64(1.0 - Float64(z / x)) * x)
          	tmp = 0.0
          	if (x <= -115000000.0)
          		tmp = t_0;
          	elseif (x <= 2.9e-23)
          		tmp = Float64(-z);
          	else
          		tmp = t_0;
          	end
          	return tmp
          end
          
          function tmp_2 = code(x, y, z)
          	t_0 = (1.0 - (z / x)) * x;
          	tmp = 0.0;
          	if (x <= -115000000.0)
          		tmp = t_0;
          	elseif (x <= 2.9e-23)
          		tmp = -z;
          	else
          		tmp = t_0;
          	end
          	tmp_2 = tmp;
          end
          
          code[x_, y_, z_] := Block[{t$95$0 = N[(N[(1 - N[(z / x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[x, -115000000], t$95$0, If[LessEqual[x, 616761790044201/21267647932558653966460912964485513216], (-z), t$95$0]]]
          
          \begin{array}{l}
          t_0 := \left(1 - \frac{z}{x}\right) \cdot x\\
          \mathbf{if}\;x \leq -115000000:\\
          \;\;\;\;t\_0\\
          
          \mathbf{elif}\;x \leq \frac{616761790044201}{21267647932558653966460912964485513216}:\\
          \;\;\;\;-z\\
          
          \mathbf{else}:\\
          \;\;\;\;t\_0\\
          
          
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if x < -1.15e8 or 2.9000000000000002e-23 < x

            1. Initial program 99.8%

              \[\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z \]
            2. 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. sub-flipN/A

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

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

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

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

                \[\leadsto \color{blue}{x - \left(\left(\left(y + \frac{1}{2}\right) \cdot \log y - y\right) - \left(\mathsf{neg}\left(z\right)\right)\right)} \]
              7. sub-to-multN/A

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

                \[\leadsto \color{blue}{\left(1 - \frac{\left(\left(y + \frac{1}{2}\right) \cdot \log y - y\right) - \left(\mathsf{neg}\left(z\right)\right)}{x}\right) \cdot x} \]
            3. Applied rewrites79.2%

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

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

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

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

                \[\leadsto \left(1 - \frac{z - \frac{-1}{2} \cdot \log y}{x}\right) \cdot x \]
            6. Applied rewrites59.7%

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

              \[\leadsto \left(1 - \color{blue}{\frac{z}{x}}\right) \cdot x \]
            8. Step-by-step derivation
              1. lower-/.f6447.2%

                \[\leadsto \left(1 - \frac{z}{\color{blue}{x}}\right) \cdot x \]
            9. Applied rewrites47.2%

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

            if -1.15e8 < x < 2.9000000000000002e-23

            1. Initial program 99.8%

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

              \[\leadsto \color{blue}{-1 \cdot z} \]
            3. Step-by-step derivation
              1. lower-*.f6430.0%

                \[\leadsto -1 \cdot \color{blue}{z} \]
            4. Applied rewrites30.0%

              \[\leadsto \color{blue}{-1 \cdot z} \]
            5. Step-by-step derivation
              1. lift-*.f64N/A

                \[\leadsto -1 \cdot \color{blue}{z} \]
              2. mul-1-negN/A

                \[\leadsto \mathsf{neg}\left(z\right) \]
              3. lower-neg.f6430.0%

                \[\leadsto -z \]
            6. Applied rewrites30.0%

              \[\leadsto -z \]
          3. Recombined 2 regimes into one program.
          4. Add Preprocessing

          Alternative 8: 46.7% accurate, 6.5× speedup?

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

            1. Initial program 99.8%

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

              \[\leadsto \color{blue}{-1 \cdot z} \]
            3. Step-by-step derivation
              1. lower-*.f6430.0%

                \[\leadsto -1 \cdot \color{blue}{z} \]
            4. Applied rewrites30.0%

              \[\leadsto \color{blue}{-1 \cdot z} \]
            5. Step-by-step derivation
              1. lift-*.f64N/A

                \[\leadsto -1 \cdot \color{blue}{z} \]
              2. mul-1-negN/A

                \[\leadsto \mathsf{neg}\left(z\right) \]
              3. lower-neg.f6430.0%

                \[\leadsto -z \]
            6. Applied rewrites30.0%

              \[\leadsto -z \]

            if -4.7999999999999997e94 < z < 4.0000000000000001e116

            1. Initial program 99.8%

              \[\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z \]
            2. 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. sub-flipN/A

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

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

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

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

                \[\leadsto \color{blue}{x - \left(\left(\left(y + \frac{1}{2}\right) \cdot \log y - y\right) - \left(\mathsf{neg}\left(z\right)\right)\right)} \]
              7. sub-to-multN/A

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

                \[\leadsto \color{blue}{\left(1 - \frac{\left(\left(y + \frac{1}{2}\right) \cdot \log y - y\right) - \left(\mathsf{neg}\left(z\right)\right)}{x}\right) \cdot x} \]
            3. Applied rewrites79.2%

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

              \[\leadsto \color{blue}{1} \cdot x \]
            5. Step-by-step derivation
              1. Applied rewrites29.0%

                \[\leadsto \color{blue}{1} \cdot x \]
            6. Recombined 2 regimes into one program.
            7. Add Preprocessing

            Alternative 9: 30.0% accurate, 39.3× speedup?

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

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

              \[\leadsto \color{blue}{-1 \cdot z} \]
            3. Step-by-step derivation
              1. lower-*.f6430.0%

                \[\leadsto -1 \cdot \color{blue}{z} \]
            4. Applied rewrites30.0%

              \[\leadsto \color{blue}{-1 \cdot z} \]
            5. Step-by-step derivation
              1. lift-*.f64N/A

                \[\leadsto -1 \cdot \color{blue}{z} \]
              2. mul-1-negN/A

                \[\leadsto \mathsf{neg}\left(z\right) \]
              3. lower-neg.f6430.0%

                \[\leadsto -z \]
            6. Applied rewrites30.0%

              \[\leadsto -z \]
            7. Add Preprocessing

            Reproduce

            ?
            herbie shell --seed 2025271 -o generate:evaluate
            (FPCore (x y z)
              :name "Numeric.SpecFunctions:stirlingError from math-functions-0.1.5.2"
              :precision binary64
              (- (+ (- x (* (+ y 1/2) (log y))) y) z))