Average Error: 0.1 → 0
Time: 15.4s
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 r535304 = x;
        double r535305 = y;
        double r535306 = r535304 - r535305;
        double r535307 = 2.0;
        double r535308 = r535306 / r535307;
        double r535309 = r535304 + r535308;
        return r535309;
}

double f(double x, double y) {
        double r535310 = 1.5;
        double r535311 = x;
        double r535312 = 0.5;
        double r535313 = -r535312;
        double r535314 = y;
        double r535315 = r535313 * r535314;
        double r535316 = fma(r535310, r535311, r535315);
        return r535316;
}

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, \left(-0.5\right) \cdot y\right)}\]
  8. Final simplification0

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

Reproduce

herbie shell --seed 2019179 +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)))