Data.Colour.SRGB:transferFunction from colour-2.3.3

Percentage Accurate: 100.0% → 100.0%
Time: 4.5s
Alternatives: 10
Speedup: 1.2×

Specification

?
\[\begin{array}{l} \\ \left(x + 1\right) \cdot y - x \end{array} \]
(FPCore (x y) :precision binary64 (- (* (+ x 1.0) y) x))
double code(double x, double y) {
	return ((x + 1.0) * y) - 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 + 1.0d0) * y) - x
end function
public static double code(double x, double y) {
	return ((x + 1.0) * y) - x;
}
def code(x, y):
	return ((x + 1.0) * y) - x
function code(x, y)
	return Float64(Float64(Float64(x + 1.0) * y) - x)
end
function tmp = code(x, y)
	tmp = ((x + 1.0) * y) - x;
end
code[x_, y_] := N[(N[(N[(x + 1.0), $MachinePrecision] * y), $MachinePrecision] - x), $MachinePrecision]
\begin{array}{l}

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

Sampling outcomes in binary64 precision:

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 10 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?

\[\begin{array}{l} \\ \left(x + 1\right) \cdot y - x \end{array} \]
(FPCore (x y) :precision binary64 (- (* (+ x 1.0) y) x))
double code(double x, double y) {
	return ((x + 1.0) * y) - 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 + 1.0d0) * y) - x
end function
public static double code(double x, double y) {
	return ((x + 1.0) * y) - x;
}
def code(x, y):
	return ((x + 1.0) * y) - x
function code(x, y)
	return Float64(Float64(Float64(x + 1.0) * y) - x)
end
function tmp = code(x, y)
	tmp = ((x + 1.0) * y) - x;
end
code[x_, y_] := N[(N[(N[(x + 1.0), $MachinePrecision] * y), $MachinePrecision] - x), $MachinePrecision]
\begin{array}{l}

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

Alternative 1: 100.0% accurate, 1.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(y \cdot x + \color{blue}{y}\right) - x \]
    10. lower-fma.f64100.0

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, x, y\right)} - x \]
  4. Applied rewrites100.0%

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

Alternative 2: 85.3% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(x + 1\right) \cdot y - x\\ \mathbf{if}\;t\_0 \leq -2 \cdot 10^{+288} \lor \neg \left(t\_0 \leq 2 \cdot 10^{+279}\right):\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;y - x\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (- (* (+ x 1.0) y) x)))
   (if (or (<= t_0 -2e+288) (not (<= t_0 2e+279))) (* x y) (- y x))))
double code(double x, double y) {
	double t_0 = ((x + 1.0) * y) - x;
	double tmp;
	if ((t_0 <= -2e+288) || !(t_0 <= 2e+279)) {
		tmp = x * y;
	} else {
		tmp = y - 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) * y) - x
    if ((t_0 <= (-2d+288)) .or. (.not. (t_0 <= 2d+279))) then
        tmp = x * y
    else
        tmp = y - x
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = ((x + 1.0) * y) - x;
	double tmp;
	if ((t_0 <= -2e+288) || !(t_0 <= 2e+279)) {
		tmp = x * y;
	} else {
		tmp = y - x;
	}
	return tmp;
}
def code(x, y):
	t_0 = ((x + 1.0) * y) - x
	tmp = 0
	if (t_0 <= -2e+288) or not (t_0 <= 2e+279):
		tmp = x * y
	else:
		tmp = y - x
	return tmp
function code(x, y)
	t_0 = Float64(Float64(Float64(x + 1.0) * y) - x)
	tmp = 0.0
	if ((t_0 <= -2e+288) || !(t_0 <= 2e+279))
		tmp = Float64(x * y);
	else
		tmp = Float64(y - x);
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = ((x + 1.0) * y) - x;
	tmp = 0.0;
	if ((t_0 <= -2e+288) || ~((t_0 <= 2e+279)))
		tmp = x * y;
	else
		tmp = y - x;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(N[(N[(x + 1.0), $MachinePrecision] * y), $MachinePrecision] - x), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -2e+288], N[Not[LessEqual[t$95$0, 2e+279]], $MachinePrecision]], N[(x * y), $MachinePrecision], N[(y - x), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(x + 1\right) \cdot y - x\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{+288} \lor \neg \left(t\_0 \leq 2 \cdot 10^{+279}\right):\\
\;\;\;\;x \cdot y\\

\mathbf{else}:\\
\;\;\;\;y - x\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (*.f64 (+.f64 x #s(literal 1 binary64)) y) x) < -2e288 or 2.00000000000000012e279 < (-.f64 (*.f64 (+.f64 x #s(literal 1 binary64)) y) x)

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{y \cdot \left(1 + x\right)} \]
    4. Applied rewrites97.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, x, y\right)} \]
    5. Taylor expanded in x around inf

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

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

      if -2e288 < (-.f64 (*.f64 (+.f64 x #s(literal 1 binary64)) y) x) < 2.00000000000000012e279

      1. Initial program 100.0%

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

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

          \[\leadsto \color{blue}{y} - x \]
      5. Recombined 2 regimes into one program.
      6. Final simplification92.1%

        \[\leadsto \begin{array}{l} \mathbf{if}\;\left(x + 1\right) \cdot y - x \leq -2 \cdot 10^{+288} \lor \neg \left(\left(x + 1\right) \cdot y - x \leq 2 \cdot 10^{+279}\right):\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;y - x\\ \end{array} \]
      7. Add Preprocessing

      Alternative 3: 98.5% accurate, 0.6× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 1.08 \cdot 10^{-23}\right):\\ \;\;\;\;\left(y - 1\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;y - x\\ \end{array} \end{array} \]
      (FPCore (x y)
       :precision binary64
       (if (or (<= x -1.0) (not (<= x 1.08e-23))) (* (- y 1.0) x) (- y x)))
      double code(double x, double y) {
      	double tmp;
      	if ((x <= -1.0) || !(x <= 1.08e-23)) {
      		tmp = (y - 1.0) * x;
      	} else {
      		tmp = y - 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) :: tmp
          if ((x <= (-1.0d0)) .or. (.not. (x <= 1.08d-23))) then
              tmp = (y - 1.0d0) * x
          else
              tmp = y - x
          end if
          code = tmp
      end function
      
      public static double code(double x, double y) {
      	double tmp;
      	if ((x <= -1.0) || !(x <= 1.08e-23)) {
      		tmp = (y - 1.0) * x;
      	} else {
      		tmp = y - x;
      	}
      	return tmp;
      }
      
      def code(x, y):
      	tmp = 0
      	if (x <= -1.0) or not (x <= 1.08e-23):
      		tmp = (y - 1.0) * x
      	else:
      		tmp = y - x
      	return tmp
      
      function code(x, y)
      	tmp = 0.0
      	if ((x <= -1.0) || !(x <= 1.08e-23))
      		tmp = Float64(Float64(y - 1.0) * x);
      	else
      		tmp = Float64(y - x);
      	end
      	return tmp
      end
      
      function tmp_2 = code(x, y)
      	tmp = 0.0;
      	if ((x <= -1.0) || ~((x <= 1.08e-23)))
      		tmp = (y - 1.0) * x;
      	else
      		tmp = y - x;
      	end
      	tmp_2 = tmp;
      end
      
      code[x_, y_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 1.08e-23]], $MachinePrecision]], N[(N[(y - 1.0), $MachinePrecision] * x), $MachinePrecision], N[(y - x), $MachinePrecision]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 1.08 \cdot 10^{-23}\right):\\
      \;\;\;\;\left(y - 1\right) \cdot x\\
      
      \mathbf{else}:\\
      \;\;\;\;y - x\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if x < -1 or 1.08000000000000003e-23 < x

        1. Initial program 100.0%

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

          \[\leadsto \color{blue}{x \cdot \left(y - 1\right)} \]
        4. Step-by-step derivation
          1. Applied rewrites99.2%

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

          if -1 < x < 1.08000000000000003e-23

          1. Initial program 100.0%

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

            \[\leadsto \color{blue}{y} - x \]
          4. Step-by-step derivation
            1. Applied rewrites99.8%

              \[\leadsto \color{blue}{y} - x \]
          5. Recombined 2 regimes into one program.
          6. Final simplification99.5%

            \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 1.08 \cdot 10^{-23}\right):\\ \;\;\;\;\left(y - 1\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;y - x\\ \end{array} \]
          7. Add Preprocessing

          Alternative 4: 98.5% accurate, 0.6× speedup?

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

            1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

                \[\leadsto \left(y \cdot x + \color{blue}{y}\right) - x \]
              10. lower-fma.f64100.0

                \[\leadsto \color{blue}{\mathsf{fma}\left(y, x, y\right)} - x \]
            4. Applied rewrites100.0%

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

              \[\leadsto \color{blue}{x \cdot \left(y - 1\right)} \]
            6. Step-by-step derivation
              1. Applied rewrites98.1%

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

              if -1 < x < 1.08000000000000003e-23

              1. Initial program 100.0%

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

                \[\leadsto \color{blue}{y} - x \]
              4. Step-by-step derivation
                1. Applied rewrites99.8%

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

                if 1.08000000000000003e-23 < x

                1. Initial program 100.0%

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

                  \[\leadsto \color{blue}{x \cdot \left(y - 1\right)} \]
                4. Step-by-step derivation
                  1. Applied rewrites100.0%

                    \[\leadsto \color{blue}{\left(y - 1\right) \cdot x} \]
                5. Recombined 3 regimes into one program.
                6. Final simplification99.5%

                  \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;\mathsf{fma}\left(x, y, -x\right)\\ \mathbf{elif}\;x \leq 1.08 \cdot 10^{-23}:\\ \;\;\;\;y - x\\ \mathbf{else}:\\ \;\;\;\;\left(y - 1\right) \cdot x\\ \end{array} \]
                7. Add Preprocessing

                Alternative 5: 98.8% accurate, 0.6× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 2.45 \cdot 10^{-6}\right):\\ \;\;\;\;\mathsf{fma}\left(y, x, y\right)\\ \mathbf{else}:\\ \;\;\;\;y - x\\ \end{array} \end{array} \]
                (FPCore (x y)
                 :precision binary64
                 (if (or (<= y -1.0) (not (<= y 2.45e-6))) (fma y x y) (- y x)))
                double code(double x, double y) {
                	double tmp;
                	if ((y <= -1.0) || !(y <= 2.45e-6)) {
                		tmp = fma(y, x, y);
                	} else {
                		tmp = y - x;
                	}
                	return tmp;
                }
                
                function code(x, y)
                	tmp = 0.0
                	if ((y <= -1.0) || !(y <= 2.45e-6))
                		tmp = fma(y, x, y);
                	else
                		tmp = Float64(y - x);
                	end
                	return tmp
                end
                
                code[x_, y_] := If[Or[LessEqual[y, -1.0], N[Not[LessEqual[y, 2.45e-6]], $MachinePrecision]], N[(y * x + y), $MachinePrecision], N[(y - x), $MachinePrecision]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                \mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 2.45 \cdot 10^{-6}\right):\\
                \;\;\;\;\mathsf{fma}\left(y, x, y\right)\\
                
                \mathbf{else}:\\
                \;\;\;\;y - x\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if y < -1 or 2.44999999999999984e-6 < y

                  1. Initial program 100.0%

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

                    \[\leadsto \color{blue}{y \cdot \left(1 + x\right)} \]
                  4. Applied rewrites98.6%

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

                  if -1 < y < 2.44999999999999984e-6

                  1. Initial program 100.0%

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

                    \[\leadsto \color{blue}{y} - x \]
                  4. Step-by-step derivation
                    1. Applied rewrites99.1%

                      \[\leadsto \color{blue}{y} - x \]
                  5. Recombined 2 regimes into one program.
                  6. Final simplification98.9%

                    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 2.45 \cdot 10^{-6}\right):\\ \;\;\;\;\mathsf{fma}\left(y, x, y\right)\\ \mathbf{else}:\\ \;\;\;\;y - x\\ \end{array} \]
                  7. Add Preprocessing

                  Alternative 6: 63.5% accurate, 0.7× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -210000:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq 2.1 \cdot 10^{-51}:\\ \;\;\;\;-x\\ \mathbf{else}:\\ \;\;\;\;y + x\\ \end{array} \end{array} \]
                  (FPCore (x y)
                   :precision binary64
                   (if (<= y -210000.0) y (if (<= y 2.1e-51) (- x) (+ y x))))
                  double code(double x, double y) {
                  	double tmp;
                  	if (y <= -210000.0) {
                  		tmp = y;
                  	} else if (y <= 2.1e-51) {
                  		tmp = -x;
                  	} else {
                  		tmp = y + 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) :: tmp
                      if (y <= (-210000.0d0)) then
                          tmp = y
                      else if (y <= 2.1d-51) then
                          tmp = -x
                      else
                          tmp = y + x
                      end if
                      code = tmp
                  end function
                  
                  public static double code(double x, double y) {
                  	double tmp;
                  	if (y <= -210000.0) {
                  		tmp = y;
                  	} else if (y <= 2.1e-51) {
                  		tmp = -x;
                  	} else {
                  		tmp = y + x;
                  	}
                  	return tmp;
                  }
                  
                  def code(x, y):
                  	tmp = 0
                  	if y <= -210000.0:
                  		tmp = y
                  	elif y <= 2.1e-51:
                  		tmp = -x
                  	else:
                  		tmp = y + x
                  	return tmp
                  
                  function code(x, y)
                  	tmp = 0.0
                  	if (y <= -210000.0)
                  		tmp = y;
                  	elseif (y <= 2.1e-51)
                  		tmp = Float64(-x);
                  	else
                  		tmp = Float64(y + x);
                  	end
                  	return tmp
                  end
                  
                  function tmp_2 = code(x, y)
                  	tmp = 0.0;
                  	if (y <= -210000.0)
                  		tmp = y;
                  	elseif (y <= 2.1e-51)
                  		tmp = -x;
                  	else
                  		tmp = y + x;
                  	end
                  	tmp_2 = tmp;
                  end
                  
                  code[x_, y_] := If[LessEqual[y, -210000.0], y, If[LessEqual[y, 2.1e-51], (-x), N[(y + x), $MachinePrecision]]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  \mathbf{if}\;y \leq -210000:\\
                  \;\;\;\;y\\
                  
                  \mathbf{elif}\;y \leq 2.1 \cdot 10^{-51}:\\
                  \;\;\;\;-x\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;y + x\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 3 regimes
                  2. if y < -2.1e5

                    1. Initial program 100.0%

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

                      \[\leadsto \color{blue}{y} \]
                    4. Step-by-step derivation
                      1. Applied rewrites55.6%

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

                      if -2.1e5 < y < 2.10000000000000002e-51

                      1. Initial program 100.0%

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

                        \[\leadsto \color{blue}{-1 \cdot x} \]
                      4. Step-by-step derivation
                        1. Applied rewrites78.4%

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

                        if 2.10000000000000002e-51 < y

                        1. Initial program 100.0%

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

                          \[\leadsto \color{blue}{y} - x \]
                        4. Step-by-step derivation
                          1. Applied rewrites68.2%

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

                              \[\leadsto \color{blue}{y - x} \]
                            2. add-cube-cbrtN/A

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

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

                              \[\leadsto y + \color{blue}{\left(\mathsf{neg}\left(\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \sqrt[3]{x}\right)\right)} \]
                            5. add-cube-cbrtN/A

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

                              \[\leadsto y + \color{blue}{\left(-x\right)} \]
                            7. add-sqr-sqrtN/A

                              \[\leadsto y + \color{blue}{\sqrt{-x} \cdot \sqrt{-x}} \]
                            8. sqrt-unprodN/A

                              \[\leadsto y + \color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}} \]
                            9. lift-neg.f64N/A

                              \[\leadsto y + \sqrt{\color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(-x\right)} \]
                            10. lift-neg.f64N/A

                              \[\leadsto y + \sqrt{\left(\mathsf{neg}\left(x\right)\right) \cdot \color{blue}{\left(\mathsf{neg}\left(x\right)\right)}} \]
                            11. sqr-neg-revN/A

                              \[\leadsto y + \sqrt{\color{blue}{x \cdot x}} \]
                            12. sqrt-unprodN/A

                              \[\leadsto y + \color{blue}{\sqrt{x} \cdot \sqrt{x}} \]
                            13. add-sqr-sqrtN/A

                              \[\leadsto y + \color{blue}{x} \]
                            14. lower-+.f6464.1

                              \[\leadsto \color{blue}{y + x} \]
                          3. Applied rewrites64.1%

                            \[\leadsto \color{blue}{y + x} \]
                        5. Recombined 3 regimes into one program.
                        6. Final simplification69.3%

                          \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -210000:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq 2.1 \cdot 10^{-51}:\\ \;\;\;\;-x\\ \mathbf{else}:\\ \;\;\;\;y + x\\ \end{array} \]
                        7. Add Preprocessing

                        Alternative 7: 63.2% accurate, 0.8× speedup?

                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -210000:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq 2.1 \cdot 10^{-51}:\\ \;\;\;\;-x\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \end{array} \]
                        (FPCore (x y)
                         :precision binary64
                         (if (<= y -210000.0) y (if (<= y 2.1e-51) (- x) y)))
                        double code(double x, double y) {
                        	double tmp;
                        	if (y <= -210000.0) {
                        		tmp = y;
                        	} else if (y <= 2.1e-51) {
                        		tmp = -x;
                        	} else {
                        		tmp = 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 <= (-210000.0d0)) then
                                tmp = y
                            else if (y <= 2.1d-51) then
                                tmp = -x
                            else
                                tmp = y
                            end if
                            code = tmp
                        end function
                        
                        public static double code(double x, double y) {
                        	double tmp;
                        	if (y <= -210000.0) {
                        		tmp = y;
                        	} else if (y <= 2.1e-51) {
                        		tmp = -x;
                        	} else {
                        		tmp = y;
                        	}
                        	return tmp;
                        }
                        
                        def code(x, y):
                        	tmp = 0
                        	if y <= -210000.0:
                        		tmp = y
                        	elif y <= 2.1e-51:
                        		tmp = -x
                        	else:
                        		tmp = y
                        	return tmp
                        
                        function code(x, y)
                        	tmp = 0.0
                        	if (y <= -210000.0)
                        		tmp = y;
                        	elseif (y <= 2.1e-51)
                        		tmp = Float64(-x);
                        	else
                        		tmp = y;
                        	end
                        	return tmp
                        end
                        
                        function tmp_2 = code(x, y)
                        	tmp = 0.0;
                        	if (y <= -210000.0)
                        		tmp = y;
                        	elseif (y <= 2.1e-51)
                        		tmp = -x;
                        	else
                        		tmp = y;
                        	end
                        	tmp_2 = tmp;
                        end
                        
                        code[x_, y_] := If[LessEqual[y, -210000.0], y, If[LessEqual[y, 2.1e-51], (-x), y]]
                        
                        \begin{array}{l}
                        
                        \\
                        \begin{array}{l}
                        \mathbf{if}\;y \leq -210000:\\
                        \;\;\;\;y\\
                        
                        \mathbf{elif}\;y \leq 2.1 \cdot 10^{-51}:\\
                        \;\;\;\;-x\\
                        
                        \mathbf{else}:\\
                        \;\;\;\;y\\
                        
                        
                        \end{array}
                        \end{array}
                        
                        Derivation
                        1. Split input into 2 regimes
                        2. if y < -2.1e5 or 2.10000000000000002e-51 < y

                          1. Initial program 100.0%

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

                            \[\leadsto \color{blue}{y} \]
                          4. Step-by-step derivation
                            1. Applied rewrites60.4%

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

                            if -2.1e5 < y < 2.10000000000000002e-51

                            1. Initial program 100.0%

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

                              \[\leadsto \color{blue}{-1 \cdot x} \]
                            4. Step-by-step derivation
                              1. Applied rewrites78.4%

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

                            Alternative 8: 75.9% accurate, 3.0× speedup?

                            \[\begin{array}{l} \\ y - x \end{array} \]
                            (FPCore (x y) :precision binary64 (- y x))
                            double code(double x, double y) {
                            	return y - 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 = y - x
                            end function
                            
                            public static double code(double x, double y) {
                            	return y - x;
                            }
                            
                            def code(x, y):
                            	return y - x
                            
                            function code(x, y)
                            	return Float64(y - x)
                            end
                            
                            function tmp = code(x, y)
                            	tmp = y - x;
                            end
                            
                            code[x_, y_] := N[(y - x), $MachinePrecision]
                            
                            \begin{array}{l}
                            
                            \\
                            y - x
                            \end{array}
                            
                            Derivation
                            1. Initial program 100.0%

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

                              \[\leadsto \color{blue}{y} - x \]
                            4. Step-by-step derivation
                              1. Applied rewrites80.1%

                                \[\leadsto \color{blue}{y} - x \]
                              2. Final simplification80.1%

                                \[\leadsto y - x \]
                              3. Add Preprocessing

                              Alternative 9: 39.3% accurate, 12.0× speedup?

                              \[\begin{array}{l} \\ y \end{array} \]
                              (FPCore (x y) :precision binary64 y)
                              double code(double x, double y) {
                              	return 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 = y
                              end function
                              
                              public static double code(double x, double y) {
                              	return y;
                              }
                              
                              def code(x, y):
                              	return y
                              
                              function code(x, y)
                              	return y
                              end
                              
                              function tmp = code(x, y)
                              	tmp = y;
                              end
                              
                              code[x_, y_] := y
                              
                              \begin{array}{l}
                              
                              \\
                              y
                              \end{array}
                              
                              Derivation
                              1. Initial program 100.0%

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

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

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

                                Alternative 10: 2.6% accurate, 12.0× 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 100.0%

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

                                  \[\leadsto \color{blue}{-1 \cdot x} \]
                                4. Step-by-step derivation
                                  1. Applied rewrites40.9%

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

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

                                    Reproduce

                                    ?
                                    herbie shell --seed 2025021 
                                    (FPCore (x y)
                                      :name "Data.Colour.SRGB:transferFunction from colour-2.3.3"
                                      :precision binary64
                                      (- (* (+ x 1.0) y) x))