Average Error: 0.0 → 0.0
Time: 2.9s
Precision: binary64
Cost: 448
\[x \cdot y + z \cdot \left(1 - y\right) \]
\[z + y \cdot \left(x - z\right) \]
(FPCore (x y z) :precision binary64 (+ (* x y) (* z (- 1.0 y))))
(FPCore (x y z) :precision binary64 (+ z (* y (- x 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 - 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 - 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 - z));
}
def code(x, y, z):
	return (x * y) + (z * (1.0 - y))
def code(x, y, z):
	return z + (y * (x - 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(z + Float64(y * Float64(x - 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 - 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[(z + N[(y * N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x \cdot y + z \cdot \left(1 - y\right)
z + y \cdot \left(x - z\right)

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 0.0

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

    \[\leadsto \color{blue}{z + y \cdot \left(-1 \cdot z + x\right)} \]
  3. Taylor expanded in z around 0 0.0

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

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

    [Start]0.0

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

    +-commutative [<=]0.0

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

    mul-1-neg [=>]0.0

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

    sub-neg [<=]0.0

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

    distribute-lft-out-- [=>]0.0

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

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

Alternatives

Alternative 1
Error24.5
Cost1048
\[\begin{array}{l} t_0 := z \cdot \left(-y\right)\\ \mathbf{if}\;y \leq -3 \cdot 10^{+79}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -3.5 \cdot 10^{-22}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;y \leq -1.4 \cdot 10^{-64}:\\ \;\;\;\;z\\ \mathbf{elif}\;y \leq -8.5 \cdot 10^{-98}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;y \leq 9.5 \cdot 10^{-41}:\\ \;\;\;\;z\\ \mathbf{elif}\;y \leq 4.2 \cdot 10^{+103}:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error13.4
Cost850
\[\begin{array}{l} \mathbf{if}\;y \leq -8.4 \cdot 10^{-23} \lor \neg \left(y \leq -5.5 \cdot 10^{-64} \lor \neg \left(y \leq -7 \cdot 10^{-98}\right) \land y \leq 7.5 \cdot 10^{-42}\right):\\ \;\;\;\;y \cdot \left(x - z\right)\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \]
Alternative 3
Error24.3
Cost720
\[\begin{array}{l} \mathbf{if}\;z \leq -1.45 \cdot 10^{-36}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq 4.6 \cdot 10^{-88}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;z \leq 2.8 \cdot 10^{-72}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq 5 \cdot 10^{-44}:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \]
Alternative 4
Error0.8
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 5
Error34.9
Cost64
\[z \]

Error

Reproduce

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