Numeric.SpecFunctions:logGamma from math-functions-0.1.5.2, A

Percentage Accurate: 100.0% → 100.0%
Time: 8.0s
Alternatives: 9
Speedup: N/A×

Specification

?
\[\left(x \cdot \left(y - 1\right) - y \cdot \frac{1}{2}\right) + \frac{918938533204673}{1000000000000000} \]
(FPCore (x y)
  :precision binary64
  (+ (- (* x (- y 1)) (* y 1/2)) 918938533204673/1000000000000000))
double code(double x, double y) {
	return ((x * (y - 1.0)) - (y * 0.5)) + 0.918938533204673;
}
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)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = ((x * (y - 1.0d0)) - (y * 0.5d0)) + 0.918938533204673d0
end function
public static double code(double x, double y) {
	return ((x * (y - 1.0)) - (y * 0.5)) + 0.918938533204673;
}
def code(x, y):
	return ((x * (y - 1.0)) - (y * 0.5)) + 0.918938533204673
function code(x, y)
	return Float64(Float64(Float64(x * Float64(y - 1.0)) - Float64(y * 0.5)) + 0.918938533204673)
end
function tmp = code(x, y)
	tmp = ((x * (y - 1.0)) - (y * 0.5)) + 0.918938533204673;
end
code[x_, y_] := N[(N[(N[(x * N[(y - 1), $MachinePrecision]), $MachinePrecision] - N[(y * 1/2), $MachinePrecision]), $MachinePrecision] + 918938533204673/1000000000000000), $MachinePrecision]
\left(x \cdot \left(y - 1\right) - y \cdot \frac{1}{2}\right) + \frac{918938533204673}{1000000000000000}

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 9 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: 100.0% accurate, 1.0× speedup?

\[\left(x \cdot \left(y - 1\right) - y \cdot \frac{1}{2}\right) + \frac{918938533204673}{1000000000000000} \]
(FPCore (x y)
  :precision binary64
  (+ (- (* x (- y 1)) (* y 1/2)) 918938533204673/1000000000000000))
double code(double x, double y) {
	return ((x * (y - 1.0)) - (y * 0.5)) + 0.918938533204673;
}
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)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = ((x * (y - 1.0d0)) - (y * 0.5d0)) + 0.918938533204673d0
end function
public static double code(double x, double y) {
	return ((x * (y - 1.0)) - (y * 0.5)) + 0.918938533204673;
}
def code(x, y):
	return ((x * (y - 1.0)) - (y * 0.5)) + 0.918938533204673
function code(x, y)
	return Float64(Float64(Float64(x * Float64(y - 1.0)) - Float64(y * 0.5)) + 0.918938533204673)
end
function tmp = code(x, y)
	tmp = ((x * (y - 1.0)) - (y * 0.5)) + 0.918938533204673;
end
code[x_, y_] := N[(N[(N[(x * N[(y - 1), $MachinePrecision]), $MachinePrecision] - N[(y * 1/2), $MachinePrecision]), $MachinePrecision] + 918938533204673/1000000000000000), $MachinePrecision]
\left(x \cdot \left(y - 1\right) - y \cdot \frac{1}{2}\right) + \frac{918938533204673}{1000000000000000}

Alternative 1: 100.0% accurate, 1.3× speedup?

\[\left(y \cdot \left(\frac{-1}{2} + x\right) - x\right) - \frac{-918938533204673}{1000000000000000} \]
(FPCore (x y)
  :precision binary64
  (- (- (* y (+ -1/2 x)) x) -918938533204673/1000000000000000))
double code(double x, double y) {
	return ((y * (-0.5 + x)) - x) - -0.918938533204673;
}
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)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = ((y * ((-0.5d0) + x)) - x) - (-0.918938533204673d0)
end function
public static double code(double x, double y) {
	return ((y * (-0.5 + x)) - x) - -0.918938533204673;
}
def code(x, y):
	return ((y * (-0.5 + x)) - x) - -0.918938533204673
function code(x, y)
	return Float64(Float64(Float64(y * Float64(-0.5 + x)) - x) - -0.918938533204673)
end
function tmp = code(x, y)
	tmp = ((y * (-0.5 + x)) - x) - -0.918938533204673;
end
code[x_, y_] := N[(N[(N[(y * N[(-1/2 + x), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] - -918938533204673/1000000000000000), $MachinePrecision]
\left(y \cdot \left(\frac{-1}{2} + x\right) - x\right) - \frac{-918938533204673}{1000000000000000}
Derivation
  1. Initial program 100.0%

    \[\left(x \cdot \left(y - 1\right) - y \cdot \frac{1}{2}\right) + \frac{918938533204673}{1000000000000000} \]
  2. Step-by-step derivation
    1. lift-+.f64N/A

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

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

      \[\leadsto \color{blue}{\left(x \cdot \left(y - 1\right) - y \cdot \frac{1}{2}\right) - \left(\mathsf{neg}\left(\frac{918938533204673}{1000000000000000}\right)\right)} \]
  3. Applied rewrites100.0%

    \[\leadsto \color{blue}{\left(y \cdot \left(\frac{-1}{2} + x\right) - x\right) - \frac{-918938533204673}{1000000000000000}} \]
  4. Add Preprocessing

Alternative 2: 98.5% accurate, 0.8× speedup?

\[\begin{array}{l} t_0 := x \cdot \left(y - 1\right)\\ \mathbf{if}\;x \leq -31500000000:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 860000000:\\ \;\;\;\;y \cdot \left(x - \frac{1}{2}\right) + \frac{918938533204673}{1000000000000000}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
(FPCore (x y)
  :precision binary64
  (let* ((t_0 (* x (- y 1))))
  (if (<= x -31500000000)
    t_0
    (if (<= x 860000000)
      (+ (* y (- x 1/2)) 918938533204673/1000000000000000)
      t_0))))
double code(double x, double y) {
	double t_0 = x * (y - 1.0);
	double tmp;
	if (x <= -31500000000.0) {
		tmp = t_0;
	} else if (x <= 860000000.0) {
		tmp = (y * (x - 0.5)) + 0.918938533204673;
	} 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)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: tmp
    t_0 = x * (y - 1.0d0)
    if (x <= (-31500000000.0d0)) then
        tmp = t_0
    else if (x <= 860000000.0d0) then
        tmp = (y * (x - 0.5d0)) + 0.918938533204673d0
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = x * (y - 1.0);
	double tmp;
	if (x <= -31500000000.0) {
		tmp = t_0;
	} else if (x <= 860000000.0) {
		tmp = (y * (x - 0.5)) + 0.918938533204673;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = x * (y - 1.0)
	tmp = 0
	if x <= -31500000000.0:
		tmp = t_0
	elif x <= 860000000.0:
		tmp = (y * (x - 0.5)) + 0.918938533204673
	else:
		tmp = t_0
	return tmp
function code(x, y)
	t_0 = Float64(x * Float64(y - 1.0))
	tmp = 0.0
	if (x <= -31500000000.0)
		tmp = t_0;
	elseif (x <= 860000000.0)
		tmp = Float64(Float64(y * Float64(x - 0.5)) + 0.918938533204673);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = x * (y - 1.0);
	tmp = 0.0;
	if (x <= -31500000000.0)
		tmp = t_0;
	elseif (x <= 860000000.0)
		tmp = (y * (x - 0.5)) + 0.918938533204673;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(x * N[(y - 1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -31500000000], t$95$0, If[LessEqual[x, 860000000], N[(N[(y * N[(x - 1/2), $MachinePrecision]), $MachinePrecision] + 918938533204673/1000000000000000), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := x \cdot \left(y - 1\right)\\
\mathbf{if}\;x \leq -31500000000:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 860000000:\\
\;\;\;\;y \cdot \left(x - \frac{1}{2}\right) + \frac{918938533204673}{1000000000000000}\\

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -3.15e10 or 8.6e8 < x

    1. Initial program 100.0%

      \[\left(x \cdot \left(y - 1\right) - y \cdot \frac{1}{2}\right) + \frac{918938533204673}{1000000000000000} \]
    2. Taylor expanded in y around 0

      \[\leadsto \color{blue}{\frac{918938533204673}{1000000000000000} + -1 \cdot x} \]
    3. Step-by-step derivation
      1. lower-+.f64N/A

        \[\leadsto \frac{918938533204673}{1000000000000000} + \color{blue}{-1 \cdot x} \]
      2. lower-*.f6450.1%

        \[\leadsto \frac{918938533204673}{1000000000000000} + -1 \cdot \color{blue}{x} \]
    4. Applied rewrites50.1%

      \[\leadsto \color{blue}{\frac{918938533204673}{1000000000000000} + -1 \cdot x} \]
    5. Taylor expanded in x around inf

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

        \[\leadsto x \cdot \color{blue}{\left(y - 1\right)} \]
      2. lower--.f6450.1%

        \[\leadsto x \cdot \left(y - \color{blue}{1}\right) \]
    7. Applied rewrites50.1%

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

    if -3.15e10 < x < 8.6e8

    1. Initial program 100.0%

      \[\left(x \cdot \left(y - 1\right) - y \cdot \frac{1}{2}\right) + \frac{918938533204673}{1000000000000000} \]
    2. Taylor expanded in y around inf

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

        \[\leadsto y \cdot \color{blue}{\left(x - \frac{1}{2}\right)} + \frac{918938533204673}{1000000000000000} \]
      2. lower--.f6475.4%

        \[\leadsto y \cdot \left(x - \color{blue}{\frac{1}{2}}\right) + \frac{918938533204673}{1000000000000000} \]
    4. Applied rewrites75.4%

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

Alternative 3: 97.7% accurate, 1.0× speedup?

\[\begin{array}{l} t_0 := x \cdot \left(y - 1\right)\\ \mathbf{if}\;x \leq -31500000000:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 380:\\ \;\;\;\;\frac{-1}{2} \cdot y + \frac{918938533204673}{1000000000000000}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
(FPCore (x y)
  :precision binary64
  (let* ((t_0 (* x (- y 1))))
  (if (<= x -31500000000)
    t_0
    (if (<= x 380)
      (+ (* -1/2 y) 918938533204673/1000000000000000)
      t_0))))
double code(double x, double y) {
	double t_0 = x * (y - 1.0);
	double tmp;
	if (x <= -31500000000.0) {
		tmp = t_0;
	} else if (x <= 380.0) {
		tmp = (-0.5 * y) + 0.918938533204673;
	} 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)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: tmp
    t_0 = x * (y - 1.0d0)
    if (x <= (-31500000000.0d0)) then
        tmp = t_0
    else if (x <= 380.0d0) then
        tmp = ((-0.5d0) * y) + 0.918938533204673d0
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = x * (y - 1.0);
	double tmp;
	if (x <= -31500000000.0) {
		tmp = t_0;
	} else if (x <= 380.0) {
		tmp = (-0.5 * y) + 0.918938533204673;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = x * (y - 1.0)
	tmp = 0
	if x <= -31500000000.0:
		tmp = t_0
	elif x <= 380.0:
		tmp = (-0.5 * y) + 0.918938533204673
	else:
		tmp = t_0
	return tmp
function code(x, y)
	t_0 = Float64(x * Float64(y - 1.0))
	tmp = 0.0
	if (x <= -31500000000.0)
		tmp = t_0;
	elseif (x <= 380.0)
		tmp = Float64(Float64(-0.5 * y) + 0.918938533204673);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = x * (y - 1.0);
	tmp = 0.0;
	if (x <= -31500000000.0)
		tmp = t_0;
	elseif (x <= 380.0)
		tmp = (-0.5 * y) + 0.918938533204673;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(x * N[(y - 1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -31500000000], t$95$0, If[LessEqual[x, 380], N[(N[(-1/2 * y), $MachinePrecision] + 918938533204673/1000000000000000), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := x \cdot \left(y - 1\right)\\
\mathbf{if}\;x \leq -31500000000:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 380:\\
\;\;\;\;\frac{-1}{2} \cdot y + \frac{918938533204673}{1000000000000000}\\

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -3.15e10 or 380 < x

    1. Initial program 100.0%

      \[\left(x \cdot \left(y - 1\right) - y \cdot \frac{1}{2}\right) + \frac{918938533204673}{1000000000000000} \]
    2. Taylor expanded in y around 0

      \[\leadsto \color{blue}{\frac{918938533204673}{1000000000000000} + -1 \cdot x} \]
    3. Step-by-step derivation
      1. lower-+.f64N/A

        \[\leadsto \frac{918938533204673}{1000000000000000} + \color{blue}{-1 \cdot x} \]
      2. lower-*.f6450.1%

        \[\leadsto \frac{918938533204673}{1000000000000000} + -1 \cdot \color{blue}{x} \]
    4. Applied rewrites50.1%

      \[\leadsto \color{blue}{\frac{918938533204673}{1000000000000000} + -1 \cdot x} \]
    5. Taylor expanded in x around inf

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

        \[\leadsto x \cdot \color{blue}{\left(y - 1\right)} \]
      2. lower--.f6450.1%

        \[\leadsto x \cdot \left(y - \color{blue}{1}\right) \]
    7. Applied rewrites50.1%

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

    if -3.15e10 < x < 380

    1. Initial program 100.0%

      \[\left(x \cdot \left(y - 1\right) - y \cdot \frac{1}{2}\right) + \frac{918938533204673}{1000000000000000} \]
    2. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\frac{-1}{2} \cdot y} + \frac{918938533204673}{1000000000000000} \]
    3. Step-by-step derivation
      1. lower-*.f6451.1%

        \[\leadsto \frac{-1}{2} \cdot \color{blue}{y} + \frac{918938533204673}{1000000000000000} \]
    4. Applied rewrites51.1%

      \[\leadsto \color{blue}{\frac{-1}{2} \cdot y} + \frac{918938533204673}{1000000000000000} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 4: 97.4% accurate, 1.0× speedup?

\[\begin{array}{l} t_0 := y \cdot \left(x - \frac{1}{2}\right)\\ \mathbf{if}\;y \leq -25000:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq \frac{11}{2}:\\ \;\;\;\;\frac{918938533204673}{1000000000000000} - x\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
(FPCore (x y)
  :precision binary64
  (let* ((t_0 (* y (- x 1/2))))
  (if (<= y -25000)
    t_0
    (if (<= y 11/2) (- 918938533204673/1000000000000000 x) t_0))))
double code(double x, double y) {
	double t_0 = y * (x - 0.5);
	double tmp;
	if (y <= -25000.0) {
		tmp = t_0;
	} else if (y <= 5.5) {
		tmp = 0.918938533204673 - x;
	} 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)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: tmp
    t_0 = y * (x - 0.5d0)
    if (y <= (-25000.0d0)) then
        tmp = t_0
    else if (y <= 5.5d0) then
        tmp = 0.918938533204673d0 - x
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = y * (x - 0.5);
	double tmp;
	if (y <= -25000.0) {
		tmp = t_0;
	} else if (y <= 5.5) {
		tmp = 0.918938533204673 - x;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = y * (x - 0.5)
	tmp = 0
	if y <= -25000.0:
		tmp = t_0
	elif y <= 5.5:
		tmp = 0.918938533204673 - x
	else:
		tmp = t_0
	return tmp
function code(x, y)
	t_0 = Float64(y * Float64(x - 0.5))
	tmp = 0.0
	if (y <= -25000.0)
		tmp = t_0;
	elseif (y <= 5.5)
		tmp = Float64(0.918938533204673 - x);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = y * (x - 0.5);
	tmp = 0.0;
	if (y <= -25000.0)
		tmp = t_0;
	elseif (y <= 5.5)
		tmp = 0.918938533204673 - x;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(y * N[(x - 1/2), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -25000], t$95$0, If[LessEqual[y, 11/2], N[(918938533204673/1000000000000000 - x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := y \cdot \left(x - \frac{1}{2}\right)\\
\mathbf{if}\;y \leq -25000:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq \frac{11}{2}:\\
\;\;\;\;\frac{918938533204673}{1000000000000000} - x\\

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -25000 or 5.5 < y

    1. Initial program 100.0%

      \[\left(x \cdot \left(y - 1\right) - y \cdot \frac{1}{2}\right) + \frac{918938533204673}{1000000000000000} \]
    2. Taylor expanded in y around 0

      \[\leadsto \color{blue}{\frac{918938533204673}{1000000000000000} + -1 \cdot x} \]
    3. Step-by-step derivation
      1. lower-+.f64N/A

        \[\leadsto \frac{918938533204673}{1000000000000000} + \color{blue}{-1 \cdot x} \]
      2. lower-*.f6450.1%

        \[\leadsto \frac{918938533204673}{1000000000000000} + -1 \cdot \color{blue}{x} \]
    4. Applied rewrites50.1%

      \[\leadsto \color{blue}{\frac{918938533204673}{1000000000000000} + -1 \cdot x} \]
    5. Taylor expanded in x around 0

      \[\leadsto \frac{918938533204673}{1000000000000000} \]
    6. Step-by-step derivation
      1. Applied rewrites26.2%

        \[\leadsto \frac{918938533204673}{1000000000000000} \]
      2. Taylor expanded in y around inf

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

          \[\leadsto y \cdot \color{blue}{\left(x - \frac{1}{2}\right)} \]
        2. lower--.f6451.3%

          \[\leadsto y \cdot \left(x - \color{blue}{\frac{1}{2}}\right) \]
      4. Applied rewrites51.3%

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

      if -25000 < y < 5.5

      1. Initial program 100.0%

        \[\left(x \cdot \left(y - 1\right) - y \cdot \frac{1}{2}\right) + \frac{918938533204673}{1000000000000000} \]
      2. Step-by-step derivation
        1. lift-+.f64N/A

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

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

          \[\leadsto \color{blue}{\left(x \cdot \left(y - 1\right) - y \cdot \frac{1}{2}\right) - \left(\mathsf{neg}\left(\frac{918938533204673}{1000000000000000}\right)\right)} \]
      3. Applied rewrites100.0%

        \[\leadsto \color{blue}{\left(y \cdot \left(\frac{-1}{2} + x\right) - x\right) - \frac{-918938533204673}{1000000000000000}} \]
      4. Taylor expanded in y around 0

        \[\leadsto \color{blue}{\frac{918938533204673}{1000000000000000} - x} \]
      5. Step-by-step derivation
        1. lower--.f6450.1%

          \[\leadsto \frac{918938533204673}{1000000000000000} - \color{blue}{x} \]
      6. Applied rewrites50.1%

        \[\leadsto \color{blue}{\frac{918938533204673}{1000000000000000} - x} \]
    7. Recombined 2 regimes into one program.
    8. Add Preprocessing

    Alternative 5: 73.6% accurate, 0.2× speedup?

    \[\begin{array}{l} t_0 := x \cdot \left(y - 1\right)\\ t_1 := \left(t\_0 - y \cdot \frac{1}{2}\right) + \frac{918938533204673}{1000000000000000}\\ \mathbf{if}\;t\_1 \leq -19999999999999999022865849278470264106778320922372433398933167781147023447499918366556775778344680456191750897534276513413896506501104986185271471852552907987540733076746850001554473076458172448768:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;t\_1 \leq -10000000000:\\ \;\;\;\;y \cdot \frac{-1}{2}\\ \mathbf{elif}\;t\_1 \leq 500000000000000039145770202298121921152680149943058432:\\ \;\;\;\;\frac{918938533204673}{1000000000000000} - x\\ \mathbf{elif}\;t\_1 \leq 2999999999999999980486599061817381213271671188243728977063313482190191329280:\\ \;\;\;\;y \cdot \frac{-1}{2}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
    (FPCore (x y)
      :precision binary64
      (let* ((t_0 (* x (- y 1)))
           (t_1 (+ (- t_0 (* y 1/2)) 918938533204673/1000000000000000)))
      (if (<=
           t_1
           -19999999999999999022865849278470264106778320922372433398933167781147023447499918366556775778344680456191750897534276513413896506501104986185271471852552907987540733076746850001554473076458172448768)
        t_0
        (if (<= t_1 -10000000000)
          (* y -1/2)
          (if (<=
               t_1
               500000000000000039145770202298121921152680149943058432)
            (- 918938533204673/1000000000000000 x)
            (if (<=
                 t_1
                 2999999999999999980486599061817381213271671188243728977063313482190191329280)
              (* y -1/2)
              t_0))))))
    double code(double x, double y) {
    	double t_0 = x * (y - 1.0);
    	double t_1 = (t_0 - (y * 0.5)) + 0.918938533204673;
    	double tmp;
    	if (t_1 <= -2e+196) {
    		tmp = t_0;
    	} else if (t_1 <= -10000000000.0) {
    		tmp = y * -0.5;
    	} else if (t_1 <= 5e+53) {
    		tmp = 0.918938533204673 - x;
    	} else if (t_1 <= 3e+75) {
    		tmp = y * -0.5;
    	} 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)
    use fmin_fmax_functions
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        real(8) :: t_0
        real(8) :: t_1
        real(8) :: tmp
        t_0 = x * (y - 1.0d0)
        t_1 = (t_0 - (y * 0.5d0)) + 0.918938533204673d0
        if (t_1 <= (-2d+196)) then
            tmp = t_0
        else if (t_1 <= (-10000000000.0d0)) then
            tmp = y * (-0.5d0)
        else if (t_1 <= 5d+53) then
            tmp = 0.918938533204673d0 - x
        else if (t_1 <= 3d+75) then
            tmp = y * (-0.5d0)
        else
            tmp = t_0
        end if
        code = tmp
    end function
    
    public static double code(double x, double y) {
    	double t_0 = x * (y - 1.0);
    	double t_1 = (t_0 - (y * 0.5)) + 0.918938533204673;
    	double tmp;
    	if (t_1 <= -2e+196) {
    		tmp = t_0;
    	} else if (t_1 <= -10000000000.0) {
    		tmp = y * -0.5;
    	} else if (t_1 <= 5e+53) {
    		tmp = 0.918938533204673 - x;
    	} else if (t_1 <= 3e+75) {
    		tmp = y * -0.5;
    	} else {
    		tmp = t_0;
    	}
    	return tmp;
    }
    
    def code(x, y):
    	t_0 = x * (y - 1.0)
    	t_1 = (t_0 - (y * 0.5)) + 0.918938533204673
    	tmp = 0
    	if t_1 <= -2e+196:
    		tmp = t_0
    	elif t_1 <= -10000000000.0:
    		tmp = y * -0.5
    	elif t_1 <= 5e+53:
    		tmp = 0.918938533204673 - x
    	elif t_1 <= 3e+75:
    		tmp = y * -0.5
    	else:
    		tmp = t_0
    	return tmp
    
    function code(x, y)
    	t_0 = Float64(x * Float64(y - 1.0))
    	t_1 = Float64(Float64(t_0 - Float64(y * 0.5)) + 0.918938533204673)
    	tmp = 0.0
    	if (t_1 <= -2e+196)
    		tmp = t_0;
    	elseif (t_1 <= -10000000000.0)
    		tmp = Float64(y * -0.5);
    	elseif (t_1 <= 5e+53)
    		tmp = Float64(0.918938533204673 - x);
    	elseif (t_1 <= 3e+75)
    		tmp = Float64(y * -0.5);
    	else
    		tmp = t_0;
    	end
    	return tmp
    end
    
    function tmp_2 = code(x, y)
    	t_0 = x * (y - 1.0);
    	t_1 = (t_0 - (y * 0.5)) + 0.918938533204673;
    	tmp = 0.0;
    	if (t_1 <= -2e+196)
    		tmp = t_0;
    	elseif (t_1 <= -10000000000.0)
    		tmp = y * -0.5;
    	elseif (t_1 <= 5e+53)
    		tmp = 0.918938533204673 - x;
    	elseif (t_1 <= 3e+75)
    		tmp = y * -0.5;
    	else
    		tmp = t_0;
    	end
    	tmp_2 = tmp;
    end
    
    code[x_, y_] := Block[{t$95$0 = N[(x * N[(y - 1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 - N[(y * 1/2), $MachinePrecision]), $MachinePrecision] + 918938533204673/1000000000000000), $MachinePrecision]}, If[LessEqual[t$95$1, -19999999999999999022865849278470264106778320922372433398933167781147023447499918366556775778344680456191750897534276513413896506501104986185271471852552907987540733076746850001554473076458172448768], t$95$0, If[LessEqual[t$95$1, -10000000000], N[(y * -1/2), $MachinePrecision], If[LessEqual[t$95$1, 500000000000000039145770202298121921152680149943058432], N[(918938533204673/1000000000000000 - x), $MachinePrecision], If[LessEqual[t$95$1, 2999999999999999980486599061817381213271671188243728977063313482190191329280], N[(y * -1/2), $MachinePrecision], t$95$0]]]]]]
    
    \begin{array}{l}
    t_0 := x \cdot \left(y - 1\right)\\
    t_1 := \left(t\_0 - y \cdot \frac{1}{2}\right) + \frac{918938533204673}{1000000000000000}\\
    \mathbf{if}\;t\_1 \leq -19999999999999999022865849278470264106778320922372433398933167781147023447499918366556775778344680456191750897534276513413896506501104986185271471852552907987540733076746850001554473076458172448768:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;t\_1 \leq -10000000000:\\
    \;\;\;\;y \cdot \frac{-1}{2}\\
    
    \mathbf{elif}\;t\_1 \leq 500000000000000039145770202298121921152680149943058432:\\
    \;\;\;\;\frac{918938533204673}{1000000000000000} - x\\
    
    \mathbf{elif}\;t\_1 \leq 2999999999999999980486599061817381213271671188243728977063313482190191329280:\\
    \;\;\;\;y \cdot \frac{-1}{2}\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_0\\
    
    
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if (+.f64 (-.f64 (*.f64 x (-.f64 y #s(literal 1 binary64))) (*.f64 y #s(literal 1/2 binary64))) #s(literal 918938533204673/1000000000000000 binary64)) < -1.9999999999999999e196 or 3e75 < (+.f64 (-.f64 (*.f64 x (-.f64 y #s(literal 1 binary64))) (*.f64 y #s(literal 1/2 binary64))) #s(literal 918938533204673/1000000000000000 binary64))

      1. Initial program 100.0%

        \[\left(x \cdot \left(y - 1\right) - y \cdot \frac{1}{2}\right) + \frac{918938533204673}{1000000000000000} \]
      2. Taylor expanded in y around 0

        \[\leadsto \color{blue}{\frac{918938533204673}{1000000000000000} + -1 \cdot x} \]
      3. Step-by-step derivation
        1. lower-+.f64N/A

          \[\leadsto \frac{918938533204673}{1000000000000000} + \color{blue}{-1 \cdot x} \]
        2. lower-*.f6450.1%

          \[\leadsto \frac{918938533204673}{1000000000000000} + -1 \cdot \color{blue}{x} \]
      4. Applied rewrites50.1%

        \[\leadsto \color{blue}{\frac{918938533204673}{1000000000000000} + -1 \cdot x} \]
      5. Taylor expanded in x around inf

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

          \[\leadsto x \cdot \color{blue}{\left(y - 1\right)} \]
        2. lower--.f6450.1%

          \[\leadsto x \cdot \left(y - \color{blue}{1}\right) \]
      7. Applied rewrites50.1%

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

      if -1.9999999999999999e196 < (+.f64 (-.f64 (*.f64 x (-.f64 y #s(literal 1 binary64))) (*.f64 y #s(literal 1/2 binary64))) #s(literal 918938533204673/1000000000000000 binary64)) < -1e10 or 5.0000000000000004e53 < (+.f64 (-.f64 (*.f64 x (-.f64 y #s(literal 1 binary64))) (*.f64 y #s(literal 1/2 binary64))) #s(literal 918938533204673/1000000000000000 binary64)) < 3e75

      1. Initial program 100.0%

        \[\left(x \cdot \left(y - 1\right) - y \cdot \frac{1}{2}\right) + \frac{918938533204673}{1000000000000000} \]
      2. Taylor expanded in y around 0

        \[\leadsto \color{blue}{\frac{918938533204673}{1000000000000000} + -1 \cdot x} \]
      3. Step-by-step derivation
        1. lower-+.f64N/A

          \[\leadsto \frac{918938533204673}{1000000000000000} + \color{blue}{-1 \cdot x} \]
        2. lower-*.f6450.1%

          \[\leadsto \frac{918938533204673}{1000000000000000} + -1 \cdot \color{blue}{x} \]
      4. Applied rewrites50.1%

        \[\leadsto \color{blue}{\frac{918938533204673}{1000000000000000} + -1 \cdot x} \]
      5. Taylor expanded in x around 0

        \[\leadsto \frac{918938533204673}{1000000000000000} \]
      6. Step-by-step derivation
        1. Applied rewrites26.2%

          \[\leadsto \frac{918938533204673}{1000000000000000} \]
        2. Taylor expanded in y around inf

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

            \[\leadsto y \cdot \color{blue}{\left(x - \frac{1}{2}\right)} \]
          2. lower--.f6451.3%

            \[\leadsto y \cdot \left(x - \color{blue}{\frac{1}{2}}\right) \]
        4. Applied rewrites51.3%

          \[\leadsto \color{blue}{y \cdot \left(x - \frac{1}{2}\right)} \]
        5. Taylor expanded in x around 0

          \[\leadsto y \cdot \frac{-1}{2} \]
        6. Step-by-step derivation
          1. Applied rewrites26.9%

            \[\leadsto y \cdot \frac{-1}{2} \]

          if -1e10 < (+.f64 (-.f64 (*.f64 x (-.f64 y #s(literal 1 binary64))) (*.f64 y #s(literal 1/2 binary64))) #s(literal 918938533204673/1000000000000000 binary64)) < 5.0000000000000004e53

          1. Initial program 100.0%

            \[\left(x \cdot \left(y - 1\right) - y \cdot \frac{1}{2}\right) + \frac{918938533204673}{1000000000000000} \]
          2. Step-by-step derivation
            1. lift-+.f64N/A

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

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

              \[\leadsto \color{blue}{\left(x \cdot \left(y - 1\right) - y \cdot \frac{1}{2}\right) - \left(\mathsf{neg}\left(\frac{918938533204673}{1000000000000000}\right)\right)} \]
          3. Applied rewrites100.0%

            \[\leadsto \color{blue}{\left(y \cdot \left(\frac{-1}{2} + x\right) - x\right) - \frac{-918938533204673}{1000000000000000}} \]
          4. Taylor expanded in y around 0

            \[\leadsto \color{blue}{\frac{918938533204673}{1000000000000000} - x} \]
          5. Step-by-step derivation
            1. lower--.f6450.1%

              \[\leadsto \frac{918938533204673}{1000000000000000} - \color{blue}{x} \]
          6. Applied rewrites50.1%

            \[\leadsto \color{blue}{\frac{918938533204673}{1000000000000000} - x} \]
        7. Recombined 3 regimes into one program.
        8. Add Preprocessing

        Alternative 6: 72.9% accurate, 0.7× speedup?

        \[\begin{array}{l} \mathbf{if}\;y \leq -60000000000000002807012422227762526562645946359988349865723547266293968589294224216830388071681671922486927166140031906922005288910511928360257579557507738543076049824450300405816469334962855765094694912:\\ \;\;\;\;y \cdot \frac{-1}{2}\\ \mathbf{elif}\;y \leq -4499999999999999974429565382633177664789268512599431293281255448379551384886050990420847233375141888:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq -25000:\\ \;\;\;\;y \cdot \frac{-1}{2}\\ \mathbf{elif}\;y \leq \frac{11}{2}:\\ \;\;\;\;\frac{918938533204673}{1000000000000000} - x\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{-1}{2}\\ \end{array} \]
        (FPCore (x y)
          :precision binary64
          (if (<=
             y
             -60000000000000002807012422227762526562645946359988349865723547266293968589294224216830388071681671922486927166140031906922005288910511928360257579557507738543076049824450300405816469334962855765094694912)
          (* y -1/2)
          (if (<=
               y
               -4499999999999999974429565382633177664789268512599431293281255448379551384886050990420847233375141888)
            (* x y)
            (if (<= y -25000)
              (* y -1/2)
              (if (<= y 11/2)
                (- 918938533204673/1000000000000000 x)
                (* y -1/2))))))
        double code(double x, double y) {
        	double tmp;
        	if (y <= -6e+202) {
        		tmp = y * -0.5;
        	} else if (y <= -4.5e+99) {
        		tmp = x * y;
        	} else if (y <= -25000.0) {
        		tmp = y * -0.5;
        	} else if (y <= 5.5) {
        		tmp = 0.918938533204673 - x;
        	} else {
        		tmp = y * -0.5;
        	}
        	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)
        use fmin_fmax_functions
            real(8), intent (in) :: x
            real(8), intent (in) :: y
            real(8) :: tmp
            if (y <= (-6d+202)) then
                tmp = y * (-0.5d0)
            else if (y <= (-4.5d+99)) then
                tmp = x * y
            else if (y <= (-25000.0d0)) then
                tmp = y * (-0.5d0)
            else if (y <= 5.5d0) then
                tmp = 0.918938533204673d0 - x
            else
                tmp = y * (-0.5d0)
            end if
            code = tmp
        end function
        
        public static double code(double x, double y) {
        	double tmp;
        	if (y <= -6e+202) {
        		tmp = y * -0.5;
        	} else if (y <= -4.5e+99) {
        		tmp = x * y;
        	} else if (y <= -25000.0) {
        		tmp = y * -0.5;
        	} else if (y <= 5.5) {
        		tmp = 0.918938533204673 - x;
        	} else {
        		tmp = y * -0.5;
        	}
        	return tmp;
        }
        
        def code(x, y):
        	tmp = 0
        	if y <= -6e+202:
        		tmp = y * -0.5
        	elif y <= -4.5e+99:
        		tmp = x * y
        	elif y <= -25000.0:
        		tmp = y * -0.5
        	elif y <= 5.5:
        		tmp = 0.918938533204673 - x
        	else:
        		tmp = y * -0.5
        	return tmp
        
        function code(x, y)
        	tmp = 0.0
        	if (y <= -6e+202)
        		tmp = Float64(y * -0.5);
        	elseif (y <= -4.5e+99)
        		tmp = Float64(x * y);
        	elseif (y <= -25000.0)
        		tmp = Float64(y * -0.5);
        	elseif (y <= 5.5)
        		tmp = Float64(0.918938533204673 - x);
        	else
        		tmp = Float64(y * -0.5);
        	end
        	return tmp
        end
        
        function tmp_2 = code(x, y)
        	tmp = 0.0;
        	if (y <= -6e+202)
        		tmp = y * -0.5;
        	elseif (y <= -4.5e+99)
        		tmp = x * y;
        	elseif (y <= -25000.0)
        		tmp = y * -0.5;
        	elseif (y <= 5.5)
        		tmp = 0.918938533204673 - x;
        	else
        		tmp = y * -0.5;
        	end
        	tmp_2 = tmp;
        end
        
        code[x_, y_] := If[LessEqual[y, -60000000000000002807012422227762526562645946359988349865723547266293968589294224216830388071681671922486927166140031906922005288910511928360257579557507738543076049824450300405816469334962855765094694912], N[(y * -1/2), $MachinePrecision], If[LessEqual[y, -4499999999999999974429565382633177664789268512599431293281255448379551384886050990420847233375141888], N[(x * y), $MachinePrecision], If[LessEqual[y, -25000], N[(y * -1/2), $MachinePrecision], If[LessEqual[y, 11/2], N[(918938533204673/1000000000000000 - x), $MachinePrecision], N[(y * -1/2), $MachinePrecision]]]]]
        
        \begin{array}{l}
        \mathbf{if}\;y \leq -60000000000000002807012422227762526562645946359988349865723547266293968589294224216830388071681671922486927166140031906922005288910511928360257579557507738543076049824450300405816469334962855765094694912:\\
        \;\;\;\;y \cdot \frac{-1}{2}\\
        
        \mathbf{elif}\;y \leq -4499999999999999974429565382633177664789268512599431293281255448379551384886050990420847233375141888:\\
        \;\;\;\;x \cdot y\\
        
        \mathbf{elif}\;y \leq -25000:\\
        \;\;\;\;y \cdot \frac{-1}{2}\\
        
        \mathbf{elif}\;y \leq \frac{11}{2}:\\
        \;\;\;\;\frac{918938533204673}{1000000000000000} - x\\
        
        \mathbf{else}:\\
        \;\;\;\;y \cdot \frac{-1}{2}\\
        
        
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if y < -6.0000000000000003e202 or -4.5e99 < y < -25000 or 5.5 < y

          1. Initial program 100.0%

            \[\left(x \cdot \left(y - 1\right) - y \cdot \frac{1}{2}\right) + \frac{918938533204673}{1000000000000000} \]
          2. Taylor expanded in y around 0

            \[\leadsto \color{blue}{\frac{918938533204673}{1000000000000000} + -1 \cdot x} \]
          3. Step-by-step derivation
            1. lower-+.f64N/A

              \[\leadsto \frac{918938533204673}{1000000000000000} + \color{blue}{-1 \cdot x} \]
            2. lower-*.f6450.1%

              \[\leadsto \frac{918938533204673}{1000000000000000} + -1 \cdot \color{blue}{x} \]
          4. Applied rewrites50.1%

            \[\leadsto \color{blue}{\frac{918938533204673}{1000000000000000} + -1 \cdot x} \]
          5. Taylor expanded in x around 0

            \[\leadsto \frac{918938533204673}{1000000000000000} \]
          6. Step-by-step derivation
            1. Applied rewrites26.2%

              \[\leadsto \frac{918938533204673}{1000000000000000} \]
            2. Taylor expanded in y around inf

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

                \[\leadsto y \cdot \color{blue}{\left(x - \frac{1}{2}\right)} \]
              2. lower--.f6451.3%

                \[\leadsto y \cdot \left(x - \color{blue}{\frac{1}{2}}\right) \]
            4. Applied rewrites51.3%

              \[\leadsto \color{blue}{y \cdot \left(x - \frac{1}{2}\right)} \]
            5. Taylor expanded in x around 0

              \[\leadsto y \cdot \frac{-1}{2} \]
            6. Step-by-step derivation
              1. Applied rewrites26.9%

                \[\leadsto y \cdot \frac{-1}{2} \]

              if -6.0000000000000003e202 < y < -4.5e99

              1. Initial program 100.0%

                \[\left(x \cdot \left(y - 1\right) - y \cdot \frac{1}{2}\right) + \frac{918938533204673}{1000000000000000} \]
              2. Taylor expanded in y around 0

                \[\leadsto \color{blue}{\frac{918938533204673}{1000000000000000} + -1 \cdot x} \]
              3. Step-by-step derivation
                1. lower-+.f64N/A

                  \[\leadsto \frac{918938533204673}{1000000000000000} + \color{blue}{-1 \cdot x} \]
                2. lower-*.f6450.1%

                  \[\leadsto \frac{918938533204673}{1000000000000000} + -1 \cdot \color{blue}{x} \]
              4. Applied rewrites50.1%

                \[\leadsto \color{blue}{\frac{918938533204673}{1000000000000000} + -1 \cdot x} \]
              5. Taylor expanded in x around inf

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

                  \[\leadsto x \cdot \color{blue}{\left(y - 1\right)} \]
                2. lower--.f6450.1%

                  \[\leadsto x \cdot \left(y - \color{blue}{1}\right) \]
              7. Applied rewrites50.1%

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

                \[\leadsto x \cdot \color{blue}{y} \]
              9. Step-by-step derivation
                1. lower-*.f6426.5%

                  \[\leadsto x \cdot y \]
              10. Applied rewrites26.5%

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

              if -25000 < y < 5.5

              1. Initial program 100.0%

                \[\left(x \cdot \left(y - 1\right) - y \cdot \frac{1}{2}\right) + \frac{918938533204673}{1000000000000000} \]
              2. Step-by-step derivation
                1. lift-+.f64N/A

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

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

                  \[\leadsto \color{blue}{\left(x \cdot \left(y - 1\right) - y \cdot \frac{1}{2}\right) - \left(\mathsf{neg}\left(\frac{918938533204673}{1000000000000000}\right)\right)} \]
              3. Applied rewrites100.0%

                \[\leadsto \color{blue}{\left(y \cdot \left(\frac{-1}{2} + x\right) - x\right) - \frac{-918938533204673}{1000000000000000}} \]
              4. Taylor expanded in y around 0

                \[\leadsto \color{blue}{\frac{918938533204673}{1000000000000000} - x} \]
              5. Step-by-step derivation
                1. lower--.f6450.1%

                  \[\leadsto \frac{918938533204673}{1000000000000000} - \color{blue}{x} \]
              6. Applied rewrites50.1%

                \[\leadsto \color{blue}{\frac{918938533204673}{1000000000000000} - x} \]
            7. Recombined 3 regimes into one program.
            8. Add Preprocessing

            Alternative 7: 72.0% accurate, 1.1× speedup?

            \[\begin{array}{l} \mathbf{if}\;y \leq -1350000000000000:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq \frac{11}{2}:\\ \;\;\;\;\frac{918938533204673}{1000000000000000} - x\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
            (FPCore (x y)
              :precision binary64
              (if (<= y -1350000000000000)
              (* x y)
              (if (<= y 11/2) (- 918938533204673/1000000000000000 x) (* x y))))
            double code(double x, double y) {
            	double tmp;
            	if (y <= -1.35e+15) {
            		tmp = x * y;
            	} else if (y <= 5.5) {
            		tmp = 0.918938533204673 - x;
            	} else {
            		tmp = x * y;
            	}
            	return tmp;
            }
            
            module fmin_fmax_functions
                implicit none
                private
                public fmax
                public fmin
            
                interface fmax
                    module procedure fmax88
                    module procedure fmax44
                    module procedure fmax84
                    module procedure fmax48
                end interface
                interface fmin
                    module procedure fmin88
                    module procedure fmin44
                    module procedure fmin84
                    module procedure fmin48
                end interface
            contains
                real(8) function fmax88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(4) function fmax44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(8) function fmax84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmax48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                end function
                real(8) function fmin88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(4) function fmin44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(8) function fmin84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmin48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                end function
            end module
            
            real(8) function code(x, y)
            use fmin_fmax_functions
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                real(8) :: tmp
                if (y <= (-1.35d+15)) then
                    tmp = x * y
                else if (y <= 5.5d0) then
                    tmp = 0.918938533204673d0 - x
                else
                    tmp = x * y
                end if
                code = tmp
            end function
            
            public static double code(double x, double y) {
            	double tmp;
            	if (y <= -1.35e+15) {
            		tmp = x * y;
            	} else if (y <= 5.5) {
            		tmp = 0.918938533204673 - x;
            	} else {
            		tmp = x * y;
            	}
            	return tmp;
            }
            
            def code(x, y):
            	tmp = 0
            	if y <= -1.35e+15:
            		tmp = x * y
            	elif y <= 5.5:
            		tmp = 0.918938533204673 - x
            	else:
            		tmp = x * y
            	return tmp
            
            function code(x, y)
            	tmp = 0.0
            	if (y <= -1.35e+15)
            		tmp = Float64(x * y);
            	elseif (y <= 5.5)
            		tmp = Float64(0.918938533204673 - x);
            	else
            		tmp = Float64(x * y);
            	end
            	return tmp
            end
            
            function tmp_2 = code(x, y)
            	tmp = 0.0;
            	if (y <= -1.35e+15)
            		tmp = x * y;
            	elseif (y <= 5.5)
            		tmp = 0.918938533204673 - x;
            	else
            		tmp = x * y;
            	end
            	tmp_2 = tmp;
            end
            
            code[x_, y_] := If[LessEqual[y, -1350000000000000], N[(x * y), $MachinePrecision], If[LessEqual[y, 11/2], N[(918938533204673/1000000000000000 - x), $MachinePrecision], N[(x * y), $MachinePrecision]]]
            
            \begin{array}{l}
            \mathbf{if}\;y \leq -1350000000000000:\\
            \;\;\;\;x \cdot y\\
            
            \mathbf{elif}\;y \leq \frac{11}{2}:\\
            \;\;\;\;\frac{918938533204673}{1000000000000000} - x\\
            
            \mathbf{else}:\\
            \;\;\;\;x \cdot y\\
            
            
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if y < -1.35e15 or 5.5 < y

              1. Initial program 100.0%

                \[\left(x \cdot \left(y - 1\right) - y \cdot \frac{1}{2}\right) + \frac{918938533204673}{1000000000000000} \]
              2. Taylor expanded in y around 0

                \[\leadsto \color{blue}{\frac{918938533204673}{1000000000000000} + -1 \cdot x} \]
              3. Step-by-step derivation
                1. lower-+.f64N/A

                  \[\leadsto \frac{918938533204673}{1000000000000000} + \color{blue}{-1 \cdot x} \]
                2. lower-*.f6450.1%

                  \[\leadsto \frac{918938533204673}{1000000000000000} + -1 \cdot \color{blue}{x} \]
              4. Applied rewrites50.1%

                \[\leadsto \color{blue}{\frac{918938533204673}{1000000000000000} + -1 \cdot x} \]
              5. Taylor expanded in x around inf

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

                  \[\leadsto x \cdot \color{blue}{\left(y - 1\right)} \]
                2. lower--.f6450.1%

                  \[\leadsto x \cdot \left(y - \color{blue}{1}\right) \]
              7. Applied rewrites50.1%

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

                \[\leadsto x \cdot \color{blue}{y} \]
              9. Step-by-step derivation
                1. lower-*.f6426.5%

                  \[\leadsto x \cdot y \]
              10. Applied rewrites26.5%

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

              if -1.35e15 < y < 5.5

              1. Initial program 100.0%

                \[\left(x \cdot \left(y - 1\right) - y \cdot \frac{1}{2}\right) + \frac{918938533204673}{1000000000000000} \]
              2. Step-by-step derivation
                1. lift-+.f64N/A

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

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

                  \[\leadsto \color{blue}{\left(x \cdot \left(y - 1\right) - y \cdot \frac{1}{2}\right) - \left(\mathsf{neg}\left(\frac{918938533204673}{1000000000000000}\right)\right)} \]
              3. Applied rewrites100.0%

                \[\leadsto \color{blue}{\left(y \cdot \left(\frac{-1}{2} + x\right) - x\right) - \frac{-918938533204673}{1000000000000000}} \]
              4. Taylor expanded in y around 0

                \[\leadsto \color{blue}{\frac{918938533204673}{1000000000000000} - x} \]
              5. Step-by-step derivation
                1. lower--.f6450.1%

                  \[\leadsto \frac{918938533204673}{1000000000000000} - \color{blue}{x} \]
              6. Applied rewrites50.1%

                \[\leadsto \color{blue}{\frac{918938533204673}{1000000000000000} - x} \]
            3. Recombined 2 regimes into one program.
            4. Add Preprocessing

            Alternative 8: 50.1% accurate, 5.0× speedup?

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

              \[\left(x \cdot \left(y - 1\right) - y \cdot \frac{1}{2}\right) + \frac{918938533204673}{1000000000000000} \]
            2. Step-by-step derivation
              1. lift-+.f64N/A

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

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

                \[\leadsto \color{blue}{\left(x \cdot \left(y - 1\right) - y \cdot \frac{1}{2}\right) - \left(\mathsf{neg}\left(\frac{918938533204673}{1000000000000000}\right)\right)} \]
            3. Applied rewrites100.0%

              \[\leadsto \color{blue}{\left(y \cdot \left(\frac{-1}{2} + x\right) - x\right) - \frac{-918938533204673}{1000000000000000}} \]
            4. Taylor expanded in y around 0

              \[\leadsto \color{blue}{\frac{918938533204673}{1000000000000000} - x} \]
            5. Step-by-step derivation
              1. lower--.f6450.1%

                \[\leadsto \frac{918938533204673}{1000000000000000} - \color{blue}{x} \]
            6. Applied rewrites50.1%

              \[\leadsto \color{blue}{\frac{918938533204673}{1000000000000000} - x} \]
            7. Add Preprocessing

            Alternative 9: 26.2% accurate, 20.0× speedup?

            \[\frac{918938533204673}{1000000000000000} \]
            (FPCore (x y)
              :precision binary64
              918938533204673/1000000000000000)
            double code(double x, double y) {
            	return 0.918938533204673;
            }
            
            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)
            use fmin_fmax_functions
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                code = 0.918938533204673d0
            end function
            
            public static double code(double x, double y) {
            	return 0.918938533204673;
            }
            
            def code(x, y):
            	return 0.918938533204673
            
            function code(x, y)
            	return 0.918938533204673
            end
            
            function tmp = code(x, y)
            	tmp = 0.918938533204673;
            end
            
            code[x_, y_] := 918938533204673/1000000000000000
            
            \frac{918938533204673}{1000000000000000}
            
            Derivation
            1. Initial program 100.0%

              \[\left(x \cdot \left(y - 1\right) - y \cdot \frac{1}{2}\right) + \frac{918938533204673}{1000000000000000} \]
            2. Taylor expanded in y around 0

              \[\leadsto \color{blue}{\frac{918938533204673}{1000000000000000} + -1 \cdot x} \]
            3. Step-by-step derivation
              1. lower-+.f64N/A

                \[\leadsto \frac{918938533204673}{1000000000000000} + \color{blue}{-1 \cdot x} \]
              2. lower-*.f6450.1%

                \[\leadsto \frac{918938533204673}{1000000000000000} + -1 \cdot \color{blue}{x} \]
            4. Applied rewrites50.1%

              \[\leadsto \color{blue}{\frac{918938533204673}{1000000000000000} + -1 \cdot x} \]
            5. Taylor expanded in x around 0

              \[\leadsto \frac{918938533204673}{1000000000000000} \]
            6. Step-by-step derivation
              1. Applied rewrites26.2%

                \[\leadsto \frac{918938533204673}{1000000000000000} \]
              2. Add Preprocessing

              Reproduce

              ?
              herbie shell --seed 2025271 -o generate:evaluate
              (FPCore (x y)
                :name "Numeric.SpecFunctions:logGamma from math-functions-0.1.5.2, A"
                :precision binary64
                (+ (- (* x (- y 1)) (* y 1/2)) 918938533204673/1000000000000000))