Average Error: 16.3 → 7.5
Time: 51.3s
Precision: 64
\[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\]
\[x + \mathsf{fma}\left(\frac{t - z}{a - t}, y, y\right)\]
\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
x + \mathsf{fma}\left(\frac{t - z}{a - t}, y, y\right)
double f(double x, double y, double z, double t, double a) {
        double r23858164 = x;
        double r23858165 = y;
        double r23858166 = r23858164 + r23858165;
        double r23858167 = z;
        double r23858168 = t;
        double r23858169 = r23858167 - r23858168;
        double r23858170 = r23858169 * r23858165;
        double r23858171 = a;
        double r23858172 = r23858171 - r23858168;
        double r23858173 = r23858170 / r23858172;
        double r23858174 = r23858166 - r23858173;
        return r23858174;
}

double f(double x, double y, double z, double t, double a) {
        double r23858175 = x;
        double r23858176 = t;
        double r23858177 = z;
        double r23858178 = r23858176 - r23858177;
        double r23858179 = a;
        double r23858180 = r23858179 - r23858176;
        double r23858181 = r23858178 / r23858180;
        double r23858182 = y;
        double r23858183 = fma(r23858181, r23858182, r23858182);
        double r23858184 = r23858175 + r23858183;
        return r23858184;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original16.3
Target8.3
Herbie7.5
\[\begin{array}{l} \mathbf{if}\;\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} \lt -1.366497088939072697550672266103566343531 \cdot 10^{-7}:\\ \;\;\;\;\left(y + x\right) - \left(\left(z - t\right) \cdot \frac{1}{a - t}\right) \cdot y\\ \mathbf{elif}\;\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} \lt 1.475429344457723334351036314450840066235 \cdot 10^{-239}:\\ \;\;\;\;\frac{y \cdot \left(a - z\right) - x \cdot t}{a - t}\\ \mathbf{else}:\\ \;\;\;\;\left(y + x\right) - \left(\left(z - t\right) \cdot \frac{1}{a - t}\right) \cdot y\\ \end{array}\]

Derivation

  1. Initial program 16.3

    \[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\]
  2. Simplified11.8

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{a - t}, t - z, y + x\right)}\]
  3. Using strategy rm
  4. Applied fma-udef11.8

    \[\leadsto \color{blue}{\frac{y}{a - t} \cdot \left(t - z\right) + \left(y + x\right)}\]
  5. Using strategy rm
  6. Applied div-inv11.9

    \[\leadsto \color{blue}{\left(y \cdot \frac{1}{a - t}\right)} \cdot \left(t - z\right) + \left(y + x\right)\]
  7. Applied associate-*l*11.6

    \[\leadsto \color{blue}{y \cdot \left(\frac{1}{a - t} \cdot \left(t - z\right)\right)} + \left(y + x\right)\]
  8. Simplified11.5

    \[\leadsto y \cdot \color{blue}{\frac{t - z}{a - t}} + \left(y + x\right)\]
  9. Using strategy rm
  10. Applied associate-+r+7.5

    \[\leadsto \color{blue}{\left(y \cdot \frac{t - z}{a - t} + y\right) + x}\]
  11. Simplified7.5

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{t - z}{a - t}, y, y\right)} + x\]
  12. Final simplification7.5

    \[\leadsto x + \mathsf{fma}\left(\frac{t - z}{a - t}, y, y\right)\]

Reproduce

herbie shell --seed 2019200 +o rules:numerics
(FPCore (x y z t a)
  :name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisTick from plot-0.2.3.4, B"

  :herbie-target
  (if (< (- (+ x y) (/ (* (- z t) y) (- a t))) -1.3664970889390727e-07) (- (+ y x) (* (* (- z t) (/ 1.0 (- a t))) y)) (if (< (- (+ x y) (/ (* (- z t) y) (- a t))) 1.4754293444577233e-239) (/ (- (* y (- a z)) (* x t)) (- a t)) (- (+ y x) (* (* (- z t) (/ 1.0 (- a t))) y))))

  (- (+ x y) (/ (* (- z t) y) (- a t))))