Average Error: 0.0 → 0.0
Time: 1.5s
Precision: 64
\[0.5 \cdot \left(x \cdot x - y\right)\]
\[\left(0.5 \cdot x\right) \cdot x + 0.5 \cdot \left(-y\right)\]
0.5 \cdot \left(x \cdot x - y\right)
\left(0.5 \cdot x\right) \cdot x + 0.5 \cdot \left(-y\right)
double code(double x, double y) {
	return (0.5 * ((x * x) - y));
}
double code(double x, double y) {
	return (((0.5 * x) * x) + (0.5 * -y));
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 0.0

    \[0.5 \cdot \left(x \cdot x - y\right)\]
  2. Using strategy rm
  3. Applied *-un-lft-identity0.0

    \[\leadsto 0.5 \cdot \left(x \cdot \color{blue}{\left(1 \cdot x\right)} - y\right)\]
  4. Applied associate-*r*0.0

    \[\leadsto 0.5 \cdot \left(\color{blue}{\left(x \cdot 1\right) \cdot x} - y\right)\]
  5. Applied fma-neg0.0

    \[\leadsto 0.5 \cdot \color{blue}{\mathsf{fma}\left(x \cdot 1, x, -y\right)}\]
  6. Using strategy rm
  7. Applied fma-udef0.0

    \[\leadsto 0.5 \cdot \color{blue}{\left(\left(x \cdot 1\right) \cdot x + \left(-y\right)\right)}\]
  8. Applied distribute-lft-in0.0

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

    \[\leadsto \color{blue}{\left(0.5 \cdot x\right) \cdot x} + 0.5 \cdot \left(-y\right)\]
  10. Final simplification0.0

    \[\leadsto \left(0.5 \cdot x\right) \cdot x + 0.5 \cdot \left(-y\right)\]

Reproduce

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