?

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

?

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

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. Simplified0.0

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

    [Start]0.0

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

    rational_best_oopsla_all_46_json_45_simplify-74 [=>]0.0

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

    rational_best_oopsla_all_46_json_45_simplify-13 [=>]0.0

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

    rational_best_oopsla_all_46_json_45_simplify-74 [=>]0.0

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

    rational_best_oopsla_all_46_json_45_simplify-52 [=>]0.0

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

    rational_best_oopsla_all_46_json_45_simplify-74 [=>]0.0

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

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

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

    [Start]0.0

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

    rational_best_oopsla_all_46_json_45_simplify-102 [=>]0.0

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

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

Alternatives

Alternative 1
Error24.9
Cost1180
\[\begin{array}{l} t_0 := y \cdot \left(-x\right)\\ \mathbf{if}\;x \leq -4.4 \cdot 10^{+135}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -1.24 \cdot 10^{-60}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;x \leq -5.2 \cdot 10^{-106}:\\ \;\;\;\;y\\ \mathbf{elif}\;x \leq -3.7 \cdot 10^{-123}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;x \leq 0.0013:\\ \;\;\;\;y\\ \mathbf{elif}\;x \leq 6.5 \cdot 10^{+171}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;x \leq 6.2 \cdot 10^{+299}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;z \cdot x\\ \end{array} \]
Alternative 2
Error13.9
Cost848
\[\begin{array}{l} t_0 := \left(z - y\right) \cdot x\\ \mathbf{if}\;x \leq -1.35 \cdot 10^{-60}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -5 \cdot 10^{-106}:\\ \;\;\;\;y\\ \mathbf{elif}\;x \leq -2.8 \cdot 10^{-148}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 0.0013:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error24.7
Cost720
\[\begin{array}{l} \mathbf{if}\;x \leq -1.22 \cdot 10^{-60}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;x \leq -4.7 \cdot 10^{-105}:\\ \;\;\;\;y\\ \mathbf{elif}\;x \leq -1.95 \cdot 10^{-122}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;x \leq 0.0013:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;z \cdot x\\ \end{array} \]
Alternative 4
Error1.0
Cost584
\[\begin{array}{l} t_0 := \left(z - y\right) \cdot x\\ \mathbf{if}\;x \leq -8200000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;z \cdot x + y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error35.3
Cost64
\[y \]

Error

Reproduce?

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