Average Error: 0.0 → 0.0
Time: 3.4s
Precision: binary64
Cost: 448
\[x \cdot y + \left(1 - x\right) \cdot z \]
\[z + x \cdot \left(y - z\right) \]
(FPCore (x y z) :precision binary64 (+ (* x y) (* (- 1.0 x) z)))
(FPCore (x y z) :precision binary64 (+ z (* x (- y z))))
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 * (y - 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) + ((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 * (y - z))
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 * (y - z));
}
def code(x, y, z):
	return (x * y) + ((1.0 - x) * z)
def code(x, y, z):
	return z + (x * (y - z))
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(y - z)))
end
function tmp = code(x, y, z)
	tmp = (x * y) + ((1.0 - x) * z);
end
function tmp = code(x, y, z)
	tmp = z + (x * (y - z));
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[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x \cdot y + \left(1 - x\right) \cdot z
z + x \cdot \left(y - z\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}{\mathsf{fma}\left(x, y - z, z\right)} \]
  3. Applied egg-rr0.0

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

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

Alternatives

Alternative 1
Error23.7
Cost916
\[\begin{array}{l} t_0 := z \cdot \left(-x\right)\\ \mathbf{if}\;x \leq -4.1 \cdot 10^{+48}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -5.760787946117718 \cdot 10^{-38}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \leq 9.935908931899959 \cdot 10^{-12}:\\ \;\;\;\;z\\ \mathbf{elif}\;x \leq 4.7 \cdot 10^{+93}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \leq 2.95 \cdot 10^{+162}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 2
Error12.7
Cost652
\[\begin{array}{l} t_0 := z \cdot \left(-x\right)\\ \mathbf{if}\;x \leq -7 \cdot 10^{+48}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2.05 \cdot 10^{+69}:\\ \;\;\;\;z + x \cdot y\\ \mathbf{elif}\;x \leq 2.95 \cdot 10^{+162}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 3
Error1.4
Cost584
\[\begin{array}{l} t_0 := x \cdot \left(y - z\right)\\ \mathbf{if}\;x \leq -36131107985763373000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 9.935908931899959 \cdot 10^{-12}:\\ \;\;\;\;z + x \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error23.2
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -5.760787946117718 \cdot 10^{-38}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \leq 9.935908931899959 \cdot 10^{-12}:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 5
Error35.0
Cost64
\[z \]

Error

Reproduce

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