Average Error: 10.5 → 1.4
Time: 5.3s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot t}{a - z}\]
\[\mathsf{fma}\left(\frac{y}{a - z} - \frac{z}{a - z}, t, x\right)\]
x + \frac{\left(y - z\right) \cdot t}{a - z}
\mathsf{fma}\left(\frac{y}{a - z} - \frac{z}{a - z}, t, x\right)
double f(double x, double y, double z, double t, double a) {
        double r596590 = x;
        double r596591 = y;
        double r596592 = z;
        double r596593 = r596591 - r596592;
        double r596594 = t;
        double r596595 = r596593 * r596594;
        double r596596 = a;
        double r596597 = r596596 - r596592;
        double r596598 = r596595 / r596597;
        double r596599 = r596590 + r596598;
        return r596599;
}

double f(double x, double y, double z, double t, double a) {
        double r596600 = y;
        double r596601 = a;
        double r596602 = z;
        double r596603 = r596601 - r596602;
        double r596604 = r596600 / r596603;
        double r596605 = r596602 / r596603;
        double r596606 = r596604 - r596605;
        double r596607 = t;
        double r596608 = x;
        double r596609 = fma(r596606, r596607, r596608);
        return r596609;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original10.5
Target0.7
Herbie1.4
\[\begin{array}{l} \mathbf{if}\;t \lt -1.0682974490174067 \cdot 10^{-39}:\\ \;\;\;\;x + \frac{y - z}{a - z} \cdot t\\ \mathbf{elif}\;t \lt 3.9110949887586375 \cdot 10^{-141}:\\ \;\;\;\;x + \frac{\left(y - z\right) \cdot t}{a - z}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y - z}{a - z} \cdot t\\ \end{array}\]

Derivation

  1. Initial program 10.5

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

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

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

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

Reproduce

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

  :herbie-target
  (if (< t -1.0682974490174067e-39) (+ x (* (/ (- y z) (- a z)) t)) (if (< t 3.9110949887586375e-141) (+ x (/ (* (- y z) t) (- a z))) (+ x (* (/ (- y z) (- a z)) t))))

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