?

Average Accuracy: 100.0% → 100.0%
Time: 3.9s
Precision: binary64
Cost: 448

?

\[\left(1 - x\right) \cdot y + x \cdot z \]
\[y + \left(z - y\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 - 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 - y\right) \cdot x

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original100.0%
Target100.0%
Herbie100.0%
\[y - x \cdot \left(y - z\right) \]

Derivation?

  1. Initial program 100.0%

    \[\left(1 - x\right) \cdot y + x \cdot z \]
  2. Simplified100.0%

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

    [Start]100.0

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

    sub-neg [=>]100.0

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

    +-commutative [=>]100.0

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

    distribute-rgt1-in [<=]100.0

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

    associate-+l+ [=>]100.0

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

    +-commutative [=>]100.0

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

    *-commutative [=>]100.0

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

    neg-mul-1 [=>]100.0

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

    associate-*r* [=>]100.0

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

    *-commutative [=>]100.0

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

    distribute-rgt-out [=>]100.0

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

    fma-def [=>]100.0

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

    +-commutative [=>]100.0

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

    *-commutative [=>]100.0

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

    neg-mul-1 [<=]100.0

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

    unsub-neg [=>]100.0

    \[ \mathsf{fma}\left(x, \color{blue}{z - y}, y\right) \]
  3. Taylor expanded in x around 0 100.0%

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

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

Alternatives

Alternative 1
Accuracy60.6%
Cost1048
\[\begin{array}{l} t_0 := y \cdot \left(-x\right)\\ \mathbf{if}\;x \leq -1 \cdot 10^{+214}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;x \leq -14:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -1.95 \cdot 10^{-88}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;x \leq 1.05 \cdot 10^{-78}:\\ \;\;\;\;y\\ \mathbf{elif}\;x \leq 3.2 \cdot 10^{+25}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;x \leq 7.8 \cdot 10^{+155}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;z \cdot x\\ \end{array} \]
Alternative 2
Accuracy79.3%
Cost585
\[\begin{array}{l} \mathbf{if}\;x \leq -6 \cdot 10^{-88} \lor \neg \left(x \leq 9 \cdot 10^{-79}\right):\\ \;\;\;\;\left(z - y\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]
Alternative 3
Accuracy98.7%
Cost585
\[\begin{array}{l} \mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 0.31\right):\\ \;\;\;\;\left(z - y\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;y + z \cdot x\\ \end{array} \]
Alternative 4
Accuracy62.2%
Cost456
\[\begin{array}{l} \mathbf{if}\;y \leq -1.1 \cdot 10^{-34}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq 5.6 \cdot 10^{-76}:\\ \;\;\;\;z \cdot x\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]
Alternative 5
Accuracy46.0%
Cost64
\[y \]

Error

Reproduce?

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