Average Error: 0.0 → 0.0
Time: 3.5s
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
Error23.6
Cost852
\[\begin{array}{l} \mathbf{if}\;x \leq -2.65 \cdot 10^{+110}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \leq -1.6 \cdot 10^{+29}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;x \leq -2.1 \cdot 10^{-20}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \leq 1.15 \cdot 10^{-17}:\\ \;\;\;\;-z\\ \mathbf{elif}\;x \leq 7 \cdot 10^{+34}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;x \cdot z\\ \end{array} \]
Alternative 2
Error26.1
Cost721
\[\begin{array}{l} \mathbf{if}\;z \leq -6.3 \cdot 10^{+38}:\\ \;\;\;\;-z\\ \mathbf{elif}\;z \leq -3.8 \cdot 10^{-40} \lor \neg \left(z \leq -3.8 \cdot 10^{-79}\right) \land z \leq 4.6 \cdot 10^{-49}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \]
Alternative 3
Error11.8
Cost585
\[\begin{array}{l} \mathbf{if}\;x \leq -1.6 \cdot 10^{-20} \lor \neg \left(x \leq 1.26 \cdot 10^{-17}\right):\\ \;\;\;\;x \cdot \left(y + z\right)\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \]
Alternative 4
Error1.0
Cost585
\[\begin{array}{l} \mathbf{if}\;x \leq -200000000000 \lor \neg \left(x \leq 1\right):\\ \;\;\;\;x \cdot \left(y + z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot y - z\\ \end{array} \]
Alternative 5
Error35.4
Cost128
\[-z \]

Error

Reproduce

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