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

Percentage Accurate: 77.8% → 100.0%
Time: 8.8s
Alternatives: 7
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 7 alternatives:

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

Initial Program: 77.8% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 0.1× speedup?

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

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

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

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

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

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

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

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

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

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

      \[\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. fma-define100.0%

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

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

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

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

Alternative 2: 99.0% accurate, 0.6× speedup?

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

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

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


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

    1. Initial program 51.5%

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

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

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

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

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

        \[\leadsto \left(1 - x\right) \cdot \color{blue}{\left(\left(-y\right) + 1\right)} - \left(-x\right) \]
      6. distribute-rgt-in51.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-identity51.5%

        \[\leadsto \left(\left(-y\right) \cdot \left(1 - x\right) + \color{blue}{\left(1 - x\right)}\right) - \left(-x\right) \]
      8. associate-+r-51.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 97.7%

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

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

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

    if -1 < x < 0.640000000000000013

    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-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. Taylor expanded in x around 0 97.8%

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

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

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

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

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

Alternative 3: 100.0% accurate, 1.3× speedup?

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

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

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

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

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

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

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

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

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

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

      \[\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. fma-define100.0%

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

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

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

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

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

Alternative 4: 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 77.4%

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

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

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

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

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

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

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

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

      \[\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. Add Preprocessing

Alternative 5: 62.4% accurate, 3.0× speedup?

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

\\
1 - y
\end{array}
Derivation
  1. Initial program 77.4%

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

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

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

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

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

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

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

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

      \[\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 68.6%

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

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

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

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

Alternative 6: 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 77.4%

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

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

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

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

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

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

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

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

      \[\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.8%

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

Alternative 7: 2.5% accurate, 9.0× speedup?

\[\begin{array}{l} \\ 0 \end{array} \]
(FPCore (x y) :precision binary64 0.0)
double code(double x, double y) {
	return 0.0;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = 0.0d0
end function
public static double code(double x, double y) {
	return 0.0;
}
def code(x, y):
	return 0.0
function code(x, y)
	return 0.0
end
function tmp = code(x, y)
	tmp = 0.0;
end
code[x_, y_] := 0.0
\begin{array}{l}

\\
0
\end{array}
Derivation
  1. Initial program 77.4%

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

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

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

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

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

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

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

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

      \[\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 68.3%

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

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

    \[\leadsto 1 + \color{blue}{y \cdot x} \]
  8. Step-by-step derivation
    1. add-sqr-sqrt36.3%

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

      \[\leadsto 1 + \color{blue}{\sqrt{y \cdot y}} \cdot x \]
    3. sqr-neg51.2%

      \[\leadsto 1 + \sqrt{\color{blue}{\left(-y\right) \cdot \left(-y\right)}} \cdot x \]
    4. sqrt-unprod17.8%

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

      \[\leadsto 1 + \color{blue}{\left(-y\right)} \cdot x \]
    6. cancel-sign-sub-inv38.3%

      \[\leadsto \color{blue}{1 - y \cdot x} \]
  9. Applied egg-rr38.3%

    \[\leadsto \color{blue}{1 - y \cdot x} \]
  10. Taylor expanded in y around inf 2.7%

    \[\leadsto \color{blue}{-1 \cdot \left(x \cdot y\right)} \]
  11. Step-by-step derivation
    1. mul-1-neg2.7%

      \[\leadsto \color{blue}{-x \cdot y} \]
    2. *-commutative2.7%

      \[\leadsto -\color{blue}{y \cdot x} \]
    3. distribute-rgt-neg-in2.7%

      \[\leadsto \color{blue}{y \cdot \left(-x\right)} \]
  12. Simplified2.7%

    \[\leadsto \color{blue}{y \cdot \left(-x\right)} \]
  13. Step-by-step derivation
    1. add-log-exp2.4%

      \[\leadsto \color{blue}{\log \left(e^{y \cdot \left(-x\right)}\right)} \]
    2. add-sqr-sqrt2.4%

      \[\leadsto \log \color{blue}{\left(\sqrt{e^{y \cdot \left(-x\right)}} \cdot \sqrt{e^{y \cdot \left(-x\right)}}\right)} \]
    3. sqrt-unprod2.4%

      \[\leadsto \log \color{blue}{\left(\sqrt{e^{y \cdot \left(-x\right)} \cdot e^{y \cdot \left(-x\right)}}\right)} \]
    4. exp-prod2.3%

      \[\leadsto \log \left(\sqrt{e^{y \cdot \left(-x\right)} \cdot \color{blue}{{\left(e^{y}\right)}^{\left(-x\right)}}}\right) \]
    5. add-sqr-sqrt2.2%

      \[\leadsto \log \left(\sqrt{e^{y \cdot \left(-x\right)} \cdot {\left(e^{y}\right)}^{\left(-\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right)}}\right) \]
    6. sqrt-unprod2.4%

      \[\leadsto \log \left(\sqrt{e^{y \cdot \left(-x\right)} \cdot {\left(e^{y}\right)}^{\left(-\color{blue}{\sqrt{x \cdot x}}\right)}}\right) \]
    7. sqr-neg2.4%

      \[\leadsto \log \left(\sqrt{e^{y \cdot \left(-x\right)} \cdot {\left(e^{y}\right)}^{\left(-\sqrt{\color{blue}{\left(-x\right) \cdot \left(-x\right)}}\right)}}\right) \]
    8. sqrt-unprod1.5%

      \[\leadsto \log \left(\sqrt{e^{y \cdot \left(-x\right)} \cdot {\left(e^{y}\right)}^{\left(-\color{blue}{\sqrt{-x} \cdot \sqrt{-x}}\right)}}\right) \]
    9. add-sqr-sqrt1.6%

      \[\leadsto \log \left(\sqrt{e^{y \cdot \left(-x\right)} \cdot {\left(e^{y}\right)}^{\left(-\color{blue}{\left(-x\right)}\right)}}\right) \]
    10. pow-flip1.6%

      \[\leadsto \log \left(\sqrt{e^{y \cdot \left(-x\right)} \cdot \color{blue}{\frac{1}{{\left(e^{y}\right)}^{\left(-x\right)}}}}\right) \]
    11. exp-prod1.5%

      \[\leadsto \log \left(\sqrt{e^{y \cdot \left(-x\right)} \cdot \frac{1}{\color{blue}{e^{y \cdot \left(-x\right)}}}}\right) \]
    12. rgt-mult-inverse2.5%

      \[\leadsto \log \left(\sqrt{\color{blue}{1}}\right) \]
    13. metadata-eval2.5%

      \[\leadsto \log \color{blue}{1} \]
    14. metadata-eval2.5%

      \[\leadsto \color{blue}{0} \]
  14. Applied egg-rr2.5%

    \[\leadsto \color{blue}{0} \]
  15. 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 2024177 
(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))))