Average Error: 3.1 → 0.7
Time: 4.0s
Precision: binary64
\[[z, t] = \mathsf{sort}([z, t]) \\]
\[\frac{x}{y - z \cdot t} \]
\[\begin{array}{l} t_1 := \frac{1}{\frac{y}{x} - t \cdot \frac{z}{x}}\\ \mathbf{if}\;z \cdot t \leq -5.730067932082404 \cdot 10^{+303}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \cdot t \leq 1.7341482575187142 \cdot 10^{+305}:\\ \;\;\;\;\frac{x}{y - z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
\frac{x}{y - z \cdot t}
\begin{array}{l}
t_1 := \frac{1}{\frac{y}{x} - t \cdot \frac{z}{x}}\\
\mathbf{if}\;z \cdot t \leq -5.730067932082404 \cdot 10^{+303}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;z \cdot t \leq 1.7341482575187142 \cdot 10^{+305}:\\
\;\;\;\;\frac{x}{y - z \cdot t}\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
(FPCore (x y z t) :precision binary64 (/ x (- y (* z t))))
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (/ 1.0 (- (/ y x) (* t (/ z x))))))
   (if (<= (* z t) -5.730067932082404e+303)
     t_1
     (if (<= (* z t) 1.7341482575187142e+305) (/ x (- y (* z t))) t_1))))
double code(double x, double y, double z, double t) {
	return x / (y - (z * t));
}
double code(double x, double y, double z, double t) {
	double t_1 = 1.0 / ((y / x) - (t * (z / x)));
	double tmp;
	if ((z * t) <= -5.730067932082404e+303) {
		tmp = t_1;
	} else if ((z * t) <= 1.7341482575187142e+305) {
		tmp = x / (y - (z * t));
	} else {
		tmp = t_1;
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original3.1
Target1.9
Herbie0.7
\[\begin{array}{l} \mathbf{if}\;x < -1.618195973607049 \cdot 10^{+50}:\\ \;\;\;\;\frac{1}{\frac{y}{x} - \frac{z}{x} \cdot t}\\ \mathbf{elif}\;x < 2.1378306434876444 \cdot 10^{+131}:\\ \;\;\;\;\frac{x}{y - z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{y}{x} - \frac{z}{x} \cdot t}\\ \end{array} \]

Derivation

  1. Split input into 2 regimes
  2. if (*.f64 z t) < -5.7300679320824035e303 or 1.7341482575187142e305 < (*.f64 z t)

    1. Initial program 21.2

      \[\frac{x}{y - z \cdot t} \]
    2. Applied clear-num_binary6421.2

      \[\leadsto \color{blue}{\frac{1}{\frac{y - z \cdot t}{x}}} \]
    3. Taylor expanded in y around 0 25.1

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

      \[\leadsto \frac{1}{\frac{y}{x} - \frac{t \cdot z}{\color{blue}{1 \cdot x}}} \]
    5. Applied times-frac_binary644.7

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

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

    if -5.7300679320824035e303 < (*.f64 z t) < 1.7341482575187142e305

    1. Initial program 0.1

      \[\frac{x}{y - z \cdot t} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \cdot t \leq -5.730067932082404 \cdot 10^{+303}:\\ \;\;\;\;\frac{1}{\frac{y}{x} - t \cdot \frac{z}{x}}\\ \mathbf{elif}\;z \cdot t \leq 1.7341482575187142 \cdot 10^{+305}:\\ \;\;\;\;\frac{x}{y - z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{y}{x} - t \cdot \frac{z}{x}}\\ \end{array} \]

Reproduce

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

  :herbie-target
  (if (< x -1.618195973607049e+50) (/ 1.0 (- (/ y x) (* (/ z x) t))) (if (< x 2.1378306434876444e+131) (/ x (- y (* z t))) (/ 1.0 (- (/ y x) (* (/ z x) t)))))

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