?

Average Error: 16.5 → 0.0
Time: 3.3s
Precision: binary64
Cost: 448

?

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

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original16.5
Target0.0
Herbie0.0
\[y \cdot x - \left(y - 1\right) \]

Derivation?

  1. Initial program 16.5

    \[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
  2. Simplified0.0

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

    [Start]16.5

    \[ x + \left(1 - x\right) \cdot \left(1 - y\right) \]

    +-commutative [=>]16.5

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

    sub-neg [=>]16.5

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

    distribute-rgt-in [=>]16.5

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

    +-commutative [=>]16.5

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

    sub-neg [=>]16.5

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

    distribute-lft-in [=>]16.5

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

    metadata-eval [=>]16.5

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

    associate-+r+ [=>]16.5

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

    associate-+l+ [=>]0.0

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

    neg-mul-1 [=>]0.0

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

    associate-*r* [=>]0.0

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

    metadata-eval [=>]0.0

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

    distribute-lft1-in [=>]0.0

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

    metadata-eval [=>]0.0

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

    metadata-eval [<=]0.0

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

    associate-*r* [<=]0.0

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

    metadata-eval [<=]0.0

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

    associate-*r* [<=]0.0

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

    neg-mul-1 [<=]0.0

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

    mul0-lft [=>]0.0

    \[ \left(\left(-y\right) \cdot \left(1 - x\right) + 1\right) + \color{blue}{0} \]
  3. Applied egg-rr0.0

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

    \[\leadsto y \cdot \left(x + -1\right) + 1 \]

Alternatives

Alternative 1
Error27.0
Cost1248
\[\begin{array}{l} \mathbf{if}\;x \leq -6 \cdot 10^{+81}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;x \leq -5 \cdot 10^{-75}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -5.4 \cdot 10^{-234}:\\ \;\;\;\;-y\\ \mathbf{elif}\;x \leq -7 \cdot 10^{-289}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 8.2 \cdot 10^{-171}:\\ \;\;\;\;-y\\ \mathbf{elif}\;x \leq 4.2 \cdot 10^{-65}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 1.85 \cdot 10^{-17}:\\ \;\;\;\;-y\\ \mathbf{elif}\;x \leq 1.85 \cdot 10^{+17}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 2
Error1.0
Cost585
\[\begin{array}{l} \mathbf{if}\;x \leq -66 \lor \neg \left(x \leq 1.1 \cdot 10^{-13}\right):\\ \;\;\;\;1 + y \cdot x\\ \mathbf{else}:\\ \;\;\;\;1 - y\\ \end{array} \]
Alternative 3
Error9.4
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -3 \cdot 10^{+81}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;x \leq 1.7 \cdot 10^{+18}:\\ \;\;\;\;1 - y\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 4
Error19.5
Cost392
\[\begin{array}{l} \mathbf{if}\;y \leq -0.0138:\\ \;\;\;\;-y\\ \mathbf{elif}\;y \leq 1:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-y\\ \end{array} \]
Alternative 5
Error36.2
Cost64
\[1 \]

Error

Reproduce?

herbie shell --seed 2023018 
(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))))