Average Error: 0.1 → 0
Time: 13.9s
Precision: 64
\[x + \frac{x - y}{2.0}\]
\[\mathsf{fma}\left(1.5, x, -0.5 \cdot y\right)\]
x + \frac{x - y}{2.0}
\mathsf{fma}\left(1.5, x, -0.5 \cdot y\right)
double f(double x, double y) {
        double r29093495 = x;
        double r29093496 = y;
        double r29093497 = r29093495 - r29093496;
        double r29093498 = 2.0;
        double r29093499 = r29093497 / r29093498;
        double r29093500 = r29093495 + r29093499;
        return r29093500;
}

double f(double x, double y) {
        double r29093501 = 1.5;
        double r29093502 = x;
        double r29093503 = 0.5;
        double r29093504 = y;
        double r29093505 = r29093503 * r29093504;
        double r29093506 = -r29093505;
        double r29093507 = fma(r29093501, r29093502, r29093506);
        return r29093507;
}

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.0}\]
  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. Final simplification0

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

Reproduce

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