Average Error: 0.1 → 0
Time: 14.9s
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 r368755 = x;
        double r368756 = y;
        double r368757 = r368755 - r368756;
        double r368758 = 2.0;
        double r368759 = r368757 / r368758;
        double r368760 = r368755 + r368759;
        return r368760;
}

double f(double x, double y) {
        double r368761 = 1.5;
        double r368762 = x;
        double r368763 = 0.5;
        double r368764 = -r368763;
        double r368765 = y;
        double r368766 = r368764 * r368765;
        double r368767 = fma(r368761, r368762, r368766);
        return r368767;
}

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 2019174 +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)))