?

Average Error: 0.0 → 0.0
Time: 8.6s
Precision: binary64
Cost: 512

?

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

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original0.0
Target0.0
Herbie0.0
\[y - x \cdot \left(y - z\right) \]

Derivation?

  1. Initial program 0.0

    \[\left(1 - x\right) \cdot y + x \cdot z \]
  2. Taylor expanded in x around 0 0.0

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

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

    [Start]0.0

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

    rational_best-simplify-1 [=>]0.0

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

    rational_best-simplify-2 [=>]0.0

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

    rational_best-simplify-12 [=>]0.0

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

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

Alternatives

Alternative 1
Error24.4
Cost1576
\[\begin{array}{l} t_0 := y \cdot \left(-x\right)\\ \mathbf{if}\;x \leq -1.6 \cdot 10^{+241}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;x \leq -1.8 \cdot 10^{+115}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -3.2 \cdot 10^{+40}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;x \leq -410000000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -2.7 \cdot 10^{-64}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;x \leq 1.16 \cdot 10^{-32}:\\ \;\;\;\;y\\ \mathbf{elif}\;x \leq 4.5 \cdot 10^{+75}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{+102}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 9.2 \cdot 10^{+123}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;x \leq 1.65 \cdot 10^{+190}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;z \cdot x\\ \end{array} \]
Alternative 2
Error17.0
Cost584
\[\begin{array}{l} t_0 := y \cdot \left(1 - x\right)\\ \mathbf{if}\;y \leq -1.2 \cdot 10^{-217}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 5 \cdot 10^{-84}:\\ \;\;\;\;z \cdot x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error12.5
Cost584
\[\begin{array}{l} t_0 := \left(z - y\right) \cdot x\\ \mathbf{if}\;x \leq -1.65 \cdot 10^{-61}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 45000:\\ \;\;\;\;y \cdot \left(1 - x\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error0.9
Cost584
\[\begin{array}{l} t_0 := \left(z - y\right) \cdot x\\ \mathbf{if}\;x \leq -1:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;y + z \cdot x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error24.5
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -3.8 \cdot 10^{-61}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;x \leq 7.5 \cdot 10^{-35}:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;z \cdot x\\ \end{array} \]
Alternative 6
Error35.1
Cost64
\[y \]

Error

Reproduce?

herbie shell --seed 2023092 
(FPCore (x y z)
  :name "Diagrams.Color.HSV:lerp  from diagrams-contrib-1.3.0.5"
  :precision binary64

  :herbie-target
  (- y (* x (- y z)))

  (+ (* (- 1.0 x) y) (* x z)))