Numeric.SpecFunctions:stirlingError from math-functions-0.1.5.2

Percentage Accurate: 99.8% → 99.9%
Time: 7.1s
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}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 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.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\left(x + \mathsf{fma}\left(-\log y, 0.5 + y, y\right)\right)} - z \]
  5. Step-by-step derivation
    1. lift-fma.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\left(-\log y\right) - -1, y, \color{blue}{\frac{-1}{2} \cdot \log y + x}\right) - z \]
    19. lift-fma.f6499.8

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

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

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

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

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

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

Alternative 2: 75.3% accurate, 0.2× speedup?

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

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

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

\mathbf{elif}\;t\_0 \leq -1 \cdot 10^{+24} \lor \neg \left(t\_0 \leq 500\right):\\
\;\;\;\;x - z\\

\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \log y - z\\


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

    1. Initial program 99.5%

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\left(\frac{1}{2} + y\right)\right), \log y, x + y\right) \]
      7. distribute-neg-inN/A

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

        \[\leadsto \mathsf{fma}\left(\frac{-1}{2} + \left(\mathsf{neg}\left(y\right)\right), \log y, x + y\right) \]
      9. mul-1-negN/A

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

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

        \[\leadsto \mathsf{fma}\left(\frac{-1}{2} - 1 \cdot y, \log y, x + y\right) \]
      12. *-lft-identityN/A

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

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

        \[\leadsto \mathsf{fma}\left(\frac{-1}{2} - y, \log y, x + y\right) \]
      15. +-commutativeN/A

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

        \[\leadsto \mathsf{fma}\left(-0.5 - y, \log y, y + x\right) \]
    5. Applied rewrites99.6%

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

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

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

      if -2e295 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -4.7999999999999999e188

      1. Initial program 99.6%

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

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

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

          \[\leadsto \left(1 - \left(\mathsf{neg}\left(\log \left(\frac{1}{y}\right)\right)\right)\right) \cdot y \]
        3. log-recN/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. lower-log.f6470.5

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

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

      if -4.7999999999999999e188 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -9.9999999999999998e23 or 500 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y)

      1. Initial program 99.8%

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

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

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

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

        1. Initial program 99.9%

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

          \[\leadsto \color{blue}{\left(x - \frac{1}{2} \cdot \log y\right)} - z \]
        4. Step-by-step derivation
          1. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

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

            \[\leadsto \frac{-1}{2} \cdot \log y - z \]
          2. lower-log.f6489.8

            \[\leadsto -0.5 \cdot \log y - z \]
        8. Applied rewrites89.8%

          \[\leadsto -0.5 \cdot \color{blue}{\log y} - z \]
      5. Recombined 4 regimes into one program.
      6. Final simplification77.5%

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

      Alternative 3: 75.5% accurate, 0.3× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(x - \left(y + 0.5\right) \cdot \log y\right) + y\\ \mathbf{if}\;t\_0 \leq -4.8 \cdot 10^{+188}:\\ \;\;\;\;\left(1 - \log y\right) \cdot y\\ \mathbf{elif}\;t\_0 \leq -1 \cdot 10^{+24} \lor \neg \left(t\_0 \leq 500\right):\\ \;\;\;\;x - z\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \log y - z\\ \end{array} \end{array} \]
      (FPCore (x y z)
       :precision binary64
       (let* ((t_0 (+ (- x (* (+ y 0.5) (log y))) y)))
         (if (<= t_0 -4.8e+188)
           (* (- 1.0 (log y)) y)
           (if (or (<= t_0 -1e+24) (not (<= t_0 500.0)))
             (- x z)
             (- (* -0.5 (log y)) z)))))
      double code(double x, double y, double z) {
      	double t_0 = (x - ((y + 0.5) * log(y))) + y;
      	double tmp;
      	if (t_0 <= -4.8e+188) {
      		tmp = (1.0 - log(y)) * y;
      	} else if ((t_0 <= -1e+24) || !(t_0 <= 500.0)) {
      		tmp = x - z;
      	} else {
      		tmp = (-0.5 * log(y)) - z;
      	}
      	return tmp;
      }
      
      module fmin_fmax_functions
          implicit none
          private
          public fmax
          public fmin
      
          interface fmax
              module procedure fmax88
              module procedure fmax44
              module procedure fmax84
              module procedure fmax48
          end interface
          interface fmin
              module procedure fmin88
              module procedure fmin44
              module procedure fmin84
              module procedure fmin48
          end interface
      contains
          real(8) function fmax88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(4) function fmax44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(8) function fmax84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmax48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
          end function
          real(8) function fmin88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(4) function fmin44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(8) function fmin84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmin48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
          end function
      end module
      
      real(8) function code(x, y, z)
      use fmin_fmax_functions
          real(8), intent (in) :: x
          real(8), intent (in) :: y
          real(8), intent (in) :: z
          real(8) :: t_0
          real(8) :: tmp
          t_0 = (x - ((y + 0.5d0) * log(y))) + y
          if (t_0 <= (-4.8d+188)) then
              tmp = (1.0d0 - log(y)) * y
          else if ((t_0 <= (-1d+24)) .or. (.not. (t_0 <= 500.0d0))) then
              tmp = x - z
          else
              tmp = ((-0.5d0) * log(y)) - 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 <= -4.8e+188) {
      		tmp = (1.0 - Math.log(y)) * y;
      	} else if ((t_0 <= -1e+24) || !(t_0 <= 500.0)) {
      		tmp = x - z;
      	} else {
      		tmp = (-0.5 * Math.log(y)) - z;
      	}
      	return tmp;
      }
      
      def code(x, y, z):
      	t_0 = (x - ((y + 0.5) * math.log(y))) + y
      	tmp = 0
      	if t_0 <= -4.8e+188:
      		tmp = (1.0 - math.log(y)) * y
      	elif (t_0 <= -1e+24) or not (t_0 <= 500.0):
      		tmp = x - z
      	else:
      		tmp = (-0.5 * math.log(y)) - 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 <= -4.8e+188)
      		tmp = Float64(Float64(1.0 - log(y)) * y);
      	elseif ((t_0 <= -1e+24) || !(t_0 <= 500.0))
      		tmp = Float64(x - z);
      	else
      		tmp = Float64(Float64(-0.5 * log(y)) - 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 <= -4.8e+188)
      		tmp = (1.0 - log(y)) * y;
      	elseif ((t_0 <= -1e+24) || ~((t_0 <= 500.0)))
      		tmp = x - z;
      	else
      		tmp = (-0.5 * log(y)) - 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, -4.8e+188], N[(N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], If[Or[LessEqual[t$95$0, -1e+24], N[Not[LessEqual[t$95$0, 500.0]], $MachinePrecision]], N[(x - z), $MachinePrecision], N[(N[(-0.5 * N[Log[y], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := \left(x - \left(y + 0.5\right) \cdot \log y\right) + y\\
      \mathbf{if}\;t\_0 \leq -4.8 \cdot 10^{+188}:\\
      \;\;\;\;\left(1 - \log y\right) \cdot y\\
      
      \mathbf{elif}\;t\_0 \leq -1 \cdot 10^{+24} \lor \neg \left(t\_0 \leq 500\right):\\
      \;\;\;\;x - z\\
      
      \mathbf{else}:\\
      \;\;\;\;-0.5 \cdot \log y - 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) < -4.7999999999999999e188

        1. Initial program 99.6%

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

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

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

            \[\leadsto \left(1 - \left(\mathsf{neg}\left(\log \left(\frac{1}{y}\right)\right)\right)\right) \cdot y \]
          3. log-recN/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. lower-log.f6463.9

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

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

        if -4.7999999999999999e188 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -9.9999999999999998e23 or 500 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y)

        1. Initial program 99.8%

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

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

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

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

          1. Initial program 99.9%

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

            \[\leadsto \color{blue}{\left(x - \frac{1}{2} \cdot \log y\right)} - z \]
          4. Step-by-step derivation
            1. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

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

              \[\leadsto \frac{-1}{2} \cdot \log y - z \]
            2. lower-log.f6489.8

              \[\leadsto -0.5 \cdot \log y - z \]
          8. Applied rewrites89.8%

            \[\leadsto -0.5 \cdot \color{blue}{\log y} - z \]
        5. Recombined 3 regimes into one program.
        6. Final simplification75.6%

          \[\leadsto \begin{array}{l} \mathbf{if}\;\left(x - \left(y + 0.5\right) \cdot \log y\right) + y \leq -4.8 \cdot 10^{+188}:\\ \;\;\;\;\left(1 - \log y\right) \cdot y\\ \mathbf{elif}\;\left(x - \left(y + 0.5\right) \cdot \log y\right) + y \leq -1 \cdot 10^{+24} \lor \neg \left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y \leq 500\right):\\ \;\;\;\;x - z\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \log y - z\\ \end{array} \]
        7. Add Preprocessing

        Alternative 4: 88.3% accurate, 0.9× speedup?

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

          1. Initial program 99.9%

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

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

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

            if -5.7999999999999999e88 < z < 1.1500000000000001e127

            1. Initial program 99.7%

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

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

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

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

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

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

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

                \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\left(\frac{1}{2} + y\right)\right), \log y, x + y\right) \]
              7. distribute-neg-inN/A

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

                \[\leadsto \mathsf{fma}\left(\frac{-1}{2} + \left(\mathsf{neg}\left(y\right)\right), \log y, x + y\right) \]
              9. mul-1-negN/A

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

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

                \[\leadsto \mathsf{fma}\left(\frac{-1}{2} - 1 \cdot y, \log y, x + y\right) \]
              12. *-lft-identityN/A

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

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

                \[\leadsto \mathsf{fma}\left(\frac{-1}{2} - y, \log y, x + y\right) \]
              15. +-commutativeN/A

                \[\leadsto \mathsf{fma}\left(\frac{-1}{2} - y, \log y, y + x\right) \]
              16. lower-+.f6494.7

                \[\leadsto \mathsf{fma}\left(-0.5 - y, \log y, y + x\right) \]
            5. Applied rewrites94.7%

              \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5 - y, \log y, y + x\right)} \]
            6. Step-by-step derivation
              1. lift-fma.f64N/A

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

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

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

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

                \[\leadsto \mathsf{fma}\left(-0.5 - y, \log y, y\right) + x \]
            7. Applied rewrites94.8%

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

            \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -5.8 \cdot 10^{+88} \lor \neg \left(z \leq 1.15 \cdot 10^{+127}\right):\\ \;\;\;\;x - z\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-0.5 - y, \log y, y\right) + x\\ \end{array} \]
          7. Add Preprocessing

          Alternative 5: 88.3% accurate, 0.9× speedup?

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

            1. Initial program 99.9%

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

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

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

              if -5.7999999999999999e88 < z < 1.1500000000000001e127

              1. Initial program 99.7%

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

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

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

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

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

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

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

                  \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\left(\frac{1}{2} + y\right)\right), \log y, x + y\right) \]
                7. distribute-neg-inN/A

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

                  \[\leadsto \mathsf{fma}\left(\frac{-1}{2} + \left(\mathsf{neg}\left(y\right)\right), \log y, x + y\right) \]
                9. mul-1-negN/A

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

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

                  \[\leadsto \mathsf{fma}\left(\frac{-1}{2} - 1 \cdot y, \log y, x + y\right) \]
                12. *-lft-identityN/A

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

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

                  \[\leadsto \mathsf{fma}\left(\frac{-1}{2} - y, \log y, x + y\right) \]
                15. +-commutativeN/A

                  \[\leadsto \mathsf{fma}\left(\frac{-1}{2} - y, \log y, y + x\right) \]
                16. lower-+.f6494.7

                  \[\leadsto \mathsf{fma}\left(-0.5 - y, \log y, y + x\right) \]
              5. Applied rewrites94.7%

                \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5 - y, \log y, y + x\right)} \]
              6. Step-by-step derivation
                1. lift-fma.f64N/A

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

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

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

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

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

                  \[\leadsto \mathsf{fma}\left(-0.5 - y, \log y, x\right) + y \]
              7. Applied rewrites94.7%

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

              \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -5.8 \cdot 10^{+88} \lor \neg \left(z \leq 1.15 \cdot 10^{+127}\right):\\ \;\;\;\;x - z\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-0.5 - y, \log y, x\right) + y\\ \end{array} \]
            7. Add Preprocessing

            Alternative 6: 99.1% accurate, 1.0× speedup?

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

              1. Initial program 100.0%

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

                \[\leadsto \color{blue}{\left(x - \frac{1}{2} \cdot \log y\right)} - z \]
              4. Step-by-step derivation
                1. fp-cancel-sub-sign-invN/A

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

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

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

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

                  \[\leadsto \mathsf{fma}\left(-0.5, \log y, x\right) - z \]
              5. Applied rewrites98.7%

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

              if 0.28000000000000003 < y

              1. Initial program 99.6%

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

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

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

              Alternative 7: 89.5% accurate, 1.0× speedup?

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

                1. Initial program 99.9%

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

                  \[\leadsto \color{blue}{\left(x - \frac{1}{2} \cdot \log y\right)} - z \]
                4. Step-by-step derivation
                  1. fp-cancel-sub-sign-invN/A

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(-0.5, \log y, x\right) - z \]
                5. Applied rewrites91.7%

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

                if 1.6499999999999999e60 < y

                1. Initial program 99.5%

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

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

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

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\left(\frac{1}{2} + y\right)\right), \log y, x + y\right) \]
                  7. distribute-neg-inN/A

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

                    \[\leadsto \mathsf{fma}\left(\frac{-1}{2} + \left(\mathsf{neg}\left(y\right)\right), \log y, x + y\right) \]
                  9. mul-1-negN/A

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

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

                    \[\leadsto \mathsf{fma}\left(\frac{-1}{2} - 1 \cdot y, \log y, x + y\right) \]
                  12. *-lft-identityN/A

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

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

                    \[\leadsto \mathsf{fma}\left(\frac{-1}{2} - y, \log y, x + y\right) \]
                  15. +-commutativeN/A

                    \[\leadsto \mathsf{fma}\left(\frac{-1}{2} - y, \log y, y + x\right) \]
                  16. lower-+.f6486.6

                    \[\leadsto \mathsf{fma}\left(-0.5 - y, \log y, y + x\right) \]
                5. Applied rewrites86.6%

                  \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5 - y, \log y, y + x\right)} \]
                6. Step-by-step derivation
                  1. lift-fma.f64N/A

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

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

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

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

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

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

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

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

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

                    \[\leadsto \left(x + y\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \log y \]
                  2. lower-neg.f6486.5

                    \[\leadsto \left(x + y\right) + \left(-y\right) \cdot \log y \]
                10. Applied rewrites86.5%

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

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

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

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

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

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

                    \[\leadsto \left(\left(-y\right) \cdot \log y + y\right) + x \]
                  7. lift-*.f64N/A

                    \[\leadsto \left(\left(-y\right) \cdot \log y + y\right) + x \]
                  8. lower-fma.f6486.6

                    \[\leadsto \mathsf{fma}\left(-y, \log y, y\right) + x \]
                12. Applied rewrites86.6%

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

              Alternative 8: 89.5% accurate, 1.0× speedup?

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

                1. Initial program 99.9%

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

                  \[\leadsto \color{blue}{\left(x - \frac{1}{2} \cdot \log y\right)} - z \]
                4. Step-by-step derivation
                  1. fp-cancel-sub-sign-invN/A

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(-0.5, \log y, x\right) - z \]
                5. Applied rewrites91.7%

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

                if 1.6499999999999999e60 < y

                1. Initial program 99.5%

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

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

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

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\left(\frac{1}{2} + y\right)\right), \log y, x + y\right) \]
                  7. distribute-neg-inN/A

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

                    \[\leadsto \mathsf{fma}\left(\frac{-1}{2} + \left(\mathsf{neg}\left(y\right)\right), \log y, x + y\right) \]
                  9. mul-1-negN/A

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

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

                    \[\leadsto \mathsf{fma}\left(\frac{-1}{2} - 1 \cdot y, \log y, x + y\right) \]
                  12. *-lft-identityN/A

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

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

                    \[\leadsto \mathsf{fma}\left(\frac{-1}{2} - y, \log y, x + y\right) \]
                  15. +-commutativeN/A

                    \[\leadsto \mathsf{fma}\left(\frac{-1}{2} - y, \log y, y + x\right) \]
                  16. lower-+.f6486.6

                    \[\leadsto \mathsf{fma}\left(-0.5 - y, \log y, y + x\right) \]
                5. Applied rewrites86.6%

                  \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5 - y, \log y, y + x\right)} \]
                6. Step-by-step derivation
                  1. lift-fma.f64N/A

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

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

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

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

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

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

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

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

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

                    \[\leadsto \left(x + y\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \log y \]
                  2. lower-neg.f6486.5

                    \[\leadsto \left(x + y\right) + \left(-y\right) \cdot \log y \]
                10. Applied rewrites86.5%

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

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

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

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

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

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

                    \[\leadsto \left(\left(-y\right) \cdot \log y + x\right) + y \]
                  7. lower-fma.f6486.5

                    \[\leadsto \mathsf{fma}\left(-y, \log y, x\right) + y \]
                12. Applied rewrites86.5%

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

              Alternative 9: 99.9% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              Alternative 10: 83.4% accurate, 1.0× speedup?

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

                1. Initial program 99.8%

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

                  \[\leadsto \color{blue}{\left(x - \frac{1}{2} \cdot \log y\right)} - z \]
                4. Step-by-step derivation
                  1. fp-cancel-sub-sign-invN/A

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(-0.5, \log y, x\right) - z \]
                5. Applied rewrites83.1%

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

                if 3.50000000000000023e182 < y

                1. Initial program 99.4%

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

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

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

                    \[\leadsto \left(1 - \left(\mathsf{neg}\left(\log \left(\frac{1}{y}\right)\right)\right)\right) \cdot y \]
                  3. log-recN/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. lower-log.f6485.6

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

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

              Alternative 11: 70.8% accurate, 1.0× speedup?

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

                1. Initial program 99.8%

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

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

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

                  if 3.50000000000000023e182 < y

                  1. Initial program 99.4%

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

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

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

                      \[\leadsto \left(1 - \left(\mathsf{neg}\left(\log \left(\frac{1}{y}\right)\right)\right)\right) \cdot y \]
                    3. log-recN/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. lower-log.f6485.6

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

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

                Alternative 12: 48.6% accurate, 7.9× speedup?

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

                  1. Initial program 99.8%

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

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

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

                    if -3.35000000000000012e38 < x < 4.4e13

                    1. Initial program 99.7%

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

                      \[\leadsto \color{blue}{-1 \cdot z} \]
                    4. Step-by-step derivation
                      1. mul-1-negN/A

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

                        \[\leadsto -z \]
                    5. Applied rewrites35.5%

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

                  Alternative 13: 58.3% accurate, 29.5× speedup?

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

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

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

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

                    Alternative 14: 29.6% accurate, 118.0× speedup?

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

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

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

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

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

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

                      Reproduce

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