Average Error: 10.2 → 1.2
Time: 17.7s
Precision: 64
\[x + \frac{y \cdot \left(z - t\right)}{a - t}\]
\[\mathsf{fma}\left(y, \frac{z - t}{a - t}, x\right)\]
x + \frac{y \cdot \left(z - t\right)}{a - t}
\mathsf{fma}\left(y, \frac{z - t}{a - t}, x\right)
double f(double x, double y, double z, double t, double a) {
        double r21882559 = x;
        double r21882560 = y;
        double r21882561 = z;
        double r21882562 = t;
        double r21882563 = r21882561 - r21882562;
        double r21882564 = r21882560 * r21882563;
        double r21882565 = a;
        double r21882566 = r21882565 - r21882562;
        double r21882567 = r21882564 / r21882566;
        double r21882568 = r21882559 + r21882567;
        return r21882568;
}

double f(double x, double y, double z, double t, double a) {
        double r21882569 = y;
        double r21882570 = z;
        double r21882571 = t;
        double r21882572 = r21882570 - r21882571;
        double r21882573 = a;
        double r21882574 = r21882573 - r21882571;
        double r21882575 = r21882572 / r21882574;
        double r21882576 = x;
        double r21882577 = fma(r21882569, r21882575, r21882576);
        return r21882577;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original10.2
Target1.1
Herbie1.2
\[x + \frac{y}{\frac{a - t}{z - t}}\]

Derivation

  1. Initial program 10.2

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

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

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

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

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

    \[\leadsto y \cdot \color{blue}{\frac{z - t}{a - t}} + x\]
  9. Using strategy rm
  10. Applied fma-def1.2

    \[\leadsto \color{blue}{\mathsf{fma}\left(y, \frac{z - t}{a - t}, x\right)}\]
  11. Final simplification1.2

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

Reproduce

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

  :herbie-target
  (+ x (/ y (/ (- a t) (- z t))))

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