Average Error: 12.7 → 0.0
Time: 11.3s
Precision: binary64
Cost: 6848
\[\left(\left(x \cdot y - y \cdot y\right) + y \cdot y\right) - y \cdot z \]
\[-\mathsf{fma}\left(z, y, -x \cdot y\right) \]
(FPCore (x y z)
 :precision binary64
 (- (+ (- (* x y) (* y y)) (* y y)) (* y z)))
(FPCore (x y z) :precision binary64 (- (fma z y (- (* x 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(z, y, -(x * 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(z, y, Float64(-Float64(x * 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[(z * y + (-N[(x * y), $MachinePrecision])), $MachinePrecision])
\left(\left(x \cdot y - y \cdot y\right) + y \cdot y\right) - y \cdot z
-\mathsf{fma}\left(z, y, -x \cdot y\right)

Error

Target

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

Derivation

  1. Initial program 12.7

    \[\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}{\mathsf{fma}\left(z, y, -x \cdot y\right)} \]

Alternatives

Alternative 1
Error16.0
Cost848
\[\begin{array}{l} t_0 := -y \cdot z\\ t_1 := -\left(-y \cdot x\right)\\ \mathbf{if}\;z \leq -5.4 \cdot 10^{+30}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -7.6 \cdot 10^{-45}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -8.5 \cdot 10^{-72}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 4.9 \cdot 10^{-57}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error0.0
Cost384
\[-y \cdot \left(z - x\right) \]
Alternative 3
Error29.5
Cost256
\[-y \cdot z \]

Error

Reproduce

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