Average Error: 10.6 → 2.9
Time: 4.8s
Precision: binary64
\[\frac{x - y \cdot z}{t - a \cdot z}\]
\[\frac{x}{t - z \cdot a} - \frac{y}{\frac{t}{z} - a}\]
\frac{x - y \cdot z}{t - a \cdot z}
\frac{x}{t - z \cdot a} - \frac{y}{\frac{t}{z} - a}
double code(double x, double y, double z, double t, double a) {
	return (((double) (x - ((double) (y * z)))) / ((double) (t - ((double) (a * z)))));
}
double code(double x, double y, double z, double t, double a) {
	return ((double) ((x / ((double) (t - ((double) (z * a))))) - (y / ((double) ((t / z) - a)))));
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original10.6
Target2.0
Herbie2.9
\[\begin{array}{l} \mathbf{if}\;z < -32113435955957344:\\ \;\;\;\;\frac{x}{t - a \cdot z} - \frac{y}{\frac{t}{z} - a}\\ \mathbf{elif}\;z < 3.5139522372978296 \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 Error: 10.6 bits

    \[\frac{x - y \cdot z}{t - a \cdot z}\]
  2. Using strategy rm
  3. Applied div-subError: 10.6 bits

    \[\leadsto \color{blue}{\frac{x}{t - a \cdot z} - \frac{y \cdot z}{t - a \cdot z}}\]
  4. SimplifiedError: 10.6 bits

    \[\leadsto \color{blue}{\frac{x}{t - z \cdot a}} - \frac{y \cdot z}{t - a \cdot z}\]
  5. SimplifiedError: 7.7 bits

    \[\leadsto \frac{x}{t - z \cdot a} - \color{blue}{y \cdot \frac{z}{t - z \cdot a}}\]
  6. Using strategy rm
  7. Applied sub-negError: 7.7 bits

    \[\leadsto \color{blue}{\frac{x}{t - z \cdot a} + \left(-y \cdot \frac{z}{t - z \cdot a}\right)}\]
  8. SimplifiedError: 2.9 bits

    \[\leadsto \frac{x}{t - z \cdot a} + \color{blue}{\frac{-y}{\frac{t}{z} - a}}\]
  9. Final simplificationError: 2.9 bits

    \[\leadsto \frac{x}{t - z \cdot a} - \frac{y}{\frac{t}{z} - a}\]

Reproduce

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

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

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