Average Error: 0.1 → 0
Time: 11.2s
Precision: 64
\[x + \frac{x - y}{2}\]
\[\mathsf{fma}\left(1.5, x, -y \cdot 0.5\right)\]
x + \frac{x - y}{2}
\mathsf{fma}\left(1.5, x, -y \cdot 0.5\right)
double f(double x, double y) {
        double r50449 = x;
        double r50450 = y;
        double r50451 = r50449 - r50450;
        double r50452 = 2.0;
        double r50453 = r50451 / r50452;
        double r50454 = r50449 + r50453;
        return r50454;
}

double f(double x, double y) {
        double r50455 = 1.5;
        double r50456 = x;
        double r50457 = y;
        double r50458 = 0.5;
        double r50459 = r50457 * r50458;
        double r50460 = -r50459;
        double r50461 = fma(r50455, r50456, r50460);
        return r50461;
}

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. Taylor expanded around 0 0.1

    \[\leadsto \color{blue}{1.5 \cdot x - 0.5 \cdot y}\]
  3. Using strategy rm
  4. Applied fma-neg0

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

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

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

Reproduce

herbie shell --seed 2019315 +o rules:numerics
(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)))