?

Average Accuracy: 78.7% → 78.7%
Time: 5.6s
Precision: binary64
Cost: 576

?

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

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original78.7%
Target78.7%
Herbie78.7%
\[z - \left(z - x\right) \cdot y \]

Derivation?

  1. Initial program 81.6%

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(y, x - z, z\right)} \]
    Step-by-step derivation

    [Start]81.6

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

    +-commutative [=>]81.6

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

    sub-neg [=>]81.6

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

    distribute-rgt-in [=>]81.6

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

    *-lft-identity [=>]81.6

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

    associate-+l+ [=>]81.6

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

    +-commutative [=>]81.6

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

    *-commutative [=>]81.6

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

    neg-mul-1 [=>]81.6

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

    associate-*r* [=>]81.6

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

    distribute-rgt-out [=>]81.6

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

    fma-def [=>]81.6

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

    +-commutative [=>]81.6

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

    *-commutative [=>]81.6

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

    neg-mul-1 [<=]81.6

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

    unsub-neg [=>]81.6

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

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

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

Alternatives

Alternative 1
Accuracy62.5%
Cost585
\[\begin{array}{l} \mathbf{if}\;y \leq -2.2 \cdot 10^{-10} \lor \neg \left(y \leq 1.95 \cdot 10^{-75}\right):\\ \;\;\;\;y \cdot \left(x - z\right)\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \]
Alternative 2
Accuracy77.6%
Cost585
\[\begin{array}{l} \mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 1\right):\\ \;\;\;\;y \cdot \left(x - z\right)\\ \mathbf{else}:\\ \;\;\;\;z + y \cdot x\\ \end{array} \]
Alternative 3
Accuracy78.7%
Cost576
\[y \cdot x + z \cdot \left(1 - y\right) \]
Alternative 4
Accuracy48.7%
Cost456
\[\begin{array}{l} \mathbf{if}\;y \leq -7.5 \cdot 10^{-11}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;y \leq 1.2 \cdot 10^{-74}:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 5
Accuracy48.6%
Cost456
\[\begin{array}{l} \mathbf{if}\;y \leq -4.5 \cdot 10^{-9}:\\ \;\;\;\;y \cdot \left(-z\right)\\ \mathbf{elif}\;y \leq 5.5 \cdot 10^{-77}:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 6
Accuracy78.7%
Cost448
\[z + y \cdot \left(x - z\right) \]
Alternative 7
Accuracy36.3%
Cost64
\[z \]

Error

Reproduce?

herbie shell --seed 2023157 
(FPCore (x y z)
  :name "Diagrams.TwoD.Segment:bezierClip from diagrams-lib-1.3.0.3"
  :precision binary64

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

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