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

Percentage Accurate: 99.9% → 99.9%
Time: 3.0s
Alternatives: 8
Speedup: 1.0×

Specification

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

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

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

\\
x \cdot \left(1 - x \cdot y\right)
\end{array}

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 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: 99.9% accurate, 1.0× speedup?

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

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

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

\\
x \cdot \left(1 - x \cdot y\right)
\end{array}

Alternative 1: 99.9% accurate, 1.0× speedup?

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

\\
\mathsf{fma}\left(y \cdot \left(-x\right), x, x\right)
\end{array}
Derivation
  1. Initial program 99.9%

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

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

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

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

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

      \[\leadsto \color{blue}{\left(1 + \left(\mathsf{neg}\left(x\right)\right) \cdot y\right)} \cdot x \]
    6. mul-1-negN/A

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(-1 \cdot \color{blue}{\left(y \cdot x\right)}, x, x\right) \]
    12. associate-*l*N/A

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

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

      \[\leadsto \mathsf{fma}\left(\left(y \cdot \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}\right) \cdot x, x, x\right) \]
    15. distribute-rgt-neg-outN/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(y \cdot 1\right)\right)} \cdot x, x, x\right) \]
    16. distribute-lft-neg-outN/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{neg}\left(\left(y \cdot 1\right) \cdot x\right)}, x, x\right) \]
    17. distribute-rgt-neg-inN/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(y \cdot 1\right) \cdot \left(\mathsf{neg}\left(x\right)\right)}, x, x\right) \]
    18. mul-1-negN/A

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(y \cdot 1\right) \cdot \left(-1 \cdot x\right)}, x, x\right) \]
    20. *-rgt-identityN/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{y} \cdot \left(-1 \cdot x\right), x, x\right) \]
    21. mul-1-negN/A

      \[\leadsto \mathsf{fma}\left(y \cdot \color{blue}{\left(\mathsf{neg}\left(x\right)\right)}, x, x\right) \]
    22. lower-neg.f6499.9

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

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

Alternative 2: 99.9% accurate, 1.0× speedup?

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

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

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

\\
x \cdot \left(1 - x \cdot y\right)
\end{array}
Derivation
  1. Initial program 99.9%

    \[x \cdot \left(1 - x \cdot y\right) \]
  2. Add Preprocessing

Alternative 3: 81.8% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \left(1 - x \cdot y\right)\\ t_1 := x \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{if}\;t\_0 \leq -1 \cdot 10^{+52}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+18}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* x (- 1.0 (* x y)))) (t_1 (* x (* y (- x)))))
   (if (<= t_0 -1e+52) t_1 (if (<= t_0 5e+18) x t_1))))
double code(double x, double y) {
	double t_0 = x * (1.0 - (x * y));
	double t_1 = x * (y * -x);
	double tmp;
	if (t_0 <= -1e+52) {
		tmp = t_1;
	} else if (t_0 <= 5e+18) {
		tmp = x;
	} else {
		tmp = t_1;
	}
	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 * (1.0d0 - (x * y))
    t_1 = x * (y * -x)
    if (t_0 <= (-1d+52)) then
        tmp = t_1
    else if (t_0 <= 5d+18) then
        tmp = x
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = x * (1.0 - (x * y));
	double t_1 = x * (y * -x);
	double tmp;
	if (t_0 <= -1e+52) {
		tmp = t_1;
	} else if (t_0 <= 5e+18) {
		tmp = x;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y):
	t_0 = x * (1.0 - (x * y))
	t_1 = x * (y * -x)
	tmp = 0
	if t_0 <= -1e+52:
		tmp = t_1
	elif t_0 <= 5e+18:
		tmp = x
	else:
		tmp = t_1
	return tmp
function code(x, y)
	t_0 = Float64(x * Float64(1.0 - Float64(x * y)))
	t_1 = Float64(x * Float64(y * Float64(-x)))
	tmp = 0.0
	if (t_0 <= -1e+52)
		tmp = t_1;
	elseif (t_0 <= 5e+18)
		tmp = x;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = x * (1.0 - (x * y));
	t_1 = x * (y * -x);
	tmp = 0.0;
	if (t_0 <= -1e+52)
		tmp = t_1;
	elseif (t_0 <= 5e+18)
		tmp = x;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(x * N[(1.0 - N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(y * (-x)), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1e+52], t$95$1, If[LessEqual[t$95$0, 5e+18], x, t$95$1]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x \cdot \left(1 - x \cdot y\right)\\
t_1 := x \cdot \left(y \cdot \left(-x\right)\right)\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{+52}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+18}:\\
\;\;\;\;x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x (-.f64 #s(literal 1 binary64) (*.f64 x y))) < -9.9999999999999999e51 or 5e18 < (*.f64 x (-.f64 #s(literal 1 binary64) (*.f64 x y)))

    1. Initial program 99.9%

      \[x \cdot \left(1 - x \cdot y\right) \]
    2. Taylor expanded in x around inf

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

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

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

        \[\leadsto x \cdot \left(\left(y \cdot -1\right) \cdot x\right) \]
      4. metadata-evalN/A

        \[\leadsto x \cdot \left(\left(y \cdot \left(\mathsf{neg}\left(1\right)\right)\right) \cdot x\right) \]
      5. distribute-rgt-neg-outN/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(y \cdot 1\right)\right) \cdot x\right) \]
      6. distribute-lft-neg-outN/A

        \[\leadsto x \cdot \left(\mathsf{neg}\left(\left(y \cdot 1\right) \cdot x\right)\right) \]
      7. distribute-rgt-neg-inN/A

        \[\leadsto x \cdot \left(\left(y \cdot 1\right) \cdot \color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right) \]
      8. mul-1-negN/A

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

        \[\leadsto x \cdot \left(\left(y \cdot 1\right) \cdot \color{blue}{\left(-1 \cdot x\right)}\right) \]
      10. *-rgt-identityN/A

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

        \[\leadsto x \cdot \left(y \cdot \left(\mathsf{neg}\left(x\right)\right)\right) \]
      12. lower-neg.f6452.3

        \[\leadsto x \cdot \left(y \cdot \left(-x\right)\right) \]
    4. Applied rewrites52.3%

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

    if -9.9999999999999999e51 < (*.f64 x (-.f64 #s(literal 1 binary64) (*.f64 x y))) < 5e18

    1. Initial program 99.9%

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

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

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

    Alternative 4: 79.3% accurate, 0.3× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \left(1 - x \cdot y\right)\\ t_1 := \left(\left(-x\right) \cdot x\right) \cdot y\\ \mathbf{if}\;t\_0 \leq -1 \cdot 10^{+52}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+18}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
    (FPCore (x y)
     :precision binary64
     (let* ((t_0 (* x (- 1.0 (* x y)))) (t_1 (* (* (- x) x) y)))
       (if (<= t_0 -1e+52) t_1 (if (<= t_0 5e+18) x t_1))))
    double code(double x, double y) {
    	double t_0 = x * (1.0 - (x * y));
    	double t_1 = (-x * x) * y;
    	double tmp;
    	if (t_0 <= -1e+52) {
    		tmp = t_1;
    	} else if (t_0 <= 5e+18) {
    		tmp = x;
    	} else {
    		tmp = t_1;
    	}
    	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 * (1.0d0 - (x * y))
        t_1 = (-x * x) * y
        if (t_0 <= (-1d+52)) then
            tmp = t_1
        else if (t_0 <= 5d+18) then
            tmp = x
        else
            tmp = t_1
        end if
        code = tmp
    end function
    
    public static double code(double x, double y) {
    	double t_0 = x * (1.0 - (x * y));
    	double t_1 = (-x * x) * y;
    	double tmp;
    	if (t_0 <= -1e+52) {
    		tmp = t_1;
    	} else if (t_0 <= 5e+18) {
    		tmp = x;
    	} else {
    		tmp = t_1;
    	}
    	return tmp;
    }
    
    def code(x, y):
    	t_0 = x * (1.0 - (x * y))
    	t_1 = (-x * x) * y
    	tmp = 0
    	if t_0 <= -1e+52:
    		tmp = t_1
    	elif t_0 <= 5e+18:
    		tmp = x
    	else:
    		tmp = t_1
    	return tmp
    
    function code(x, y)
    	t_0 = Float64(x * Float64(1.0 - Float64(x * y)))
    	t_1 = Float64(Float64(Float64(-x) * x) * y)
    	tmp = 0.0
    	if (t_0 <= -1e+52)
    		tmp = t_1;
    	elseif (t_0 <= 5e+18)
    		tmp = x;
    	else
    		tmp = t_1;
    	end
    	return tmp
    end
    
    function tmp_2 = code(x, y)
    	t_0 = x * (1.0 - (x * y));
    	t_1 = (-x * x) * y;
    	tmp = 0.0;
    	if (t_0 <= -1e+52)
    		tmp = t_1;
    	elseif (t_0 <= 5e+18)
    		tmp = x;
    	else
    		tmp = t_1;
    	end
    	tmp_2 = tmp;
    end
    
    code[x_, y_] := Block[{t$95$0 = N[(x * N[(1.0 - N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[((-x) * x), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[t$95$0, -1e+52], t$95$1, If[LessEqual[t$95$0, 5e+18], x, t$95$1]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := x \cdot \left(1 - x \cdot y\right)\\
    t_1 := \left(\left(-x\right) \cdot x\right) \cdot y\\
    \mathbf{if}\;t\_0 \leq -1 \cdot 10^{+52}:\\
    \;\;\;\;t\_1\\
    
    \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+18}:\\
    \;\;\;\;x\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_1\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (*.f64 x (-.f64 #s(literal 1 binary64) (*.f64 x y))) < -9.9999999999999999e51 or 5e18 < (*.f64 x (-.f64 #s(literal 1 binary64) (*.f64 x y)))

      1. Initial program 99.9%

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

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

          \[\leadsto x \cdot \left(1 - \color{blue}{\left(x \cdot y\right) \cdot 1}\right) \]
        3. metadata-evalN/A

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

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

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

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

          \[\leadsto x \cdot \left(1 - \left(\color{blue}{{x}^{1}} \cdot \left(-1 \cdot y\right) + \left(x \cdot y\right) \cdot 2\right)\right) \]
        8. metadata-evalN/A

          \[\leadsto x \cdot \left(1 - \left({x}^{\color{blue}{\left(-1 + 2\right)}} \cdot \left(-1 \cdot y\right) + \left(x \cdot y\right) \cdot 2\right)\right) \]
        9. pow-prod-upN/A

          \[\leadsto x \cdot \left(1 - \left(\color{blue}{\left({x}^{-1} \cdot {x}^{2}\right)} \cdot \left(-1 \cdot y\right) + \left(x \cdot y\right) \cdot 2\right)\right) \]
        10. inv-powN/A

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

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

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

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

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

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

        \[\leadsto x \cdot \left(1 - \color{blue}{\mathsf{fma}\left(\frac{1}{x}, \left(-x\right) \cdot \left(y \cdot x\right), \left(y \cdot x\right) \cdot 2\right)}\right) \]
      4. Taylor expanded in x around inf

        \[\leadsto \color{blue}{-1 \cdot \left({x}^{2} \cdot \left(-1 \cdot y + 2 \cdot y\right)\right)} \]
      5. Applied rewrites47.1%

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

      if -9.9999999999999999e51 < (*.f64 x (-.f64 #s(literal 1 binary64) (*.f64 x y))) < 5e18

      1. Initial program 99.9%

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

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

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

      Alternative 5: 59.2% accurate, 0.3× speedup?

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

        1. Initial program 99.9%

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

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

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

            \[\leadsto \color{blue}{x \cdot \left(1 - x \cdot y\right)} \]
          4. distribute-rgt-out--N/A

            \[\leadsto \color{blue}{1 \cdot x - \left(x \cdot y\right) \cdot x} \]
          5. fp-cancel-sub-signN/A

            \[\leadsto \color{blue}{1 \cdot x + \left(\mathsf{neg}\left(x \cdot y\right)\right) \cdot x} \]
          6. mul-1-negN/A

            \[\leadsto 1 \cdot x + \color{blue}{\left(-1 \cdot \left(x \cdot y\right)\right)} \cdot x \]
          7. distribute-rgt-inN/A

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

            \[\leadsto \color{blue}{\left(x \cdot 1\right)} \cdot \left(1 + -1 \cdot \left(x \cdot y\right)\right) \]
          9. lft-mult-inverseN/A

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

            \[\leadsto \color{blue}{\left(\left(x \cdot \frac{1}{y}\right) \cdot y\right)} \cdot \left(1 + -1 \cdot \left(x \cdot y\right)\right) \]
          11. mult-flipN/A

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

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

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

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

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

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

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

            \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(x\right)}{\mathsf{neg}\left(y\right)}} \cdot \left(\left(y \cdot 1\right) \cdot \left(1 - x \cdot y\right)\right) \]
          19. mul-1-negN/A

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

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

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

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

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

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

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

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

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

          \[\leadsto \frac{x}{y} \cdot \color{blue}{y} \]
        5. Step-by-step derivation
          1. Applied rewrites41.0%

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

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

              \[\leadsto \color{blue}{\frac{x}{y}} \cdot y \]
            3. associate-*l/N/A

              \[\leadsto \color{blue}{\frac{x \cdot y}{y}} \]
            4. lower-/.f64N/A

              \[\leadsto \color{blue}{\frac{x \cdot y}{y}} \]
            5. *-commutativeN/A

              \[\leadsto \frac{\color{blue}{y \cdot x}}{y} \]
            6. lower-*.f6445.8

              \[\leadsto \frac{\color{blue}{y \cdot x}}{y} \]
          3. Applied rewrites45.8%

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

          if -2e143 < (*.f64 x (-.f64 #s(literal 1 binary64) (*.f64 x y))) < 2.0000000000000001e241

          1. Initial program 99.9%

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

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

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

            if 2.0000000000000001e241 < (*.f64 x (-.f64 #s(literal 1 binary64) (*.f64 x y)))

            1. Initial program 99.9%

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

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

                \[\leadsto x \cdot \left(1 - \color{blue}{\left(x \cdot y\right) \cdot 1}\right) \]
              3. metadata-evalN/A

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

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

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

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

                \[\leadsto x \cdot \left(1 - \left(\color{blue}{{x}^{1}} \cdot \left(-1 \cdot y\right) + \left(x \cdot y\right) \cdot 2\right)\right) \]
              8. metadata-evalN/A

                \[\leadsto x \cdot \left(1 - \left({x}^{\color{blue}{\left(-1 + 2\right)}} \cdot \left(-1 \cdot y\right) + \left(x \cdot y\right) \cdot 2\right)\right) \]
              9. pow-prod-upN/A

                \[\leadsto x \cdot \left(1 - \left(\color{blue}{\left({x}^{-1} \cdot {x}^{2}\right)} \cdot \left(-1 \cdot y\right) + \left(x \cdot y\right) \cdot 2\right)\right) \]
              10. inv-powN/A

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

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

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

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

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

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

              \[\leadsto x \cdot \left(1 - \color{blue}{\mathsf{fma}\left(\frac{1}{x}, \left(-x\right) \cdot \left(y \cdot x\right), \left(y \cdot x\right) \cdot 2\right)}\right) \]
            4. Taylor expanded in x around inf

              \[\leadsto x \cdot \color{blue}{\left(-1 \cdot \left(x \cdot \left(-1 \cdot y + 2 \cdot y\right)\right)\right)} \]
            5. Applied rewrites52.3%

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

                \[\leadsto \color{blue}{x \cdot \left(\left(-y\right) \cdot x\right)} \]
              2. *-rgt-identityN/A

                \[\leadsto \color{blue}{\left(x \cdot 1\right)} \cdot \left(\left(-y\right) \cdot x\right) \]
              3. rgt-mult-inverseN/A

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

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

                \[\leadsto \left(\color{blue}{{x}^{2}} \cdot \frac{1}{x}\right) \cdot \left(\left(-y\right) \cdot x\right) \]
              6. mult-flip-revN/A

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

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

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

                \[\leadsto \frac{\color{blue}{{x}^{2} \cdot \left(\left(-y\right) \cdot x\right)}}{x} \]
              10. unpow2N/A

                \[\leadsto \frac{\color{blue}{\left(x \cdot x\right)} \cdot \left(\left(-y\right) \cdot x\right)}{x} \]
              11. lower-*.f6444.3

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

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

              \[\leadsto \frac{\color{blue}{{x}^{2}}}{x} \]
            9. Step-by-step derivation
              1. pow2N/A

                \[\leadsto \frac{x \cdot \color{blue}{x}}{x} \]
              2. lift-*.f6436.8

                \[\leadsto \frac{x \cdot \color{blue}{x}}{x} \]
            10. Applied rewrites36.8%

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

          Alternative 6: 58.0% accurate, 0.3× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \left(1 - x \cdot y\right)\\ t_1 := \frac{x \cdot x}{x}\\ \mathbf{if}\;t\_0 \leq -\infty:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 1.35 \cdot 10^{+252}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
          (FPCore (x y)
           :precision binary64
           (let* ((t_0 (* x (- 1.0 (* x y)))) (t_1 (/ (* x x) x)))
             (if (<= t_0 (- INFINITY)) t_1 (if (<= t_0 1.35e+252) x t_1))))
          double code(double x, double y) {
          	double t_0 = x * (1.0 - (x * y));
          	double t_1 = (x * x) / x;
          	double tmp;
          	if (t_0 <= -((double) INFINITY)) {
          		tmp = t_1;
          	} else if (t_0 <= 1.35e+252) {
          		tmp = x;
          	} else {
          		tmp = t_1;
          	}
          	return tmp;
          }
          
          public static double code(double x, double y) {
          	double t_0 = x * (1.0 - (x * y));
          	double t_1 = (x * x) / x;
          	double tmp;
          	if (t_0 <= -Double.POSITIVE_INFINITY) {
          		tmp = t_1;
          	} else if (t_0 <= 1.35e+252) {
          		tmp = x;
          	} else {
          		tmp = t_1;
          	}
          	return tmp;
          }
          
          def code(x, y):
          	t_0 = x * (1.0 - (x * y))
          	t_1 = (x * x) / x
          	tmp = 0
          	if t_0 <= -math.inf:
          		tmp = t_1
          	elif t_0 <= 1.35e+252:
          		tmp = x
          	else:
          		tmp = t_1
          	return tmp
          
          function code(x, y)
          	t_0 = Float64(x * Float64(1.0 - Float64(x * y)))
          	t_1 = Float64(Float64(x * x) / x)
          	tmp = 0.0
          	if (t_0 <= Float64(-Inf))
          		tmp = t_1;
          	elseif (t_0 <= 1.35e+252)
          		tmp = x;
          	else
          		tmp = t_1;
          	end
          	return tmp
          end
          
          function tmp_2 = code(x, y)
          	t_0 = x * (1.0 - (x * y));
          	t_1 = (x * x) / x;
          	tmp = 0.0;
          	if (t_0 <= -Inf)
          		tmp = t_1;
          	elseif (t_0 <= 1.35e+252)
          		tmp = x;
          	else
          		tmp = t_1;
          	end
          	tmp_2 = tmp;
          end
          
          code[x_, y_] := Block[{t$95$0 = N[(x * N[(1.0 - N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * x), $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], t$95$1, If[LessEqual[t$95$0, 1.35e+252], x, t$95$1]]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          t_0 := x \cdot \left(1 - x \cdot y\right)\\
          t_1 := \frac{x \cdot x}{x}\\
          \mathbf{if}\;t\_0 \leq -\infty:\\
          \;\;\;\;t\_1\\
          
          \mathbf{elif}\;t\_0 \leq 1.35 \cdot 10^{+252}:\\
          \;\;\;\;x\\
          
          \mathbf{else}:\\
          \;\;\;\;t\_1\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if (*.f64 x (-.f64 #s(literal 1 binary64) (*.f64 x y))) < -inf.0 or 1.35000000000000005e252 < (*.f64 x (-.f64 #s(literal 1 binary64) (*.f64 x y)))

            1. Initial program 99.9%

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

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

                \[\leadsto x \cdot \left(1 - \color{blue}{\left(x \cdot y\right) \cdot 1}\right) \]
              3. metadata-evalN/A

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

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

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

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

                \[\leadsto x \cdot \left(1 - \left(\color{blue}{{x}^{1}} \cdot \left(-1 \cdot y\right) + \left(x \cdot y\right) \cdot 2\right)\right) \]
              8. metadata-evalN/A

                \[\leadsto x \cdot \left(1 - \left({x}^{\color{blue}{\left(-1 + 2\right)}} \cdot \left(-1 \cdot y\right) + \left(x \cdot y\right) \cdot 2\right)\right) \]
              9. pow-prod-upN/A

                \[\leadsto x \cdot \left(1 - \left(\color{blue}{\left({x}^{-1} \cdot {x}^{2}\right)} \cdot \left(-1 \cdot y\right) + \left(x \cdot y\right) \cdot 2\right)\right) \]
              10. inv-powN/A

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

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

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

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

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

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

              \[\leadsto x \cdot \left(1 - \color{blue}{\mathsf{fma}\left(\frac{1}{x}, \left(-x\right) \cdot \left(y \cdot x\right), \left(y \cdot x\right) \cdot 2\right)}\right) \]
            4. Taylor expanded in x around inf

              \[\leadsto x \cdot \color{blue}{\left(-1 \cdot \left(x \cdot \left(-1 \cdot y + 2 \cdot y\right)\right)\right)} \]
            5. Applied rewrites52.3%

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

                \[\leadsto \color{blue}{x \cdot \left(\left(-y\right) \cdot x\right)} \]
              2. *-rgt-identityN/A

                \[\leadsto \color{blue}{\left(x \cdot 1\right)} \cdot \left(\left(-y\right) \cdot x\right) \]
              3. rgt-mult-inverseN/A

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

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

                \[\leadsto \left(\color{blue}{{x}^{2}} \cdot \frac{1}{x}\right) \cdot \left(\left(-y\right) \cdot x\right) \]
              6. mult-flip-revN/A

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

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

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

                \[\leadsto \frac{\color{blue}{{x}^{2} \cdot \left(\left(-y\right) \cdot x\right)}}{x} \]
              10. unpow2N/A

                \[\leadsto \frac{\color{blue}{\left(x \cdot x\right)} \cdot \left(\left(-y\right) \cdot x\right)}{x} \]
              11. lower-*.f6444.3

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

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

              \[\leadsto \frac{\color{blue}{{x}^{2}}}{x} \]
            9. Step-by-step derivation
              1. pow2N/A

                \[\leadsto \frac{x \cdot \color{blue}{x}}{x} \]
              2. lift-*.f6436.8

                \[\leadsto \frac{x \cdot \color{blue}{x}}{x} \]
            10. Applied rewrites36.8%

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

            if -inf.0 < (*.f64 x (-.f64 #s(literal 1 binary64) (*.f64 x y))) < 1.35000000000000005e252

            1. Initial program 99.9%

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

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

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

            Alternative 7: 51.0% accurate, 0.5× speedup?

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

              1. Initial program 99.9%

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

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

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

                if 2.0000000000000001e241 < (*.f64 x (-.f64 #s(literal 1 binary64) (*.f64 x y)))

                1. Initial program 99.9%

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

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

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

                    \[\leadsto \color{blue}{x \cdot \left(1 - x \cdot y\right)} \]
                  4. distribute-rgt-out--N/A

                    \[\leadsto \color{blue}{1 \cdot x - \left(x \cdot y\right) \cdot x} \]
                  5. fp-cancel-sub-signN/A

                    \[\leadsto \color{blue}{1 \cdot x + \left(\mathsf{neg}\left(x \cdot y\right)\right) \cdot x} \]
                  6. mul-1-negN/A

                    \[\leadsto 1 \cdot x + \color{blue}{\left(-1 \cdot \left(x \cdot y\right)\right)} \cdot x \]
                  7. distribute-rgt-inN/A

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

                    \[\leadsto \color{blue}{\left(x \cdot 1\right)} \cdot \left(1 + -1 \cdot \left(x \cdot y\right)\right) \]
                  9. lft-mult-inverseN/A

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

                    \[\leadsto \color{blue}{\left(\left(x \cdot \frac{1}{y}\right) \cdot y\right)} \cdot \left(1 + -1 \cdot \left(x \cdot y\right)\right) \]
                  11. mult-flipN/A

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

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

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

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

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

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

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

                    \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(x\right)}{\mathsf{neg}\left(y\right)}} \cdot \left(\left(y \cdot 1\right) \cdot \left(1 - x \cdot y\right)\right) \]
                  19. mul-1-negN/A

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

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

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

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

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

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

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

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

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

                  \[\leadsto \frac{x}{y} \cdot \color{blue}{y} \]
                5. Step-by-step derivation
                  1. Applied rewrites41.0%

                    \[\leadsto \frac{x}{y} \cdot \color{blue}{y} \]
                6. Recombined 2 regimes into one program.
                7. Add Preprocessing

                Alternative 8: 50.1% accurate, 9.5× speedup?

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

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

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

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

                  Reproduce

                  ?
                  herbie shell --seed 2025136 
                  (FPCore (x y)
                    :name "Numeric.SpecFunctions:log1p from math-functions-0.1.5.2, A"
                    :precision binary64
                    (* x (- 1.0 (* x y))))