?

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

?

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

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(1 - x\right) \cdot z \]
  2. Simplified0.0

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

    [Start]0.0

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

    rational_best-simplify-1 [=>]0.0

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

    rational_best-simplify-68 [=>]0.0

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

    rational_best-simplify-1 [=>]0.0

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

    rational_best-simplify-18 [=>]0.0

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

    rational_best-simplify-74 [<=]0.0

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

    rational_best-simplify-11 [=>]0.0

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

    rational_best-simplify-1 [=>]0.0

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

    rational_best-simplify-53 [=>]0.0

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

    metadata-eval [=>]0.0

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

    rational_best-simplify-7 [=>]0.0

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

    rational_best-simplify-47 [=>]0.0

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

    rational_best-simplify-1 [=>]0.0

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

    rational_best-simplify-1 [=>]0.0

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

    rational_best-simplify-74 [=>]0.0

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

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

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

Alternatives

Alternative 1
Error12.7
Cost848
\[\begin{array}{l} t_0 := \left(y - z\right) \cdot x\\ t_1 := z \cdot \left(1 - x\right)\\ \mathbf{if}\;x \leq -0.38:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -1.6 \cdot 10^{-25}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.75 \cdot 10^{-75}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 9 \cdot 10^{-44}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error23.8
Cost784
\[\begin{array}{l} t_0 := z \cdot \left(-x\right)\\ \mathbf{if}\;x \leq -65000000000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -2.8 \cdot 10^{-53}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;x \leq 5.8 \cdot 10^{-43}:\\ \;\;\;\;z\\ \mathbf{elif}\;x \leq 5.2 \cdot 10^{+176}:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error15.7
Cost584
\[\begin{array}{l} t_0 := z \cdot \left(1 - x\right)\\ \mathbf{if}\;z \leq -1.5 \cdot 10^{-115}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 2.2 \cdot 10^{-128}:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error1.0
Cost584
\[\begin{array}{l} t_0 := \left(y - z\right) \cdot x\\ \mathbf{if}\;x \leq -59000000000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;x \cdot y + z\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error23.9
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -2.1 \cdot 10^{-53}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;x \leq 1.95 \cdot 10^{-48}:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 6
Error34.8
Cost64
\[z \]

Error

Reproduce?

herbie shell --seed 2023101 
(FPCore (x y z)
  :name "Diagrams.Backend.Rasterific:$crender from diagrams-rasterific-1.3.1.3"
  :precision binary64
  (+ (* x y) (* (- 1.0 x) z)))