Average Error: 0.1 → 0
Time: 5.6s
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 r677836 = x;
        double r677837 = y;
        double r677838 = r677836 - r677837;
        double r677839 = 2.0;
        double r677840 = r677838 / r677839;
        double r677841 = r677836 + r677840;
        return r677841;
}

double f(double x, double y) {
        double r677842 = 1.5;
        double r677843 = x;
        double r677844 = y;
        double r677845 = 0.5;
        double r677846 = r677844 * r677845;
        double r677847 = -r677846;
        double r677848 = fma(r677842, r677843, r677847);
        return r677848;
}

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

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

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

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

Reproduce

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