?

Average Error: 0.0 → 0.0
Time: 5.3s
Precision: binary64
Cost: 448

?

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

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 0.0

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

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

    [Start]0.0

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

    *-commutative [=>]0.0

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

    sub-neg [=>]0.0

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

    distribute-rgt-in [=>]0.0

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

    metadata-eval [=>]0.0

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

    mul-1-neg [=>]0.0

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

    unsub-neg [=>]0.0

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

    associate-+r- [=>]0.0

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

    distribute-lft-out [=>]0.0

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

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

Alternatives

Alternative 1
Error28.4
Cost1116
\[\begin{array}{l} \mathbf{if}\;z \leq -1.95 \cdot 10^{+27}:\\ \;\;\;\;-z\\ \mathbf{elif}\;z \leq -5.2 \cdot 10^{-55}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq -2.3 \cdot 10^{-116}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;z \leq -3.5 \cdot 10^{-137}:\\ \;\;\;\;-z\\ \mathbf{elif}\;z \leq 1.05 \cdot 10^{-171}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;z \leq 3.15 \cdot 10^{+159}:\\ \;\;\;\;-z\\ \mathbf{elif}\;z \leq 1.15 \cdot 10^{+232}:\\ \;\;\;\;x \cdot z\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \]
Alternative 2
Error15.0
Cost850
\[\begin{array}{l} \mathbf{if}\;z \leq -3 \cdot 10^{+27} \lor \neg \left(z \leq -8.6 \cdot 10^{-117}\right) \land \left(z \leq -9.6 \cdot 10^{-136} \lor \neg \left(z \leq 9.2 \cdot 10^{-172}\right)\right):\\ \;\;\;\;z \cdot \left(x - 1\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y + z\right)\\ \end{array} \]
Alternative 3
Error26.6
Cost721
\[\begin{array}{l} \mathbf{if}\;z \leq -2.3 \cdot 10^{+27}:\\ \;\;\;\;-z\\ \mathbf{elif}\;z \leq -2.45 \cdot 10^{-116} \lor \neg \left(z \leq -8.3 \cdot 10^{-137}\right) \land z \leq 1.05 \cdot 10^{-171}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \]
Alternative 4
Error0.9
Cost712
\[\begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;x \cdot \left(y + z\right)\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;x \cdot y - z\\ \mathbf{else}:\\ \;\;\;\;x \cdot y + x \cdot z\\ \end{array} \]
Alternative 5
Error12.0
Cost585
\[\begin{array}{l} \mathbf{if}\;x \leq -1.08 \cdot 10^{-7} \lor \neg \left(x \leq 0.00039\right):\\ \;\;\;\;x \cdot \left(y + z\right)\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \]
Alternative 6
Error0.9
Cost585
\[\begin{array}{l} \mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 1\right):\\ \;\;\;\;x \cdot \left(y + z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot y - z\\ \end{array} \]
Alternative 7
Error34.6
Cost128
\[-z \]

Error

Reproduce?

herbie shell --seed 2023055 
(FPCore (x y z)
  :name "Graphics.Rendering.Chart.Drawing:drawTextsR from Chart-1.5.3"
  :precision binary64
  (+ (* x y) (* (- x 1.0) z)))