Numeric.SpecFunctions:stirlingError from math-functions-0.1.5.2

Percentage Accurate: 99.8% → 99.9%
Time: 4.7s
Alternatives: 12
Speedup: 0.7×

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 12 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(\left(\frac{y}{\log y \cdot \left(-0.5 - y\right)} + 1\right) \cdot \left(-0.5 - y\right), \log y, x - z\right) \end{array} \]
(FPCore (x y z)
 :precision binary64
 (fma (* (+ (/ y (* (log y) (- -0.5 y))) 1.0) (- -0.5 y)) (log y) (- x z)))
double code(double x, double y, double z) {
	return fma((((y / (log(y) * (-0.5 - y))) + 1.0) * (-0.5 - y)), log(y), (x - z));
}
function code(x, y, z)
	return fma(Float64(Float64(Float64(y / Float64(log(y) * Float64(-0.5 - y))) + 1.0) * Float64(-0.5 - y)), log(y), Float64(x - z))
end
code[x_, y_, z_] := N[(N[(N[(N[(y / N[(N[Log[y], $MachinePrecision] * N[(-0.5 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[(-0.5 - y), $MachinePrecision]), $MachinePrecision] * N[Log[y], $MachinePrecision] + N[(x - z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(\left(\frac{y}{\log y \cdot \left(-0.5 - y\right)} + 1\right) \cdot \left(-0.5 - y\right), \log y, x - 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 \left(\color{blue}{\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right)} + y\right) - z \]
    3. sub-flipN/A

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(x + \mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) - y}, \log y, y\right)\right) - z \]
    13. metadata-eval99.9

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

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

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

Alternative 2: 99.9% accurate, 0.7× speedup?

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

\\
\mathsf{fma}\left(\log y, \mathsf{fma}\left(\frac{1}{\log y} - 1, y, -0.5\right), x - 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 \left(\color{blue}{\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right)} + y\right) - z \]
    3. sub-flipN/A

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(x + \mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) - y}, \log y, y\right)\right) - z \]
    13. metadata-eval99.9

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 99.8% accurate, 1.0× speedup?

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

\\
\mathsf{fma}\left(-0.5 - y, \log y, y\right) - \left(z - x\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 \left(\color{blue}{\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right)} + y\right) - z \]
    3. sub-flipN/A

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(x + \mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) - y}, \log y, y\right)\right) - z \]
    13. metadata-eval99.9

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 99.8% accurate, 1.0× speedup?

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

\\
x - \mathsf{fma}\left(y - -0.5, \log y, z - y\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 \left(\color{blue}{\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right)} + y\right) - z \]
    3. sub-flipN/A

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(x + \mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) - y}, \log y, y\right)\right) - z \]
    13. metadata-eval99.9

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

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

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

Alternative 5: 89.6% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(-0.5 - y, \log y, y\right)\\ t_1 := t\_0 + x\\ \mathbf{if}\;x \leq -5 \cdot 10^{+31}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 2.9 \cdot 10^{+76}:\\ \;\;\;\;t\_0 - z\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (fma (- -0.5 y) (log y) y)) (t_1 (+ t_0 x)))
   (if (<= x -5e+31) t_1 (if (<= x 2.9e+76) (- t_0 z) t_1))))
double code(double x, double y, double z) {
	double t_0 = fma((-0.5 - y), log(y), y);
	double t_1 = t_0 + x;
	double tmp;
	if (x <= -5e+31) {
		tmp = t_1;
	} else if (x <= 2.9e+76) {
		tmp = t_0 - z;
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x, y, z)
	t_0 = fma(Float64(-0.5 - y), log(y), y)
	t_1 = Float64(t_0 + x)
	tmp = 0.0
	if (x <= -5e+31)
		tmp = t_1;
	elseif (x <= 2.9e+76)
		tmp = Float64(t_0 - z);
	else
		tmp = t_1;
	end
	return tmp
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(-0.5 - y), $MachinePrecision] * N[Log[y], $MachinePrecision] + y), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 + x), $MachinePrecision]}, If[LessEqual[x, -5e+31], t$95$1, If[LessEqual[x, 2.9e+76], N[(t$95$0 - z), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq 2.9 \cdot 10^{+76}:\\
\;\;\;\;t\_0 - z\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -5.00000000000000027e31 or 2.9000000000000002e76 < x

    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. lower-*.f6430.4

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

      \[\leadsto \color{blue}{-1 \cdot z} \]
    5. Taylor expanded in z around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(x + \left(\mathsf{neg}\left(\left(y + \frac{1}{2}\right)\right)\right) \cdot \log y\right) + y \]
      13. add-flipN/A

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

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

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

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

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

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

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

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

    if -5.00000000000000027e31 < x < 2.9000000000000002e76

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(x + \mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) - y}, \log y, y\right)\right) - z \]
      13. metadata-eval99.9

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(-0.5 - y, \log y, y\right) - \color{blue}{z} \]
    9. Recombined 2 regimes into one program.
    10. Add Preprocessing

    Alternative 6: 89.3% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \left(x + \mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) - y}, \log y, y\right)\right) - z \]
        13. metadata-eval99.9

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

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

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

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

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

        if 5.49999999999999975e-11 < y

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \left(x + \mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) - y}, \log y, y\right)\right) - z \]
          13. metadata-eval99.9

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{fma}\left(-0.5 - y, \log y, y\right) - \color{blue}{z} \]
        9. Recombined 2 regimes into one program.
        10. Add Preprocessing

        Alternative 7: 84.2% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \left(x + \mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) - y}, \log y, y\right)\right) - z \]
            13. metadata-eval99.9

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

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

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

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

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

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

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

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

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

                \[\leadsto y \cdot \left(1 + \log \left(\frac{1}{y}\right)\right) \]
              4. lower-/.f6431.3

                \[\leadsto y \cdot \left(1 + \log \left(\frac{1}{y}\right)\right) \]
            4. Applied rewrites31.3%

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

          Alternative 8: 84.2% accurate, 1.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \left(x + \mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) - y}, \log y, y\right)\right) - z \]
              13. metadata-eval99.9

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

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

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

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

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

              if 7.00000000000000015e120 < 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 z around inf

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

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

                \[\leadsto \color{blue}{-1 \cdot z} \]
              5. Taylor expanded in z around 0

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

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

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

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

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

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

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

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

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

              Alternative 9: 70.1% accurate, 1.4× speedup?

              \[\begin{array}{l} \\ \mathsf{fma}\left(-0.5, \log y, x - z\right) \end{array} \]
              (FPCore (x y z) :precision binary64 (fma -0.5 (log y) (- x z)))
              double code(double x, double y, double z) {
              	return fma(-0.5, log(y), (x - z));
              }
              
              function code(x, y, z)
              	return fma(-0.5, log(y), Float64(x - z))
              end
              
              code[x_, y_, z_] := N[(-0.5 * N[Log[y], $MachinePrecision] + N[(x - z), $MachinePrecision]), $MachinePrecision]
              
              \begin{array}{l}
              
              \\
              \mathsf{fma}\left(-0.5, \log y, x - 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 \left(\color{blue}{\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right)} + y\right) - z \]
                3. sub-flipN/A

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

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

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

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

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

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

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

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

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

                  \[\leadsto \left(x + \mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) - y}, \log y, y\right)\right) - z \]
                13. metadata-eval99.9

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

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

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

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

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

                Alternative 10: 59.2% accurate, 1.1× speedup?

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

                  1. Initial program 99.8%

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

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

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

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

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

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

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

                    \[\leadsto -z \]

                  if -2.69999999999999977e55 < z < 5.49999999999999996e125

                  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. lower-*.f6430.4

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

                    \[\leadsto \color{blue}{-1 \cdot z} \]
                  5. Taylor expanded in z around 0

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

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

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

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

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

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

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

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

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

                      \[\leadsto x - \frac{1}{2} \cdot \log y \]
                    3. lower-log.f6441.4

                      \[\leadsto x - 0.5 \cdot \log y \]
                  10. Applied rewrites41.4%

                    \[\leadsto x - \color{blue}{0.5 \cdot \log y} \]
                  11. Step-by-step derivation
                    1. lift-*.f64N/A

                      \[\leadsto x - \frac{1}{2} \cdot \log y \]
                    2. lift-log.f64N/A

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

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

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

                      \[\leadsto x - \log \left(\sqrt{y}\right) \]
                    6. lower-sqrt.f6441.4

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

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

                Alternative 11: 38.4% accurate, 1.4× speedup?

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

                  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}{z \cdot \left(\left(\frac{x}{z} + \frac{y}{z}\right) - \left(1 + \frac{\log y \cdot \left(\frac{1}{2} + y\right)}{z}\right)\right)} \]
                  3. Step-by-step derivation
                    1. lower-*.f64N/A

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

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

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

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

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

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

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

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

                      \[\leadsto z \cdot \left(\left(\frac{x}{z} + \frac{y}{z}\right) - \left(1 + \frac{\log y \cdot \left(\frac{1}{2} + y\right)}{z}\right)\right) \]
                    10. lower-+.f6479.4

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

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

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

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

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

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

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

                      \[\leadsto z \cdot \left(y \cdot \left(\frac{1}{z} + \frac{\log \left(\frac{1}{y}\right)}{z}\right)\right) \]
                    6. lower-/.f6421.5

                      \[\leadsto z \cdot \left(y \cdot \left(\frac{1}{z} + \frac{\log \left(\frac{1}{y}\right)}{z}\right)\right) \]
                  7. Applied rewrites21.5%

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

                    \[\leadsto z \cdot \frac{x}{\color{blue}{z}} \]
                  9. Step-by-step derivation
                    1. lower-/.f6419.7

                      \[\leadsto z \cdot \frac{x}{z} \]
                  10. Applied rewrites19.7%

                    \[\leadsto z \cdot \frac{x}{\color{blue}{z}} \]

                  if -5.00000000000000027e31 < x < 5e103

                  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. lower-*.f6430.4

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

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

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

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

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

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

                Alternative 12: 30.4% accurate, 10.4× speedup?

                \[\begin{array}{l} \\ -z \end{array} \]
                (FPCore (x y z) :precision binary64 (- z))
                double code(double x, double y, double z) {
                	return -z;
                }
                
                module fmin_fmax_functions
                    implicit none
                    private
                    public fmax
                    public fmin
                
                    interface fmax
                        module procedure fmax88
                        module procedure fmax44
                        module procedure fmax84
                        module procedure fmax48
                    end interface
                    interface fmin
                        module procedure fmin88
                        module procedure fmin44
                        module procedure fmin84
                        module procedure fmin48
                    end interface
                contains
                    real(8) function fmax88(x, y) result (res)
                        real(8), intent (in) :: x
                        real(8), intent (in) :: y
                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                    end function
                    real(4) function fmax44(x, y) result (res)
                        real(4), intent (in) :: x
                        real(4), intent (in) :: y
                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                    end function
                    real(8) function fmax84(x, y) result(res)
                        real(8), intent (in) :: x
                        real(4), intent (in) :: y
                        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                    end function
                    real(8) function fmax48(x, y) result(res)
                        real(4), intent (in) :: x
                        real(8), intent (in) :: y
                        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                    end function
                    real(8) function fmin88(x, y) result (res)
                        real(8), intent (in) :: x
                        real(8), intent (in) :: y
                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                    end function
                    real(4) function fmin44(x, y) result (res)
                        real(4), intent (in) :: x
                        real(4), intent (in) :: y
                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                    end function
                    real(8) function fmin84(x, y) result(res)
                        real(8), intent (in) :: x
                        real(4), intent (in) :: y
                        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                    end function
                    real(8) function fmin48(x, y) result(res)
                        real(4), intent (in) :: x
                        real(8), intent (in) :: y
                        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                    end function
                end module
                
                real(8) function code(x, y, z)
                use fmin_fmax_functions
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    real(8), intent (in) :: z
                    code = -z
                end function
                
                public static double code(double x, double y, double z) {
                	return -z;
                }
                
                def code(x, y, z):
                	return -z
                
                function code(x, y, z)
                	return Float64(-z)
                end
                
                function tmp = code(x, y, z)
                	tmp = -z;
                end
                
                code[x_, y_, z_] := (-z)
                
                \begin{array}{l}
                
                \\
                -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 z around inf

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

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

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

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

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

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

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

                Reproduce

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