Numeric.SpecFunctions:stirlingError from math-functions-0.1.5.2

Percentage Accurate: 99.8% → 99.9%
Time: 3.6s
Alternatives: 11
Speedup: 0.9×

Specification

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

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

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

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

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 11 alternatives:

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

Initial Program: 99.8% accurate, 1.0× speedup?

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

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

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

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

Alternative 1: 99.9% accurate, 0.9× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.8% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 99.8% accurate, 0.9× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 1.64999999999999999e-27

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

    if 1.64999999999999999e-27 < y

    1. Initial program 99.7%

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

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

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

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

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

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

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

          \[\leadsto \left(x - y \cdot \log y\right) + \color{blue}{\left(y - z\right)} \]
      3. Applied rewrites97.5%

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

    Alternative 4: 98.7% accurate, 1.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 5: 90.1% accurate, 1.1× speedup?

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

      1. Initial program 100.0%

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

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

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

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

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

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

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

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

      if 4.3999999999999998e40 < y

      1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \left(\mathsf{fma}\left(1 - \log y, y, x\right) - \log \left(\sqrt{y}\right)\right) - z \]
        3. flip3--N/A

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

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

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

          \[\leadsto \left(\mathsf{fma}\left(\frac{1 - {\log y}^{3}}{1 \cdot 1 + \left(\log y \cdot \log y + 1 \cdot \log y\right)}, y, x\right) - \log \left(\sqrt{y}\right)\right) - z \]
        7. lower-pow.f64N/A

          \[\leadsto \left(\mathsf{fma}\left(\frac{1 - {\log y}^{3}}{1 \cdot 1 + \left(\log y \cdot \log y + 1 \cdot \log y\right)}, y, x\right) - \log \left(\sqrt{y}\right)\right) - z \]
        8. lift-log.f64N/A

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

          \[\leadsto \left(\mathsf{fma}\left(\frac{1 - {\log y}^{3}}{1 + \left(\log y \cdot \log y + 1 \cdot \log y\right)}, y, x\right) - \log \left(\sqrt{y}\right)\right) - z \]
        10. lower-+.f64N/A

          \[\leadsto \left(\mathsf{fma}\left(\frac{1 - {\log y}^{3}}{1 + \left(\log y \cdot \log y + 1 \cdot \log y\right)}, y, x\right) - \log \left(\sqrt{y}\right)\right) - z \]
        11. lower-fma.f64N/A

          \[\leadsto \left(\mathsf{fma}\left(\frac{1 - {\log y}^{3}}{1 + \mathsf{fma}\left(\log y, \log y, 1 \cdot \log y\right)}, y, x\right) - \log \left(\sqrt{y}\right)\right) - z \]
        12. lift-log.f64N/A

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

          \[\leadsto \left(\mathsf{fma}\left(\frac{1 - {\log y}^{3}}{1 + \mathsf{fma}\left(\log y, \log y, 1 \cdot \log y\right)}, y, x\right) - \log \left(\sqrt{y}\right)\right) - z \]
        14. lower-*.f64N/A

          \[\leadsto \left(\mathsf{fma}\left(\frac{1 - {\log y}^{3}}{1 + \mathsf{fma}\left(\log y, \log y, 1 \cdot \log y\right)}, y, x\right) - \log \left(\sqrt{y}\right)\right) - z \]
        15. lift-log.f6499.6

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

        \[\leadsto \left(\mathsf{fma}\left(\frac{1 - {\log y}^{3}}{1 + \mathsf{fma}\left(\log y, \log y, 1 \cdot \log y\right)}, y, x\right) - \log \left(\sqrt{\color{blue}{y}}\right)\right) - z \]
      7. Taylor expanded in x around 0

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

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

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

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

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

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

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

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

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

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

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

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

      Alternative 6: 84.3% accurate, 0.3× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z\\ \mathbf{if}\;t\_0 \leq -500000000000:\\ \;\;\;\;y - \mathsf{fma}\left(\log y, y, z\right)\\ \mathbf{elif}\;t\_0 \leq 500:\\ \;\;\;\;\left(-\log \left(\sqrt{y}\right)\right) - z\\ \mathbf{else}:\\ \;\;\;\;x - z\\ \end{array} \end{array} \]
      (FPCore (x y z)
       :precision binary64
       (let* ((t_0 (- (+ (- x (* (+ y 0.5) (log y))) y) z)))
         (if (<= t_0 -500000000000.0)
           (- y (fma (log y) y z))
           (if (<= t_0 500.0) (- (- (log (sqrt y))) z) (- x z)))))
      double code(double x, double y, double z) {
      	double t_0 = ((x - ((y + 0.5) * log(y))) + y) - z;
      	double tmp;
      	if (t_0 <= -500000000000.0) {
      		tmp = y - fma(log(y), y, z);
      	} else if (t_0 <= 500.0) {
      		tmp = -log(sqrt(y)) - z;
      	} else {
      		tmp = x - z;
      	}
      	return tmp;
      }
      
      function code(x, y, z)
      	t_0 = Float64(Float64(Float64(x - Float64(Float64(y + 0.5) * log(y))) + y) - z)
      	tmp = 0.0
      	if (t_0 <= -500000000000.0)
      		tmp = Float64(y - fma(log(y), y, z));
      	elseif (t_0 <= 500.0)
      		tmp = Float64(Float64(-log(sqrt(y))) - z);
      	else
      		tmp = Float64(x - z);
      	end
      	return tmp
      end
      
      code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]}, If[LessEqual[t$95$0, -500000000000.0], N[(y - N[(N[Log[y], $MachinePrecision] * y + z), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 500.0], N[((-N[Log[N[Sqrt[y], $MachinePrecision]], $MachinePrecision]) - z), $MachinePrecision], N[(x - z), $MachinePrecision]]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := \left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z\\
      \mathbf{if}\;t\_0 \leq -500000000000:\\
      \;\;\;\;y - \mathsf{fma}\left(\log y, y, z\right)\\
      
      \mathbf{elif}\;t\_0 \leq 500:\\
      \;\;\;\;\left(-\log \left(\sqrt{y}\right)\right) - z\\
      
      \mathbf{else}:\\
      \;\;\;\;x - z\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if (-.f64 (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) z) < -5e11

        1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \left(\mathsf{fma}\left(1 - \log y, y, x\right) - \log \left(\sqrt{y}\right)\right) - z \]
          3. flip3--N/A

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

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

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

            \[\leadsto \left(\mathsf{fma}\left(\frac{1 - {\log y}^{3}}{1 \cdot 1 + \left(\log y \cdot \log y + 1 \cdot \log y\right)}, y, x\right) - \log \left(\sqrt{y}\right)\right) - z \]
          7. lower-pow.f64N/A

            \[\leadsto \left(\mathsf{fma}\left(\frac{1 - {\log y}^{3}}{1 \cdot 1 + \left(\log y \cdot \log y + 1 \cdot \log y\right)}, y, x\right) - \log \left(\sqrt{y}\right)\right) - z \]
          8. lift-log.f64N/A

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

            \[\leadsto \left(\mathsf{fma}\left(\frac{1 - {\log y}^{3}}{1 + \left(\log y \cdot \log y + 1 \cdot \log y\right)}, y, x\right) - \log \left(\sqrt{y}\right)\right) - z \]
          10. lower-+.f64N/A

            \[\leadsto \left(\mathsf{fma}\left(\frac{1 - {\log y}^{3}}{1 + \left(\log y \cdot \log y + 1 \cdot \log y\right)}, y, x\right) - \log \left(\sqrt{y}\right)\right) - z \]
          11. lower-fma.f64N/A

            \[\leadsto \left(\mathsf{fma}\left(\frac{1 - {\log y}^{3}}{1 + \mathsf{fma}\left(\log y, \log y, 1 \cdot \log y\right)}, y, x\right) - \log \left(\sqrt{y}\right)\right) - z \]
          12. lift-log.f64N/A

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

            \[\leadsto \left(\mathsf{fma}\left(\frac{1 - {\log y}^{3}}{1 + \mathsf{fma}\left(\log y, \log y, 1 \cdot \log y\right)}, y, x\right) - \log \left(\sqrt{y}\right)\right) - z \]
          14. lower-*.f64N/A

            \[\leadsto \left(\mathsf{fma}\left(\frac{1 - {\log y}^{3}}{1 + \mathsf{fma}\left(\log y, \log y, 1 \cdot \log y\right)}, y, x\right) - \log \left(\sqrt{y}\right)\right) - z \]
          15. lift-log.f6499.7

            \[\leadsto \left(\mathsf{fma}\left(\frac{1 - {\log y}^{3}}{1 + \mathsf{fma}\left(\log y, \log y, 1 \cdot \log y\right)}, y, x\right) - \log \left(\sqrt{y}\right)\right) - z \]
        6. Applied rewrites99.7%

          \[\leadsto \left(\mathsf{fma}\left(\frac{1 - {\log y}^{3}}{1 + \mathsf{fma}\left(\log y, \log y, 1 \cdot \log y\right)}, y, x\right) - \log \left(\sqrt{\color{blue}{y}}\right)\right) - z \]
        7. Taylor expanded in x around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

          1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \left(\mathsf{neg}\left(\log \left({y}^{\frac{1}{2}}\right)\right)\right) - z \]
            3. log-pow-revN/A

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

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

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

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

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

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

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

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

          1. Initial program 100.0%

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

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

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

          Alternative 7: 74.1% accurate, 0.3× speedup?

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

            1. Initial program 99.7%

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

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

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

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

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

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

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

                \[\leadsto \left(1 - \log \left({y}^{\left(-1 \cdot -1\right)}\right)\right) \cdot y \]
              7. metadata-evalN/A

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

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

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

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

              \[\leadsto \color{blue}{\left(1 - 1 \cdot \log y\right) \cdot y} \]
            5. Step-by-step derivation
              1. associate-+l-64.5

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

                \[\leadsto \left(1 - 1 \cdot \log y\right) \cdot y \]
              3. lift-log.f64N/A

                \[\leadsto \left(1 - 1 \cdot \log y\right) \cdot y \]
              4. *-lft-identityN/A

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

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

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

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

            1. Initial program 99.8%

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

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

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

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

              1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \left(\mathsf{neg}\left(\log \left({y}^{\frac{1}{2}}\right)\right)\right) - z \]
                3. log-pow-revN/A

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

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

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

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

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

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

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

            Alternative 8: 68.8% accurate, 0.7× speedup?

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

              1. Initial program 99.9%

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

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

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

                if 3.9999999999999997e126 < y < 1.7000000000000001e170 or 1.05000000000000001e221 < y

                1. Initial program 99.6%

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

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

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

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

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

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

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

                    \[\leadsto \left(1 - \log \left({y}^{\left(-1 \cdot -1\right)}\right)\right) \cdot y \]
                  7. metadata-evalN/A

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

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

                    \[\leadsto \left(1 - 1 \cdot \log y\right) \cdot y \]
                  10. lift-log.f6475.2

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

                  \[\leadsto \color{blue}{\left(1 - 1 \cdot \log y\right) \cdot y} \]
                5. Step-by-step derivation
                  1. associate-+l-75.2

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

                    \[\leadsto \left(1 - 1 \cdot \log y\right) \cdot y \]
                  3. lift-log.f64N/A

                    \[\leadsto \left(1 - 1 \cdot \log y\right) \cdot y \]
                  4. *-lft-identityN/A

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

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

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

              Alternative 9: 57.9% accurate, 4.0× speedup?

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

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

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

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

                Alternative 10: 47.5% accurate, 1.2× speedup?

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

                  1. Initial program 99.9%

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

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

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

                    if -9.49999999999999922e103 < x < 2.0000000000000001e-4

                    1. Initial program 99.8%

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

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

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

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

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

                  Alternative 11: 29.3% accurate, 12.0× speedup?

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

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

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

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

                    Reproduce

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