Average Error: 0.0 → 0.0
Time: 2.2s
Precision: binary64
Cost: 576
\[x \cdot y + \left(1 - x\right) \cdot z \]
\[\left(1 - x\right) \cdot z + x \cdot y \]
(FPCore (x y z) :precision binary64 (+ (* x y) (* (- 1.0 x) z)))
(FPCore (x y z) :precision binary64 (+ (* (- 1.0 x) z) (* x 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 ((1.0 - x) * z) + (x * 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 = ((1.0d0 - x) * z) + (x * 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 ((1.0 - x) * z) + (x * y);
}
def code(x, y, z):
	return (x * y) + ((1.0 - x) * z)
def code(x, y, z):
	return ((1.0 - x) * z) + (x * 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(Float64(Float64(1.0 - x) * z) + Float64(x * y))
end
function tmp = code(x, y, z)
	tmp = (x * y) + ((1.0 - x) * z);
end
function tmp = code(x, y, z)
	tmp = ((1.0 - x) * z) + (x * 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[(N[(N[(1.0 - x), $MachinePrecision] * z), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision]
x \cdot y + \left(1 - x\right) \cdot z
\left(1 - x\right) \cdot z + x \cdot y

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. Final simplification0.0

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

Alternatives

Alternative 1
Error14.8
Cost848
\[\begin{array}{l} t_0 := z - x \cdot z\\ t_1 := x \cdot \left(y - z\right)\\ \mathbf{if}\;z \leq -6.68337000111986 \cdot 10^{+21}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.2257532009159281 \cdot 10^{-96}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.63350159373066 \cdot 10^{-11}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 2.2580619758485436 \cdot 10^{+85}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error26.0
Cost720
\[\begin{array}{l} \mathbf{if}\;z \leq -6.68337000111986 \cdot 10^{+21}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq 1.2257532009159281 \cdot 10^{-96}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;z \leq 2.63350159373066 \cdot 10^{-11}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq 2.2580619758485436 \cdot 10^{+85}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \]
Alternative 3
Error24.8
Cost720
\[\begin{array}{l} \mathbf{if}\;x \leq -3.8 \cdot 10^{+96}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \leq -117400125672067660:\\ \;\;\;\;z \cdot \left(-x\right)\\ \mathbf{elif}\;x \leq -4.885592608485508 \cdot 10^{-129}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \leq 1.0837309768533918 \cdot 10^{-15}:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 4
Error16.1
Cost584
\[\begin{array}{l} t_0 := z - x \cdot z\\ \mathbf{if}\;z \leq -9.415968692039606 \cdot 10^{-97}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.2257532009159281 \cdot 10^{-96}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error35.1
Cost64
\[z \]

Error

Reproduce

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