Average Error: 0.0 → 0.0
Time: 2.6s
Precision: binary64
Cost: 6784
\[0.5 \cdot \left(x \cdot x - y\right) \]
\[0.5 \cdot \mathsf{fma}\left(x, x, -y\right) \]
(FPCore (x y) :precision binary64 (* 0.5 (- (* x x) y)))
(FPCore (x y) :precision binary64 (* 0.5 (fma x x (- y))))
double code(double x, double y) {
	return 0.5 * ((x * x) - y);
}
double code(double x, double y) {
	return 0.5 * fma(x, x, -y);
}
function code(x, y)
	return Float64(0.5 * Float64(Float64(x * x) - y))
end
function code(x, y)
	return Float64(0.5 * fma(x, x, Float64(-y)))
end
code[x_, y_] := N[(0.5 * N[(N[(x * x), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := N[(0.5 * N[(x * x + (-y)), $MachinePrecision]), $MachinePrecision]
0.5 \cdot \left(x \cdot x - y\right)
0.5 \cdot \mathsf{fma}\left(x, x, -y\right)

Error

Derivation

  1. Initial program 0.0

    \[0.5 \cdot \left(x \cdot x - y\right) \]
  2. Taylor expanded in x around 0 0.0

    \[\leadsto 0.5 \cdot \color{blue}{\left({x}^{2} + -1 \cdot y\right)} \]
  3. Simplified0.0

    \[\leadsto 0.5 \cdot \color{blue}{\mathsf{fma}\left(x, x, -y\right)} \]
    Proof
    (fma.f64 x x (neg.f64 y)): 0 points increase in error, 0 points decrease in error
    (fma.f64 x x (Rewrite<= mul-1-neg_binary64 (*.f64 -1 y))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= fma-def_binary64 (+.f64 (*.f64 x x) (*.f64 -1 y))): 0 points increase in error, 1 points decrease in error
    (+.f64 (Rewrite<= unpow2_binary64 (pow.f64 x 2)) (*.f64 -1 y)): 1 points increase in error, 0 points decrease in error
  4. Final simplification0.0

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

Alternatives

Alternative 1
Error12.1
Cost1100
\[\begin{array}{l} t_0 := 0.5 \cdot \left(x \cdot x\right)\\ \mathbf{if}\;x \cdot x \leq 5.329720765956209 \cdot 10^{-117}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;x \cdot x \leq 1.2453460218705353 \cdot 10^{-104}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot x \leq 1.3492346191998738 \cdot 10^{+78}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error0.0
Cost448
\[0.5 \cdot \left(x \cdot x - y\right) \]
Alternative 3
Error21.3
Cost192
\[y \cdot -0.5 \]

Error

Reproduce

herbie shell --seed 2022297 
(FPCore (x y)
  :name "System.Random.MWC.Distributions:standard from mwc-random-0.13.3.2"
  :precision binary64
  (* 0.5 (- (* x x) y)))