Average Error: 10.7 → 1.4
Time: 25.2s
Precision: 64
\[x + \frac{y \cdot \left(z - t\right)}{a - t}\]
\[\mathsf{fma}\left(y, \left(z - t\right) \cdot \frac{1}{a - t}, x\right)\]
x + \frac{y \cdot \left(z - t\right)}{a - t}
\mathsf{fma}\left(y, \left(z - t\right) \cdot \frac{1}{a - t}, x\right)
double f(double x, double y, double z, double t, double a) {
        double r22456654 = x;
        double r22456655 = y;
        double r22456656 = z;
        double r22456657 = t;
        double r22456658 = r22456656 - r22456657;
        double r22456659 = r22456655 * r22456658;
        double r22456660 = a;
        double r22456661 = r22456660 - r22456657;
        double r22456662 = r22456659 / r22456661;
        double r22456663 = r22456654 + r22456662;
        return r22456663;
}

double f(double x, double y, double z, double t, double a) {
        double r22456664 = y;
        double r22456665 = z;
        double r22456666 = t;
        double r22456667 = r22456665 - r22456666;
        double r22456668 = 1.0;
        double r22456669 = a;
        double r22456670 = r22456669 - r22456666;
        double r22456671 = r22456668 / r22456670;
        double r22456672 = r22456667 * r22456671;
        double r22456673 = x;
        double r22456674 = fma(r22456664, r22456672, r22456673);
        return r22456674;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

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

Derivation

  1. Initial program 10.7

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

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

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

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

Reproduce

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