?

Average Error: 0.0 → 0.0
Time: 5.8s
Precision: binary64
Cost: 640

?

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

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(y + -1 \cdot \left(y \cdot x\right)\right)} + x \cdot z \]
  3. Simplified0.0

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

    [Start]0.0

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

    rational.json-simplify-43 [=>]0.0

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

    rational.json-simplify-9 [=>]0.0

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

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

Alternatives

Alternative 1
Error23.8
Cost652
\[\begin{array}{l} \mathbf{if}\;x \leq -3.8 \cdot 10^{-11}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;x \leq 1400000:\\ \;\;\;\;y\\ \mathbf{elif}\;x \leq 4.1 \cdot 10^{+166}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot x\\ \end{array} \]
Alternative 2
Error0.9
Cost644
\[\begin{array}{l} \mathbf{if}\;x \leq -100000:\\ \;\;\;\;y \cdot \left(-x\right) + x \cdot z\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;y + x \cdot z\\ \mathbf{else}:\\ \;\;\;\;\left(z - y\right) \cdot x\\ \end{array} \]
Alternative 3
Error12.2
Cost584
\[\begin{array}{l} t_0 := \left(z - y\right) \cdot x\\ \mathbf{if}\;x \leq -1.15 \cdot 10^{-10}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 5 \cdot 10^{-7}:\\ \;\;\;\;y\\ \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 -100000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;y + x \cdot z\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error0.0
Cost576
\[\left(1 - x\right) \cdot y + x \cdot z \]
Alternative 6
Error24.3
Cost456
\[\begin{array}{l} \mathbf{if}\;y \leq -3.6 \cdot 10^{-53}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq 2.4 \cdot 10^{-48}:\\ \;\;\;\;z \cdot x\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]
Alternative 7
Error34.9
Cost64
\[y \]

Error

Reproduce?

herbie shell --seed 2023073 
(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)))