Average Error: 0.1 → 0
Time: 12.8s
Precision: 64
\[x + \frac{x - y}{2}\]
\[\mathsf{fma}\left(1.5, x, \left(-0.5\right) \cdot y\right)\]
x + \frac{x - y}{2}
\mathsf{fma}\left(1.5, x, \left(-0.5\right) \cdot y\right)
double f(double x, double y) {
        double r541931 = x;
        double r541932 = y;
        double r541933 = r541931 - r541932;
        double r541934 = 2.0;
        double r541935 = r541933 / r541934;
        double r541936 = r541931 + r541935;
        return r541936;
}

double f(double x, double y) {
        double r541937 = 1.5;
        double r541938 = x;
        double r541939 = 0.5;
        double r541940 = -r541939;
        double r541941 = y;
        double r541942 = r541940 * r541941;
        double r541943 = fma(r541937, r541938, r541942);
        return r541943;
}

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. Using strategy rm
  3. Applied div-sub0.1

    \[\leadsto x + \color{blue}{\left(\frac{x}{2} - \frac{y}{2}\right)}\]
  4. Applied associate-+r-0.1

    \[\leadsto \color{blue}{\left(x + \frac{x}{2}\right) - \frac{y}{2}}\]
  5. Simplified0.1

    \[\leadsto \color{blue}{\left(\frac{x}{2} + x\right)} - \frac{y}{2}\]
  6. Taylor expanded around 0 0.1

    \[\leadsto \color{blue}{1.5 \cdot x - 0.5 \cdot y}\]
  7. Simplified0

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

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

Reproduce

herbie shell --seed 2019194 +o rules:numerics
(FPCore (x y)
  :name "Graphics.Rendering.Chart.Axis.Types:hBufferRect from Chart-1.5.3"

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

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