Graphics.Rendering.Chart.Plot.Vectors:renderPlotVectors from Chart-1.5.3

Percentage Accurate: 77.8% → 100.0%
Time: 6.6s
Alternatives: 7
Speedup: 1.5×

Specification

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

\\
x + \left(1 - x\right) \cdot \left(1 - y\right)
\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 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: 77.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x + \left(1 - x\right) \cdot \left(1 - y\right) \end{array} \]
(FPCore (x y) :precision binary64 (+ x (* (- 1.0 x) (- 1.0 y))))
double code(double x, double y) {
	return x + ((1.0 - x) * (1.0 - y));
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = x + ((1.0d0 - x) * (1.0d0 - y))
end function
public static double code(double x, double y) {
	return x + ((1.0 - x) * (1.0 - y));
}
def code(x, y):
	return x + ((1.0 - x) * (1.0 - y))
function code(x, y)
	return Float64(x + Float64(Float64(1.0 - x) * Float64(1.0 - y)))
end
function tmp = code(x, y)
	tmp = x + ((1.0 - x) * (1.0 - y));
end
code[x_, y_] := N[(x + N[(N[(1.0 - x), $MachinePrecision] * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Alternative 1: 100.0% accurate, 1.5× speedup?

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{\left(1 + \left(\mathsf{neg}\left(x\right)\right)\right)}\right), y, 1\right) \]
    7. +-commutativeN/A

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right) + \left(\mathsf{neg}\left(1\right)\right)}, y, 1\right) \]
    9. remove-double-negN/A

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

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

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

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

Alternative 2: 86.2% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1.2 \cdot 10^{-31}:\\ \;\;\;\;\left(x - 1\right) \cdot y\\ \mathbf{elif}\;y \leq 2.75 \cdot 10^{-83}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y, x, -y\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -1.2e-31) (* (- x 1.0) y) (if (<= y 2.75e-83) 1.0 (fma y x (- y)))))
double code(double x, double y) {
	double tmp;
	if (y <= -1.2e-31) {
		tmp = (x - 1.0) * y;
	} else if (y <= 2.75e-83) {
		tmp = 1.0;
	} else {
		tmp = fma(y, x, -y);
	}
	return tmp;
}
function code(x, y)
	tmp = 0.0
	if (y <= -1.2e-31)
		tmp = Float64(Float64(x - 1.0) * y);
	elseif (y <= 2.75e-83)
		tmp = 1.0;
	else
		tmp = fma(y, x, Float64(-y));
	end
	return tmp
end
code[x_, y_] := If[LessEqual[y, -1.2e-31], N[(N[(x - 1.0), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[y, 2.75e-83], 1.0, N[(y * x + (-y)), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.2 \cdot 10^{-31}:\\
\;\;\;\;\left(x - 1\right) \cdot y\\

\mathbf{elif}\;y \leq 2.75 \cdot 10^{-83}:\\
\;\;\;\;1\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, x, -y\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.2e-31

    1. Initial program 91.5%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(x - 1\right)} \cdot y \]
    5. Applied rewrites94.9%

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

    if -1.2e-31 < y < 2.74999999999999982e-83

    1. Initial program 44.7%

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

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

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

      if 2.74999999999999982e-83 < y

      1. Initial program 85.2%

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{\left(x - 1\right)} \cdot y \]
      5. Applied rewrites89.9%

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

          \[\leadsto \mathsf{fma}\left(y, \color{blue}{x}, -y\right) \]
      7. Recombined 3 regimes into one program.
      8. Add Preprocessing

      Alternative 3: 86.2% accurate, 0.7× speedup?

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

        1. Initial program 88.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

        if -1.2e-31 < y < 2.74999999999999982e-83

        1. Initial program 44.7%

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

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

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

        Alternative 4: 84.4% accurate, 0.8× speedup?

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

          1. Initial program 49.1%

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

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

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

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

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

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

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

              \[\leadsto x \cdot \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)\right)} \]
            7. remove-double-negN/A

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

              \[\leadsto \color{blue}{x \cdot y} \]
          5. Applied rewrites85.6%

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

          if -6.2000000000000002e75 < x < 2.9000000000000002e112

          1. Initial program 84.0%

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

            \[\leadsto \color{blue}{1 - y} \]
          4. Step-by-step derivation
            1. lower--.f6486.1

              \[\leadsto \color{blue}{1 - y} \]
          5. Applied rewrites86.1%

            \[\leadsto \color{blue}{1 - y} \]
        3. Recombined 2 regimes into one program.
        4. Final simplification85.9%

          \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -6.2 \cdot 10^{+75}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;x \leq 2.9 \cdot 10^{+112}:\\ \;\;\;\;1 - y\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
        5. Add Preprocessing

        Alternative 5: 62.1% accurate, 1.0× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1:\\ \;\;\;\;-y\\ \mathbf{elif}\;y \leq 1:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-y\\ \end{array} \end{array} \]
        (FPCore (x y)
         :precision binary64
         (if (<= y -1.0) (- y) (if (<= y 1.0) 1.0 (- y))))
        double code(double x, double y) {
        	double tmp;
        	if (y <= -1.0) {
        		tmp = -y;
        	} else if (y <= 1.0) {
        		tmp = 1.0;
        	} else {
        		tmp = -y;
        	}
        	return tmp;
        }
        
        real(8) function code(x, y)
            real(8), intent (in) :: x
            real(8), intent (in) :: y
            real(8) :: tmp
            if (y <= (-1.0d0)) then
                tmp = -y
            else if (y <= 1.0d0) then
                tmp = 1.0d0
            else
                tmp = -y
            end if
            code = tmp
        end function
        
        public static double code(double x, double y) {
        	double tmp;
        	if (y <= -1.0) {
        		tmp = -y;
        	} else if (y <= 1.0) {
        		tmp = 1.0;
        	} else {
        		tmp = -y;
        	}
        	return tmp;
        }
        
        def code(x, y):
        	tmp = 0
        	if y <= -1.0:
        		tmp = -y
        	elif y <= 1.0:
        		tmp = 1.0
        	else:
        		tmp = -y
        	return tmp
        
        function code(x, y)
        	tmp = 0.0
        	if (y <= -1.0)
        		tmp = Float64(-y);
        	elseif (y <= 1.0)
        		tmp = 1.0;
        	else
        		tmp = Float64(-y);
        	end
        	return tmp
        end
        
        function tmp_2 = code(x, y)
        	tmp = 0.0;
        	if (y <= -1.0)
        		tmp = -y;
        	elseif (y <= 1.0)
        		tmp = 1.0;
        	else
        		tmp = -y;
        	end
        	tmp_2 = tmp;
        end
        
        code[x_, y_] := If[LessEqual[y, -1.0], (-y), If[LessEqual[y, 1.0], 1.0, (-y)]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;y \leq -1:\\
        \;\;\;\;-y\\
        
        \mathbf{elif}\;y \leq 1:\\
        \;\;\;\;1\\
        
        \mathbf{else}:\\
        \;\;\;\;-y\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if y < -1 or 1 < y

          1. Initial program 100.0%

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

            \[\leadsto \color{blue}{1 - y} \]
          4. Step-by-step derivation
            1. lower--.f6452.9

              \[\leadsto \color{blue}{1 - y} \]
          5. Applied rewrites52.9%

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

            \[\leadsto -1 \cdot \color{blue}{y} \]
          7. Step-by-step derivation
            1. Applied rewrites52.5%

              \[\leadsto -y \]

            if -1 < y < 1

            1. Initial program 43.4%

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

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

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

            Alternative 6: 63.1% accurate, 3.8× speedup?

            \[\begin{array}{l} \\ 1 - y \end{array} \]
            (FPCore (x y) :precision binary64 (- 1.0 y))
            double code(double x, double y) {
            	return 1.0 - y;
            }
            
            real(8) function code(x, y)
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                code = 1.0d0 - y
            end function
            
            public static double code(double x, double y) {
            	return 1.0 - y;
            }
            
            def code(x, y):
            	return 1.0 - y
            
            function code(x, y)
            	return Float64(1.0 - y)
            end
            
            function tmp = code(x, y)
            	tmp = 1.0 - y;
            end
            
            code[x_, y_] := N[(1.0 - y), $MachinePrecision]
            
            \begin{array}{l}
            
            \\
            1 - y
            \end{array}
            
            Derivation
            1. Initial program 71.1%

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

              \[\leadsto \color{blue}{1 - y} \]
            4. Step-by-step derivation
              1. lower--.f6460.4

                \[\leadsto \color{blue}{1 - y} \]
            5. Applied rewrites60.4%

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

            Alternative 7: 39.0% accurate, 15.0× speedup?

            \[\begin{array}{l} \\ 1 \end{array} \]
            (FPCore (x y) :precision binary64 1.0)
            double code(double x, double y) {
            	return 1.0;
            }
            
            real(8) function code(x, y)
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                code = 1.0d0
            end function
            
            public static double code(double x, double y) {
            	return 1.0;
            }
            
            def code(x, y):
            	return 1.0
            
            function code(x, y)
            	return 1.0
            end
            
            function tmp = code(x, y)
            	tmp = 1.0;
            end
            
            code[x_, y_] := 1.0
            
            \begin{array}{l}
            
            \\
            1
            \end{array}
            
            Derivation
            1. Initial program 71.1%

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

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

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

              Developer Target 1: 100.0% accurate, 1.3× speedup?

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

              Reproduce

              ?
              herbie shell --seed 2024267 
              (FPCore (x y)
                :name "Graphics.Rendering.Chart.Plot.Vectors:renderPlotVectors from Chart-1.5.3"
                :precision binary64
              
                :alt
                (! :herbie-platform default (- (* y x) (- y 1)))
              
                (+ x (* (- 1.0 x) (- 1.0 y))))