Average Error: 10.9 → 8.1
Time: 4.3s
Precision: 64
\[\frac{x - y \cdot z}{t - a \cdot z}\]
\[\frac{x}{t - a \cdot z} - y \cdot \left(z \cdot \frac{1}{t - a \cdot z}\right)\]
\frac{x - y \cdot z}{t - a \cdot z}
\frac{x}{t - a \cdot z} - y \cdot \left(z \cdot \frac{1}{t - a \cdot z}\right)
double code(double x, double y, double z, double t, double a) {
	return ((x - (y * z)) / (t - (a * z)));
}
double code(double x, double y, double z, double t, double a) {
	return ((x / (t - (a * z))) - (y * (z * (1.0 / (t - (a * z))))));
}

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.9
Target1.8
Herbie8.1
\[\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.9

    \[\frac{x - y \cdot z}{t - a \cdot z}\]
  2. Using strategy rm
  3. Applied div-sub10.9

    \[\leadsto \color{blue}{\frac{x}{t - a \cdot z} - \frac{y \cdot z}{t - a \cdot z}}\]
  4. Using strategy rm
  5. Applied *-un-lft-identity10.9

    \[\leadsto \frac{x}{t - a \cdot z} - \frac{y \cdot z}{\color{blue}{1 \cdot \left(t - a \cdot z\right)}}\]
  6. Applied times-frac8.1

    \[\leadsto \frac{x}{t - a \cdot z} - \color{blue}{\frac{y}{1} \cdot \frac{z}{t - a \cdot z}}\]
  7. Simplified8.1

    \[\leadsto \frac{x}{t - a \cdot z} - \color{blue}{y} \cdot \frac{z}{t - a \cdot z}\]
  8. Using strategy rm
  9. Applied div-inv8.1

    \[\leadsto \frac{x}{t - a \cdot z} - y \cdot \color{blue}{\left(z \cdot \frac{1}{t - a \cdot z}\right)}\]
  10. Final simplification8.1

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

Reproduce

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