Average Error: 0.0 → 0.0
Time: 3.0s
Precision: binary64
Cost: 6848
\[\frac{x \cdot y}{2} - \frac{z}{8} \]
\[\mathsf{fma}\left(x, \frac{y}{2}, \frac{z}{-8}\right) \]
(FPCore (x y z) :precision binary64 (- (/ (* x y) 2.0) (/ z 8.0)))
(FPCore (x y z) :precision binary64 (fma x (/ y 2.0) (/ z -8.0)))
double code(double x, double y, double z) {
	return ((x * y) / 2.0) - (z / 8.0);
}
double code(double x, double y, double z) {
	return fma(x, (y / 2.0), (z / -8.0));
}
function code(x, y, z)
	return Float64(Float64(Float64(x * y) / 2.0) - Float64(z / 8.0))
end
function code(x, y, z)
	return fma(x, Float64(y / 2.0), Float64(z / -8.0))
end
code[x_, y_, z_] := N[(N[(N[(x * y), $MachinePrecision] / 2.0), $MachinePrecision] - N[(z / 8.0), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := N[(x * N[(y / 2.0), $MachinePrecision] + N[(z / -8.0), $MachinePrecision]), $MachinePrecision]
\frac{x \cdot y}{2} - \frac{z}{8}
\mathsf{fma}\left(x, \frac{y}{2}, \frac{z}{-8}\right)

Error

Derivation

  1. Initial program 0.0

    \[\frac{x \cdot y}{2} - \frac{z}{8} \]
  2. Simplified0.0

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, \frac{y}{2}, \frac{z}{-8}\right)} \]
    Proof
    (fma.f64 x (/.f64 y 2) (/.f64 z -8)): 0 points increase in error, 0 points decrease in error
    (fma.f64 x (/.f64 y 2) (/.f64 z (Rewrite<= metadata-eval (/.f64 8 -1)))): 0 points increase in error, 0 points decrease in error
    (fma.f64 x (/.f64 y 2) (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 z -1) 8))): 0 points increase in error, 0 points decrease in error
    (fma.f64 x (/.f64 y 2) (/.f64 (Rewrite<= *-commutative_binary64 (*.f64 -1 z)) 8)): 0 points increase in error, 0 points decrease in error
    (fma.f64 x (/.f64 y 2) (Rewrite<= associate-*r/_binary64 (*.f64 -1 (/.f64 z 8)))): 0 points increase in error, 0 points decrease in error
    (fma.f64 x (/.f64 y 2) (Rewrite<= neg-mul-1_binary64 (neg.f64 (/.f64 z 8)))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= fma-neg_binary64 (-.f64 (*.f64 x (/.f64 y 2)) (/.f64 z 8))): 0 points increase in error, 0 points decrease in error
    (-.f64 (Rewrite<= *-commutative_binary64 (*.f64 (/.f64 y 2) x)) (/.f64 z 8)): 0 points increase in error, 0 points decrease in error
    (-.f64 (Rewrite=> associate-*l/_binary64 (/.f64 (*.f64 y x) 2)) (/.f64 z 8)): 8 points increase in error, 0 points decrease in error
    (-.f64 (/.f64 (Rewrite<= *-commutative_binary64 (*.f64 x y)) 2) (/.f64 z 8)): 0 points increase in error, 8 points decrease in error
  3. Final simplification0.0

    \[\leadsto \mathsf{fma}\left(x, \frac{y}{2}, \frac{z}{-8}\right) \]

Alternatives

Alternative 1
Error17.4
Cost584
\[\begin{array}{l} \mathbf{if}\;z \leq -1.55 \cdot 10^{-12}:\\ \;\;\;\;z \cdot -0.125\\ \mathbf{elif}\;z \leq 4.6 \cdot 10^{-13}:\\ \;\;\;\;y \cdot \left(x \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot -0.125\\ \end{array} \]
Alternative 2
Error0.1
Cost576
\[\frac{x}{\frac{2}{y}} - \frac{z}{8} \]
Alternative 3
Error0.0
Cost576
\[\frac{x \cdot y}{2} - \frac{z}{8} \]
Alternative 4
Error26.9
Cost192
\[z \cdot -0.125 \]

Error

Reproduce

herbie shell --seed 2022343 
(FPCore (x y z)
  :name "Diagrams.Solve.Polynomial:quartForm  from diagrams-solve-0.1, D"
  :precision binary64
  (- (/ (* x y) 2.0) (/ z 8.0)))