Data.Colour.SRGB:transferFunction from colour-2.3.3

Percentage Accurate: 100.0% → 100.0%
Time: 1.9s
Alternatives: 7
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}

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

Alternative 2: 99.0% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(y - 1\right) \cdot x\\ \mathbf{if}\;x \leq -1:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 0.00021:\\ \;\;\;\;y - x\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* (- y 1.0) x)))
   (if (<= x -1.0) t_0 (if (<= x 0.00021) (- y x) t_0))))
double code(double x, double y) {
	double t_0 = (y - 1.0) * x;
	double tmp;
	if (x <= -1.0) {
		tmp = t_0;
	} else if (x <= 0.00021) {
		tmp = y - x;
	} else {
		tmp = t_0;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (y - 1.0d0) * x
    if (x <= (-1.0d0)) then
        tmp = t_0
    else if (x <= 0.00021d0) then
        tmp = y - x
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = (y - 1.0) * x;
	double tmp;
	if (x <= -1.0) {
		tmp = t_0;
	} else if (x <= 0.00021) {
		tmp = y - x;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = (y - 1.0) * x
	tmp = 0
	if x <= -1.0:
		tmp = t_0
	elif x <= 0.00021:
		tmp = y - x
	else:
		tmp = t_0
	return tmp
function code(x, y)
	t_0 = Float64(Float64(y - 1.0) * x)
	tmp = 0.0
	if (x <= -1.0)
		tmp = t_0;
	elseif (x <= 0.00021)
		tmp = Float64(y - x);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = (y - 1.0) * x;
	tmp = 0.0;
	if (x <= -1.0)
		tmp = t_0;
	elseif (x <= 0.00021)
		tmp = y - x;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(N[(y - 1.0), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[x, -1.0], t$95$0, If[LessEqual[x, 0.00021], N[(y - x), $MachinePrecision], t$95$0]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq 0.00021:\\
\;\;\;\;y - x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1 or 2.1000000000000001e-4 < x

    1. Initial program 100.0%

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

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

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

        \[\leadsto \left(y - 1\right) \cdot \color{blue}{x} \]
      3. lower--.f6498.5

        \[\leadsto \left(y - 1\right) \cdot x \]
    4. Applied rewrites98.5%

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

    if -1 < x < 2.1000000000000001e-4

    1. Initial program 100.0%

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

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

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

    Alternative 3: 98.7% accurate, 0.7× speedup?

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

      1. Initial program 100.0%

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

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

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

          \[\leadsto x \cdot y + \color{blue}{1 \cdot y} \]
        3. *-commutativeN/A

          \[\leadsto y \cdot x + \color{blue}{1} \cdot y \]
        4. *-lft-identityN/A

          \[\leadsto y \cdot x + y \]
        5. lower-fma.f6498.8

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

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

      if -1 < y < 2.50000000000000012e-5

      1. Initial program 100.0%

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

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

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

      Alternative 4: 85.7% 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^{+276}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+307}:\\ \;\;\;\;y - x\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \end{array} \]
      (FPCore (x y)
       :precision binary64
       (let* ((t_0 (- (* (+ x 1.0) y) x)))
         (if (<= t_0 -1e+276) (* y x) (if (<= t_0 4e+307) (- y x) (* y x)))))
      double code(double x, double y) {
      	double t_0 = ((x + 1.0) * y) - x;
      	double tmp;
      	if (t_0 <= -1e+276) {
      		tmp = y * x;
      	} else if (t_0 <= 4e+307) {
      		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+276)) then
              tmp = y * x
          else if (t_0 <= 4d+307) 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+276) {
      		tmp = y * x;
      	} else if (t_0 <= 4e+307) {
      		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+276:
      		tmp = y * x
      	elif t_0 <= 4e+307:
      		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+276)
      		tmp = Float64(y * x);
      	elseif (t_0 <= 4e+307)
      		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+276)
      		tmp = y * x;
      	elseif (t_0 <= 4e+307)
      		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[LessEqual[t$95$0, -1e+276], N[(y * x), $MachinePrecision], If[LessEqual[t$95$0, 4e+307], 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^{+276}:\\
      \;\;\;\;y \cdot x\\
      
      \mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+307}:\\
      \;\;\;\;y - x\\
      
      \mathbf{else}:\\
      \;\;\;\;y \cdot 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.0000000000000001e276 or 3.99999999999999994e307 < (-.f64 (*.f64 (+.f64 x #s(literal 1 binary64)) y) x)

        1. Initial program 100.0%

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

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

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

            \[\leadsto \left(y - 1\right) \cdot \color{blue}{x} \]
          3. lower--.f6491.9

            \[\leadsto \left(y - 1\right) \cdot x \]
        4. Applied rewrites91.9%

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

          \[\leadsto y \cdot x \]
        6. Step-by-step derivation
          1. Applied rewrites84.9%

            \[\leadsto y \cdot x \]

          if -1.0000000000000001e276 < (-.f64 (*.f64 (+.f64 x #s(literal 1 binary64)) y) x) < 3.99999999999999994e307

          1. Initial program 100.0%

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

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

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

          Alternative 5: 74.8% accurate, 2.6× 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. Taylor expanded in x around 0

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

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

            Alternative 6: 62.4% accurate, 1.0× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1.05 \cdot 10^{-11}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq 4.6 \cdot 10^{-66}:\\ \;\;\;\;-x\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \end{array} \]
            (FPCore (x y)
             :precision binary64
             (if (<= y -1.05e-11) y (if (<= y 4.6e-66) (- x) y)))
            double code(double x, double y) {
            	double tmp;
            	if (y <= -1.05e-11) {
            		tmp = y;
            	} else if (y <= 4.6e-66) {
            		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.05d-11)) then
                    tmp = y
                else if (y <= 4.6d-66) 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.05e-11) {
            		tmp = y;
            	} else if (y <= 4.6e-66) {
            		tmp = -x;
            	} else {
            		tmp = y;
            	}
            	return tmp;
            }
            
            def code(x, y):
            	tmp = 0
            	if y <= -1.05e-11:
            		tmp = y
            	elif y <= 4.6e-66:
            		tmp = -x
            	else:
            		tmp = y
            	return tmp
            
            function code(x, y)
            	tmp = 0.0
            	if (y <= -1.05e-11)
            		tmp = y;
            	elseif (y <= 4.6e-66)
            		tmp = Float64(-x);
            	else
            		tmp = y;
            	end
            	return tmp
            end
            
            function tmp_2 = code(x, y)
            	tmp = 0.0;
            	if (y <= -1.05e-11)
            		tmp = y;
            	elseif (y <= 4.6e-66)
            		tmp = -x;
            	else
            		tmp = y;
            	end
            	tmp_2 = tmp;
            end
            
            code[x_, y_] := If[LessEqual[y, -1.05e-11], y, If[LessEqual[y, 4.6e-66], (-x), y]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            \mathbf{if}\;y \leq -1.05 \cdot 10^{-11}:\\
            \;\;\;\;y\\
            
            \mathbf{elif}\;y \leq 4.6 \cdot 10^{-66}:\\
            \;\;\;\;-x\\
            
            \mathbf{else}:\\
            \;\;\;\;y\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if y < -1.0499999999999999e-11 or 4.59999999999999984e-66 < y

              1. Initial program 100.0%

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

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

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

                if -1.0499999999999999e-11 < y < 4.59999999999999984e-66

                1. Initial program 100.0%

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

                  \[\leadsto \color{blue}{-1 \cdot x} \]
                3. Step-by-step derivation
                  1. mul-1-negN/A

                    \[\leadsto \mathsf{neg}\left(x\right) \]
                  2. lower-neg.f6478.4

                    \[\leadsto -x \]
                4. Applied rewrites78.4%

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

              Alternative 7: 38.4% accurate, 9.3× 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. Taylor expanded in x around 0

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

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

                Reproduce

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