Average Error: 10.8 → 10.8
Time: 3.8s
Precision: 64
\[\frac{x - y \cdot z}{t - a \cdot z}\]
\[\frac{\mathsf{fma}\left(-1, x, y \cdot z\right)}{\mathsf{fma}\left(z, a, -t\right)}\]
\frac{x - y \cdot z}{t - a \cdot z}
\frac{\mathsf{fma}\left(-1, x, y \cdot z\right)}{\mathsf{fma}\left(z, a, -t\right)}
double f(double x, double y, double z, double t, double a) {
        double r679062 = x;
        double r679063 = y;
        double r679064 = z;
        double r679065 = r679063 * r679064;
        double r679066 = r679062 - r679065;
        double r679067 = t;
        double r679068 = a;
        double r679069 = r679068 * r679064;
        double r679070 = r679067 - r679069;
        double r679071 = r679066 / r679070;
        return r679071;
}

double f(double x, double y, double z, double t, double a) {
        double r679072 = -1.0;
        double r679073 = x;
        double r679074 = y;
        double r679075 = z;
        double r679076 = r679074 * r679075;
        double r679077 = fma(r679072, r679073, r679076);
        double r679078 = a;
        double r679079 = t;
        double r679080 = -r679079;
        double r679081 = fma(r679075, r679078, r679080);
        double r679082 = r679077 / r679081;
        return r679082;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original10.8
Target1.7
Herbie10.8
\[\begin{array}{l} \mathbf{if}\;z \lt -32113435955957344:\\ \;\;\;\;\frac{x}{t - a \cdot z} - \frac{y}{\frac{t}{z} - a}\\ \mathbf{elif}\;z \lt 3.51395223729782958 \cdot 10^{-86}:\\ \;\;\;\;\left(x - y \cdot z\right) \cdot \frac{1}{t - a \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{t - a \cdot z} - \frac{y}{\frac{t}{z} - a}\\ \end{array}\]

Derivation

  1. Initial program 10.8

    \[\frac{x - y \cdot z}{t - a \cdot z}\]
  2. Using strategy rm
  3. Applied add-cube-cbrt11.3

    \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \sqrt[3]{x}} - y \cdot z}{t - a \cdot z}\]
  4. Applied fma-neg11.3

    \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\sqrt[3]{x} \cdot \sqrt[3]{x}, \sqrt[3]{x}, -y \cdot z\right)}}{t - a \cdot z}\]
  5. Using strategy rm
  6. Applied frac-2neg11.3

    \[\leadsto \color{blue}{\frac{-\mathsf{fma}\left(\sqrt[3]{x} \cdot \sqrt[3]{x}, \sqrt[3]{x}, -y \cdot z\right)}{-\left(t - a \cdot z\right)}}\]
  7. Simplified10.8

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

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

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

Reproduce

herbie shell --seed 2020046 +o rules:numerics
(FPCore (x y z t a)
  :name "Diagrams.Solve.Tridiagonal:solveTriDiagonal from diagrams-solve-0.1, A"
  :precision binary64

  :herbie-target
  (if (< z -32113435955957344) (- (/ x (- t (* a z))) (/ y (- (/ t z) a))) (if (< z 3.5139522372978296e-86) (* (- x (* y z)) (/ 1 (- t (* a z)))) (- (/ x (- t (* a z))) (/ y (- (/ t z) a)))))

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