Average Error: 0.0 → 0.0
Time: 1.9s
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))): 1 points increase in error, 1 points decrease in error
    (+.f64 (Rewrite<= unpow2_binary64 (pow.f64 x 2)) (*.f64 -1 y)): 0 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
Error11.5
Cost584
\[\begin{array}{l} t_0 := 0.5 \cdot \left(x \cdot x\right)\\ \mathbf{if}\;x \leq -2.3666808788350538 \cdot 10^{+51}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 5.684120816616748 \cdot 10^{-31}:\\ \;\;\;\;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
Error20.7
Cost192
\[y \cdot -0.5 \]

Error

Reproduce

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