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

Percentage Accurate: 78.0% → 100.0%
Time: 8.8s
Alternatives: 8
Speedup: 1.3×

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 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: 78.0% 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.3× speedup?

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

\\
\left(1 + y \cdot x\right) - y
\end{array}
Derivation
  1. Initial program 76.9%

    \[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
  2. Step-by-step derivation
    1. sub-negN/A

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(1 + 0 \cdot x\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
    11. metadata-evalN/A

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

      \[\leadsto \left(1 + 0 \cdot \left(-1 \cdot x\right)\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
    13. neg-mul-1N/A

      \[\leadsto \left(1 + 0 \cdot \left(\mathsf{neg}\left(x\right)\right)\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
    14. mul0-lftN/A

      \[\leadsto \left(1 + 0\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
    15. metadata-evalN/A

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

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

      \[\leadsto \mathsf{+.f64}\left(1, \left(\mathsf{neg}\left(y \cdot \left(1 - x\right)\right)\right)\right) \]
    18. distribute-rgt-neg-inN/A

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

      \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(1 + \left(\mathsf{neg}\left(x\right)\right)\right)\right)\right)\right)\right) \]
    20. +-commutativeN/A

      \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(x\right)\right) + 1\right)\right)\right)\right)\right) \]
    21. neg-sub0N/A

      \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(\left(0 - x\right) + 1\right)\right)\right)\right)\right) \]
    22. associate-+l-N/A

      \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(0 - \left(x - 1\right)\right)\right)\right)\right)\right) \]
    23. sub0-negN/A

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

      \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(x - \color{blue}{1}\right)\right)\right) \]
  3. Simplified100.0%

    \[\leadsto \color{blue}{1 + y \cdot \left(x + -1\right)} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. distribute-rgt-inN/A

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

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

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

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

      \[\leadsto \mathsf{\_.f64}\left(\left(1 + x \cdot y\right), \color{blue}{y}\right) \]
    6. +-lowering-+.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \left(x \cdot y\right)\right), y\right) \]
    7. *-commutativeN/A

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \left(y \cdot x\right)\right), y\right) \]
    8. *-lowering-*.f64100.0%

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(y, x\right)\right), y\right) \]
  6. Applied egg-rr100.0%

    \[\leadsto \color{blue}{\left(1 + y \cdot x\right) - y} \]
  7. Add Preprocessing

Alternative 2: 98.8% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;1 - y \leq -20000000:\\ \;\;\;\;y \cdot \left(x + -1\right)\\ \mathbf{elif}\;1 - y \leq 2:\\ \;\;\;\;1 + y \cdot x\\ \mathbf{else}:\\ \;\;\;\;y \cdot x - y\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= (- 1.0 y) -20000000.0)
   (* y (+ x -1.0))
   (if (<= (- 1.0 y) 2.0) (+ 1.0 (* y x)) (- (* y x) y))))
double code(double x, double y) {
	double tmp;
	if ((1.0 - y) <= -20000000.0) {
		tmp = y * (x + -1.0);
	} else if ((1.0 - y) <= 2.0) {
		tmp = 1.0 + (y * x);
	} else {
		tmp = (y * x) - y;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if ((1.0d0 - y) <= (-20000000.0d0)) then
        tmp = y * (x + (-1.0d0))
    else if ((1.0d0 - y) <= 2.0d0) then
        tmp = 1.0d0 + (y * x)
    else
        tmp = (y * x) - y
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if ((1.0 - y) <= -20000000.0) {
		tmp = y * (x + -1.0);
	} else if ((1.0 - y) <= 2.0) {
		tmp = 1.0 + (y * x);
	} else {
		tmp = (y * x) - y;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (1.0 - y) <= -20000000.0:
		tmp = y * (x + -1.0)
	elif (1.0 - y) <= 2.0:
		tmp = 1.0 + (y * x)
	else:
		tmp = (y * x) - y
	return tmp
function code(x, y)
	tmp = 0.0
	if (Float64(1.0 - y) <= -20000000.0)
		tmp = Float64(y * Float64(x + -1.0));
	elseif (Float64(1.0 - y) <= 2.0)
		tmp = Float64(1.0 + Float64(y * x));
	else
		tmp = Float64(Float64(y * x) - y);
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if ((1.0 - y) <= -20000000.0)
		tmp = y * (x + -1.0);
	elseif ((1.0 - y) <= 2.0)
		tmp = 1.0 + (y * x);
	else
		tmp = (y * x) - y;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[N[(1.0 - y), $MachinePrecision], -20000000.0], N[(y * N[(x + -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 - y), $MachinePrecision], 2.0], N[(1.0 + N[(y * x), $MachinePrecision]), $MachinePrecision], N[(N[(y * x), $MachinePrecision] - y), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;1 - y \leq -20000000:\\
\;\;\;\;y \cdot \left(x + -1\right)\\

\mathbf{elif}\;1 - y \leq 2:\\
\;\;\;\;1 + y \cdot x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (-.f64 #s(literal 1 binary64) y) < -2e7

    1. Initial program 100.0%

      \[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
    2. Step-by-step derivation
      1. sub-negN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(1 + 0 \cdot x\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      11. metadata-evalN/A

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

        \[\leadsto \left(1 + 0 \cdot \left(-1 \cdot x\right)\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      13. neg-mul-1N/A

        \[\leadsto \left(1 + 0 \cdot \left(\mathsf{neg}\left(x\right)\right)\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      14. mul0-lftN/A

        \[\leadsto \left(1 + 0\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      15. metadata-evalN/A

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

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(\mathsf{neg}\left(y \cdot \left(1 - x\right)\right)\right)\right) \]
      18. distribute-rgt-neg-inN/A

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(1 + \left(\mathsf{neg}\left(x\right)\right)\right)\right)\right)\right)\right) \]
      20. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(x\right)\right) + 1\right)\right)\right)\right)\right) \]
      21. neg-sub0N/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(\left(0 - x\right) + 1\right)\right)\right)\right)\right) \]
      22. associate-+l-N/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(0 - \left(x - 1\right)\right)\right)\right)\right)\right) \]
      23. sub0-negN/A

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(x - \color{blue}{1}\right)\right)\right) \]
    3. Simplified100.0%

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

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

        \[\leadsto \mathsf{*.f64}\left(y, \color{blue}{\left(x - 1\right)}\right) \]
      2. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(y, \left(x + \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}\right)\right) \]
      3. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(y, \left(x + -1\right)\right) \]
      4. +-lowering-+.f6499.3%

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{+.f64}\left(x, \color{blue}{-1}\right)\right) \]
    7. Simplified99.3%

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

    if -2e7 < (-.f64 #s(literal 1 binary64) y) < 2

    1. Initial program 54.2%

      \[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
    2. Step-by-step derivation
      1. sub-negN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(1 + 0 \cdot x\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      11. metadata-evalN/A

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

        \[\leadsto \left(1 + 0 \cdot \left(-1 \cdot x\right)\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      13. neg-mul-1N/A

        \[\leadsto \left(1 + 0 \cdot \left(\mathsf{neg}\left(x\right)\right)\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      14. mul0-lftN/A

        \[\leadsto \left(1 + 0\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      15. metadata-evalN/A

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

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(\mathsf{neg}\left(y \cdot \left(1 - x\right)\right)\right)\right) \]
      18. distribute-rgt-neg-inN/A

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(1 + \left(\mathsf{neg}\left(x\right)\right)\right)\right)\right)\right)\right) \]
      20. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(x\right)\right) + 1\right)\right)\right)\right)\right) \]
      21. neg-sub0N/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(\left(0 - x\right) + 1\right)\right)\right)\right)\right) \]
      22. associate-+l-N/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(0 - \left(x - 1\right)\right)\right)\right)\right)\right) \]
      23. sub0-negN/A

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(x - \color{blue}{1}\right)\right)\right) \]
    3. Simplified100.0%

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

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \color{blue}{x}\right)\right) \]
      2. *-lowering-*.f6498.9%

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(y, \color{blue}{x}\right)\right) \]
    7. Simplified98.9%

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

    if 2 < (-.f64 #s(literal 1 binary64) y)

    1. Initial program 100.0%

      \[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
    2. Step-by-step derivation
      1. sub-negN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(1 + 0 \cdot x\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      11. metadata-evalN/A

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

        \[\leadsto \left(1 + 0 \cdot \left(-1 \cdot x\right)\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      13. neg-mul-1N/A

        \[\leadsto \left(1 + 0 \cdot \left(\mathsf{neg}\left(x\right)\right)\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      14. mul0-lftN/A

        \[\leadsto \left(1 + 0\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      15. metadata-evalN/A

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

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(\mathsf{neg}\left(y \cdot \left(1 - x\right)\right)\right)\right) \]
      18. distribute-rgt-neg-inN/A

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(1 + \left(\mathsf{neg}\left(x\right)\right)\right)\right)\right)\right)\right) \]
      20. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(x\right)\right) + 1\right)\right)\right)\right)\right) \]
      21. neg-sub0N/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(\left(0 - x\right) + 1\right)\right)\right)\right)\right) \]
      22. associate-+l-N/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(0 - \left(x - 1\right)\right)\right)\right)\right)\right) \]
      23. sub0-negN/A

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(x - \color{blue}{1}\right)\right)\right) \]
    3. Simplified100.0%

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

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

        \[\leadsto \mathsf{*.f64}\left(y, \color{blue}{\left(x - 1\right)}\right) \]
      2. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(y, \left(x + \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}\right)\right) \]
      3. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(y, \left(x + -1\right)\right) \]
      4. +-lowering-+.f6499.4%

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{+.f64}\left(x, \color{blue}{-1}\right)\right) \]
    7. Simplified99.4%

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

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

        \[\leadsto y \cdot x + \color{blue}{-1} \cdot y \]
      3. neg-mul-1N/A

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

        \[\leadsto y \cdot x - \color{blue}{y} \]
      5. --lowering--.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\left(y \cdot x\right), \color{blue}{y}\right) \]
      6. *-lowering-*.f6499.5%

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{*.f64}\left(y, x\right), y\right) \]
    9. Applied egg-rr99.5%

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

Alternative 3: 98.8% accurate, 0.5× speedup?

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

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

\mathbf{elif}\;1 - y \leq 2:\\
\;\;\;\;1 + y \cdot x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 #s(literal 1 binary64) y) < -2e7 or 2 < (-.f64 #s(literal 1 binary64) y)

    1. Initial program 100.0%

      \[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
    2. Step-by-step derivation
      1. sub-negN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(1 + 0 \cdot x\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      11. metadata-evalN/A

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

        \[\leadsto \left(1 + 0 \cdot \left(-1 \cdot x\right)\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      13. neg-mul-1N/A

        \[\leadsto \left(1 + 0 \cdot \left(\mathsf{neg}\left(x\right)\right)\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      14. mul0-lftN/A

        \[\leadsto \left(1 + 0\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      15. metadata-evalN/A

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

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(\mathsf{neg}\left(y \cdot \left(1 - x\right)\right)\right)\right) \]
      18. distribute-rgt-neg-inN/A

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(1 + \left(\mathsf{neg}\left(x\right)\right)\right)\right)\right)\right)\right) \]
      20. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(x\right)\right) + 1\right)\right)\right)\right)\right) \]
      21. neg-sub0N/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(\left(0 - x\right) + 1\right)\right)\right)\right)\right) \]
      22. associate-+l-N/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(0 - \left(x - 1\right)\right)\right)\right)\right)\right) \]
      23. sub0-negN/A

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(x - \color{blue}{1}\right)\right)\right) \]
    3. Simplified100.0%

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

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

        \[\leadsto \mathsf{*.f64}\left(y, \color{blue}{\left(x - 1\right)}\right) \]
      2. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(y, \left(x + \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}\right)\right) \]
      3. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(y, \left(x + -1\right)\right) \]
      4. +-lowering-+.f6499.4%

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{+.f64}\left(x, \color{blue}{-1}\right)\right) \]
    7. Simplified99.4%

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

    if -2e7 < (-.f64 #s(literal 1 binary64) y) < 2

    1. Initial program 54.2%

      \[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
    2. Step-by-step derivation
      1. sub-negN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(1 + 0 \cdot x\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      11. metadata-evalN/A

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

        \[\leadsto \left(1 + 0 \cdot \left(-1 \cdot x\right)\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      13. neg-mul-1N/A

        \[\leadsto \left(1 + 0 \cdot \left(\mathsf{neg}\left(x\right)\right)\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      14. mul0-lftN/A

        \[\leadsto \left(1 + 0\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      15. metadata-evalN/A

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

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(\mathsf{neg}\left(y \cdot \left(1 - x\right)\right)\right)\right) \]
      18. distribute-rgt-neg-inN/A

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(1 + \left(\mathsf{neg}\left(x\right)\right)\right)\right)\right)\right)\right) \]
      20. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(x\right)\right) + 1\right)\right)\right)\right)\right) \]
      21. neg-sub0N/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(\left(0 - x\right) + 1\right)\right)\right)\right)\right) \]
      22. associate-+l-N/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(0 - \left(x - 1\right)\right)\right)\right)\right)\right) \]
      23. sub0-negN/A

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(x - \color{blue}{1}\right)\right)\right) \]
    3. Simplified100.0%

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

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \color{blue}{x}\right)\right) \]
      2. *-lowering-*.f6498.9%

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(y, \color{blue}{x}\right)\right) \]
    7. Simplified98.9%

      \[\leadsto 1 + \color{blue}{y \cdot x} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 4: 87.3% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -8400:\\ \;\;\;\;y \cdot \left(x + -1\right)\\ \mathbf{elif}\;x \leq 4.1 \cdot 10^{+24}:\\ \;\;\;\;1 - y\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x -8400.0) (* y (+ x -1.0)) (if (<= x 4.1e+24) (- 1.0 y) (* y x))))
double code(double x, double y) {
	double tmp;
	if (x <= -8400.0) {
		tmp = y * (x + -1.0);
	} else if (x <= 4.1e+24) {
		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 <= (-8400.0d0)) then
        tmp = y * (x + (-1.0d0))
    else if (x <= 4.1d+24) 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 <= -8400.0) {
		tmp = y * (x + -1.0);
	} else if (x <= 4.1e+24) {
		tmp = 1.0 - y;
	} else {
		tmp = y * x;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= -8400.0:
		tmp = y * (x + -1.0)
	elif x <= 4.1e+24:
		tmp = 1.0 - y
	else:
		tmp = y * x
	return tmp
function code(x, y)
	tmp = 0.0
	if (x <= -8400.0)
		tmp = Float64(y * Float64(x + -1.0));
	elseif (x <= 4.1e+24)
		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 <= -8400.0)
		tmp = y * (x + -1.0);
	elseif (x <= 4.1e+24)
		tmp = 1.0 - y;
	else
		tmp = y * x;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[x, -8400.0], N[(y * N[(x + -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4.1e+24], N[(1.0 - y), $MachinePrecision], N[(y * x), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -8400:\\
\;\;\;\;y \cdot \left(x + -1\right)\\

\mathbf{elif}\;x \leq 4.1 \cdot 10^{+24}:\\
\;\;\;\;1 - y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -8400

    1. Initial program 47.7%

      \[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
    2. Step-by-step derivation
      1. sub-negN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(1 + 0 \cdot x\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      11. metadata-evalN/A

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

        \[\leadsto \left(1 + 0 \cdot \left(-1 \cdot x\right)\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      13. neg-mul-1N/A

        \[\leadsto \left(1 + 0 \cdot \left(\mathsf{neg}\left(x\right)\right)\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      14. mul0-lftN/A

        \[\leadsto \left(1 + 0\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      15. metadata-evalN/A

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

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(\mathsf{neg}\left(y \cdot \left(1 - x\right)\right)\right)\right) \]
      18. distribute-rgt-neg-inN/A

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(1 + \left(\mathsf{neg}\left(x\right)\right)\right)\right)\right)\right)\right) \]
      20. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(x\right)\right) + 1\right)\right)\right)\right)\right) \]
      21. neg-sub0N/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(\left(0 - x\right) + 1\right)\right)\right)\right)\right) \]
      22. associate-+l-N/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(0 - \left(x - 1\right)\right)\right)\right)\right)\right) \]
      23. sub0-negN/A

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(x - \color{blue}{1}\right)\right)\right) \]
    3. Simplified100.0%

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

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

        \[\leadsto \mathsf{*.f64}\left(y, \color{blue}{\left(x - 1\right)}\right) \]
      2. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(y, \left(x + \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}\right)\right) \]
      3. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(y, \left(x + -1\right)\right) \]
      4. +-lowering-+.f6470.3%

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{+.f64}\left(x, \color{blue}{-1}\right)\right) \]
    7. Simplified70.3%

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

    if -8400 < x < 4.1000000000000001e24

    1. Initial program 98.6%

      \[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
    2. Step-by-step derivation
      1. sub-negN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(1 + 0 \cdot x\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      11. metadata-evalN/A

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

        \[\leadsto \left(1 + 0 \cdot \left(-1 \cdot x\right)\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      13. neg-mul-1N/A

        \[\leadsto \left(1 + 0 \cdot \left(\mathsf{neg}\left(x\right)\right)\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      14. mul0-lftN/A

        \[\leadsto \left(1 + 0\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      15. metadata-evalN/A

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

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(\mathsf{neg}\left(y \cdot \left(1 - x\right)\right)\right)\right) \]
      18. distribute-rgt-neg-inN/A

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(1 + \left(\mathsf{neg}\left(x\right)\right)\right)\right)\right)\right)\right) \]
      20. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(x\right)\right) + 1\right)\right)\right)\right)\right) \]
      21. neg-sub0N/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(\left(0 - x\right) + 1\right)\right)\right)\right)\right) \]
      22. associate-+l-N/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(0 - \left(x - 1\right)\right)\right)\right)\right)\right) \]
      23. sub0-negN/A

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(x - \color{blue}{1}\right)\right)\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{1 + y \cdot \left(x + -1\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0

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

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

        \[\leadsto 1 - \color{blue}{y} \]
      3. --lowering--.f6496.8%

        \[\leadsto \mathsf{\_.f64}\left(1, \color{blue}{y}\right) \]
    7. Simplified96.8%

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

    if 4.1000000000000001e24 < x

    1. Initial program 56.2%

      \[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
    2. Step-by-step derivation
      1. sub-negN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(1 + 0 \cdot x\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      11. metadata-evalN/A

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

        \[\leadsto \left(1 + 0 \cdot \left(-1 \cdot x\right)\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      13. neg-mul-1N/A

        \[\leadsto \left(1 + 0 \cdot \left(\mathsf{neg}\left(x\right)\right)\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      14. mul0-lftN/A

        \[\leadsto \left(1 + 0\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      15. metadata-evalN/A

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

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(\mathsf{neg}\left(y \cdot \left(1 - x\right)\right)\right)\right) \]
      18. distribute-rgt-neg-inN/A

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(1 + \left(\mathsf{neg}\left(x\right)\right)\right)\right)\right)\right)\right) \]
      20. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(x\right)\right) + 1\right)\right)\right)\right)\right) \]
      21. neg-sub0N/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(\left(0 - x\right) + 1\right)\right)\right)\right)\right) \]
      22. associate-+l-N/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(0 - \left(x - 1\right)\right)\right)\right)\right)\right) \]
      23. sub0-negN/A

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(x - \color{blue}{1}\right)\right)\right) \]
    3. Simplified100.0%

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

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

        \[\leadsto y \cdot \color{blue}{x} \]
      2. *-lowering-*.f6486.4%

        \[\leadsto \mathsf{*.f64}\left(y, \color{blue}{x}\right) \]
    7. Simplified86.4%

      \[\leadsto \color{blue}{y \cdot x} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 5: 87.3% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -4.2 \cdot 10^{+14}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;x \leq 2.3 \cdot 10^{+26}:\\ \;\;\;\;1 - y\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x -4.2e+14) (* y x) (if (<= x 2.3e+26) (- 1.0 y) (* y x))))
double code(double x, double y) {
	double tmp;
	if (x <= -4.2e+14) {
		tmp = y * x;
	} else if (x <= 2.3e+26) {
		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 <= (-4.2d+14)) then
        tmp = y * x
    else if (x <= 2.3d+26) 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 <= -4.2e+14) {
		tmp = y * x;
	} else if (x <= 2.3e+26) {
		tmp = 1.0 - y;
	} else {
		tmp = y * x;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= -4.2e+14:
		tmp = y * x
	elif x <= 2.3e+26:
		tmp = 1.0 - y
	else:
		tmp = y * x
	return tmp
function code(x, y)
	tmp = 0.0
	if (x <= -4.2e+14)
		tmp = Float64(y * x);
	elseif (x <= 2.3e+26)
		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 <= -4.2e+14)
		tmp = y * x;
	elseif (x <= 2.3e+26)
		tmp = 1.0 - y;
	else
		tmp = y * x;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[x, -4.2e+14], N[(y * x), $MachinePrecision], If[LessEqual[x, 2.3e+26], N[(1.0 - y), $MachinePrecision], N[(y * x), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.2 \cdot 10^{+14}:\\
\;\;\;\;y \cdot x\\

\mathbf{elif}\;x \leq 2.3 \cdot 10^{+26}:\\
\;\;\;\;1 - y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -4.2e14 or 2.3000000000000001e26 < x

    1. Initial program 49.4%

      \[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
    2. Step-by-step derivation
      1. sub-negN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(1 + 0 \cdot x\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      11. metadata-evalN/A

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

        \[\leadsto \left(1 + 0 \cdot \left(-1 \cdot x\right)\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      13. neg-mul-1N/A

        \[\leadsto \left(1 + 0 \cdot \left(\mathsf{neg}\left(x\right)\right)\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      14. mul0-lftN/A

        \[\leadsto \left(1 + 0\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      15. metadata-evalN/A

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

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(\mathsf{neg}\left(y \cdot \left(1 - x\right)\right)\right)\right) \]
      18. distribute-rgt-neg-inN/A

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(1 + \left(\mathsf{neg}\left(x\right)\right)\right)\right)\right)\right)\right) \]
      20. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(x\right)\right) + 1\right)\right)\right)\right)\right) \]
      21. neg-sub0N/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(\left(0 - x\right) + 1\right)\right)\right)\right)\right) \]
      22. associate-+l-N/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(0 - \left(x - 1\right)\right)\right)\right)\right)\right) \]
      23. sub0-negN/A

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(x - \color{blue}{1}\right)\right)\right) \]
    3. Simplified100.0%

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

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

        \[\leadsto y \cdot \color{blue}{x} \]
      2. *-lowering-*.f6478.4%

        \[\leadsto \mathsf{*.f64}\left(y, \color{blue}{x}\right) \]
    7. Simplified78.4%

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

    if -4.2e14 < x < 2.3000000000000001e26

    1. Initial program 98.6%

      \[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
    2. Step-by-step derivation
      1. sub-negN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(1 + 0 \cdot x\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      11. metadata-evalN/A

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

        \[\leadsto \left(1 + 0 \cdot \left(-1 \cdot x\right)\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      13. neg-mul-1N/A

        \[\leadsto \left(1 + 0 \cdot \left(\mathsf{neg}\left(x\right)\right)\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      14. mul0-lftN/A

        \[\leadsto \left(1 + 0\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      15. metadata-evalN/A

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

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(\mathsf{neg}\left(y \cdot \left(1 - x\right)\right)\right)\right) \]
      18. distribute-rgt-neg-inN/A

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(1 + \left(\mathsf{neg}\left(x\right)\right)\right)\right)\right)\right)\right) \]
      20. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(x\right)\right) + 1\right)\right)\right)\right)\right) \]
      21. neg-sub0N/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(\left(0 - x\right) + 1\right)\right)\right)\right)\right) \]
      22. associate-+l-N/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(0 - \left(x - 1\right)\right)\right)\right)\right)\right) \]
      23. sub0-negN/A

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(x - \color{blue}{1}\right)\right)\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{1 + y \cdot \left(x + -1\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0

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

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

        \[\leadsto 1 - \color{blue}{y} \]
      3. --lowering--.f6495.1%

        \[\leadsto \mathsf{\_.f64}\left(1, \color{blue}{y}\right) \]
    7. Simplified95.1%

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

Alternative 6: 62.7% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -22500000000000:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;x \leq 1.9 \cdot 10^{+38}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x -22500000000000.0) (* y x) (if (<= x 1.9e+38) 1.0 (* y x))))
double code(double x, double y) {
	double tmp;
	if (x <= -22500000000000.0) {
		tmp = y * x;
	} else if (x <= 1.9e+38) {
		tmp = 1.0;
	} 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 <= (-22500000000000.0d0)) then
        tmp = y * x
    else if (x <= 1.9d+38) then
        tmp = 1.0d0
    else
        tmp = y * x
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (x <= -22500000000000.0) {
		tmp = y * x;
	} else if (x <= 1.9e+38) {
		tmp = 1.0;
	} else {
		tmp = y * x;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= -22500000000000.0:
		tmp = y * x
	elif x <= 1.9e+38:
		tmp = 1.0
	else:
		tmp = y * x
	return tmp
function code(x, y)
	tmp = 0.0
	if (x <= -22500000000000.0)
		tmp = Float64(y * x);
	elseif (x <= 1.9e+38)
		tmp = 1.0;
	else
		tmp = Float64(y * x);
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= -22500000000000.0)
		tmp = y * x;
	elseif (x <= 1.9e+38)
		tmp = 1.0;
	else
		tmp = y * x;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[x, -22500000000000.0], N[(y * x), $MachinePrecision], If[LessEqual[x, 1.9e+38], 1.0, N[(y * x), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -22500000000000:\\
\;\;\;\;y \cdot x\\

\mathbf{elif}\;x \leq 1.9 \cdot 10^{+38}:\\
\;\;\;\;1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.25e13 or 1.8999999999999999e38 < x

    1. Initial program 49.3%

      \[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
    2. Step-by-step derivation
      1. sub-negN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(1 + 0 \cdot x\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      11. metadata-evalN/A

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

        \[\leadsto \left(1 + 0 \cdot \left(-1 \cdot x\right)\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      13. neg-mul-1N/A

        \[\leadsto \left(1 + 0 \cdot \left(\mathsf{neg}\left(x\right)\right)\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      14. mul0-lftN/A

        \[\leadsto \left(1 + 0\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      15. metadata-evalN/A

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

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(\mathsf{neg}\left(y \cdot \left(1 - x\right)\right)\right)\right) \]
      18. distribute-rgt-neg-inN/A

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(1 + \left(\mathsf{neg}\left(x\right)\right)\right)\right)\right)\right)\right) \]
      20. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(x\right)\right) + 1\right)\right)\right)\right)\right) \]
      21. neg-sub0N/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(\left(0 - x\right) + 1\right)\right)\right)\right)\right) \]
      22. associate-+l-N/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(0 - \left(x - 1\right)\right)\right)\right)\right)\right) \]
      23. sub0-negN/A

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(x - \color{blue}{1}\right)\right)\right) \]
    3. Simplified100.0%

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

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

        \[\leadsto y \cdot \color{blue}{x} \]
      2. *-lowering-*.f6478.9%

        \[\leadsto \mathsf{*.f64}\left(y, \color{blue}{x}\right) \]
    7. Simplified78.9%

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

    if -2.25e13 < x < 1.8999999999999999e38

    1. Initial program 98.0%

      \[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
    2. Step-by-step derivation
      1. sub-negN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(1 + 0 \cdot x\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      11. metadata-evalN/A

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

        \[\leadsto \left(1 + 0 \cdot \left(-1 \cdot x\right)\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      13. neg-mul-1N/A

        \[\leadsto \left(1 + 0 \cdot \left(\mathsf{neg}\left(x\right)\right)\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      14. mul0-lftN/A

        \[\leadsto \left(1 + 0\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      15. metadata-evalN/A

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

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(\mathsf{neg}\left(y \cdot \left(1 - x\right)\right)\right)\right) \]
      18. distribute-rgt-neg-inN/A

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(1 + \left(\mathsf{neg}\left(x\right)\right)\right)\right)\right)\right)\right) \]
      20. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(x\right)\right) + 1\right)\right)\right)\right)\right) \]
      21. neg-sub0N/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(\left(0 - x\right) + 1\right)\right)\right)\right)\right) \]
      22. associate-+l-N/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(0 - \left(x - 1\right)\right)\right)\right)\right)\right) \]
      23. sub0-negN/A

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(x - \color{blue}{1}\right)\right)\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{1 + y \cdot \left(x + -1\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around 0

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

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

    Alternative 7: 100.0% accurate, 1.3× speedup?

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

      \[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
    2. Step-by-step derivation
      1. sub-negN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(1 + 0 \cdot x\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      11. metadata-evalN/A

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

        \[\leadsto \left(1 + 0 \cdot \left(-1 \cdot x\right)\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      13. neg-mul-1N/A

        \[\leadsto \left(1 + 0 \cdot \left(\mathsf{neg}\left(x\right)\right)\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      14. mul0-lftN/A

        \[\leadsto \left(1 + 0\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      15. metadata-evalN/A

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

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(\mathsf{neg}\left(y \cdot \left(1 - x\right)\right)\right)\right) \]
      18. distribute-rgt-neg-inN/A

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(1 + \left(\mathsf{neg}\left(x\right)\right)\right)\right)\right)\right)\right) \]
      20. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(x\right)\right) + 1\right)\right)\right)\right)\right) \]
      21. neg-sub0N/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(\left(0 - x\right) + 1\right)\right)\right)\right)\right) \]
      22. associate-+l-N/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(0 - \left(x - 1\right)\right)\right)\right)\right)\right) \]
      23. sub0-negN/A

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(x - \color{blue}{1}\right)\right)\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{1 + y \cdot \left(x + -1\right)} \]
    4. Add Preprocessing
    5. Add Preprocessing

    Alternative 8: 37.7% accurate, 9.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 76.9%

      \[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
    2. Step-by-step derivation
      1. sub-negN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(1 + 0 \cdot x\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      11. metadata-evalN/A

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

        \[\leadsto \left(1 + 0 \cdot \left(-1 \cdot x\right)\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      13. neg-mul-1N/A

        \[\leadsto \left(1 + 0 \cdot \left(\mathsf{neg}\left(x\right)\right)\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      14. mul0-lftN/A

        \[\leadsto \left(1 + 0\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(1 - x\right) \]
      15. metadata-evalN/A

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

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(\mathsf{neg}\left(y \cdot \left(1 - x\right)\right)\right)\right) \]
      18. distribute-rgt-neg-inN/A

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(1 + \left(\mathsf{neg}\left(x\right)\right)\right)\right)\right)\right)\right) \]
      20. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(x\right)\right) + 1\right)\right)\right)\right)\right) \]
      21. neg-sub0N/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(\left(0 - x\right) + 1\right)\right)\right)\right)\right) \]
      22. associate-+l-N/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(\mathsf{neg}\left(\left(0 - \left(x - 1\right)\right)\right)\right)\right)\right) \]
      23. sub0-negN/A

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(y \cdot \left(x - \color{blue}{1}\right)\right)\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{1 + y \cdot \left(x + -1\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around 0

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

        \[\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 2024192 
      (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))))