Average Error: 0.1 → 0
Time: 2.2s
Precision: binary64
Cost: 6592
\[x - \frac{3}{8} \cdot y \]
\[\mathsf{fma}\left(y, -0.375, x\right) \]
(FPCore (x y) :precision binary64 (- x (* (/ 3.0 8.0) y)))
(FPCore (x y) :precision binary64 (fma y -0.375 x))
double code(double x, double y) {
	return x - ((3.0 / 8.0) * y);
}
double code(double x, double y) {
	return fma(y, -0.375, x);
}
function code(x, y)
	return Float64(x - Float64(Float64(3.0 / 8.0) * y))
end
function code(x, y)
	return fma(y, -0.375, x)
end
code[x_, y_] := N[(x - N[(N[(3.0 / 8.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := N[(y * -0.375 + x), $MachinePrecision]
x - \frac{3}{8} \cdot y
\mathsf{fma}\left(y, -0.375, x\right)

Error

Derivation

  1. Initial program 0.1

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(y, -0.375, x\right)} \]
    Proof
    (fma.f64 y -3/8 x): 0 points increase in error, 0 points decrease in error
    (fma.f64 y (Rewrite<= metadata-eval (neg.f64 3/8)) x): 0 points increase in error, 0 points decrease in error
    (fma.f64 y (neg.f64 (Rewrite<= metadata-eval (/.f64 3 8))) x): 0 points increase in error, 0 points decrease in error
    (Rewrite<= fma-def_binary64 (+.f64 (*.f64 y (neg.f64 (/.f64 3 8))) x)): 24 points increase in error, 0 points decrease in error
    (+.f64 (Rewrite<= distribute-rgt-neg-in_binary64 (neg.f64 (*.f64 y (/.f64 3 8)))) x): 0 points increase in error, 0 points decrease in error
    (+.f64 (neg.f64 (Rewrite<= *-commutative_binary64 (*.f64 (/.f64 3 8) y))) x): 0 points increase in error, 0 points decrease in error
    (Rewrite<= +-commutative_binary64 (+.f64 x (neg.f64 (*.f64 (/.f64 3 8) y)))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= sub-neg_binary64 (-.f64 x (*.f64 (/.f64 3 8) y))): 0 points increase in error, 0 points decrease in error
  3. Final simplification0

    \[\leadsto \mathsf{fma}\left(y, -0.375, x\right) \]

Alternatives

Alternative 1
Error15.9
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -1.143189810419369 \cdot 10^{-11}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 128903.20277625337:\\ \;\;\;\;y \cdot -0.375\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Error0.1
Cost320
\[x + y \cdot -0.375 \]
Alternative 3
Error30.8
Cost64
\[x \]

Error

Reproduce

herbie shell --seed 2022317 
(FPCore (x y)
  :name "Diagrams.Solve.Polynomial:quartForm  from diagrams-solve-0.1, A"
  :precision binary64
  (- x (* (/ 3.0 8.0) y)))