Numeric.SpecFunctions:stirlingError from math-functions-0.1.5.2

Percentage Accurate: 99.8% → 99.9%
Time: 3.2s
Alternatives: 14
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 14 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.9% accurate, 0.8× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\mathsf{fma}\left(1 - \log y, y, x\right) - \log \left(\sqrt{y}\right)\right) - z \]
    10. lower-sqrt.f6499.9

      \[\leadsto \left(\mathsf{fma}\left(1 - \log y, y, x\right) - \log \left(\sqrt{y}\right)\right) - z \]
  4. Applied rewrites99.9%

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

Alternative 2: 99.8% accurate, 1.0× speedup?

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

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

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

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

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

Alternative 3: 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 4: 99.2% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.33:\\
\;\;\;\;x - \mathsf{fma}\left(\log y, y - -0.5, z\right)\\

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


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

    1. Initial program 100.0%

      \[\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--.f64100.0

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

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

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

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

      if 0.330000000000000016 < 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 y around inf

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

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

      Alternative 5: 99.2% accurate, 1.0× speedup?

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

        1. Initial program 100.0%

          \[\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--.f64100.0

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

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

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

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

          if 0.330000000000000016 < 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 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.7

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

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

            \[\leadsto \left(y + x\right) - \mathsf{fma}\left(\log y, y, z\right) \]
          6. Step-by-step derivation
            1. Applied rewrites99.0%

              \[\leadsto \left(y + x\right) - \mathsf{fma}\left(\log y, y, z\right) \]
          7. Recombined 2 regimes into one program.
          8. Add Preprocessing

          Alternative 6: 90.2% accurate, 1.0× speedup?

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

            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 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.9

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

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

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

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

              if 5.59999999999999964e69 < 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 x around 0

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

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

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

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

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

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

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

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

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

                  \[\leadsto y - \mathsf{fma}\left(\log y, y - \frac{-1}{2}, z\right) \]
                10. lower--.f6482.4

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

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

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

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

              Alternative 7: 89.4% accurate, 1.1× speedup?

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

                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.f6493.7

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

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

                if 9.50000000000000069e68 < 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 x around 0

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

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

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

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

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

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

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

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

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

                    \[\leadsto y - \mathsf{fma}\left(\log y, y - \frac{-1}{2}, z\right) \]
                  10. lower--.f6482.3

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

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

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

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

                Alternative 8: 84.1% accurate, 1.2× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 5.6 \cdot 10^{+113}:\\ \;\;\;\;\left(x - \log \left(\sqrt{y}\right)\right) - z\\ \mathbf{else}:\\ \;\;\;\;\left(1 - \log y\right) \cdot y\\ \end{array} \end{array} \]
                (FPCore (x y z)
                 :precision binary64
                 (if (<= y 5.6e+113) (- (- x (log (sqrt y))) z) (* (- 1.0 (log y)) y)))
                double code(double x, double y, double z) {
                	double tmp;
                	if (y <= 5.6e+113) {
                		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 <= 5.6d+113) 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 <= 5.6e+113) {
                		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 <= 5.6e+113:
                		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 <= 5.6e+113)
                		tmp = Float64(Float64(x - log(sqrt(y))) - z);
                	else
                		tmp = Float64(Float64(1.0 - log(y)) * y);
                	end
                	return tmp
                end
                
                function tmp_2 = code(x, y, z)
                	tmp = 0.0;
                	if (y <= 5.6e+113)
                		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, 5.6e+113], 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 5.6 \cdot 10^{+113}:\\
                \;\;\;\;\left(x - \log \left(\sqrt{y}\right)\right) - z\\
                
                \mathbf{else}:\\
                \;\;\;\;\left(1 - \log y\right) \cdot y\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if y < 5.59999999999999995e113

                  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.f6490.2

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

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

                  if 5.59999999999999995e113 < y

                  1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

                      \[\leadsto \left(\left(x - \mathsf{fma}\left(\log y, y, \color{blue}{\log \left({y}^{\frac{1}{2}}\right)}\right)\right) + y\right) - z \]
                    13. unpow1/2N/A

                      \[\leadsto \left(\left(x - \mathsf{fma}\left(\log y, y, \log \color{blue}{\left(\sqrt{y}\right)}\right)\right) + y\right) - z \]
                    14. lower-sqrt.f6499.6

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

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

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

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

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

                      \[\leadsto \left(1 - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log y\right)\right)\right)\right)\right) \cdot y \]
                    4. remove-double-negN/A

                      \[\leadsto \left(1 - \log y\right) \cdot y \]
                    5. lower-*.f64N/A

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

                      \[\leadsto \left(1 - \log y\right) \cdot y \]
                    7. lift-log.f6470.7

                      \[\leadsto \left(1 - \log y\right) \cdot y \]
                  6. Applied rewrites70.7%

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

                Alternative 9: 74.1% 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 -5 \cdot 10^{+90}:\\ \;\;\;\;\left(1 - \log y\right) \cdot y\\ \mathbf{elif}\;t\_0 \leq -5 \cdot 10^{+19}:\\ \;\;\;\;x - z\\ \mathbf{elif}\;t\_0 \leq 335:\\ \;\;\;\;\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 -5e+90)
                     (* (- 1.0 (log y)) y)
                     (if (<= t_0 -5e+19)
                       (- x z)
                       (if (<= t_0 335.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 <= -5e+90) {
                		tmp = (1.0 - log(y)) * y;
                	} else if (t_0 <= -5e+19) {
                		tmp = x - z;
                	} else if (t_0 <= 335.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 <= (-5d+90)) then
                        tmp = (1.0d0 - log(y)) * y
                    else if (t_0 <= (-5d+19)) then
                        tmp = x - z
                    else if (t_0 <= 335.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 <= -5e+90) {
                		tmp = (1.0 - Math.log(y)) * y;
                	} else if (t_0 <= -5e+19) {
                		tmp = x - z;
                	} else if (t_0 <= 335.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 <= -5e+90:
                		tmp = (1.0 - math.log(y)) * y
                	elif t_0 <= -5e+19:
                		tmp = x - z
                	elif t_0 <= 335.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 <= -5e+90)
                		tmp = Float64(Float64(1.0 - log(y)) * y);
                	elseif (t_0 <= -5e+19)
                		tmp = Float64(x - z);
                	elseif (t_0 <= 335.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 <= -5e+90)
                		tmp = (1.0 - log(y)) * y;
                	elseif (t_0 <= -5e+19)
                		tmp = x - z;
                	elseif (t_0 <= 335.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, -5e+90], N[(N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[t$95$0, -5e+19], N[(x - z), $MachinePrecision], If[LessEqual[t$95$0, 335.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 -5 \cdot 10^{+90}:\\
                \;\;\;\;\left(1 - \log y\right) \cdot y\\
                
                \mathbf{elif}\;t\_0 \leq -5 \cdot 10^{+19}:\\
                \;\;\;\;x - z\\
                
                \mathbf{elif}\;t\_0 \leq 335:\\
                \;\;\;\;\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) < -5.0000000000000004e90

                  1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

                      \[\leadsto \left(\left(x - \mathsf{fma}\left(\log y, y, \color{blue}{\log \left({y}^{\frac{1}{2}}\right)}\right)\right) + y\right) - z \]
                    13. unpow1/2N/A

                      \[\leadsto \left(\left(x - \mathsf{fma}\left(\log y, y, \log \color{blue}{\left(\sqrt{y}\right)}\right)\right) + y\right) - z \]
                    14. lower-sqrt.f6499.7

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

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

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

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

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

                      \[\leadsto \left(1 - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log y\right)\right)\right)\right)\right) \cdot y \]
                    4. remove-double-negN/A

                      \[\leadsto \left(1 - \log y\right) \cdot y \]
                    5. lower-*.f64N/A

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

                      \[\leadsto \left(1 - \log y\right) \cdot y \]
                    7. lift-log.f6455.5

                      \[\leadsto \left(1 - \log y\right) \cdot y \]
                  6. Applied rewrites55.5%

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

                  if -5.0000000000000004e90 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -5e19 or 335 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y)

                  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 rewrites83.8%

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

                    if -5e19 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < 335

                    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.f6495.7

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

                      \[\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.f6493.5

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

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

                  Alternative 10: 70.7% accurate, 1.0× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -290:\\ \;\;\;\;x - z\\ \mathbf{elif}\;x \leq 9 \cdot 10^{-5}:\\ \;\;\;\;\left(-\log \left(\sqrt{y}\right)\right) - z\\ \mathbf{else}:\\ \;\;\;\;x - z\\ \end{array} \end{array} \]
                  (FPCore (x y z)
                   :precision binary64
                   (if (<= x -290.0) (- x z) (if (<= x 9e-5) (- (- (log (sqrt y))) z) (- x z))))
                  double code(double x, double y, double z) {
                  	double tmp;
                  	if (x <= -290.0) {
                  		tmp = x - z;
                  	} else if (x <= 9e-5) {
                  		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) :: tmp
                      if (x <= (-290.0d0)) then
                          tmp = x - z
                      else if (x <= 9d-5) 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 tmp;
                  	if (x <= -290.0) {
                  		tmp = x - z;
                  	} else if (x <= 9e-5) {
                  		tmp = -Math.log(Math.sqrt(y)) - z;
                  	} else {
                  		tmp = x - z;
                  	}
                  	return tmp;
                  }
                  
                  def code(x, y, z):
                  	tmp = 0
                  	if x <= -290.0:
                  		tmp = x - z
                  	elif x <= 9e-5:
                  		tmp = -math.log(math.sqrt(y)) - z
                  	else:
                  		tmp = x - z
                  	return tmp
                  
                  function code(x, y, z)
                  	tmp = 0.0
                  	if (x <= -290.0)
                  		tmp = Float64(x - z);
                  	elseif (x <= 9e-5)
                  		tmp = Float64(Float64(-log(sqrt(y))) - z);
                  	else
                  		tmp = Float64(x - z);
                  	end
                  	return tmp
                  end
                  
                  function tmp_2 = code(x, y, z)
                  	tmp = 0.0;
                  	if (x <= -290.0)
                  		tmp = x - z;
                  	elseif (x <= 9e-5)
                  		tmp = -log(sqrt(y)) - z;
                  	else
                  		tmp = x - z;
                  	end
                  	tmp_2 = tmp;
                  end
                  
                  code[x_, y_, z_] := If[LessEqual[x, -290.0], N[(x - z), $MachinePrecision], If[LessEqual[x, 9e-5], N[((-N[Log[N[Sqrt[y], $MachinePrecision]], $MachinePrecision]) - z), $MachinePrecision], N[(x - z), $MachinePrecision]]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  \mathbf{if}\;x \leq -290:\\
                  \;\;\;\;x - z\\
                  
                  \mathbf{elif}\;x \leq 9 \cdot 10^{-5}:\\
                  \;\;\;\;\left(-\log \left(\sqrt{y}\right)\right) - z\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;x - z\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if x < -290 or 9.00000000000000057e-5 < 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} - z \]
                    3. Step-by-step derivation
                      1. Applied rewrites78.5%

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

                      if -290 < x < 9.00000000000000057e-5

                      1. Initial program 99.8%

                        \[\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.f6463.4

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

                        \[\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.f6463.0

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

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

                    Alternative 11: 69.7% accurate, 0.4× speedup?

                    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z\\ \mathbf{if}\;t\_0 \leq -40000000000:\\ \;\;\;\;x - z\\ \mathbf{elif}\;t\_0 \leq 500:\\ \;\;\;\;y - \log \left(\sqrt{y}\right)\\ \mathbf{else}:\\ \;\;\;\;x - z\\ \end{array} \end{array} \]
                    (FPCore (x y z)
                     :precision binary64
                     (let* ((t_0 (- (+ (- x (* (+ y 0.5) (log y))) y) z)))
                       (if (<= t_0 -40000000000.0)
                         (- x z)
                         (if (<= t_0 500.0) (- y (log (sqrt y))) (- x z)))))
                    double code(double x, double y, double z) {
                    	double t_0 = ((x - ((y + 0.5) * log(y))) + y) - z;
                    	double tmp;
                    	if (t_0 <= -40000000000.0) {
                    		tmp = x - z;
                    	} else if (t_0 <= 500.0) {
                    		tmp = y - 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) :: t_0
                        real(8) :: tmp
                        t_0 = ((x - ((y + 0.5d0) * log(y))) + y) - z
                        if (t_0 <= (-40000000000.0d0)) then
                            tmp = x - z
                        else if (t_0 <= 500.0d0) then
                            tmp = y - log(sqrt(y))
                        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) - z;
                    	double tmp;
                    	if (t_0 <= -40000000000.0) {
                    		tmp = x - z;
                    	} else if (t_0 <= 500.0) {
                    		tmp = y - Math.log(Math.sqrt(y));
                    	} else {
                    		tmp = x - z;
                    	}
                    	return tmp;
                    }
                    
                    def code(x, y, z):
                    	t_0 = ((x - ((y + 0.5) * math.log(y))) + y) - z
                    	tmp = 0
                    	if t_0 <= -40000000000.0:
                    		tmp = x - z
                    	elif t_0 <= 500.0:
                    		tmp = y - math.log(math.sqrt(y))
                    	else:
                    		tmp = x - z
                    	return tmp
                    
                    function code(x, y, z)
                    	t_0 = Float64(Float64(Float64(x - Float64(Float64(y + 0.5) * log(y))) + y) - z)
                    	tmp = 0.0
                    	if (t_0 <= -40000000000.0)
                    		tmp = Float64(x - z);
                    	elseif (t_0 <= 500.0)
                    		tmp = Float64(y - log(sqrt(y)));
                    	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) - z;
                    	tmp = 0.0;
                    	if (t_0 <= -40000000000.0)
                    		tmp = x - z;
                    	elseif (t_0 <= 500.0)
                    		tmp = y - log(sqrt(y));
                    	else
                    		tmp = x - z;
                    	end
                    	tmp_2 = tmp;
                    end
                    
                    code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]}, If[LessEqual[t$95$0, -40000000000.0], N[(x - z), $MachinePrecision], If[LessEqual[t$95$0, 500.0], N[(y - N[Log[N[Sqrt[y], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(x - z), $MachinePrecision]]]]
                    
                    \begin{array}{l}
                    
                    \\
                    \begin{array}{l}
                    t_0 := \left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z\\
                    \mathbf{if}\;t\_0 \leq -40000000000:\\
                    \;\;\;\;x - z\\
                    
                    \mathbf{elif}\;t\_0 \leq 500:\\
                    \;\;\;\;y - \log \left(\sqrt{y}\right)\\
                    
                    \mathbf{else}:\\
                    \;\;\;\;x - z\\
                    
                    
                    \end{array}
                    \end{array}
                    
                    Derivation
                    1. Split input into 2 regimes
                    2. if (-.f64 (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) z) < -4e10 or 500 < (-.f64 (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) z)

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

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

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

                        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 0

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

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

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

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

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

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

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

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

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

                            \[\leadsto y - \mathsf{fma}\left(\log y, y - \frac{-1}{2}, z\right) \]
                          10. lower--.f6496.5

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

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

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

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

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

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

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

                            \[\leadsto y - \left(\log \left(\sqrt{y}\right) + z\right) \]
                          6. lift-log.f6490.5

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

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

                          \[\leadsto y - \log \left(\sqrt{y}\right) \]
                        9. Step-by-step derivation
                          1. lift-sqrt.f64N/A

                            \[\leadsto y - \log \left(\sqrt{y}\right) \]
                          2. lift-log.f6487.2

                            \[\leadsto y - \log \left(\sqrt{y}\right) \]
                        10. Applied rewrites87.2%

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

                      Alternative 12: 58.9% 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.9%

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

                        Alternative 13: 49.1% accurate, 2.1× speedup?

                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2.1 \cdot 10^{+44}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 4.25 \cdot 10^{+99}:\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
                        (FPCore (x y z)
                         :precision binary64
                         (if (<= x -2.1e+44) x (if (<= x 4.25e+99) (- z) x)))
                        double code(double x, double y, double z) {
                        	double tmp;
                        	if (x <= -2.1e+44) {
                        		tmp = x;
                        	} else if (x <= 4.25e+99) {
                        		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 <= (-2.1d+44)) then
                                tmp = x
                            else if (x <= 4.25d+99) 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 <= -2.1e+44) {
                        		tmp = x;
                        	} else if (x <= 4.25e+99) {
                        		tmp = -z;
                        	} else {
                        		tmp = x;
                        	}
                        	return tmp;
                        }
                        
                        def code(x, y, z):
                        	tmp = 0
                        	if x <= -2.1e+44:
                        		tmp = x
                        	elif x <= 4.25e+99:
                        		tmp = -z
                        	else:
                        		tmp = x
                        	return tmp
                        
                        function code(x, y, z)
                        	tmp = 0.0
                        	if (x <= -2.1e+44)
                        		tmp = x;
                        	elseif (x <= 4.25e+99)
                        		tmp = Float64(-z);
                        	else
                        		tmp = x;
                        	end
                        	return tmp
                        end
                        
                        function tmp_2 = code(x, y, z)
                        	tmp = 0.0;
                        	if (x <= -2.1e+44)
                        		tmp = x;
                        	elseif (x <= 4.25e+99)
                        		tmp = -z;
                        	else
                        		tmp = x;
                        	end
                        	tmp_2 = tmp;
                        end
                        
                        code[x_, y_, z_] := If[LessEqual[x, -2.1e+44], x, If[LessEqual[x, 4.25e+99], (-z), x]]
                        
                        \begin{array}{l}
                        
                        \\
                        \begin{array}{l}
                        \mathbf{if}\;x \leq -2.1 \cdot 10^{+44}:\\
                        \;\;\;\;x\\
                        
                        \mathbf{elif}\;x \leq 4.25 \cdot 10^{+99}:\\
                        \;\;\;\;-z\\
                        
                        \mathbf{else}:\\
                        \;\;\;\;x\\
                        
                        
                        \end{array}
                        \end{array}
                        
                        Derivation
                        1. Split input into 2 regimes
                        2. if x < -2.09999999999999987e44 or 4.24999999999999992e99 < 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 rewrites66.8%

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

                            if -2.09999999999999987e44 < x < 4.24999999999999992e99

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

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

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

                          Alternative 14: 30.3% 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.3%

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

                            Reproduce

                            ?
                            herbie shell --seed 2025115 
                            (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))