?

Average Error: 13.0 → 0.0
Time: 14.3s
Precision: binary64
Cost: 6848

?

\[\left(\left(x \cdot y - y \cdot y\right) + y \cdot y\right) - y \cdot z \]
\[-\mathsf{fma}\left(-y, x, z \cdot y\right) \]
(FPCore (x y z)
 :precision binary64
 (- (+ (- (* x y) (* y y)) (* y y)) (* y z)))
(FPCore (x y z) :precision binary64 (- (fma (- y) x (* z y))))
double code(double x, double y, double z) {
	return (((x * y) - (y * y)) + (y * y)) - (y * z);
}
double code(double x, double y, double z) {
	return -fma(-y, x, (z * y));
}
function code(x, y, z)
	return Float64(Float64(Float64(Float64(x * y) - Float64(y * y)) + Float64(y * y)) - Float64(y * z))
end
function code(x, y, z)
	return Float64(-fma(Float64(-y), x, Float64(z * y)))
end
code[x_, y_, z_] := N[(N[(N[(N[(x * y), $MachinePrecision] - N[(y * y), $MachinePrecision]), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := (-N[((-y) * x + N[(z * y), $MachinePrecision]), $MachinePrecision])
\left(\left(x \cdot y - y \cdot y\right) + y \cdot y\right) - y \cdot z
-\mathsf{fma}\left(-y, x, z \cdot y\right)

Error?

Target

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

Derivation?

  1. Initial program 13.0

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

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

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

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

Alternatives

Alternative 1
Error15.6
Cost584
\[\begin{array}{l} t_0 := -\left(-y \cdot x\right)\\ \mathbf{if}\;x \leq -8.3 \cdot 10^{+52}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 6 \cdot 10^{+22}:\\ \;\;\;\;-z \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error0.0
Cost384
\[-y \cdot \left(z - x\right) \]
Alternative 3
Error30.3
Cost256
\[-z \cdot y \]

Error

Reproduce?

herbie shell --seed 2023033 
(FPCore (x y z)
  :name "Linear.Quaternion:$c/ from linear-1.19.1.3, D"
  :precision binary64

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

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