Data.Colour.SRGB:transferFunction from colour-2.3.3

Percentage Accurate: 100.0% → 100.0%
Time: 3.0s
Alternatives: 6
Speedup: 1.0×

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 6 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.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}
Derivation
  1. Initial program 100.0%

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

Alternative 2: 86.9% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(x + 1\right) \cdot y - x\\ \mathbf{if}\;t\_0 \leq -1 \cdot 10^{+306} \lor \neg \left(t\_0 \leq 10^{+308}\right):\\ \;\;\;\;y \cdot x\\ \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 -1e+306) (not (<= t_0 1e+308))) (* y x) (- y x))))
double code(double x, double y) {
	double t_0 = ((x + 1.0) * y) - x;
	double tmp;
	if ((t_0 <= -1e+306) || !(t_0 <= 1e+308)) {
		tmp = y * 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) :: t_0
    real(8) :: tmp
    t_0 = ((x + 1.0d0) * y) - x
    if ((t_0 <= (-1d+306)) .or. (.not. (t_0 <= 1d+308))) then
        tmp = y * x
    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 <= -1e+306) || !(t_0 <= 1e+308)) {
		tmp = y * x;
	} else {
		tmp = y - x;
	}
	return tmp;
}
def code(x, y):
	t_0 = ((x + 1.0) * y) - x
	tmp = 0
	if (t_0 <= -1e+306) or not (t_0 <= 1e+308):
		tmp = y * x
	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 <= -1e+306) || !(t_0 <= 1e+308))
		tmp = Float64(y * x);
	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 <= -1e+306) || ~((t_0 <= 1e+308)))
		tmp = y * x;
	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, -1e+306], N[Not[LessEqual[t$95$0, 1e+308]], $MachinePrecision]], N[(y * x), $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 -1 \cdot 10^{+306} \lor \neg \left(t\_0 \leq 10^{+308}\right):\\
\;\;\;\;y \cdot x\\

\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) < -1.00000000000000002e306 or 1e308 < (-.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 x around 0

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

        \[\leadsto \color{blue}{y} - x \]
      2. Taylor expanded in x around inf

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

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

          \[\leadsto y \cdot x \]
        3. Step-by-step derivation
          1. Applied rewrites97.4%

            \[\leadsto y \cdot x \]

          if -1.00000000000000002e306 < (-.f64 (*.f64 (+.f64 x #s(literal 1 binary64)) y) x) < 1e308

          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 rewrites87.8%

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

            \[\leadsto \begin{array}{l} \mathbf{if}\;\left(x + 1\right) \cdot y - x \leq -1 \cdot 10^{+306} \lor \neg \left(\left(x + 1\right) \cdot y - x \leq 10^{+308}\right):\\ \;\;\;\;y \cdot x\\ \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}\;y \leq -1.12 \cdot 10^{+16} \lor \neg \left(y \leq 1\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.12e+16) (not (<= y 1.0))) (fma y x y) (- y x)))
          double code(double x, double y) {
          	double tmp;
          	if ((y <= -1.12e+16) || !(y <= 1.0)) {
          		tmp = fma(y, x, y);
          	} else {
          		tmp = y - x;
          	}
          	return tmp;
          }
          
          function code(x, y)
          	tmp = 0.0
          	if ((y <= -1.12e+16) || !(y <= 1.0))
          		tmp = fma(y, x, y);
          	else
          		tmp = Float64(y - x);
          	end
          	return tmp
          end
          
          code[x_, y_] := If[Or[LessEqual[y, -1.12e+16], N[Not[LessEqual[y, 1.0]], $MachinePrecision]], N[(y * x + y), $MachinePrecision], N[(y - x), $MachinePrecision]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;y \leq -1.12 \cdot 10^{+16} \lor \neg \left(y \leq 1\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.12e16 or 1 < 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. Step-by-step derivation
              1. Applied rewrites100.0%

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

              if -1.12e16 < y < 1

              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 rewrites98.9%

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

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

              Alternative 4: 61.8% accurate, 0.8× speedup?

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

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

                  if -1.18000000000000004e-17 < y < 2.4000000000000003e-100

                  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 rewrites79.7%

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

                  Alternative 5: 75.2% 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 rewrites76.7%

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

                    Alternative 6: 38.0% 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 rewrites39.6%

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

                      Reproduce

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