Numeric.SpecFunctions:stirlingError from math-functions-0.1.5.2

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

Specification

?
\[\begin{array}{l} \\ \left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \end{array} \]
(FPCore (x y z) :precision binary64 (- (+ (- x (* (+ y 0.5) (log y))) y) z))
double code(double x, double y, double z) {
	return ((x - ((y + 0.5) * log(y))) + y) - z;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y, z)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = ((x - ((y + 0.5d0) * log(y))) + y) - z
end function
public static double code(double x, double y, double z) {
	return ((x - ((y + 0.5) * Math.log(y))) + y) - z;
}
def code(x, y, z):
	return ((x - ((y + 0.5) * math.log(y))) + y) - z
function code(x, y, z)
	return Float64(Float64(Float64(x - Float64(Float64(y + 0.5) * log(y))) + y) - z)
end
function tmp = code(x, y, z)
	tmp = ((x - ((y + 0.5) * log(y))) + y) - z;
end
code[x_, y_, z_] := N[(N[(N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}

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

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 11 alternatives:

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

Initial Program: 99.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \end{array} \]
(FPCore (x y z) :precision binary64 (- (+ (- x (* (+ y 0.5) (log y))) y) z))
double code(double x, double y, double z) {
	return ((x - ((y + 0.5) * log(y))) + y) - z;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y, z)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = ((x - ((y + 0.5d0) * log(y))) + y) - z
end function
public static double code(double x, double y, double z) {
	return ((x - ((y + 0.5) * Math.log(y))) + y) - z;
}
def code(x, y, z):
	return ((x - ((y + 0.5) * math.log(y))) + y) - z
function code(x, y, z)
	return Float64(Float64(Float64(x - Float64(Float64(y + 0.5) * log(y))) + y) - z)
end
function tmp = code(x, y, z)
	tmp = ((x - ((y + 0.5) * log(y))) + y) - z;
end
code[x_, y_, z_] := N[(N[(N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}

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

Alternative 1: 99.8% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(y + x\right) - \mathsf{fma}\left(\log y, \color{blue}{y} + \frac{1}{2}, z\right) \]
    8. metadata-evalN/A

      \[\leadsto \left(y + x\right) - \mathsf{fma}\left(\log y, y + \frac{1}{2} \cdot \color{blue}{1}, z\right) \]
    9. fp-cancel-sign-sub-invN/A

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

      \[\leadsto \left(y + x\right) - \mathsf{fma}\left(\log y, y - \frac{-1}{2} \cdot 1, z\right) \]
    11. metadata-evalN/A

      \[\leadsto \left(y + x\right) - \mathsf{fma}\left(\log y, y - \frac{-1}{2}, z\right) \]
    12. lower--.f6499.8

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

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

Alternative 2: 90.2% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 9 \cdot 10^{+66}:\\
\;\;\;\;\left(x - \log \left(\sqrt{y}\right)\right) - z\\

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


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

    1. Initial program 99.9%

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

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

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

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

        \[\leadsto \left(x - \log \left({y}^{\frac{1}{2}}\right)\right) - z \]
      4. unpow1/2N/A

        \[\leadsto \left(x - \log \left(\sqrt{y}\right)\right) - z \]
      5. lower-sqrt.f6494.2

        \[\leadsto \left(x - \log \left(\sqrt{y}\right)\right) - z \]
    4. Applied rewrites94.2%

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

    if 8.9999999999999997e66 < y

    1. Initial program 99.6%

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

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

        \[\leadsto \left(\log \left({\left(\frac{1}{y}\right)}^{y}\right) + y\right) - z \]
      2. inv-powN/A

        \[\leadsto \left(\log \left({\left({y}^{-1}\right)}^{y}\right) + y\right) - z \]
      3. pow-powN/A

        \[\leadsto \left(\log \left({y}^{\left(-1 \cdot y\right)}\right) + y\right) - z \]
      4. log-pow-revN/A

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

        \[\leadsto \left(-1 \cdot \color{blue}{\left(y \cdot \log y\right)} + y\right) - z \]
      6. mul-1-negN/A

        \[\leadsto \left(\left(\mathsf{neg}\left(y \cdot \log y\right)\right) + y\right) - z \]
      7. lower-neg.f64N/A

        \[\leadsto \left(\left(-y \cdot \log y\right) + y\right) - z \]
      8. *-commutativeN/A

        \[\leadsto \left(\left(-\log y \cdot y\right) + y\right) - z \]
      9. lower-*.f64N/A

        \[\leadsto \left(\left(-\log y \cdot y\right) + y\right) - z \]
      10. lift-log.f6482.2

        \[\leadsto \left(\left(-\log y \cdot y\right) + y\right) - z \]
    4. Applied rewrites82.2%

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

Alternative 3: 89.6% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 5 \cdot 10^{+31}:\\ \;\;\;\;\left(x - \log \left(\sqrt{y}\right)\right) - z\\ \mathbf{else}:\\ \;\;\;\;\left(y + x\right) - \log y \cdot y\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y 5e+31) (- (- x (log (sqrt y))) z) (- (+ y x) (* (log y) y))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= 5e+31) {
		tmp = (x - log(sqrt(y))) - z;
	} else {
		tmp = (y + x) - (log(y) * y);
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y, z)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (y <= 5d+31) then
        tmp = (x - log(sqrt(y))) - z
    else
        tmp = (y + x) - (log(y) * y)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= 5e+31) {
		tmp = (x - Math.log(Math.sqrt(y))) - z;
	} else {
		tmp = (y + x) - (Math.log(y) * y);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= 5e+31:
		tmp = (x - math.log(math.sqrt(y))) - z
	else:
		tmp = (y + x) - (math.log(y) * y)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= 5e+31)
		tmp = Float64(Float64(x - log(sqrt(y))) - z);
	else
		tmp = Float64(Float64(y + x) - Float64(log(y) * y));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= 5e+31)
		tmp = (x - log(sqrt(y))) - z;
	else
		tmp = (y + x) - (log(y) * y);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, 5e+31], N[(N[(x - N[Log[N[Sqrt[y], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[(y + x), $MachinePrecision] - N[(N[Log[y], $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq 5 \cdot 10^{+31}:\\
\;\;\;\;\left(x - \log \left(\sqrt{y}\right)\right) - z\\

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


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

    1. Initial program 100.0%

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

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

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

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

        \[\leadsto \left(x - \log \left({y}^{\frac{1}{2}}\right)\right) - z \]
      4. unpow1/2N/A

        \[\leadsto \left(x - \log \left(\sqrt{y}\right)\right) - z \]
      5. lower-sqrt.f6496.9

        \[\leadsto \left(x - \log \left(\sqrt{y}\right)\right) - z \]
    4. Applied rewrites96.9%

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

    if 5.00000000000000027e31 < y

    1. Initial program 99.7%

      \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
    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. +-commutativeN/A

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

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

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

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

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

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

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

        \[\leadsto \left(y + x\right) - \log y \cdot \left(y - \frac{-1}{2} \cdot 1\right) \]
      10. metadata-evalN/A

        \[\leadsto \left(y + x\right) - \log y \cdot \left(y - \frac{-1}{2}\right) \]
      11. lower--.f6481.5

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

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

      \[\leadsto \left(y + x\right) - \log y \cdot y \]
    6. Step-by-step derivation
      1. Applied rewrites81.5%

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

    Alternative 4: 83.5% accurate, 1.1× speedup?

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

      1. Initial program 99.9%

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

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

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

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

          \[\leadsto \left(x - \log \left({y}^{\frac{1}{2}}\right)\right) - z \]
        4. unpow1/2N/A

          \[\leadsto \left(x - \log \left(\sqrt{y}\right)\right) - z \]
        5. lower-sqrt.f6494.2

          \[\leadsto \left(x - \log \left(\sqrt{y}\right)\right) - z \]
      4. Applied rewrites94.2%

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

      if 2.1000000000000001e67 < y

      1. Initial program 99.6%

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

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

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

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

          \[\leadsto \left(1 - -1 \cdot \log \left(\frac{1}{y}\right)\right) \cdot y \]
        4. mul-1-negN/A

          \[\leadsto \left(1 - \left(\mathsf{neg}\left(\log \left(\frac{1}{y}\right)\right)\right)\right) \cdot y \]
        5. lower-neg.f64N/A

          \[\leadsto \left(1 - \left(-\log \left(\frac{1}{y}\right)\right)\right) \cdot y \]
        6. log-recN/A

          \[\leadsto \left(1 - \left(-\left(\mathsf{neg}\left(\log y\right)\right)\right)\right) \cdot y \]
        7. lower-neg.f64N/A

          \[\leadsto \left(1 - \left(-\left(-\log y\right)\right)\right) \cdot y \]
        8. lift-log.f6466.3

          \[\leadsto \left(1 - \left(-\left(-\log y\right)\right)\right) \cdot y \]
      4. Applied rewrites66.3%

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

    Alternative 5: 83.5% accurate, 1.2× speedup?

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

      1. Initial program 99.9%

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

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

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

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

          \[\leadsto \left(x - \log \left({y}^{\frac{1}{2}}\right)\right) - z \]
        4. unpow1/2N/A

          \[\leadsto \left(x - \log \left(\sqrt{y}\right)\right) - z \]
        5. lower-sqrt.f6494.2

          \[\leadsto \left(x - \log \left(\sqrt{y}\right)\right) - z \]
      4. Applied rewrites94.2%

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

      if 2.1000000000000001e67 < y

      1. Initial program 99.6%

        \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
      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. +-commutativeN/A

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

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

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

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

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

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

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

          \[\leadsto \left(y + x\right) - \log y \cdot \left(y - \frac{-1}{2} \cdot 1\right) \]
        10. metadata-evalN/A

          \[\leadsto \left(y + x\right) - \log y \cdot \left(y - \frac{-1}{2}\right) \]
        11. lower--.f6483.2

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

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

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

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

          \[\leadsto y - \log y \cdot y \]
        3. Step-by-step derivation
          1. Applied rewrites66.3%

            \[\leadsto y - \log y \cdot y \]
        4. Recombined 2 regimes into one program.
        5. Add Preprocessing

        Alternative 6: 73.0% accurate, 1.3× speedup?

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

          1. Initial program 99.9%

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

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

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

            if 2.0499999999999999e67 < y

            1. Initial program 99.6%

              \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
            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. +-commutativeN/A

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

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

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

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

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

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

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

                \[\leadsto \left(y + x\right) - \log y \cdot \left(y - \frac{-1}{2} \cdot 1\right) \]
              10. metadata-evalN/A

                \[\leadsto \left(y + x\right) - \log y \cdot \left(y - \frac{-1}{2}\right) \]
              11. lower--.f6483.2

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

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

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

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

                \[\leadsto y - \log y \cdot y \]
              3. Step-by-step derivation
                1. Applied rewrites66.3%

                  \[\leadsto y - \log y \cdot y \]
              4. Recombined 2 regimes into one program.
              5. Add Preprocessing

              Alternative 7: 70.9% accurate, 0.3× speedup?

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

                1. Initial program 99.7%

                  \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
                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. +-commutativeN/A

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

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

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

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

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

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

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

                    \[\leadsto \left(y + x\right) - \log y \cdot \left(y - \frac{-1}{2} \cdot 1\right) \]
                  10. metadata-evalN/A

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

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

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

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

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

                    \[\leadsto x - \log y \cdot y \]
                  3. Step-by-step derivation
                    1. Applied rewrites50.8%

                      \[\leadsto x - \log y \cdot y \]

                    if -3.99999999999999979e183 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -3e3 or 500 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y)

                    1. Initial program 99.8%

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

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

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

                      if -3e3 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < 500

                      1. Initial program 100.0%

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

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

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

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

                          \[\leadsto \left(x - \log \left({y}^{\frac{1}{2}}\right)\right) - z \]
                        4. unpow1/2N/A

                          \[\leadsto \left(x - \log \left(\sqrt{y}\right)\right) - z \]
                        5. lower-sqrt.f6498.6

                          \[\leadsto \left(x - \log \left(\sqrt{y}\right)\right) - z \]
                      4. Applied rewrites98.6%

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

                        \[\leadsto -1 \cdot \color{blue}{\log \left(\sqrt{y}\right)} - z \]
                      6. Step-by-step derivation
                        1. mul-1-negN/A

                          \[\leadsto \left(\mathsf{neg}\left(\log \left(\sqrt{y}\right)\right)\right) - z \]
                        2. lower-neg.f64N/A

                          \[\leadsto \left(-\log \left(\sqrt{y}\right)\right) - z \]
                        3. lift-sqrt.f64N/A

                          \[\leadsto \left(-\log \left(\sqrt{y}\right)\right) - z \]
                        4. lift-log.f6497.5

                          \[\leadsto \left(-\log \left(\sqrt{y}\right)\right) - z \]
                      7. Applied rewrites97.5%

                        \[\leadsto \left(-\log \left(\sqrt{y}\right)\right) - z \]
                    4. Recombined 3 regimes into one program.
                    5. Add Preprocessing

                    Alternative 8: 70.5% accurate, 1.1× speedup?

                    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -5.6 \cdot 10^{+17}:\\ \;\;\;\;x - z\\ \mathbf{elif}\;z \leq 0.007:\\ \;\;\;\;x - \log \left(\sqrt{y}\right)\\ \mathbf{else}:\\ \;\;\;\;x - z\\ \end{array} \end{array} \]
                    (FPCore (x y z)
                     :precision binary64
                     (if (<= z -5.6e+17) (- x z) (if (<= z 0.007) (- x (log (sqrt y))) (- x z))))
                    double code(double x, double y, double z) {
                    	double tmp;
                    	if (z <= -5.6e+17) {
                    		tmp = x - z;
                    	} else if (z <= 0.007) {
                    		tmp = x - log(sqrt(y));
                    	} else {
                    		tmp = x - z;
                    	}
                    	return tmp;
                    }
                    
                    module fmin_fmax_functions
                        implicit none
                        private
                        public fmax
                        public fmin
                    
                        interface fmax
                            module procedure fmax88
                            module procedure fmax44
                            module procedure fmax84
                            module procedure fmax48
                        end interface
                        interface fmin
                            module procedure fmin88
                            module procedure fmin44
                            module procedure fmin84
                            module procedure fmin48
                        end interface
                    contains
                        real(8) function fmax88(x, y) result (res)
                            real(8), intent (in) :: x
                            real(8), intent (in) :: y
                            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                        end function
                        real(4) function fmax44(x, y) result (res)
                            real(4), intent (in) :: x
                            real(4), intent (in) :: y
                            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                        end function
                        real(8) function fmax84(x, y) result(res)
                            real(8), intent (in) :: x
                            real(4), intent (in) :: y
                            res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                        end function
                        real(8) function fmax48(x, y) result(res)
                            real(4), intent (in) :: x
                            real(8), intent (in) :: y
                            res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                        end function
                        real(8) function fmin88(x, y) result (res)
                            real(8), intent (in) :: x
                            real(8), intent (in) :: y
                            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                        end function
                        real(4) function fmin44(x, y) result (res)
                            real(4), intent (in) :: x
                            real(4), intent (in) :: y
                            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                        end function
                        real(8) function fmin84(x, y) result(res)
                            real(8), intent (in) :: x
                            real(4), intent (in) :: y
                            res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                        end function
                        real(8) function fmin48(x, y) result(res)
                            real(4), intent (in) :: x
                            real(8), intent (in) :: y
                            res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                        end function
                    end module
                    
                    real(8) function code(x, y, z)
                    use fmin_fmax_functions
                        real(8), intent (in) :: x
                        real(8), intent (in) :: y
                        real(8), intent (in) :: z
                        real(8) :: tmp
                        if (z <= (-5.6d+17)) then
                            tmp = x - z
                        else if (z <= 0.007d0) then
                            tmp = x - log(sqrt(y))
                        else
                            tmp = x - z
                        end if
                        code = tmp
                    end function
                    
                    public static double code(double x, double y, double z) {
                    	double tmp;
                    	if (z <= -5.6e+17) {
                    		tmp = x - z;
                    	} else if (z <= 0.007) {
                    		tmp = x - Math.log(Math.sqrt(y));
                    	} else {
                    		tmp = x - z;
                    	}
                    	return tmp;
                    }
                    
                    def code(x, y, z):
                    	tmp = 0
                    	if z <= -5.6e+17:
                    		tmp = x - z
                    	elif z <= 0.007:
                    		tmp = x - math.log(math.sqrt(y))
                    	else:
                    		tmp = x - z
                    	return tmp
                    
                    function code(x, y, z)
                    	tmp = 0.0
                    	if (z <= -5.6e+17)
                    		tmp = Float64(x - z);
                    	elseif (z <= 0.007)
                    		tmp = Float64(x - log(sqrt(y)));
                    	else
                    		tmp = Float64(x - z);
                    	end
                    	return tmp
                    end
                    
                    function tmp_2 = code(x, y, z)
                    	tmp = 0.0;
                    	if (z <= -5.6e+17)
                    		tmp = x - z;
                    	elseif (z <= 0.007)
                    		tmp = x - log(sqrt(y));
                    	else
                    		tmp = x - z;
                    	end
                    	tmp_2 = tmp;
                    end
                    
                    code[x_, y_, z_] := If[LessEqual[z, -5.6e+17], N[(x - z), $MachinePrecision], If[LessEqual[z, 0.007], N[(x - N[Log[N[Sqrt[y], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(x - z), $MachinePrecision]]]
                    
                    \begin{array}{l}
                    
                    \\
                    \begin{array}{l}
                    \mathbf{if}\;z \leq -5.6 \cdot 10^{+17}:\\
                    \;\;\;\;x - z\\
                    
                    \mathbf{elif}\;z \leq 0.007:\\
                    \;\;\;\;x - \log \left(\sqrt{y}\right)\\
                    
                    \mathbf{else}:\\
                    \;\;\;\;x - z\\
                    
                    
                    \end{array}
                    \end{array}
                    
                    Derivation
                    1. Split input into 2 regimes
                    2. if z < -5.6e17 or 0.00700000000000000015 < z

                      1. Initial program 99.9%

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

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

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

                        if -5.6e17 < z < 0.00700000000000000015

                        1. Initial program 99.8%

                          \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
                        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. +-commutativeN/A

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

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

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

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

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

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

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

                            \[\leadsto \left(y + x\right) - \log y \cdot \left(y - \frac{-1}{2} \cdot 1\right) \]
                          10. metadata-evalN/A

                            \[\leadsto \left(y + x\right) - \log y \cdot \left(y - \frac{-1}{2}\right) \]
                          11. lower--.f6498.9

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

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

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

                            \[\leadsto x - \frac{1}{2} \cdot \color{blue}{\log y} \]
                          2. log-pow-revN/A

                            \[\leadsto x - \log \left({y}^{\frac{1}{2}}\right) \]
                          3. lower-log.f64N/A

                            \[\leadsto x - \log \left({y}^{\frac{1}{2}}\right) \]
                          4. unpow1/2N/A

                            \[\leadsto x - \log \left(\sqrt{y}\right) \]
                          5. lower-sqrt.f6462.5

                            \[\leadsto x - \log \left(\sqrt{y}\right) \]
                        7. Applied rewrites62.5%

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

                      Alternative 9: 58.3% accurate, 5.6× speedup?

                      \[\begin{array}{l} \\ x - z \end{array} \]
                      (FPCore (x y z) :precision binary64 (- x z))
                      double code(double x, double y, double z) {
                      	return x - z;
                      }
                      
                      module fmin_fmax_functions
                          implicit none
                          private
                          public fmax
                          public fmin
                      
                          interface fmax
                              module procedure fmax88
                              module procedure fmax44
                              module procedure fmax84
                              module procedure fmax48
                          end interface
                          interface fmin
                              module procedure fmin88
                              module procedure fmin44
                              module procedure fmin84
                              module procedure fmin48
                          end interface
                      contains
                          real(8) function fmax88(x, y) result (res)
                              real(8), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                          end function
                          real(4) function fmax44(x, y) result (res)
                              real(4), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                          end function
                          real(8) function fmax84(x, y) result(res)
                              real(8), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                          end function
                          real(8) function fmax48(x, y) result(res)
                              real(4), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                          end function
                          real(8) function fmin88(x, y) result (res)
                              real(8), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                          end function
                          real(4) function fmin44(x, y) result (res)
                              real(4), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                          end function
                          real(8) function fmin84(x, y) result(res)
                              real(8), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                          end function
                          real(8) function fmin48(x, y) result(res)
                              real(4), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                          end function
                      end module
                      
                      real(8) function code(x, y, z)
                      use fmin_fmax_functions
                          real(8), intent (in) :: x
                          real(8), intent (in) :: y
                          real(8), intent (in) :: z
                          code = x - z
                      end function
                      
                      public static double code(double x, double y, double z) {
                      	return x - z;
                      }
                      
                      def code(x, y, z):
                      	return x - z
                      
                      function code(x, y, z)
                      	return Float64(x - z)
                      end
                      
                      function tmp = code(x, y, z)
                      	tmp = x - z;
                      end
                      
                      code[x_, y_, z_] := N[(x - z), $MachinePrecision]
                      
                      \begin{array}{l}
                      
                      \\
                      x - z
                      \end{array}
                      
                      Derivation
                      1. Initial program 99.8%

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

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

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

                        Alternative 10: 48.9% accurate, 2.1× speedup?

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

                          1. Initial program 99.9%

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

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

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

                            if -1.69999999999999991e29 < x < 1.99999999999999992e88

                            1. Initial program 99.8%

                              \[\left(\left(x - \left(y + 0.5\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. mul-1-negN/A

                                \[\leadsto \mathsf{neg}\left(z\right) \]
                              2. lower-neg.f6437.3

                                \[\leadsto -z \]
                            4. Applied rewrites37.3%

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

                          Alternative 11: 30.7% accurate, 20.4× speedup?

                          \[\begin{array}{l} \\ x \end{array} \]
                          (FPCore (x y z) :precision binary64 x)
                          double code(double x, double y, double z) {
                          	return x;
                          }
                          
                          module fmin_fmax_functions
                              implicit none
                              private
                              public fmax
                              public fmin
                          
                              interface fmax
                                  module procedure fmax88
                                  module procedure fmax44
                                  module procedure fmax84
                                  module procedure fmax48
                              end interface
                              interface fmin
                                  module procedure fmin88
                                  module procedure fmin44
                                  module procedure fmin84
                                  module procedure fmin48
                              end interface
                          contains
                              real(8) function fmax88(x, y) result (res)
                                  real(8), intent (in) :: x
                                  real(8), intent (in) :: y
                                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                              end function
                              real(4) function fmax44(x, y) result (res)
                                  real(4), intent (in) :: x
                                  real(4), intent (in) :: y
                                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                              end function
                              real(8) function fmax84(x, y) result(res)
                                  real(8), intent (in) :: x
                                  real(4), intent (in) :: y
                                  res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                              end function
                              real(8) function fmax48(x, y) result(res)
                                  real(4), intent (in) :: x
                                  real(8), intent (in) :: y
                                  res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                              end function
                              real(8) function fmin88(x, y) result (res)
                                  real(8), intent (in) :: x
                                  real(8), intent (in) :: y
                                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                              end function
                              real(4) function fmin44(x, y) result (res)
                                  real(4), intent (in) :: x
                                  real(4), intent (in) :: y
                                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                              end function
                              real(8) function fmin84(x, y) result(res)
                                  real(8), intent (in) :: x
                                  real(4), intent (in) :: y
                                  res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                              end function
                              real(8) function fmin48(x, y) result(res)
                                  real(4), intent (in) :: x
                                  real(8), intent (in) :: y
                                  res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                              end function
                          end module
                          
                          real(8) function code(x, y, z)
                          use fmin_fmax_functions
                              real(8), intent (in) :: x
                              real(8), intent (in) :: y
                              real(8), intent (in) :: z
                              code = x
                          end function
                          
                          public static double code(double x, double y, double z) {
                          	return x;
                          }
                          
                          def code(x, y, z):
                          	return x
                          
                          function code(x, y, z)
                          	return x
                          end
                          
                          function tmp = code(x, y, z)
                          	tmp = x;
                          end
                          
                          code[x_, y_, z_] := x
                          
                          \begin{array}{l}
                          
                          \\
                          x
                          \end{array}
                          
                          Derivation
                          1. Initial program 99.8%

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

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

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

                            Reproduce

                            ?
                            herbie shell --seed 2025118 
                            (FPCore (x y z)
                              :name "Numeric.SpecFunctions:stirlingError from math-functions-0.1.5.2"
                              :precision binary64
                              (- (+ (- x (* (+ y 0.5) (log y))) y) z))