Average Error: 1.3 → 1.3
Time: 21.2s
Precision: 64
\[x + y \cdot \frac{z - t}{z - a}\]
\[\mathsf{fma}\left(y, \frac{z - t}{z - a}, x\right)\]
x + y \cdot \frac{z - t}{z - a}
\mathsf{fma}\left(y, \frac{z - t}{z - a}, x\right)
double f(double x, double y, double z, double t, double a) {
        double r23019170 = x;
        double r23019171 = y;
        double r23019172 = z;
        double r23019173 = t;
        double r23019174 = r23019172 - r23019173;
        double r23019175 = a;
        double r23019176 = r23019172 - r23019175;
        double r23019177 = r23019174 / r23019176;
        double r23019178 = r23019171 * r23019177;
        double r23019179 = r23019170 + r23019178;
        return r23019179;
}

double f(double x, double y, double z, double t, double a) {
        double r23019180 = y;
        double r23019181 = z;
        double r23019182 = t;
        double r23019183 = r23019181 - r23019182;
        double r23019184 = a;
        double r23019185 = r23019181 - r23019184;
        double r23019186 = r23019183 / r23019185;
        double r23019187 = x;
        double r23019188 = fma(r23019180, r23019186, r23019187);
        return r23019188;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

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

Derivation

  1. Initial program 1.3

    \[x + y \cdot \frac{z - t}{z - a}\]
  2. Using strategy rm
  3. Applied clear-num1.4

    \[\leadsto x + y \cdot \color{blue}{\frac{1}{\frac{z - a}{z - t}}}\]
  4. Using strategy rm
  5. Applied un-div-inv1.2

    \[\leadsto x + \color{blue}{\frac{y}{\frac{z - a}{z - t}}}\]
  6. Using strategy rm
  7. Applied clear-num1.4

    \[\leadsto x + \frac{y}{\color{blue}{\frac{1}{\frac{z - t}{z - a}}}}\]
  8. Using strategy rm
  9. Applied *-un-lft-identity1.4

    \[\leadsto x + \color{blue}{1 \cdot \frac{y}{\frac{1}{\frac{z - t}{z - a}}}}\]
  10. Applied *-un-lft-identity1.4

    \[\leadsto \color{blue}{1 \cdot x} + 1 \cdot \frac{y}{\frac{1}{\frac{z - t}{z - a}}}\]
  11. Applied distribute-lft-out1.4

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

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

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

Reproduce

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

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

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