Data.Colour.SRGB:transferFunction from colour-2.3.3

Percentage Accurate: 100.0% → 100.0%
Time: 6.3s
Alternatives: 8
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;
}
real(8) function code(x, y)
    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 8 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 100.0% accurate, 1.0× speedup?

\[\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;
}
real(8) function code(x, y)
    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 - x\right) \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 fma(y, x, Float64(y - x))
end
code[x_, y_] := N[(y * x + N[(y - x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(y, x, y - x\right)
\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. *-rgt-identityN/A

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, x, y - x\right)} \]
    8. lower--.f64100.0

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

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

Alternative 2: 86.0% accurate, 0.3× speedup?

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

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

\mathbf{elif}\;t\_0 \leq 10^{+298}:\\
\;\;\;\;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) < -4.00000000000000021e301 or 9.9999999999999996e297 < (-.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. Step-by-step derivation
      1. +-commutativeN/A

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

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

        \[\leadsto y \cdot x + \color{blue}{y} \]
      4. lower-fma.f64100.0

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

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

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

        \[\leadsto \color{blue}{x \cdot y} \]
    8. Applied rewrites94.9%

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

    if -4.00000000000000021e301 < (-.f64 (*.f64 (+.f64 x #s(literal 1 binary64)) y) x) < 9.9999999999999996e297

    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}{1} \cdot y - x \]
    4. Step-by-step derivation
      1. Applied rewrites81.0%

        \[\leadsto \color{blue}{1} \cdot y - x \]
      2. Step-by-step derivation
        1. *-lft-identity81.0

          \[\leadsto \color{blue}{y} - x \]
      3. Applied rewrites81.0%

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot \left(x + 1\right) - x \leq -4 \cdot 10^{+301}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;y \cdot \left(x + 1\right) - x \leq 10^{+298}:\\ \;\;\;\;y - x\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
    7. Add Preprocessing

    Alternative 3: 98.8% accurate, 0.6× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(y, x, -x\right)\\ \mathbf{if}\;x \leq -1:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;y - x\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
    (FPCore (x y)
     :precision binary64
     (let* ((t_0 (fma y x (- x))))
       (if (<= x -1.0) t_0 (if (<= x 1.0) (- y x) t_0))))
    double code(double x, double y) {
    	double t_0 = fma(y, x, -x);
    	double tmp;
    	if (x <= -1.0) {
    		tmp = t_0;
    	} else if (x <= 1.0) {
    		tmp = y - x;
    	} else {
    		tmp = t_0;
    	}
    	return tmp;
    }
    
    function code(x, y)
    	t_0 = fma(y, x, Float64(-x))
    	tmp = 0.0
    	if (x <= -1.0)
    		tmp = t_0;
    	elseif (x <= 1.0)
    		tmp = Float64(y - x);
    	else
    		tmp = t_0;
    	end
    	return tmp
    end
    
    code[x_, y_] := Block[{t$95$0 = N[(y * x + (-x)), $MachinePrecision]}, If[LessEqual[x, -1.0], t$95$0, If[LessEqual[x, 1.0], N[(y - x), $MachinePrecision], t$95$0]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \mathsf{fma}\left(y, x, -x\right)\\
    \mathbf{if}\;x \leq -1:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;x \leq 1:\\
    \;\;\;\;y - x\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_0\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if x < -1 or 1 < 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 y} - x \]
      4. Step-by-step derivation
        1. *-commutativeN/A

          \[\leadsto \color{blue}{y \cdot x} - x \]
        2. lower-*.f6497.8

          \[\leadsto \color{blue}{y \cdot x} - x \]
      5. Applied rewrites97.8%

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

          \[\leadsto \color{blue}{y \cdot x} - x \]
        2. sub-negN/A

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

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

          \[\leadsto y \cdot x + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \]
        5. lower-fma.f6497.8

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

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

      if -1 < x < 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}{1} \cdot y - x \]
      4. Step-by-step derivation
        1. Applied rewrites98.8%

          \[\leadsto \color{blue}{1} \cdot y - x \]
        2. Step-by-step derivation
          1. *-lft-identity98.8

            \[\leadsto \color{blue}{y} - x \]
        3. Applied rewrites98.8%

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

      Alternative 4: 98.8% accurate, 0.6× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot x - x\\ \mathbf{if}\;x \leq -1:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;y - x\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
      (FPCore (x y)
       :precision binary64
       (let* ((t_0 (- (* y x) x))) (if (<= x -1.0) t_0 (if (<= x 1.0) (- y x) t_0))))
      double code(double x, double y) {
      	double t_0 = (y * x) - x;
      	double tmp;
      	if (x <= -1.0) {
      		tmp = t_0;
      	} else if (x <= 1.0) {
      		tmp = y - x;
      	} else {
      		tmp = t_0;
      	}
      	return tmp;
      }
      
      real(8) function code(x, y)
          real(8), intent (in) :: x
          real(8), intent (in) :: y
          real(8) :: t_0
          real(8) :: tmp
          t_0 = (y * x) - x
          if (x <= (-1.0d0)) then
              tmp = t_0
          else if (x <= 1.0d0) 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 * x) - x;
      	double tmp;
      	if (x <= -1.0) {
      		tmp = t_0;
      	} else if (x <= 1.0) {
      		tmp = y - x;
      	} else {
      		tmp = t_0;
      	}
      	return tmp;
      }
      
      def code(x, y):
      	t_0 = (y * x) - x
      	tmp = 0
      	if x <= -1.0:
      		tmp = t_0
      	elif x <= 1.0:
      		tmp = y - x
      	else:
      		tmp = t_0
      	return tmp
      
      function code(x, y)
      	t_0 = Float64(Float64(y * x) - x)
      	tmp = 0.0
      	if (x <= -1.0)
      		tmp = t_0;
      	elseif (x <= 1.0)
      		tmp = Float64(y - x);
      	else
      		tmp = t_0;
      	end
      	return tmp
      end
      
      function tmp_2 = code(x, y)
      	t_0 = (y * x) - x;
      	tmp = 0.0;
      	if (x <= -1.0)
      		tmp = t_0;
      	elseif (x <= 1.0)
      		tmp = y - x;
      	else
      		tmp = t_0;
      	end
      	tmp_2 = tmp;
      end
      
      code[x_, y_] := Block[{t$95$0 = N[(N[(y * x), $MachinePrecision] - x), $MachinePrecision]}, If[LessEqual[x, -1.0], t$95$0, If[LessEqual[x, 1.0], N[(y - x), $MachinePrecision], t$95$0]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := y \cdot x - x\\
      \mathbf{if}\;x \leq -1:\\
      \;\;\;\;t\_0\\
      
      \mathbf{elif}\;x \leq 1:\\
      \;\;\;\;y - x\\
      
      \mathbf{else}:\\
      \;\;\;\;t\_0\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if x < -1 or 1 < 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 y} - x \]
        4. Step-by-step derivation
          1. *-commutativeN/A

            \[\leadsto \color{blue}{y \cdot x} - x \]
          2. lower-*.f6497.8

            \[\leadsto \color{blue}{y \cdot x} - x \]
        5. Applied rewrites97.8%

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

        if -1 < x < 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}{1} \cdot y - x \]
        4. Step-by-step derivation
          1. Applied rewrites98.8%

            \[\leadsto \color{blue}{1} \cdot y - x \]
          2. Step-by-step derivation
            1. *-lft-identity98.8

              \[\leadsto \color{blue}{y} - x \]
          3. Applied rewrites98.8%

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

        Alternative 5: 98.9% accurate, 0.6× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1:\\ \;\;\;\;\mathsf{fma}\left(y, x, y\right)\\ \mathbf{elif}\;y \leq 1:\\ \;\;\;\;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 1.0) (- 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 <= 1.0) {
        		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 <= 1.0)
        		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, 1.0], 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 1:\\
        \;\;\;\;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 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. +-commutativeN/A

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

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

              \[\leadsto y \cdot x + \color{blue}{y} \]
            4. lower-fma.f6497.6

              \[\leadsto \color{blue}{\mathsf{fma}\left(y, x, y\right)} \]
          5. Applied rewrites97.6%

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

          if -1 < 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}{1} \cdot y - x \]
          4. Step-by-step derivation
            1. Applied rewrites98.0%

              \[\leadsto \color{blue}{1} \cdot y - x \]
            2. Step-by-step derivation
              1. *-lft-identity98.0

                \[\leadsto \color{blue}{y} - x \]
            3. Applied rewrites98.0%

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

          Alternative 6: 61.9% accurate, 0.7× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1.2 \cdot 10^{-10}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;y \leq 4.4 \cdot 10^{-83}:\\ \;\;\;\;-x\\ \mathbf{else}:\\ \;\;\;\;y + x\\ \end{array} \end{array} \]
          (FPCore (x y)
           :precision binary64
           (if (<= y -1.2e-10) (+ y x) (if (<= y 4.4e-83) (- x) (+ y x))))
          double code(double x, double y) {
          	double tmp;
          	if (y <= -1.2e-10) {
          		tmp = y + x;
          	} else if (y <= 4.4e-83) {
          		tmp = -x;
          	} else {
          		tmp = y + x;
          	}
          	return tmp;
          }
          
          real(8) function code(x, y)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              real(8) :: tmp
              if (y <= (-1.2d-10)) then
                  tmp = y + x
              else if (y <= 4.4d-83) 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 <= -1.2e-10) {
          		tmp = y + x;
          	} else if (y <= 4.4e-83) {
          		tmp = -x;
          	} else {
          		tmp = y + x;
          	}
          	return tmp;
          }
          
          def code(x, y):
          	tmp = 0
          	if y <= -1.2e-10:
          		tmp = y + x
          	elif y <= 4.4e-83:
          		tmp = -x
          	else:
          		tmp = y + x
          	return tmp
          
          function code(x, y)
          	tmp = 0.0
          	if (y <= -1.2e-10)
          		tmp = Float64(y + x);
          	elseif (y <= 4.4e-83)
          		tmp = Float64(-x);
          	else
          		tmp = Float64(y + x);
          	end
          	return tmp
          end
          
          function tmp_2 = code(x, y)
          	tmp = 0.0;
          	if (y <= -1.2e-10)
          		tmp = y + x;
          	elseif (y <= 4.4e-83)
          		tmp = -x;
          	else
          		tmp = y + x;
          	end
          	tmp_2 = tmp;
          end
          
          code[x_, y_] := If[LessEqual[y, -1.2e-10], N[(y + x), $MachinePrecision], If[LessEqual[y, 4.4e-83], (-x), N[(y + x), $MachinePrecision]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;y \leq -1.2 \cdot 10^{-10}:\\
          \;\;\;\;y + x\\
          
          \mathbf{elif}\;y \leq 4.4 \cdot 10^{-83}:\\
          \;\;\;\;-x\\
          
          \mathbf{else}:\\
          \;\;\;\;y + x\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if y < -1.2e-10 or 4.40000000000000015e-83 < 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}{1} \cdot y - x \]
            4. Step-by-step derivation
              1. Applied rewrites47.8%

                \[\leadsto \color{blue}{1} \cdot y - x \]
              2. Step-by-step derivation
                1. *-lft-identity47.8

                  \[\leadsto \color{blue}{y} - x \]
              3. Applied rewrites47.8%

                \[\leadsto \color{blue}{y} - x \]
              4. Step-by-step derivation
                1. sub-negN/A

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

                  \[\leadsto y + \color{blue}{\left(0 - x\right)} \]
                3. flip3--N/A

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

                  \[\leadsto y + \frac{\color{blue}{0} - {x}^{3}}{0 \cdot 0 + \left(x \cdot x + 0 \cdot x\right)} \]
                5. neg-sub0N/A

                  \[\leadsto y + \frac{\color{blue}{\mathsf{neg}\left({x}^{3}\right)}}{0 \cdot 0 + \left(x \cdot x + 0 \cdot x\right)} \]
                6. cube-negN/A

                  \[\leadsto y + \frac{\color{blue}{{\left(\mathsf{neg}\left(x\right)\right)}^{3}}}{0 \cdot 0 + \left(x \cdot x + 0 \cdot x\right)} \]
                7. lift-neg.f64N/A

                  \[\leadsto y + \frac{{\color{blue}{\left(\mathsf{neg}\left(x\right)\right)}}^{3}}{0 \cdot 0 + \left(x \cdot x + 0 \cdot x\right)} \]
                8. sqr-powN/A

                  \[\leadsto y + \frac{\color{blue}{{\left(\mathsf{neg}\left(x\right)\right)}^{\left(\frac{3}{2}\right)} \cdot {\left(\mathsf{neg}\left(x\right)\right)}^{\left(\frac{3}{2}\right)}}}{0 \cdot 0 + \left(x \cdot x + 0 \cdot x\right)} \]
                9. pow-prod-downN/A

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

                  \[\leadsto y + \frac{{\left(\color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(\mathsf{neg}\left(x\right)\right)\right)}^{\left(\frac{3}{2}\right)}}{0 \cdot 0 + \left(x \cdot x + 0 \cdot x\right)} \]
                11. lift-neg.f64N/A

                  \[\leadsto y + \frac{{\left(\left(\mathsf{neg}\left(x\right)\right) \cdot \color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right)}^{\left(\frac{3}{2}\right)}}{0 \cdot 0 + \left(x \cdot x + 0 \cdot x\right)} \]
                12. sqr-negN/A

                  \[\leadsto y + \frac{{\color{blue}{\left(x \cdot x\right)}}^{\left(\frac{3}{2}\right)}}{0 \cdot 0 + \left(x \cdot x + 0 \cdot x\right)} \]
                13. pow-prod-downN/A

                  \[\leadsto y + \frac{\color{blue}{{x}^{\left(\frac{3}{2}\right)} \cdot {x}^{\left(\frac{3}{2}\right)}}}{0 \cdot 0 + \left(x \cdot x + 0 \cdot x\right)} \]
                14. sqr-powN/A

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

                  \[\leadsto y + \frac{{x}^{3}}{\color{blue}{0} + \left(x \cdot x + 0 \cdot x\right)} \]
                16. +-lft-identityN/A

                  \[\leadsto y + \frac{{x}^{3}}{\color{blue}{x \cdot x + 0 \cdot x}} \]
                17. distribute-rgt-outN/A

                  \[\leadsto y + \frac{{x}^{3}}{\color{blue}{x \cdot \left(x + 0\right)}} \]
                18. +-commutativeN/A

                  \[\leadsto y + \frac{{x}^{3}}{x \cdot \color{blue}{\left(0 + x\right)}} \]
                19. +-lft-identityN/A

                  \[\leadsto y + \frac{{x}^{3}}{x \cdot \color{blue}{x}} \]
                20. pow2N/A

                  \[\leadsto y + \frac{{x}^{3}}{\color{blue}{{x}^{2}}} \]
                21. pow-divN/A

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

                  \[\leadsto y + {x}^{\color{blue}{1}} \]
                23. unpow1N/A

                  \[\leadsto y + \color{blue}{x} \]
                24. remove-double-negN/A

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

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

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

                  \[\leadsto y + \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot -1} \]
              5. Applied rewrites45.4%

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

              if -1.2e-10 < y < 4.40000000000000015e-83

              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. mul-1-negN/A

                  \[\leadsto \color{blue}{\mathsf{neg}\left(x\right)} \]
                2. lower-neg.f6482.8

                  \[\leadsto \color{blue}{-x} \]
              5. Applied rewrites82.8%

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

            Alternative 7: 74.7% 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;
            }
            
            real(8) function code(x, y)
                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}{1} \cdot y - x \]
            4. Step-by-step derivation
              1. Applied rewrites70.1%

                \[\leadsto \color{blue}{1} \cdot y - x \]
              2. Step-by-step derivation
                1. *-lft-identity70.1

                  \[\leadsto \color{blue}{y} - x \]
              3. Applied rewrites70.1%

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

              Alternative 8: 38.1% accurate, 4.0× speedup?

              \[\begin{array}{l} \\ -x \end{array} \]
              (FPCore (x y) :precision binary64 (- x))
              double code(double x, double y) {
              	return -x;
              }
              
              real(8) function code(x, y)
                  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 Float64(-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. mul-1-negN/A

                  \[\leadsto \color{blue}{\mathsf{neg}\left(x\right)} \]
                2. lower-neg.f6439.0

                  \[\leadsto \color{blue}{-x} \]
              5. Applied rewrites39.0%

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

              Reproduce

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