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

Percentage Accurate: 77.2% → 100.0%
Time: 4.7s
Alternatives: 9
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 9 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.2% 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 + x \cdot y\right) - y \end{array} \]
(FPCore (x y) :precision binary64 (- (+ 1.0 (* x y)) y))
double code(double x, double y) {
	return (1.0 + (x * y)) - y;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = (1.0d0 + (x * y)) - y
end function
public static double code(double x, double y) {
	return (1.0 + (x * y)) - y;
}
def code(x, y):
	return (1.0 + (x * y)) - y
function code(x, y)
	return Float64(Float64(1.0 + Float64(x * y)) - y)
end
function tmp = code(x, y)
	tmp = (1.0 + (x * y)) - y;
end
code[x_, y_] := N[(N[(1.0 + N[(x * y), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]
\begin{array}{l}

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

    \[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
  2. Step-by-step derivation
    1. +-commutative79.6%

      \[\leadsto \color{blue}{\left(1 - x\right) \cdot \left(1 - y\right) + x} \]
    2. remove-double-neg79.6%

      \[\leadsto \left(1 - x\right) \cdot \left(1 - y\right) + \color{blue}{\left(-\left(-x\right)\right)} \]
    3. unsub-neg79.6%

      \[\leadsto \color{blue}{\left(1 - x\right) \cdot \left(1 - y\right) - \left(-x\right)} \]
    4. sub-neg79.6%

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

      \[\leadsto \left(1 - x\right) \cdot \color{blue}{\left(\left(-y\right) + 1\right)} - \left(-x\right) \]
    6. distribute-rgt-in79.6%

      \[\leadsto \color{blue}{\left(\left(-y\right) \cdot \left(1 - x\right) + 1 \cdot \left(1 - x\right)\right)} - \left(-x\right) \]
    7. *-lft-identity79.6%

      \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + \color{blue}{\left(1 - x\right)}\right) - \left(-x\right) \]
    8. associate-+r-79.6%

      \[\leadsto \color{blue}{\left(\left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - x\right)} - \left(-x\right) \]
    9. associate--l-100.0%

      \[\leadsto \color{blue}{\left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \left(x + \left(-x\right)\right)} \]
    10. sub-neg100.0%

      \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \color{blue}{\left(x - x\right)} \]
    11. +-inverses100.0%

      \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \color{blue}{0} \]
    12. --rgt-identity100.0%

      \[\leadsto \color{blue}{\left(-y\right) \cdot \left(1 - x\right) + 1} \]
    13. +-commutative100.0%

      \[\leadsto \color{blue}{1 + \left(-y\right) \cdot \left(1 - x\right)} \]
    14. distribute-lft-neg-out100.0%

      \[\leadsto 1 + \color{blue}{\left(-y \cdot \left(1 - x\right)\right)} \]
    15. distribute-rgt-neg-in100.0%

      \[\leadsto 1 + \color{blue}{y \cdot \left(-\left(1 - x\right)\right)} \]
    16. neg-sub0100.0%

      \[\leadsto 1 + y \cdot \color{blue}{\left(0 - \left(1 - x\right)\right)} \]
    17. associate--r-100.0%

      \[\leadsto 1 + y \cdot \color{blue}{\left(\left(0 - 1\right) + x\right)} \]
    18. metadata-eval100.0%

      \[\leadsto 1 + y \cdot \left(\color{blue}{-1} + x\right) \]
    19. +-commutative100.0%

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

    \[\leadsto \color{blue}{1 + y \cdot \left(x + -1\right)} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. distribute-lft-in100.0%

      \[\leadsto 1 + \color{blue}{\left(y \cdot x + y \cdot -1\right)} \]
    2. *-commutative100.0%

      \[\leadsto 1 + \left(y \cdot x + \color{blue}{-1 \cdot y}\right) \]
    3. mul-1-neg100.0%

      \[\leadsto 1 + \left(y \cdot x + \color{blue}{\left(-y\right)}\right) \]
  6. Applied egg-rr100.0%

    \[\leadsto 1 + \color{blue}{\left(y \cdot x + \left(-y\right)\right)} \]
  7. Taylor expanded in x around 0 100.0%

    \[\leadsto \color{blue}{\left(1 + x \cdot y\right) - y} \]
  8. Final simplification100.0%

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

Alternative 2: 98.5% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;1 - y \leq -5000000000 \lor \neg \left(1 - y \leq 2\right):\\ \;\;\;\;y \cdot \left(x + -1\right)\\ \mathbf{else}:\\ \;\;\;\;1 + x \cdot y\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (or (<= (- 1.0 y) -5000000000.0) (not (<= (- 1.0 y) 2.0)))
   (* y (+ x -1.0))
   (+ 1.0 (* x y))))
double code(double x, double y) {
	double tmp;
	if (((1.0 - y) <= -5000000000.0) || !((1.0 - y) <= 2.0)) {
		tmp = y * (x + -1.0);
	} else {
		tmp = 1.0 + (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) <= (-5000000000.0d0)) .or. (.not. ((1.0d0 - y) <= 2.0d0))) then
        tmp = y * (x + (-1.0d0))
    else
        tmp = 1.0d0 + (x * y)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (((1.0 - y) <= -5000000000.0) || !((1.0 - y) <= 2.0)) {
		tmp = y * (x + -1.0);
	} else {
		tmp = 1.0 + (x * y);
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if ((1.0 - y) <= -5000000000.0) or not ((1.0 - y) <= 2.0):
		tmp = y * (x + -1.0)
	else:
		tmp = 1.0 + (x * y)
	return tmp
function code(x, y)
	tmp = 0.0
	if ((Float64(1.0 - y) <= -5000000000.0) || !(Float64(1.0 - y) <= 2.0))
		tmp = Float64(y * Float64(x + -1.0));
	else
		tmp = Float64(1.0 + Float64(x * y));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (((1.0 - y) <= -5000000000.0) || ~(((1.0 - y) <= 2.0)))
		tmp = y * (x + -1.0);
	else
		tmp = 1.0 + (x * y);
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[Or[LessEqual[N[(1.0 - y), $MachinePrecision], -5000000000.0], N[Not[LessEqual[N[(1.0 - y), $MachinePrecision], 2.0]], $MachinePrecision]], N[(y * N[(x + -1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(x * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 1 y) < -5e9 or 2 < (-.f64 1 y)

    1. Initial program 100.0%

      \[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
    2. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto \color{blue}{\left(1 - x\right) \cdot \left(1 - y\right) + x} \]
      2. remove-double-neg100.0%

        \[\leadsto \left(1 - x\right) \cdot \left(1 - y\right) + \color{blue}{\left(-\left(-x\right)\right)} \]
      3. unsub-neg100.0%

        \[\leadsto \color{blue}{\left(1 - x\right) \cdot \left(1 - y\right) - \left(-x\right)} \]
      4. sub-neg100.0%

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

        \[\leadsto \left(1 - x\right) \cdot \color{blue}{\left(\left(-y\right) + 1\right)} - \left(-x\right) \]
      6. distribute-rgt-in100.0%

        \[\leadsto \color{blue}{\left(\left(-y\right) \cdot \left(1 - x\right) + 1 \cdot \left(1 - x\right)\right)} - \left(-x\right) \]
      7. *-lft-identity100.0%

        \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + \color{blue}{\left(1 - x\right)}\right) - \left(-x\right) \]
      8. associate-+r-100.0%

        \[\leadsto \color{blue}{\left(\left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - x\right)} - \left(-x\right) \]
      9. associate--l-100.0%

        \[\leadsto \color{blue}{\left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \left(x + \left(-x\right)\right)} \]
      10. sub-neg100.0%

        \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \color{blue}{\left(x - x\right)} \]
      11. +-inverses100.0%

        \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \color{blue}{0} \]
      12. --rgt-identity100.0%

        \[\leadsto \color{blue}{\left(-y\right) \cdot \left(1 - x\right) + 1} \]
      13. +-commutative100.0%

        \[\leadsto \color{blue}{1 + \left(-y\right) \cdot \left(1 - x\right)} \]
      14. distribute-lft-neg-out100.0%

        \[\leadsto 1 + \color{blue}{\left(-y \cdot \left(1 - x\right)\right)} \]
      15. distribute-rgt-neg-in100.0%

        \[\leadsto 1 + \color{blue}{y \cdot \left(-\left(1 - x\right)\right)} \]
      16. neg-sub0100.0%

        \[\leadsto 1 + y \cdot \color{blue}{\left(0 - \left(1 - x\right)\right)} \]
      17. associate--r-100.0%

        \[\leadsto 1 + y \cdot \color{blue}{\left(\left(0 - 1\right) + x\right)} \]
      18. metadata-eval100.0%

        \[\leadsto 1 + y \cdot \left(\color{blue}{-1} + x\right) \]
      19. +-commutative100.0%

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

      \[\leadsto \color{blue}{1 + y \cdot \left(x + -1\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. distribute-lft-in100.0%

        \[\leadsto 1 + \color{blue}{\left(y \cdot x + y \cdot -1\right)} \]
      2. *-commutative100.0%

        \[\leadsto 1 + \left(y \cdot x + \color{blue}{-1 \cdot y}\right) \]
      3. mul-1-neg100.0%

        \[\leadsto 1 + \left(y \cdot x + \color{blue}{\left(-y\right)}\right) \]
    6. Applied egg-rr100.0%

      \[\leadsto 1 + \color{blue}{\left(y \cdot x + \left(-y\right)\right)} \]
    7. Taylor expanded in x around 0 100.0%

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

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

    if -5e9 < (-.f64 1 y) < 2

    1. Initial program 58.3%

      \[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
    2. Step-by-step derivation
      1. +-commutative58.3%

        \[\leadsto \color{blue}{\left(1 - x\right) \cdot \left(1 - y\right) + x} \]
      2. remove-double-neg58.3%

        \[\leadsto \left(1 - x\right) \cdot \left(1 - y\right) + \color{blue}{\left(-\left(-x\right)\right)} \]
      3. unsub-neg58.3%

        \[\leadsto \color{blue}{\left(1 - x\right) \cdot \left(1 - y\right) - \left(-x\right)} \]
      4. sub-neg58.3%

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

        \[\leadsto \left(1 - x\right) \cdot \color{blue}{\left(\left(-y\right) + 1\right)} - \left(-x\right) \]
      6. distribute-rgt-in58.3%

        \[\leadsto \color{blue}{\left(\left(-y\right) \cdot \left(1 - x\right) + 1 \cdot \left(1 - x\right)\right)} - \left(-x\right) \]
      7. *-lft-identity58.3%

        \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + \color{blue}{\left(1 - x\right)}\right) - \left(-x\right) \]
      8. associate-+r-58.3%

        \[\leadsto \color{blue}{\left(\left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - x\right)} - \left(-x\right) \]
      9. associate--l-100.0%

        \[\leadsto \color{blue}{\left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \left(x + \left(-x\right)\right)} \]
      10. sub-neg100.0%

        \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \color{blue}{\left(x - x\right)} \]
      11. +-inverses100.0%

        \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \color{blue}{0} \]
      12. --rgt-identity100.0%

        \[\leadsto \color{blue}{\left(-y\right) \cdot \left(1 - x\right) + 1} \]
      13. +-commutative100.0%

        \[\leadsto \color{blue}{1 + \left(-y\right) \cdot \left(1 - x\right)} \]
      14. distribute-lft-neg-out100.0%

        \[\leadsto 1 + \color{blue}{\left(-y \cdot \left(1 - x\right)\right)} \]
      15. distribute-rgt-neg-in100.0%

        \[\leadsto 1 + \color{blue}{y \cdot \left(-\left(1 - x\right)\right)} \]
      16. neg-sub0100.0%

        \[\leadsto 1 + y \cdot \color{blue}{\left(0 - \left(1 - x\right)\right)} \]
      17. associate--r-100.0%

        \[\leadsto 1 + y \cdot \color{blue}{\left(\left(0 - 1\right) + x\right)} \]
      18. metadata-eval100.0%

        \[\leadsto 1 + y \cdot \left(\color{blue}{-1} + x\right) \]
      19. +-commutative100.0%

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

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

      \[\leadsto 1 + \color{blue}{x \cdot y} \]
    6. Step-by-step derivation
      1. *-commutative99.2%

        \[\leadsto 1 + \color{blue}{y \cdot x} \]
    7. Simplified99.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;1 - y \leq -5000000000 \lor \neg \left(1 - y \leq 2\right):\\ \;\;\;\;y \cdot \left(x + -1\right)\\ \mathbf{else}:\\ \;\;\;\;1 + x \cdot y\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 98.5% accurate, 0.5× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (-.f64 1 y) < -5e9

    1. Initial program 100.0%

      \[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
    2. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto \color{blue}{\left(1 - x\right) \cdot \left(1 - y\right) + x} \]
      2. remove-double-neg100.0%

        \[\leadsto \left(1 - x\right) \cdot \left(1 - y\right) + \color{blue}{\left(-\left(-x\right)\right)} \]
      3. unsub-neg100.0%

        \[\leadsto \color{blue}{\left(1 - x\right) \cdot \left(1 - y\right) - \left(-x\right)} \]
      4. sub-neg100.0%

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

        \[\leadsto \left(1 - x\right) \cdot \color{blue}{\left(\left(-y\right) + 1\right)} - \left(-x\right) \]
      6. distribute-rgt-in100.0%

        \[\leadsto \color{blue}{\left(\left(-y\right) \cdot \left(1 - x\right) + 1 \cdot \left(1 - x\right)\right)} - \left(-x\right) \]
      7. *-lft-identity100.0%

        \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + \color{blue}{\left(1 - x\right)}\right) - \left(-x\right) \]
      8. associate-+r-100.0%

        \[\leadsto \color{blue}{\left(\left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - x\right)} - \left(-x\right) \]
      9. associate--l-100.0%

        \[\leadsto \color{blue}{\left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \left(x + \left(-x\right)\right)} \]
      10. sub-neg100.0%

        \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \color{blue}{\left(x - x\right)} \]
      11. +-inverses100.0%

        \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \color{blue}{0} \]
      12. --rgt-identity100.0%

        \[\leadsto \color{blue}{\left(-y\right) \cdot \left(1 - x\right) + 1} \]
      13. +-commutative100.0%

        \[\leadsto \color{blue}{1 + \left(-y\right) \cdot \left(1 - x\right)} \]
      14. distribute-lft-neg-out100.0%

        \[\leadsto 1 + \color{blue}{\left(-y \cdot \left(1 - x\right)\right)} \]
      15. distribute-rgt-neg-in100.0%

        \[\leadsto 1 + \color{blue}{y \cdot \left(-\left(1 - x\right)\right)} \]
      16. neg-sub0100.0%

        \[\leadsto 1 + y \cdot \color{blue}{\left(0 - \left(1 - x\right)\right)} \]
      17. associate--r-100.0%

        \[\leadsto 1 + y \cdot \color{blue}{\left(\left(0 - 1\right) + x\right)} \]
      18. metadata-eval100.0%

        \[\leadsto 1 + y \cdot \left(\color{blue}{-1} + x\right) \]
      19. +-commutative100.0%

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

      \[\leadsto \color{blue}{1 + y \cdot \left(x + -1\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. distribute-lft-in100.0%

        \[\leadsto 1 + \color{blue}{\left(y \cdot x + y \cdot -1\right)} \]
      2. *-commutative100.0%

        \[\leadsto 1 + \left(y \cdot x + \color{blue}{-1 \cdot y}\right) \]
      3. mul-1-neg100.0%

        \[\leadsto 1 + \left(y \cdot x + \color{blue}{\left(-y\right)}\right) \]
    6. Applied egg-rr100.0%

      \[\leadsto 1 + \color{blue}{\left(y \cdot x + \left(-y\right)\right)} \]
    7. Taylor expanded in x around 0 100.0%

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

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

    if -5e9 < (-.f64 1 y) < 2

    1. Initial program 58.3%

      \[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
    2. Step-by-step derivation
      1. +-commutative58.3%

        \[\leadsto \color{blue}{\left(1 - x\right) \cdot \left(1 - y\right) + x} \]
      2. remove-double-neg58.3%

        \[\leadsto \left(1 - x\right) \cdot \left(1 - y\right) + \color{blue}{\left(-\left(-x\right)\right)} \]
      3. unsub-neg58.3%

        \[\leadsto \color{blue}{\left(1 - x\right) \cdot \left(1 - y\right) - \left(-x\right)} \]
      4. sub-neg58.3%

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

        \[\leadsto \left(1 - x\right) \cdot \color{blue}{\left(\left(-y\right) + 1\right)} - \left(-x\right) \]
      6. distribute-rgt-in58.3%

        \[\leadsto \color{blue}{\left(\left(-y\right) \cdot \left(1 - x\right) + 1 \cdot \left(1 - x\right)\right)} - \left(-x\right) \]
      7. *-lft-identity58.3%

        \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + \color{blue}{\left(1 - x\right)}\right) - \left(-x\right) \]
      8. associate-+r-58.3%

        \[\leadsto \color{blue}{\left(\left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - x\right)} - \left(-x\right) \]
      9. associate--l-100.0%

        \[\leadsto \color{blue}{\left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \left(x + \left(-x\right)\right)} \]
      10. sub-neg100.0%

        \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \color{blue}{\left(x - x\right)} \]
      11. +-inverses100.0%

        \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \color{blue}{0} \]
      12. --rgt-identity100.0%

        \[\leadsto \color{blue}{\left(-y\right) \cdot \left(1 - x\right) + 1} \]
      13. +-commutative100.0%

        \[\leadsto \color{blue}{1 + \left(-y\right) \cdot \left(1 - x\right)} \]
      14. distribute-lft-neg-out100.0%

        \[\leadsto 1 + \color{blue}{\left(-y \cdot \left(1 - x\right)\right)} \]
      15. distribute-rgt-neg-in100.0%

        \[\leadsto 1 + \color{blue}{y \cdot \left(-\left(1 - x\right)\right)} \]
      16. neg-sub0100.0%

        \[\leadsto 1 + y \cdot \color{blue}{\left(0 - \left(1 - x\right)\right)} \]
      17. associate--r-100.0%

        \[\leadsto 1 + y \cdot \color{blue}{\left(\left(0 - 1\right) + x\right)} \]
      18. metadata-eval100.0%

        \[\leadsto 1 + y \cdot \left(\color{blue}{-1} + x\right) \]
      19. +-commutative100.0%

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

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

      \[\leadsto 1 + \color{blue}{x \cdot y} \]
    6. Step-by-step derivation
      1. *-commutative99.2%

        \[\leadsto 1 + \color{blue}{y \cdot x} \]
    7. Simplified99.2%

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

    if 2 < (-.f64 1 y)

    1. Initial program 99.9%

      \[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
    2. Step-by-step derivation
      1. +-commutative99.9%

        \[\leadsto \color{blue}{\left(1 - x\right) \cdot \left(1 - y\right) + x} \]
      2. remove-double-neg99.9%

        \[\leadsto \left(1 - x\right) \cdot \left(1 - y\right) + \color{blue}{\left(-\left(-x\right)\right)} \]
      3. unsub-neg99.9%

        \[\leadsto \color{blue}{\left(1 - x\right) \cdot \left(1 - y\right) - \left(-x\right)} \]
      4. sub-neg99.9%

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

        \[\leadsto \left(1 - x\right) \cdot \color{blue}{\left(\left(-y\right) + 1\right)} - \left(-x\right) \]
      6. distribute-rgt-in99.9%

        \[\leadsto \color{blue}{\left(\left(-y\right) \cdot \left(1 - x\right) + 1 \cdot \left(1 - x\right)\right)} - \left(-x\right) \]
      7. *-lft-identity99.9%

        \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + \color{blue}{\left(1 - x\right)}\right) - \left(-x\right) \]
      8. associate-+r-99.9%

        \[\leadsto \color{blue}{\left(\left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - x\right)} - \left(-x\right) \]
      9. associate--l-99.9%

        \[\leadsto \color{blue}{\left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \left(x + \left(-x\right)\right)} \]
      10. sub-neg99.9%

        \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \color{blue}{\left(x - x\right)} \]
      11. +-inverses99.9%

        \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \color{blue}{0} \]
      12. --rgt-identity99.9%

        \[\leadsto \color{blue}{\left(-y\right) \cdot \left(1 - x\right) + 1} \]
      13. +-commutative99.9%

        \[\leadsto \color{blue}{1 + \left(-y\right) \cdot \left(1 - x\right)} \]
      14. distribute-lft-neg-out99.9%

        \[\leadsto 1 + \color{blue}{\left(-y \cdot \left(1 - x\right)\right)} \]
      15. distribute-rgt-neg-in99.9%

        \[\leadsto 1 + \color{blue}{y \cdot \left(-\left(1 - x\right)\right)} \]
      16. neg-sub099.9%

        \[\leadsto 1 + y \cdot \color{blue}{\left(0 - \left(1 - x\right)\right)} \]
      17. associate--r-99.9%

        \[\leadsto 1 + y \cdot \color{blue}{\left(\left(0 - 1\right) + x\right)} \]
      18. metadata-eval99.9%

        \[\leadsto 1 + y \cdot \left(\color{blue}{-1} + x\right) \]
      19. +-commutative99.9%

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

      \[\leadsto \color{blue}{1 + y \cdot \left(x + -1\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. distribute-lft-in100.0%

        \[\leadsto 1 + \color{blue}{\left(y \cdot x + y \cdot -1\right)} \]
      2. *-commutative100.0%

        \[\leadsto 1 + \left(y \cdot x + \color{blue}{-1 \cdot y}\right) \]
      3. mul-1-neg100.0%

        \[\leadsto 1 + \left(y \cdot x + \color{blue}{\left(-y\right)}\right) \]
    6. Applied egg-rr100.0%

      \[\leadsto 1 + \color{blue}{\left(y \cdot x + \left(-y\right)\right)} \]
    7. Taylor expanded in x around 0 100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;1 - y \leq -5000000000:\\ \;\;\;\;y \cdot \left(x + -1\right)\\ \mathbf{elif}\;1 - y \leq 2:\\ \;\;\;\;1 + x \cdot y\\ \mathbf{else}:\\ \;\;\;\;x \cdot y - y\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 62.0% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.5 \cdot 10^{+30}:\\
\;\;\;\;-y\\

\mathbf{elif}\;y \leq -1.9 \cdot 10^{-23}:\\
\;\;\;\;x \cdot y\\

\mathbf{elif}\;y \leq 3.7 \cdot 10^{-8}:\\
\;\;\;\;1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -2.4999999999999999e30 or 3.7e-8 < y

    1. Initial program 99.7%

      \[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
    2. Step-by-step derivation
      1. +-commutative99.7%

        \[\leadsto \color{blue}{\left(1 - x\right) \cdot \left(1 - y\right) + x} \]
      2. remove-double-neg99.7%

        \[\leadsto \left(1 - x\right) \cdot \left(1 - y\right) + \color{blue}{\left(-\left(-x\right)\right)} \]
      3. unsub-neg99.7%

        \[\leadsto \color{blue}{\left(1 - x\right) \cdot \left(1 - y\right) - \left(-x\right)} \]
      4. sub-neg99.7%

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

        \[\leadsto \left(1 - x\right) \cdot \color{blue}{\left(\left(-y\right) + 1\right)} - \left(-x\right) \]
      6. distribute-rgt-in99.7%

        \[\leadsto \color{blue}{\left(\left(-y\right) \cdot \left(1 - x\right) + 1 \cdot \left(1 - x\right)\right)} - \left(-x\right) \]
      7. *-lft-identity99.7%

        \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + \color{blue}{\left(1 - x\right)}\right) - \left(-x\right) \]
      8. associate-+r-99.7%

        \[\leadsto \color{blue}{\left(\left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - x\right)} - \left(-x\right) \]
      9. associate--l-100.0%

        \[\leadsto \color{blue}{\left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \left(x + \left(-x\right)\right)} \]
      10. sub-neg100.0%

        \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \color{blue}{\left(x - x\right)} \]
      11. +-inverses100.0%

        \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \color{blue}{0} \]
      12. --rgt-identity100.0%

        \[\leadsto \color{blue}{\left(-y\right) \cdot \left(1 - x\right) + 1} \]
      13. +-commutative100.0%

        \[\leadsto \color{blue}{1 + \left(-y\right) \cdot \left(1 - x\right)} \]
      14. distribute-lft-neg-out100.0%

        \[\leadsto 1 + \color{blue}{\left(-y \cdot \left(1 - x\right)\right)} \]
      15. distribute-rgt-neg-in100.0%

        \[\leadsto 1 + \color{blue}{y \cdot \left(-\left(1 - x\right)\right)} \]
      16. neg-sub0100.0%

        \[\leadsto 1 + y \cdot \color{blue}{\left(0 - \left(1 - x\right)\right)} \]
      17. associate--r-100.0%

        \[\leadsto 1 + y \cdot \color{blue}{\left(\left(0 - 1\right) + x\right)} \]
      18. metadata-eval100.0%

        \[\leadsto 1 + y \cdot \left(\color{blue}{-1} + x\right) \]
      19. +-commutative100.0%

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

      \[\leadsto \color{blue}{1 + y \cdot \left(x + -1\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. distribute-lft-in100.0%

        \[\leadsto 1 + \color{blue}{\left(y \cdot x + y \cdot -1\right)} \]
      2. *-commutative100.0%

        \[\leadsto 1 + \left(y \cdot x + \color{blue}{-1 \cdot y}\right) \]
      3. mul-1-neg100.0%

        \[\leadsto 1 + \left(y \cdot x + \color{blue}{\left(-y\right)}\right) \]
    6. Applied egg-rr100.0%

      \[\leadsto 1 + \color{blue}{\left(y \cdot x + \left(-y\right)\right)} \]
    7. Taylor expanded in x around 0 100.0%

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

      \[\leadsto \color{blue}{y \cdot \left(x - 1\right)} \]
    9. Taylor expanded in x around 0 58.7%

      \[\leadsto \color{blue}{-1 \cdot y} \]
    10. Step-by-step derivation
      1. neg-mul-158.7%

        \[\leadsto \color{blue}{-y} \]
    11. Simplified58.7%

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

    if -2.4999999999999999e30 < y < -1.90000000000000006e-23

    1. Initial program 60.2%

      \[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
    2. Step-by-step derivation
      1. +-commutative60.2%

        \[\leadsto \color{blue}{\left(1 - x\right) \cdot \left(1 - y\right) + x} \]
      2. remove-double-neg60.2%

        \[\leadsto \left(1 - x\right) \cdot \left(1 - y\right) + \color{blue}{\left(-\left(-x\right)\right)} \]
      3. unsub-neg60.2%

        \[\leadsto \color{blue}{\left(1 - x\right) \cdot \left(1 - y\right) - \left(-x\right)} \]
      4. sub-neg60.2%

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

        \[\leadsto \left(1 - x\right) \cdot \color{blue}{\left(\left(-y\right) + 1\right)} - \left(-x\right) \]
      6. distribute-rgt-in60.5%

        \[\leadsto \color{blue}{\left(\left(-y\right) \cdot \left(1 - x\right) + 1 \cdot \left(1 - x\right)\right)} - \left(-x\right) \]
      7. *-lft-identity60.5%

        \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + \color{blue}{\left(1 - x\right)}\right) - \left(-x\right) \]
      8. associate-+r-60.5%

        \[\leadsto \color{blue}{\left(\left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - x\right)} - \left(-x\right) \]
      9. associate--l-100.0%

        \[\leadsto \color{blue}{\left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \left(x + \left(-x\right)\right)} \]
      10. sub-neg100.0%

        \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \color{blue}{\left(x - x\right)} \]
      11. +-inverses100.0%

        \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \color{blue}{0} \]
      12. --rgt-identity100.0%

        \[\leadsto \color{blue}{\left(-y\right) \cdot \left(1 - x\right) + 1} \]
      13. +-commutative100.0%

        \[\leadsto \color{blue}{1 + \left(-y\right) \cdot \left(1 - x\right)} \]
      14. distribute-lft-neg-out100.0%

        \[\leadsto 1 + \color{blue}{\left(-y \cdot \left(1 - x\right)\right)} \]
      15. distribute-rgt-neg-in100.0%

        \[\leadsto 1 + \color{blue}{y \cdot \left(-\left(1 - x\right)\right)} \]
      16. neg-sub0100.0%

        \[\leadsto 1 + y \cdot \color{blue}{\left(0 - \left(1 - x\right)\right)} \]
      17. associate--r-100.0%

        \[\leadsto 1 + y \cdot \color{blue}{\left(\left(0 - 1\right) + x\right)} \]
      18. metadata-eval100.0%

        \[\leadsto 1 + y \cdot \left(\color{blue}{-1} + x\right) \]
      19. +-commutative100.0%

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

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

      \[\leadsto 1 + \color{blue}{x \cdot y} \]
    6. Step-by-step derivation
      1. *-commutative87.4%

        \[\leadsto 1 + \color{blue}{y \cdot x} \]
    7. Simplified87.4%

      \[\leadsto 1 + \color{blue}{y \cdot x} \]
    8. Taylor expanded in y around inf 77.6%

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

    if -1.90000000000000006e-23 < y < 3.7e-8

    1. Initial program 59.5%

      \[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
    2. Step-by-step derivation
      1. +-commutative59.5%

        \[\leadsto \color{blue}{\left(1 - x\right) \cdot \left(1 - y\right) + x} \]
      2. remove-double-neg59.5%

        \[\leadsto \left(1 - x\right) \cdot \left(1 - y\right) + \color{blue}{\left(-\left(-x\right)\right)} \]
      3. unsub-neg59.5%

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

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

        \[\leadsto \left(1 - x\right) \cdot \color{blue}{\left(\left(-y\right) + 1\right)} - \left(-x\right) \]
      6. distribute-rgt-in59.5%

        \[\leadsto \color{blue}{\left(\left(-y\right) \cdot \left(1 - x\right) + 1 \cdot \left(1 - x\right)\right)} - \left(-x\right) \]
      7. *-lft-identity59.5%

        \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + \color{blue}{\left(1 - x\right)}\right) - \left(-x\right) \]
      8. associate-+r-59.5%

        \[\leadsto \color{blue}{\left(\left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - x\right)} - \left(-x\right) \]
      9. associate--l-100.0%

        \[\leadsto \color{blue}{\left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \left(x + \left(-x\right)\right)} \]
      10. sub-neg100.0%

        \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \color{blue}{\left(x - x\right)} \]
      11. +-inverses100.0%

        \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \color{blue}{0} \]
      12. --rgt-identity100.0%

        \[\leadsto \color{blue}{\left(-y\right) \cdot \left(1 - x\right) + 1} \]
      13. +-commutative100.0%

        \[\leadsto \color{blue}{1 + \left(-y\right) \cdot \left(1 - x\right)} \]
      14. distribute-lft-neg-out100.0%

        \[\leadsto 1 + \color{blue}{\left(-y \cdot \left(1 - x\right)\right)} \]
      15. distribute-rgt-neg-in100.0%

        \[\leadsto 1 + \color{blue}{y \cdot \left(-\left(1 - x\right)\right)} \]
      16. neg-sub0100.0%

        \[\leadsto 1 + y \cdot \color{blue}{\left(0 - \left(1 - x\right)\right)} \]
      17. associate--r-100.0%

        \[\leadsto 1 + y \cdot \color{blue}{\left(\left(0 - 1\right) + x\right)} \]
      18. metadata-eval100.0%

        \[\leadsto 1 + y \cdot \left(\color{blue}{-1} + x\right) \]
      19. +-commutative100.0%

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

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

      \[\leadsto \color{blue}{1} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification69.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.5 \cdot 10^{+30}:\\ \;\;\;\;-y\\ \mathbf{elif}\;y \leq -1.9 \cdot 10^{-23}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq 3.7 \cdot 10^{-8}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-y\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 86.5% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2.7 \cdot 10^{-24} \lor \neg \left(y \leq 1.4 \cdot 10^{-9}\right):\\ \;\;\;\;y \cdot \left(x + -1\right)\\ \mathbf{else}:\\ \;\;\;\;1 - y\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (or (<= y -2.7e-24) (not (<= y 1.4e-9))) (* y (+ x -1.0)) (- 1.0 y)))
double code(double x, double y) {
	double tmp;
	if ((y <= -2.7e-24) || !(y <= 1.4e-9)) {
		tmp = y * (x + -1.0);
	} else {
		tmp = 1.0 - y;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if ((y <= (-2.7d-24)) .or. (.not. (y <= 1.4d-9))) then
        tmp = y * (x + (-1.0d0))
    else
        tmp = 1.0d0 - y
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if ((y <= -2.7e-24) || !(y <= 1.4e-9)) {
		tmp = y * (x + -1.0);
	} else {
		tmp = 1.0 - y;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (y <= -2.7e-24) or not (y <= 1.4e-9):
		tmp = y * (x + -1.0)
	else:
		tmp = 1.0 - y
	return tmp
function code(x, y)
	tmp = 0.0
	if ((y <= -2.7e-24) || !(y <= 1.4e-9))
		tmp = Float64(y * Float64(x + -1.0));
	else
		tmp = Float64(1.0 - y);
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if ((y <= -2.7e-24) || ~((y <= 1.4e-9)))
		tmp = y * (x + -1.0);
	else
		tmp = 1.0 - y;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[Or[LessEqual[y, -2.7e-24], N[Not[LessEqual[y, 1.4e-9]], $MachinePrecision]], N[(y * N[(x + -1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 - y), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.7 \cdot 10^{-24} \lor \neg \left(y \leq 1.4 \cdot 10^{-9}\right):\\
\;\;\;\;y \cdot \left(x + -1\right)\\

\mathbf{else}:\\
\;\;\;\;1 - y\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.70000000000000007e-24 or 1.39999999999999992e-9 < y

    1. Initial program 96.1%

      \[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
    2. Step-by-step derivation
      1. +-commutative96.1%

        \[\leadsto \color{blue}{\left(1 - x\right) \cdot \left(1 - y\right) + x} \]
      2. remove-double-neg96.1%

        \[\leadsto \left(1 - x\right) \cdot \left(1 - y\right) + \color{blue}{\left(-\left(-x\right)\right)} \]
      3. unsub-neg96.1%

        \[\leadsto \color{blue}{\left(1 - x\right) \cdot \left(1 - y\right) - \left(-x\right)} \]
      4. sub-neg96.1%

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

        \[\leadsto \left(1 - x\right) \cdot \color{blue}{\left(\left(-y\right) + 1\right)} - \left(-x\right) \]
      6. distribute-rgt-in96.1%

        \[\leadsto \color{blue}{\left(\left(-y\right) \cdot \left(1 - x\right) + 1 \cdot \left(1 - x\right)\right)} - \left(-x\right) \]
      7. *-lft-identity96.1%

        \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + \color{blue}{\left(1 - x\right)}\right) - \left(-x\right) \]
      8. associate-+r-96.1%

        \[\leadsto \color{blue}{\left(\left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - x\right)} - \left(-x\right) \]
      9. associate--l-100.0%

        \[\leadsto \color{blue}{\left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \left(x + \left(-x\right)\right)} \]
      10. sub-neg100.0%

        \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \color{blue}{\left(x - x\right)} \]
      11. +-inverses100.0%

        \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \color{blue}{0} \]
      12. --rgt-identity100.0%

        \[\leadsto \color{blue}{\left(-y\right) \cdot \left(1 - x\right) + 1} \]
      13. +-commutative100.0%

        \[\leadsto \color{blue}{1 + \left(-y\right) \cdot \left(1 - x\right)} \]
      14. distribute-lft-neg-out100.0%

        \[\leadsto 1 + \color{blue}{\left(-y \cdot \left(1 - x\right)\right)} \]
      15. distribute-rgt-neg-in100.0%

        \[\leadsto 1 + \color{blue}{y \cdot \left(-\left(1 - x\right)\right)} \]
      16. neg-sub0100.0%

        \[\leadsto 1 + y \cdot \color{blue}{\left(0 - \left(1 - x\right)\right)} \]
      17. associate--r-100.0%

        \[\leadsto 1 + y \cdot \color{blue}{\left(\left(0 - 1\right) + x\right)} \]
      18. metadata-eval100.0%

        \[\leadsto 1 + y \cdot \left(\color{blue}{-1} + x\right) \]
      19. +-commutative100.0%

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

      \[\leadsto \color{blue}{1 + y \cdot \left(x + -1\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. distribute-lft-in100.0%

        \[\leadsto 1 + \color{blue}{\left(y \cdot x + y \cdot -1\right)} \]
      2. *-commutative100.0%

        \[\leadsto 1 + \left(y \cdot x + \color{blue}{-1 \cdot y}\right) \]
      3. mul-1-neg100.0%

        \[\leadsto 1 + \left(y \cdot x + \color{blue}{\left(-y\right)}\right) \]
    6. Applied egg-rr100.0%

      \[\leadsto 1 + \color{blue}{\left(y \cdot x + \left(-y\right)\right)} \]
    7. Taylor expanded in x around 0 100.0%

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

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

    if -2.70000000000000007e-24 < y < 1.39999999999999992e-9

    1. Initial program 59.5%

      \[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
    2. Step-by-step derivation
      1. +-commutative59.5%

        \[\leadsto \color{blue}{\left(1 - x\right) \cdot \left(1 - y\right) + x} \]
      2. remove-double-neg59.5%

        \[\leadsto \left(1 - x\right) \cdot \left(1 - y\right) + \color{blue}{\left(-\left(-x\right)\right)} \]
      3. unsub-neg59.5%

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

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

        \[\leadsto \left(1 - x\right) \cdot \color{blue}{\left(\left(-y\right) + 1\right)} - \left(-x\right) \]
      6. distribute-rgt-in59.5%

        \[\leadsto \color{blue}{\left(\left(-y\right) \cdot \left(1 - x\right) + 1 \cdot \left(1 - x\right)\right)} - \left(-x\right) \]
      7. *-lft-identity59.5%

        \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + \color{blue}{\left(1 - x\right)}\right) - \left(-x\right) \]
      8. associate-+r-59.5%

        \[\leadsto \color{blue}{\left(\left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - x\right)} - \left(-x\right) \]
      9. associate--l-100.0%

        \[\leadsto \color{blue}{\left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \left(x + \left(-x\right)\right)} \]
      10. sub-neg100.0%

        \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \color{blue}{\left(x - x\right)} \]
      11. +-inverses100.0%

        \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \color{blue}{0} \]
      12. --rgt-identity100.0%

        \[\leadsto \color{blue}{\left(-y\right) \cdot \left(1 - x\right) + 1} \]
      13. +-commutative100.0%

        \[\leadsto \color{blue}{1 + \left(-y\right) \cdot \left(1 - x\right)} \]
      14. distribute-lft-neg-out100.0%

        \[\leadsto 1 + \color{blue}{\left(-y \cdot \left(1 - x\right)\right)} \]
      15. distribute-rgt-neg-in100.0%

        \[\leadsto 1 + \color{blue}{y \cdot \left(-\left(1 - x\right)\right)} \]
      16. neg-sub0100.0%

        \[\leadsto 1 + y \cdot \color{blue}{\left(0 - \left(1 - x\right)\right)} \]
      17. associate--r-100.0%

        \[\leadsto 1 + y \cdot \color{blue}{\left(\left(0 - 1\right) + x\right)} \]
      18. metadata-eval100.0%

        \[\leadsto 1 + y \cdot \left(\color{blue}{-1} + x\right) \]
      19. +-commutative100.0%

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

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

      \[\leadsto \color{blue}{1 + -1 \cdot y} \]
    6. Step-by-step derivation
      1. neg-mul-181.5%

        \[\leadsto 1 + \color{blue}{\left(-y\right)} \]
      2. unsub-neg81.5%

        \[\leadsto \color{blue}{1 - y} \]
    7. Simplified81.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.7 \cdot 10^{-24} \lor \neg \left(y \leq 1.4 \cdot 10^{-9}\right):\\ \;\;\;\;y \cdot \left(x + -1\right)\\ \mathbf{else}:\\ \;\;\;\;1 - y\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 85.3% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -9 \cdot 10^{+106} \lor \neg \left(x \leq 750000000\right):\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;1 - y\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (or (<= x -9e+106) (not (<= x 750000000.0))) (* x y) (- 1.0 y)))
double code(double x, double y) {
	double tmp;
	if ((x <= -9e+106) || !(x <= 750000000.0)) {
		tmp = x * y;
	} else {
		tmp = 1.0 - y;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if ((x <= (-9d+106)) .or. (.not. (x <= 750000000.0d0))) then
        tmp = x * y
    else
        tmp = 1.0d0 - y
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if ((x <= -9e+106) || !(x <= 750000000.0)) {
		tmp = x * y;
	} else {
		tmp = 1.0 - y;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (x <= -9e+106) or not (x <= 750000000.0):
		tmp = x * y
	else:
		tmp = 1.0 - y
	return tmp
function code(x, y)
	tmp = 0.0
	if ((x <= -9e+106) || !(x <= 750000000.0))
		tmp = Float64(x * y);
	else
		tmp = Float64(1.0 - y);
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if ((x <= -9e+106) || ~((x <= 750000000.0)))
		tmp = x * y;
	else
		tmp = 1.0 - y;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[Or[LessEqual[x, -9e+106], N[Not[LessEqual[x, 750000000.0]], $MachinePrecision]], N[(x * y), $MachinePrecision], N[(1.0 - y), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -9 \cdot 10^{+106} \lor \neg \left(x \leq 750000000\right):\\
\;\;\;\;x \cdot y\\

\mathbf{else}:\\
\;\;\;\;1 - y\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -8.9999999999999994e106 or 7.5e8 < x

    1. Initial program 55.2%

      \[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
    2. Step-by-step derivation
      1. +-commutative55.2%

        \[\leadsto \color{blue}{\left(1 - x\right) \cdot \left(1 - y\right) + x} \]
      2. remove-double-neg55.2%

        \[\leadsto \left(1 - x\right) \cdot \left(1 - y\right) + \color{blue}{\left(-\left(-x\right)\right)} \]
      3. unsub-neg55.2%

        \[\leadsto \color{blue}{\left(1 - x\right) \cdot \left(1 - y\right) - \left(-x\right)} \]
      4. sub-neg55.2%

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

        \[\leadsto \left(1 - x\right) \cdot \color{blue}{\left(\left(-y\right) + 1\right)} - \left(-x\right) \]
      6. distribute-rgt-in55.3%

        \[\leadsto \color{blue}{\left(\left(-y\right) \cdot \left(1 - x\right) + 1 \cdot \left(1 - x\right)\right)} - \left(-x\right) \]
      7. *-lft-identity55.3%

        \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + \color{blue}{\left(1 - x\right)}\right) - \left(-x\right) \]
      8. associate-+r-55.3%

        \[\leadsto \color{blue}{\left(\left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - x\right)} - \left(-x\right) \]
      9. associate--l-100.0%

        \[\leadsto \color{blue}{\left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \left(x + \left(-x\right)\right)} \]
      10. sub-neg100.0%

        \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \color{blue}{\left(x - x\right)} \]
      11. +-inverses100.0%

        \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \color{blue}{0} \]
      12. --rgt-identity100.0%

        \[\leadsto \color{blue}{\left(-y\right) \cdot \left(1 - x\right) + 1} \]
      13. +-commutative100.0%

        \[\leadsto \color{blue}{1 + \left(-y\right) \cdot \left(1 - x\right)} \]
      14. distribute-lft-neg-out100.0%

        \[\leadsto 1 + \color{blue}{\left(-y \cdot \left(1 - x\right)\right)} \]
      15. distribute-rgt-neg-in100.0%

        \[\leadsto 1 + \color{blue}{y \cdot \left(-\left(1 - x\right)\right)} \]
      16. neg-sub0100.0%

        \[\leadsto 1 + y \cdot \color{blue}{\left(0 - \left(1 - x\right)\right)} \]
      17. associate--r-100.0%

        \[\leadsto 1 + y \cdot \color{blue}{\left(\left(0 - 1\right) + x\right)} \]
      18. metadata-eval100.0%

        \[\leadsto 1 + y \cdot \left(\color{blue}{-1} + x\right) \]
      19. +-commutative100.0%

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

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

      \[\leadsto 1 + \color{blue}{x \cdot y} \]
    6. Step-by-step derivation
      1. *-commutative99.6%

        \[\leadsto 1 + \color{blue}{y \cdot x} \]
    7. Simplified99.6%

      \[\leadsto 1 + \color{blue}{y \cdot x} \]
    8. Taylor expanded in y around inf 78.7%

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

    if -8.9999999999999994e106 < x < 7.5e8

    1. Initial program 94.5%

      \[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
    2. Step-by-step derivation
      1. +-commutative94.5%

        \[\leadsto \color{blue}{\left(1 - x\right) \cdot \left(1 - y\right) + x} \]
      2. remove-double-neg94.5%

        \[\leadsto \left(1 - x\right) \cdot \left(1 - y\right) + \color{blue}{\left(-\left(-x\right)\right)} \]
      3. unsub-neg94.5%

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

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

        \[\leadsto \left(1 - x\right) \cdot \color{blue}{\left(\left(-y\right) + 1\right)} - \left(-x\right) \]
      6. distribute-rgt-in94.5%

        \[\leadsto \color{blue}{\left(\left(-y\right) \cdot \left(1 - x\right) + 1 \cdot \left(1 - x\right)\right)} - \left(-x\right) \]
      7. *-lft-identity94.5%

        \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + \color{blue}{\left(1 - x\right)}\right) - \left(-x\right) \]
      8. associate-+r-94.5%

        \[\leadsto \color{blue}{\left(\left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - x\right)} - \left(-x\right) \]
      9. associate--l-100.0%

        \[\leadsto \color{blue}{\left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \left(x + \left(-x\right)\right)} \]
      10. sub-neg100.0%

        \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \color{blue}{\left(x - x\right)} \]
      11. +-inverses100.0%

        \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \color{blue}{0} \]
      12. --rgt-identity100.0%

        \[\leadsto \color{blue}{\left(-y\right) \cdot \left(1 - x\right) + 1} \]
      13. +-commutative100.0%

        \[\leadsto \color{blue}{1 + \left(-y\right) \cdot \left(1 - x\right)} \]
      14. distribute-lft-neg-out100.0%

        \[\leadsto 1 + \color{blue}{\left(-y \cdot \left(1 - x\right)\right)} \]
      15. distribute-rgt-neg-in100.0%

        \[\leadsto 1 + \color{blue}{y \cdot \left(-\left(1 - x\right)\right)} \]
      16. neg-sub0100.0%

        \[\leadsto 1 + y \cdot \color{blue}{\left(0 - \left(1 - x\right)\right)} \]
      17. associate--r-100.0%

        \[\leadsto 1 + y \cdot \color{blue}{\left(\left(0 - 1\right) + x\right)} \]
      18. metadata-eval100.0%

        \[\leadsto 1 + y \cdot \left(\color{blue}{-1} + x\right) \]
      19. +-commutative100.0%

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

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

      \[\leadsto \color{blue}{1 + -1 \cdot y} \]
    6. Step-by-step derivation
      1. neg-mul-194.7%

        \[\leadsto 1 + \color{blue}{\left(-y\right)} \]
      2. unsub-neg94.7%

        \[\leadsto \color{blue}{1 - y} \]
    7. Simplified94.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -9 \cdot 10^{+106} \lor \neg \left(x \leq 750000000\right):\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;1 - y\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 61.5% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -4200000000 \lor \neg \left(y \leq 3.7 \cdot 10^{-8}\right):\\ \;\;\;\;-y\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (or (<= y -4200000000.0) (not (<= y 3.7e-8))) (- y) 1.0))
double code(double x, double y) {
	double tmp;
	if ((y <= -4200000000.0) || !(y <= 3.7e-8)) {
		tmp = -y;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if ((y <= (-4200000000.0d0)) .or. (.not. (y <= 3.7d-8))) then
        tmp = -y
    else
        tmp = 1.0d0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if ((y <= -4200000000.0) || !(y <= 3.7e-8)) {
		tmp = -y;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (y <= -4200000000.0) or not (y <= 3.7e-8):
		tmp = -y
	else:
		tmp = 1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if ((y <= -4200000000.0) || !(y <= 3.7e-8))
		tmp = Float64(-y);
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if ((y <= -4200000000.0) || ~((y <= 3.7e-8)))
		tmp = -y;
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[Or[LessEqual[y, -4200000000.0], N[Not[LessEqual[y, 3.7e-8]], $MachinePrecision]], (-y), 1.0]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -4200000000 \lor \neg \left(y \leq 3.7 \cdot 10^{-8}\right):\\
\;\;\;\;-y\\

\mathbf{else}:\\
\;\;\;\;1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -4.2e9 or 3.7e-8 < y

    1. Initial program 99.7%

      \[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
    2. Step-by-step derivation
      1. +-commutative99.7%

        \[\leadsto \color{blue}{\left(1 - x\right) \cdot \left(1 - y\right) + x} \]
      2. remove-double-neg99.7%

        \[\leadsto \left(1 - x\right) \cdot \left(1 - y\right) + \color{blue}{\left(-\left(-x\right)\right)} \]
      3. unsub-neg99.7%

        \[\leadsto \color{blue}{\left(1 - x\right) \cdot \left(1 - y\right) - \left(-x\right)} \]
      4. sub-neg99.7%

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

        \[\leadsto \left(1 - x\right) \cdot \color{blue}{\left(\left(-y\right) + 1\right)} - \left(-x\right) \]
      6. distribute-rgt-in99.7%

        \[\leadsto \color{blue}{\left(\left(-y\right) \cdot \left(1 - x\right) + 1 \cdot \left(1 - x\right)\right)} - \left(-x\right) \]
      7. *-lft-identity99.7%

        \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + \color{blue}{\left(1 - x\right)}\right) - \left(-x\right) \]
      8. associate-+r-99.7%

        \[\leadsto \color{blue}{\left(\left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - x\right)} - \left(-x\right) \]
      9. associate--l-100.0%

        \[\leadsto \color{blue}{\left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \left(x + \left(-x\right)\right)} \]
      10. sub-neg100.0%

        \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \color{blue}{\left(x - x\right)} \]
      11. +-inverses100.0%

        \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \color{blue}{0} \]
      12. --rgt-identity100.0%

        \[\leadsto \color{blue}{\left(-y\right) \cdot \left(1 - x\right) + 1} \]
      13. +-commutative100.0%

        \[\leadsto \color{blue}{1 + \left(-y\right) \cdot \left(1 - x\right)} \]
      14. distribute-lft-neg-out100.0%

        \[\leadsto 1 + \color{blue}{\left(-y \cdot \left(1 - x\right)\right)} \]
      15. distribute-rgt-neg-in100.0%

        \[\leadsto 1 + \color{blue}{y \cdot \left(-\left(1 - x\right)\right)} \]
      16. neg-sub0100.0%

        \[\leadsto 1 + y \cdot \color{blue}{\left(0 - \left(1 - x\right)\right)} \]
      17. associate--r-100.0%

        \[\leadsto 1 + y \cdot \color{blue}{\left(\left(0 - 1\right) + x\right)} \]
      18. metadata-eval100.0%

        \[\leadsto 1 + y \cdot \left(\color{blue}{-1} + x\right) \]
      19. +-commutative100.0%

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

      \[\leadsto \color{blue}{1 + y \cdot \left(x + -1\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. distribute-lft-in100.0%

        \[\leadsto 1 + \color{blue}{\left(y \cdot x + y \cdot -1\right)} \]
      2. *-commutative100.0%

        \[\leadsto 1 + \left(y \cdot x + \color{blue}{-1 \cdot y}\right) \]
      3. mul-1-neg100.0%

        \[\leadsto 1 + \left(y \cdot x + \color{blue}{\left(-y\right)}\right) \]
    6. Applied egg-rr100.0%

      \[\leadsto 1 + \color{blue}{\left(y \cdot x + \left(-y\right)\right)} \]
    7. Taylor expanded in x around 0 100.0%

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

      \[\leadsto \color{blue}{y \cdot \left(x - 1\right)} \]
    9. Taylor expanded in x around 0 58.5%

      \[\leadsto \color{blue}{-1 \cdot y} \]
    10. Step-by-step derivation
      1. neg-mul-158.5%

        \[\leadsto \color{blue}{-y} \]
    11. Simplified58.5%

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

    if -4.2e9 < y < 3.7e-8

    1. Initial program 58.9%

      \[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
    2. Step-by-step derivation
      1. +-commutative58.9%

        \[\leadsto \color{blue}{\left(1 - x\right) \cdot \left(1 - y\right) + x} \]
      2. remove-double-neg58.9%

        \[\leadsto \left(1 - x\right) \cdot \left(1 - y\right) + \color{blue}{\left(-\left(-x\right)\right)} \]
      3. unsub-neg58.9%

        \[\leadsto \color{blue}{\left(1 - x\right) \cdot \left(1 - y\right) - \left(-x\right)} \]
      4. sub-neg58.9%

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

        \[\leadsto \left(1 - x\right) \cdot \color{blue}{\left(\left(-y\right) + 1\right)} - \left(-x\right) \]
      6. distribute-rgt-in58.9%

        \[\leadsto \color{blue}{\left(\left(-y\right) \cdot \left(1 - x\right) + 1 \cdot \left(1 - x\right)\right)} - \left(-x\right) \]
      7. *-lft-identity58.9%

        \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + \color{blue}{\left(1 - x\right)}\right) - \left(-x\right) \]
      8. associate-+r-58.9%

        \[\leadsto \color{blue}{\left(\left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - x\right)} - \left(-x\right) \]
      9. associate--l-100.0%

        \[\leadsto \color{blue}{\left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \left(x + \left(-x\right)\right)} \]
      10. sub-neg100.0%

        \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \color{blue}{\left(x - x\right)} \]
      11. +-inverses100.0%

        \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \color{blue}{0} \]
      12. --rgt-identity100.0%

        \[\leadsto \color{blue}{\left(-y\right) \cdot \left(1 - x\right) + 1} \]
      13. +-commutative100.0%

        \[\leadsto \color{blue}{1 + \left(-y\right) \cdot \left(1 - x\right)} \]
      14. distribute-lft-neg-out100.0%

        \[\leadsto 1 + \color{blue}{\left(-y \cdot \left(1 - x\right)\right)} \]
      15. distribute-rgt-neg-in100.0%

        \[\leadsto 1 + \color{blue}{y \cdot \left(-\left(1 - x\right)\right)} \]
      16. neg-sub0100.0%

        \[\leadsto 1 + y \cdot \color{blue}{\left(0 - \left(1 - x\right)\right)} \]
      17. associate--r-100.0%

        \[\leadsto 1 + y \cdot \color{blue}{\left(\left(0 - 1\right) + x\right)} \]
      18. metadata-eval100.0%

        \[\leadsto 1 + y \cdot \left(\color{blue}{-1} + x\right) \]
      19. +-commutative100.0%

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

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

      \[\leadsto \color{blue}{1} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification66.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -4200000000 \lor \neg \left(y \leq 3.7 \cdot 10^{-8}\right):\\ \;\;\;\;-y\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 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 79.6%

    \[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
  2. Step-by-step derivation
    1. +-commutative79.6%

      \[\leadsto \color{blue}{\left(1 - x\right) \cdot \left(1 - y\right) + x} \]
    2. remove-double-neg79.6%

      \[\leadsto \left(1 - x\right) \cdot \left(1 - y\right) + \color{blue}{\left(-\left(-x\right)\right)} \]
    3. unsub-neg79.6%

      \[\leadsto \color{blue}{\left(1 - x\right) \cdot \left(1 - y\right) - \left(-x\right)} \]
    4. sub-neg79.6%

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

      \[\leadsto \left(1 - x\right) \cdot \color{blue}{\left(\left(-y\right) + 1\right)} - \left(-x\right) \]
    6. distribute-rgt-in79.6%

      \[\leadsto \color{blue}{\left(\left(-y\right) \cdot \left(1 - x\right) + 1 \cdot \left(1 - x\right)\right)} - \left(-x\right) \]
    7. *-lft-identity79.6%

      \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + \color{blue}{\left(1 - x\right)}\right) - \left(-x\right) \]
    8. associate-+r-79.6%

      \[\leadsto \color{blue}{\left(\left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - x\right)} - \left(-x\right) \]
    9. associate--l-100.0%

      \[\leadsto \color{blue}{\left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \left(x + \left(-x\right)\right)} \]
    10. sub-neg100.0%

      \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \color{blue}{\left(x - x\right)} \]
    11. +-inverses100.0%

      \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \color{blue}{0} \]
    12. --rgt-identity100.0%

      \[\leadsto \color{blue}{\left(-y\right) \cdot \left(1 - x\right) + 1} \]
    13. +-commutative100.0%

      \[\leadsto \color{blue}{1 + \left(-y\right) \cdot \left(1 - x\right)} \]
    14. distribute-lft-neg-out100.0%

      \[\leadsto 1 + \color{blue}{\left(-y \cdot \left(1 - x\right)\right)} \]
    15. distribute-rgt-neg-in100.0%

      \[\leadsto 1 + \color{blue}{y \cdot \left(-\left(1 - x\right)\right)} \]
    16. neg-sub0100.0%

      \[\leadsto 1 + y \cdot \color{blue}{\left(0 - \left(1 - x\right)\right)} \]
    17. associate--r-100.0%

      \[\leadsto 1 + y \cdot \color{blue}{\left(\left(0 - 1\right) + x\right)} \]
    18. metadata-eval100.0%

      \[\leadsto 1 + y \cdot \left(\color{blue}{-1} + x\right) \]
    19. +-commutative100.0%

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

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

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

Alternative 9: 38.5% 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 79.6%

    \[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
  2. Step-by-step derivation
    1. +-commutative79.6%

      \[\leadsto \color{blue}{\left(1 - x\right) \cdot \left(1 - y\right) + x} \]
    2. remove-double-neg79.6%

      \[\leadsto \left(1 - x\right) \cdot \left(1 - y\right) + \color{blue}{\left(-\left(-x\right)\right)} \]
    3. unsub-neg79.6%

      \[\leadsto \color{blue}{\left(1 - x\right) \cdot \left(1 - y\right) - \left(-x\right)} \]
    4. sub-neg79.6%

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

      \[\leadsto \left(1 - x\right) \cdot \color{blue}{\left(\left(-y\right) + 1\right)} - \left(-x\right) \]
    6. distribute-rgt-in79.6%

      \[\leadsto \color{blue}{\left(\left(-y\right) \cdot \left(1 - x\right) + 1 \cdot \left(1 - x\right)\right)} - \left(-x\right) \]
    7. *-lft-identity79.6%

      \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + \color{blue}{\left(1 - x\right)}\right) - \left(-x\right) \]
    8. associate-+r-79.6%

      \[\leadsto \color{blue}{\left(\left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - x\right)} - \left(-x\right) \]
    9. associate--l-100.0%

      \[\leadsto \color{blue}{\left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \left(x + \left(-x\right)\right)} \]
    10. sub-neg100.0%

      \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \color{blue}{\left(x - x\right)} \]
    11. +-inverses100.0%

      \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) - \color{blue}{0} \]
    12. --rgt-identity100.0%

      \[\leadsto \color{blue}{\left(-y\right) \cdot \left(1 - x\right) + 1} \]
    13. +-commutative100.0%

      \[\leadsto \color{blue}{1 + \left(-y\right) \cdot \left(1 - x\right)} \]
    14. distribute-lft-neg-out100.0%

      \[\leadsto 1 + \color{blue}{\left(-y \cdot \left(1 - x\right)\right)} \]
    15. distribute-rgt-neg-in100.0%

      \[\leadsto 1 + \color{blue}{y \cdot \left(-\left(1 - x\right)\right)} \]
    16. neg-sub0100.0%

      \[\leadsto 1 + y \cdot \color{blue}{\left(0 - \left(1 - x\right)\right)} \]
    17. associate--r-100.0%

      \[\leadsto 1 + y \cdot \color{blue}{\left(\left(0 - 1\right) + x\right)} \]
    18. metadata-eval100.0%

      \[\leadsto 1 + y \cdot \left(\color{blue}{-1} + x\right) \]
    19. +-commutative100.0%

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

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

    \[\leadsto \color{blue}{1} \]
  6. Final simplification38.4%

    \[\leadsto 1 \]
  7. Add Preprocessing

Developer target: 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 2024020 
(FPCore (x y)
  :name "Graphics.Rendering.Chart.Plot.Vectors:renderPlotVectors from Chart-1.5.3"
  :precision binary64

  :herbie-target
  (- (* y x) (- y 1.0))

  (+ x (* (- 1.0 x) (- 1.0 y))))