?

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

?

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

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

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

    [Start]0.0

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

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

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

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

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

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

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

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

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

Alternatives

Alternative 1
Error24.3
Cost1048
\[\begin{array}{l} \mathbf{if}\;y \leq -1.48 \cdot 10^{-6}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;y \leq 7.2 \cdot 10^{-96}:\\ \;\;\;\;z\\ \mathbf{elif}\;y \leq 4.2 \cdot 10^{-54}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;y \leq 0.136:\\ \;\;\;\;z\\ \mathbf{elif}\;y \leq 2.15 \cdot 10^{+43}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;y \leq 5.4 \cdot 10^{+70}:\\ \;\;\;\;z \cdot \left(-y\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 2
Error13.0
Cost848
\[\begin{array}{l} t_0 := y \cdot \left(x - z\right)\\ \mathbf{if}\;y \leq -9.5 \cdot 10^{-7}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.25 \cdot 10^{-95}:\\ \;\;\;\;z\\ \mathbf{elif}\;y \leq 3.75 \cdot 10^{-54}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;y \leq 0.136:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error12.7
Cost848
\[\begin{array}{l} t_0 := y \cdot \left(x - z\right)\\ t_1 := z \cdot \left(1 - y\right)\\ \mathbf{if}\;y \leq -1.25 \cdot 10^{-6}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.25 \cdot 10^{-95}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 6.5 \cdot 10^{-57}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;y \leq 0.58:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error24.3
Cost720
\[\begin{array}{l} \mathbf{if}\;y \leq -9.5 \cdot 10^{-7}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;y \leq 1.66 \cdot 10^{-96}:\\ \;\;\;\;z\\ \mathbf{elif}\;y \leq 6.5 \cdot 10^{-57}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;y \leq 0.136:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 5
Error1.0
Cost584
\[\begin{array}{l} t_0 := y \cdot \left(x - z\right)\\ \mathbf{if}\;y \leq -1:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1:\\ \;\;\;\;z + y \cdot x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error35.0
Cost64
\[z \]

Error

Reproduce?

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