Average Error: 0.1 → 0
Time: 3.1s
Precision: binary64
\[x + \frac{x - y}{2} \]
\[\mathsf{fma}\left(-0.5 \cdot x, -3, -0.5 \cdot y\right) \]
x + \frac{x - y}{2}
\mathsf{fma}\left(-0.5 \cdot x, -3, -0.5 \cdot y\right)
(FPCore (x y) :precision binary64 (+ x (/ (- x y) 2.0)))
(FPCore (x y) :precision binary64 (fma (* -0.5 x) -3.0 (* -0.5 y)))
double code(double x, double y) {
	return x + ((x - y) / 2.0);
}
double code(double x, double y) {
	return fma((-0.5 * x), -3.0, (-0.5 * y));
}

Error

Bits error versus x

Bits error versus y

Target

Original0.1
Target0.1
Herbie0
\[1.5 \cdot x - 0.5 \cdot y \]

Derivation

  1. Initial program 0.1

    \[x + \frac{x - y}{2} \]
  2. Simplified0.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(x - y, 0.5, x\right)} \]
  3. Applied add-cube-cbrt_binary641.3

    \[\leadsto \color{blue}{\left(\sqrt[3]{\mathsf{fma}\left(x - y, 0.5, x\right)} \cdot \sqrt[3]{\mathsf{fma}\left(x - y, 0.5, x\right)}\right) \cdot \sqrt[3]{\mathsf{fma}\left(x - y, 0.5, x\right)}} \]
  4. Applied pow3_binary641.3

    \[\leadsto \color{blue}{{\left(\sqrt[3]{\mathsf{fma}\left(x - y, 0.5, x\right)}\right)}^{3}} \]
  5. Taylor expanded in y around inf 64.0

    \[\leadsto \color{blue}{{\left(e^{0.3333333333333333 \cdot \left(\log -0.5 - \log \left(\frac{1}{y}\right)\right)}\right)}^{3} - 3 \cdot \frac{{\left(e^{0.3333333333333333 \cdot \left(\log -0.5 - \log \left(\frac{1}{y}\right)\right)}\right)}^{3} \cdot x}{y}} \]
  6. Simplified11.6

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x \cdot \left(y \cdot -0.5\right)}{y}, -3, y \cdot -0.5\right)} \]
  7. Taylor expanded in x around 0 0

    \[\leadsto \mathsf{fma}\left(\color{blue}{-0.5 \cdot x}, -3, y \cdot -0.5\right) \]
  8. Final simplification0

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

Reproduce

herbie shell --seed 2022068 
(FPCore (x y)
  :name "Graphics.Rendering.Chart.Axis.Types:hBufferRect from Chart-1.5.3"
  :precision binary64

  :herbie-target
  (- (* 1.5 x) (* 0.5 y))

  (+ x (/ (- x y) 2.0)))