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

Percentage Accurate: 100.0% → 100.0%
Time: 1.9s
Alternatives: 8
Speedup: 1.3×

Specification

?
\[\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673 \]
(FPCore (x y)
 :precision binary64
 (+ (- (* x (- y 1.0)) (* y 0.5)) 0.918938533204673))
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.0), $MachinePrecision]), $MachinePrecision] - N[(y * 0.5), $MachinePrecision]), $MachinePrecision] + 0.918938533204673), $MachinePrecision]
\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673

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 8 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 0.5\right) + 0.918938533204673 \]
(FPCore (x y)
 :precision binary64
 (+ (- (* x (- y 1.0)) (* y 0.5)) 0.918938533204673))
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.0), $MachinePrecision]), $MachinePrecision] - N[(y * 0.5), $MachinePrecision]), $MachinePrecision] + 0.918938533204673), $MachinePrecision]
\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673

Alternative 1: 100.0% accurate, 1.3× speedup?

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

    \[\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673 \]
  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. +-commutativeN/A

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

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

      \[\leadsto \frac{918938533204673}{1000000000000000} + \color{blue}{\left(\mathsf{neg}\left(\left(y \cdot \frac{1}{2} - x \cdot \left(y - 1\right)\right)\right)\right)} \]
    5. sub-flip-reverseN/A

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

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

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

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

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

      \[\leadsto \frac{918938533204673}{1000000000000000} - \left(y \cdot \frac{1}{2} - \color{blue}{\left(y \cdot x + \left(\mathsf{neg}\left(1\right)\right) \cdot x\right)}\right) \]
    11. associate--r+N/A

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

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

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

      \[\leadsto \frac{918938533204673}{1000000000000000} - \left(\left(y \cdot \frac{1}{2} - x \cdot y\right) - \color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right) \]
    15. add-flip-revN/A

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

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

      \[\leadsto \frac{918938533204673}{1000000000000000} - \left(\left(\color{blue}{\frac{1}{2} \cdot y} - x \cdot y\right) + x\right) \]
    18. distribute-rgt-out--N/A

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

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

      \[\leadsto \frac{918938533204673}{1000000000000000} - \left(y \cdot \left(\frac{1}{2} - x\right) + x \cdot \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(1\right)\right)\right)\right)}\right) \]
    21. distribute-rgt-neg-outN/A

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

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

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

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

Alternative 2: 98.4% accurate, 0.9× speedup?

\[\begin{array}{l} t_0 := x \cdot \left(y - 1\right)\\ \mathbf{if}\;x \leq -1100000000:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 4.4 \cdot 10^{+16}:\\ \;\;\;\;0.918938533204673 - \mathsf{fma}\left(y, 0.5, x\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* x (- y 1.0))))
   (if (<= x -1100000000.0)
     t_0
     (if (<= x 4.4e+16) (- 0.918938533204673 (fma y 0.5 x)) t_0))))
double code(double x, double y) {
	double t_0 = x * (y - 1.0);
	double tmp;
	if (x <= -1100000000.0) {
		tmp = t_0;
	} else if (x <= 4.4e+16) {
		tmp = 0.918938533204673 - fma(y, 0.5, x);
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(x, y)
	t_0 = Float64(x * Float64(y - 1.0))
	tmp = 0.0
	if (x <= -1100000000.0)
		tmp = t_0;
	elseif (x <= 4.4e+16)
		tmp = Float64(0.918938533204673 - fma(y, 0.5, x));
	else
		tmp = t_0;
	end
	return tmp
end
code[x_, y_] := Block[{t$95$0 = N[(x * N[(y - 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1100000000.0], t$95$0, If[LessEqual[x, 4.4e+16], N[(0.918938533204673 - N[(y * 0.5 + x), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := x \cdot \left(y - 1\right)\\
\mathbf{if}\;x \leq -1100000000:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 4.4 \cdot 10^{+16}:\\
\;\;\;\;0.918938533204673 - \mathsf{fma}\left(y, 0.5, x\right)\\

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.1e9 or 4.4e16 < x

    1. Initial program 100.0%

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

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

        \[\leadsto \frac{918938533204673}{1000000000000000} - \color{blue}{\frac{1}{2} \cdot y} \]
      2. lower-*.f6450.5

        \[\leadsto 0.918938533204673 - 0.5 \cdot \color{blue}{y} \]
    4. Applied rewrites50.5%

      \[\leadsto \color{blue}{0.918938533204673 - 0.5 \cdot y} \]
    5. Taylor expanded in y around 0

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

        \[\leadsto 0.918938533204673 \]
      2. Taylor expanded in x around inf

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

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

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

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

      if -1.1e9 < x < 4.4e16

      1. Initial program 100.0%

        \[\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673 \]
      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. +-commutativeN/A

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

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

          \[\leadsto \frac{918938533204673}{1000000000000000} + \color{blue}{\left(\mathsf{neg}\left(\left(y \cdot \frac{1}{2} - x \cdot \left(y - 1\right)\right)\right)\right)} \]
        5. sub-flip-reverseN/A

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

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

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

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

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

          \[\leadsto \frac{918938533204673}{1000000000000000} - \left(y \cdot \frac{1}{2} - \color{blue}{\left(y \cdot x + \left(\mathsf{neg}\left(1\right)\right) \cdot x\right)}\right) \]
        11. associate--r+N/A

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

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

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

          \[\leadsto \frac{918938533204673}{1000000000000000} - \left(\left(y \cdot \frac{1}{2} - x \cdot y\right) - \color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right) \]
        15. add-flip-revN/A

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

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

          \[\leadsto \frac{918938533204673}{1000000000000000} - \left(\left(\color{blue}{\frac{1}{2} \cdot y} - x \cdot y\right) + x\right) \]
        18. distribute-rgt-out--N/A

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

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

          \[\leadsto \frac{918938533204673}{1000000000000000} - \left(y \cdot \left(\frac{1}{2} - x\right) + x \cdot \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(1\right)\right)\right)\right)}\right) \]
        21. distribute-rgt-neg-outN/A

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

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

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

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

        \[\leadsto \frac{918938533204673}{1000000000000000} - \mathsf{fma}\left(y, \color{blue}{\frac{1}{2}}, x\right) \]
      5. Step-by-step derivation
        1. Applied rewrites75.0%

          \[\leadsto 0.918938533204673 - \mathsf{fma}\left(y, \color{blue}{0.5}, x\right) \]
      6. Recombined 2 regimes into one program.
      7. Add Preprocessing

      Alternative 3: 97.5% accurate, 1.1× speedup?

      \[\begin{array}{l} t_0 := x \cdot \left(y - 1\right)\\ \mathbf{if}\;x \leq -1100000000:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 95000:\\ \;\;\;\;\mathsf{fma}\left(y, -0.5, 0.918938533204673\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
      (FPCore (x y)
       :precision binary64
       (let* ((t_0 (* x (- y 1.0))))
         (if (<= x -1100000000.0)
           t_0
           (if (<= x 95000.0) (fma y -0.5 0.918938533204673) t_0))))
      double code(double x, double y) {
      	double t_0 = x * (y - 1.0);
      	double tmp;
      	if (x <= -1100000000.0) {
      		tmp = t_0;
      	} else if (x <= 95000.0) {
      		tmp = fma(y, -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 <= -1100000000.0)
      		tmp = t_0;
      	elseif (x <= 95000.0)
      		tmp = fma(y, -0.5, 0.918938533204673);
      	else
      		tmp = t_0;
      	end
      	return tmp
      end
      
      code[x_, y_] := Block[{t$95$0 = N[(x * N[(y - 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1100000000.0], t$95$0, If[LessEqual[x, 95000.0], N[(y * -0.5 + 0.918938533204673), $MachinePrecision], t$95$0]]]
      
      \begin{array}{l}
      t_0 := x \cdot \left(y - 1\right)\\
      \mathbf{if}\;x \leq -1100000000:\\
      \;\;\;\;t\_0\\
      
      \mathbf{elif}\;x \leq 95000:\\
      \;\;\;\;\mathsf{fma}\left(y, -0.5, 0.918938533204673\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;t\_0\\
      
      
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if x < -1.1e9 or 95000 < x

        1. Initial program 100.0%

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

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

            \[\leadsto \frac{918938533204673}{1000000000000000} - \color{blue}{\frac{1}{2} \cdot y} \]
          2. lower-*.f6450.5

            \[\leadsto 0.918938533204673 - 0.5 \cdot \color{blue}{y} \]
        4. Applied rewrites50.5%

          \[\leadsto \color{blue}{0.918938533204673 - 0.5 \cdot y} \]
        5. Taylor expanded in y around 0

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

            \[\leadsto 0.918938533204673 \]
          2. Taylor expanded in x around inf

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

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

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

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

          if -1.1e9 < x < 95000

          1. Initial program 100.0%

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

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

              \[\leadsto \frac{918938533204673}{1000000000000000} - \color{blue}{\frac{1}{2} \cdot y} \]
            2. lower-*.f6450.5

              \[\leadsto 0.918938533204673 - 0.5 \cdot \color{blue}{y} \]
          4. Applied rewrites50.5%

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

              \[\leadsto \frac{918938533204673}{1000000000000000} - \color{blue}{\frac{1}{2} \cdot y} \]
            2. sub-flipN/A

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

              \[\leadsto \frac{918938533204673}{1000000000000000} + \left(\mathsf{neg}\left(\frac{1}{2} \cdot y\right)\right) \]
            4. *-commutativeN/A

              \[\leadsto \frac{918938533204673}{1000000000000000} + \left(\mathsf{neg}\left(y \cdot \frac{1}{2}\right)\right) \]
            5. lift-*.f64N/A

              \[\leadsto \frac{918938533204673}{1000000000000000} + \left(\mathsf{neg}\left(y \cdot \frac{1}{2}\right)\right) \]
            6. +-commutativeN/A

              \[\leadsto \left(\mathsf{neg}\left(y \cdot \frac{1}{2}\right)\right) + \color{blue}{\frac{918938533204673}{1000000000000000}} \]
            7. lift-*.f64N/A

              \[\leadsto \left(\mathsf{neg}\left(y \cdot \frac{1}{2}\right)\right) + \frac{918938533204673}{1000000000000000} \]
            8. distribute-rgt-neg-inN/A

              \[\leadsto y \cdot \left(\mathsf{neg}\left(\frac{1}{2}\right)\right) + \frac{918938533204673}{1000000000000000} \]
            9. lower-fma.f64N/A

              \[\leadsto \mathsf{fma}\left(y, \color{blue}{\mathsf{neg}\left(\frac{1}{2}\right)}, \frac{918938533204673}{1000000000000000}\right) \]
            10. metadata-eval50.5

              \[\leadsto \mathsf{fma}\left(y, -0.5, 0.918938533204673\right) \]
          6. Applied rewrites50.5%

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

        Alternative 4: 74.5% accurate, 0.9× speedup?

        \[\begin{array}{l} \mathbf{if}\;y \leq -4.3 \cdot 10^{+32}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq -0.45:\\ \;\;\;\;\mathsf{fma}\left(y, -0.5, 0.918938533204673\right)\\ \mathbf{elif}\;y \leq 8 \cdot 10^{-31}:\\ \;\;\;\;0.918938533204673 - x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y, -0.5, 0.918938533204673\right)\\ \end{array} \]
        (FPCore (x y)
         :precision binary64
         (if (<= y -4.3e+32)
           (* x y)
           (if (<= y -0.45)
             (fma y -0.5 0.918938533204673)
             (if (<= y 8e-31)
               (- 0.918938533204673 x)
               (fma y -0.5 0.918938533204673)))))
        double code(double x, double y) {
        	double tmp;
        	if (y <= -4.3e+32) {
        		tmp = x * y;
        	} else if (y <= -0.45) {
        		tmp = fma(y, -0.5, 0.918938533204673);
        	} else if (y <= 8e-31) {
        		tmp = 0.918938533204673 - x;
        	} else {
        		tmp = fma(y, -0.5, 0.918938533204673);
        	}
        	return tmp;
        }
        
        function code(x, y)
        	tmp = 0.0
        	if (y <= -4.3e+32)
        		tmp = Float64(x * y);
        	elseif (y <= -0.45)
        		tmp = fma(y, -0.5, 0.918938533204673);
        	elseif (y <= 8e-31)
        		tmp = Float64(0.918938533204673 - x);
        	else
        		tmp = fma(y, -0.5, 0.918938533204673);
        	end
        	return tmp
        end
        
        code[x_, y_] := If[LessEqual[y, -4.3e+32], N[(x * y), $MachinePrecision], If[LessEqual[y, -0.45], N[(y * -0.5 + 0.918938533204673), $MachinePrecision], If[LessEqual[y, 8e-31], N[(0.918938533204673 - x), $MachinePrecision], N[(y * -0.5 + 0.918938533204673), $MachinePrecision]]]]
        
        \begin{array}{l}
        \mathbf{if}\;y \leq -4.3 \cdot 10^{+32}:\\
        \;\;\;\;x \cdot y\\
        
        \mathbf{elif}\;y \leq -0.45:\\
        \;\;\;\;\mathsf{fma}\left(y, -0.5, 0.918938533204673\right)\\
        
        \mathbf{elif}\;y \leq 8 \cdot 10^{-31}:\\
        \;\;\;\;0.918938533204673 - x\\
        
        \mathbf{else}:\\
        \;\;\;\;\mathsf{fma}\left(y, -0.5, 0.918938533204673\right)\\
        
        
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if y < -4.2999999999999997e32

          1. Initial program 100.0%

            \[\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673 \]
          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--.f6450.1

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

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

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

              \[\leadsto y \cdot -0.5 \]
            2. Taylor expanded in x around inf

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

                \[\leadsto x \cdot y \]
            4. Applied rewrites26.3%

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

            if -4.2999999999999997e32 < y < -0.450000000000000011 or 8.000000000000001e-31 < y

            1. Initial program 100.0%

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

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

                \[\leadsto \frac{918938533204673}{1000000000000000} - \color{blue}{\frac{1}{2} \cdot y} \]
              2. lower-*.f6450.5

                \[\leadsto 0.918938533204673 - 0.5 \cdot \color{blue}{y} \]
            4. Applied rewrites50.5%

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

                \[\leadsto \frac{918938533204673}{1000000000000000} - \color{blue}{\frac{1}{2} \cdot y} \]
              2. sub-flipN/A

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

                \[\leadsto \frac{918938533204673}{1000000000000000} + \left(\mathsf{neg}\left(\frac{1}{2} \cdot y\right)\right) \]
              4. *-commutativeN/A

                \[\leadsto \frac{918938533204673}{1000000000000000} + \left(\mathsf{neg}\left(y \cdot \frac{1}{2}\right)\right) \]
              5. lift-*.f64N/A

                \[\leadsto \frac{918938533204673}{1000000000000000} + \left(\mathsf{neg}\left(y \cdot \frac{1}{2}\right)\right) \]
              6. +-commutativeN/A

                \[\leadsto \left(\mathsf{neg}\left(y \cdot \frac{1}{2}\right)\right) + \color{blue}{\frac{918938533204673}{1000000000000000}} \]
              7. lift-*.f64N/A

                \[\leadsto \left(\mathsf{neg}\left(y \cdot \frac{1}{2}\right)\right) + \frac{918938533204673}{1000000000000000} \]
              8. distribute-rgt-neg-inN/A

                \[\leadsto y \cdot \left(\mathsf{neg}\left(\frac{1}{2}\right)\right) + \frac{918938533204673}{1000000000000000} \]
              9. lower-fma.f64N/A

                \[\leadsto \mathsf{fma}\left(y, \color{blue}{\mathsf{neg}\left(\frac{1}{2}\right)}, \frac{918938533204673}{1000000000000000}\right) \]
              10. metadata-eval50.5

                \[\leadsto \mathsf{fma}\left(y, -0.5, 0.918938533204673\right) \]
            6. Applied rewrites50.5%

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

            if -0.450000000000000011 < y < 8.000000000000001e-31

            1. Initial program 100.0%

              \[\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673 \]
            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. +-commutativeN/A

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

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

                \[\leadsto \frac{918938533204673}{1000000000000000} + \color{blue}{\left(\mathsf{neg}\left(\left(y \cdot \frac{1}{2} - x \cdot \left(y - 1\right)\right)\right)\right)} \]
              5. sub-flip-reverseN/A

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

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

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

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

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

                \[\leadsto \frac{918938533204673}{1000000000000000} - \left(y \cdot \frac{1}{2} - \color{blue}{\left(y \cdot x + \left(\mathsf{neg}\left(1\right)\right) \cdot x\right)}\right) \]
              11. associate--r+N/A

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

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

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

                \[\leadsto \frac{918938533204673}{1000000000000000} - \left(\left(y \cdot \frac{1}{2} - x \cdot y\right) - \color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right) \]
              15. add-flip-revN/A

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

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

                \[\leadsto \frac{918938533204673}{1000000000000000} - \left(\left(\color{blue}{\frac{1}{2} \cdot y} - x \cdot y\right) + x\right) \]
              18. distribute-rgt-out--N/A

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

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

                \[\leadsto \frac{918938533204673}{1000000000000000} - \left(y \cdot \left(\frac{1}{2} - x\right) + x \cdot \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(1\right)\right)\right)\right)}\right) \]
              21. distribute-rgt-neg-outN/A

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

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

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

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

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

                \[\leadsto 0.918938533204673 - \color{blue}{x} \]
            6. Applied rewrites51.2%

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

          Alternative 5: 74.5% accurate, 1.3× speedup?

          \[\begin{array}{l} \mathbf{if}\;y \leq -150000000000:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq 43:\\ \;\;\;\;0.918938533204673 - x\\ \mathbf{else}:\\ \;\;\;\;y \cdot -0.5\\ \end{array} \]
          (FPCore (x y)
           :precision binary64
           (if (<= y -150000000000.0)
             (* x y)
             (if (<= y 43.0) (- 0.918938533204673 x) (* y -0.5))))
          double code(double x, double y) {
          	double tmp;
          	if (y <= -150000000000.0) {
          		tmp = x * y;
          	} else if (y <= 43.0) {
          		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 <= (-150000000000.0d0)) then
                  tmp = x * y
              else if (y <= 43.0d0) 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 <= -150000000000.0) {
          		tmp = x * y;
          	} else if (y <= 43.0) {
          		tmp = 0.918938533204673 - x;
          	} else {
          		tmp = y * -0.5;
          	}
          	return tmp;
          }
          
          def code(x, y):
          	tmp = 0
          	if y <= -150000000000.0:
          		tmp = x * y
          	elif y <= 43.0:
          		tmp = 0.918938533204673 - x
          	else:
          		tmp = y * -0.5
          	return tmp
          
          function code(x, y)
          	tmp = 0.0
          	if (y <= -150000000000.0)
          		tmp = Float64(x * y);
          	elseif (y <= 43.0)
          		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 <= -150000000000.0)
          		tmp = x * y;
          	elseif (y <= 43.0)
          		tmp = 0.918938533204673 - x;
          	else
          		tmp = y * -0.5;
          	end
          	tmp_2 = tmp;
          end
          
          code[x_, y_] := If[LessEqual[y, -150000000000.0], N[(x * y), $MachinePrecision], If[LessEqual[y, 43.0], N[(0.918938533204673 - x), $MachinePrecision], N[(y * -0.5), $MachinePrecision]]]
          
          \begin{array}{l}
          \mathbf{if}\;y \leq -150000000000:\\
          \;\;\;\;x \cdot y\\
          
          \mathbf{elif}\;y \leq 43:\\
          \;\;\;\;0.918938533204673 - x\\
          
          \mathbf{else}:\\
          \;\;\;\;y \cdot -0.5\\
          
          
          \end{array}
          
          Derivation
          1. Split input into 3 regimes
          2. if y < -1.5e11

            1. Initial program 100.0%

              \[\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673 \]
            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--.f6450.1

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

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

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

                \[\leadsto y \cdot -0.5 \]
              2. Taylor expanded in x around inf

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

                  \[\leadsto x \cdot y \]
              4. Applied rewrites26.3%

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

              if -1.5e11 < y < 43

              1. Initial program 100.0%

                \[\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673 \]
              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. +-commutativeN/A

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

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

                  \[\leadsto \frac{918938533204673}{1000000000000000} + \color{blue}{\left(\mathsf{neg}\left(\left(y \cdot \frac{1}{2} - x \cdot \left(y - 1\right)\right)\right)\right)} \]
                5. sub-flip-reverseN/A

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

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

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

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

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

                  \[\leadsto \frac{918938533204673}{1000000000000000} - \left(y \cdot \frac{1}{2} - \color{blue}{\left(y \cdot x + \left(\mathsf{neg}\left(1\right)\right) \cdot x\right)}\right) \]
                11. associate--r+N/A

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

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

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

                  \[\leadsto \frac{918938533204673}{1000000000000000} - \left(\left(y \cdot \frac{1}{2} - x \cdot y\right) - \color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right) \]
                15. add-flip-revN/A

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

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

                  \[\leadsto \frac{918938533204673}{1000000000000000} - \left(\left(\color{blue}{\frac{1}{2} \cdot y} - x \cdot y\right) + x\right) \]
                18. distribute-rgt-out--N/A

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

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

                  \[\leadsto \frac{918938533204673}{1000000000000000} - \left(y \cdot \left(\frac{1}{2} - x\right) + x \cdot \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(1\right)\right)\right)\right)}\right) \]
                21. distribute-rgt-neg-outN/A

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

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

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

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

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

                  \[\leadsto 0.918938533204673 - \color{blue}{x} \]
              6. Applied rewrites51.2%

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

              if 43 < y

              1. Initial program 100.0%

                \[\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673 \]
              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--.f6450.1

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

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

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

                  \[\leadsto y \cdot -0.5 \]
              7. Recombined 3 regimes into one program.
              8. Add Preprocessing

              Alternative 6: 74.0% accurate, 1.3× speedup?

              \[\begin{array}{l} \mathbf{if}\;y \leq -150000000000:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq 43:\\ \;\;\;\;0.918938533204673 - x\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
              (FPCore (x y)
               :precision binary64
               (if (<= y -150000000000.0)
                 (* x y)
                 (if (<= y 43.0) (- 0.918938533204673 x) (* x y))))
              double code(double x, double y) {
              	double tmp;
              	if (y <= -150000000000.0) {
              		tmp = x * y;
              	} else if (y <= 43.0) {
              		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 <= (-150000000000.0d0)) then
                      tmp = x * y
                  else if (y <= 43.0d0) 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 <= -150000000000.0) {
              		tmp = x * y;
              	} else if (y <= 43.0) {
              		tmp = 0.918938533204673 - x;
              	} else {
              		tmp = x * y;
              	}
              	return tmp;
              }
              
              def code(x, y):
              	tmp = 0
              	if y <= -150000000000.0:
              		tmp = x * y
              	elif y <= 43.0:
              		tmp = 0.918938533204673 - x
              	else:
              		tmp = x * y
              	return tmp
              
              function code(x, y)
              	tmp = 0.0
              	if (y <= -150000000000.0)
              		tmp = Float64(x * y);
              	elseif (y <= 43.0)
              		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 <= -150000000000.0)
              		tmp = x * y;
              	elseif (y <= 43.0)
              		tmp = 0.918938533204673 - x;
              	else
              		tmp = x * y;
              	end
              	tmp_2 = tmp;
              end
              
              code[x_, y_] := If[LessEqual[y, -150000000000.0], N[(x * y), $MachinePrecision], If[LessEqual[y, 43.0], N[(0.918938533204673 - x), $MachinePrecision], N[(x * y), $MachinePrecision]]]
              
              \begin{array}{l}
              \mathbf{if}\;y \leq -150000000000:\\
              \;\;\;\;x \cdot y\\
              
              \mathbf{elif}\;y \leq 43:\\
              \;\;\;\;0.918938533204673 - x\\
              
              \mathbf{else}:\\
              \;\;\;\;x \cdot y\\
              
              
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if y < -1.5e11 or 43 < y

                1. Initial program 100.0%

                  \[\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673 \]
                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--.f6450.1

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

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

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

                    \[\leadsto y \cdot -0.5 \]
                  2. Taylor expanded in x around inf

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

                      \[\leadsto x \cdot y \]
                  4. Applied rewrites26.3%

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

                  if -1.5e11 < y < 43

                  1. Initial program 100.0%

                    \[\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673 \]
                  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. +-commutativeN/A

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

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

                      \[\leadsto \frac{918938533204673}{1000000000000000} + \color{blue}{\left(\mathsf{neg}\left(\left(y \cdot \frac{1}{2} - x \cdot \left(y - 1\right)\right)\right)\right)} \]
                    5. sub-flip-reverseN/A

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

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

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

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

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

                      \[\leadsto \frac{918938533204673}{1000000000000000} - \left(y \cdot \frac{1}{2} - \color{blue}{\left(y \cdot x + \left(\mathsf{neg}\left(1\right)\right) \cdot x\right)}\right) \]
                    11. associate--r+N/A

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

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

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

                      \[\leadsto \frac{918938533204673}{1000000000000000} - \left(\left(y \cdot \frac{1}{2} - x \cdot y\right) - \color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right) \]
                    15. add-flip-revN/A

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

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

                      \[\leadsto \frac{918938533204673}{1000000000000000} - \left(\left(\color{blue}{\frac{1}{2} \cdot y} - x \cdot y\right) + x\right) \]
                    18. distribute-rgt-out--N/A

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

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

                      \[\leadsto \frac{918938533204673}{1000000000000000} - \left(y \cdot \left(\frac{1}{2} - x\right) + x \cdot \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(1\right)\right)\right)\right)}\right) \]
                    21. distribute-rgt-neg-outN/A

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

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

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

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

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

                      \[\leadsto 0.918938533204673 - \color{blue}{x} \]
                  6. Applied rewrites51.2%

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

                Alternative 7: 51.2% accurate, 4.1× speedup?

                \[0.918938533204673 - x \]
                (FPCore (x y) :precision binary64 (- 0.918938533204673 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[(0.918938533204673 - x), $MachinePrecision]
                
                0.918938533204673 - x
                
                Derivation
                1. Initial program 100.0%

                  \[\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673 \]
                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. +-commutativeN/A

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

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

                    \[\leadsto \frac{918938533204673}{1000000000000000} + \color{blue}{\left(\mathsf{neg}\left(\left(y \cdot \frac{1}{2} - x \cdot \left(y - 1\right)\right)\right)\right)} \]
                  5. sub-flip-reverseN/A

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

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

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

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

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

                    \[\leadsto \frac{918938533204673}{1000000000000000} - \left(y \cdot \frac{1}{2} - \color{blue}{\left(y \cdot x + \left(\mathsf{neg}\left(1\right)\right) \cdot x\right)}\right) \]
                  11. associate--r+N/A

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

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

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

                    \[\leadsto \frac{918938533204673}{1000000000000000} - \left(\left(y \cdot \frac{1}{2} - x \cdot y\right) - \color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right) \]
                  15. add-flip-revN/A

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

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

                    \[\leadsto \frac{918938533204673}{1000000000000000} - \left(\left(\color{blue}{\frac{1}{2} \cdot y} - x \cdot y\right) + x\right) \]
                  18. distribute-rgt-out--N/A

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

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

                    \[\leadsto \frac{918938533204673}{1000000000000000} - \left(y \cdot \left(\frac{1}{2} - x\right) + x \cdot \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(1\right)\right)\right)\right)}\right) \]
                  21. distribute-rgt-neg-outN/A

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

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

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

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

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

                    \[\leadsto 0.918938533204673 - \color{blue}{x} \]
                6. Applied rewrites51.2%

                  \[\leadsto \color{blue}{0.918938533204673 - x} \]
                7. Add Preprocessing

                Alternative 8: 26.6% accurate, 14.9× speedup?

                \[0.918938533204673 \]
                (FPCore (x y) :precision binary64 0.918938533204673)
                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_] := 0.918938533204673
                
                0.918938533204673
                
                Derivation
                1. Initial program 100.0%

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

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

                    \[\leadsto \frac{918938533204673}{1000000000000000} - \color{blue}{\frac{1}{2} \cdot y} \]
                  2. lower-*.f6450.5

                    \[\leadsto 0.918938533204673 - 0.5 \cdot \color{blue}{y} \]
                4. Applied rewrites50.5%

                  \[\leadsto \color{blue}{0.918938533204673 - 0.5 \cdot y} \]
                5. Taylor expanded in y around 0

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

                    \[\leadsto 0.918938533204673 \]
                  2. Add Preprocessing

                  Reproduce

                  ?
                  herbie shell --seed 2025172 
                  (FPCore (x y)
                    :name "Numeric.SpecFunctions:logGamma from math-functions-0.1.5.2, A"
                    :precision binary64
                    (+ (- (* x (- y 1.0)) (* y 0.5)) 0.918938533204673))