Average Error: 6.5 → 0.4
Time: 3.1s
Precision: binary64
\[[x, y] = \mathsf{sort}([x, y]) \\]
\[\frac{x \cdot y}{z} \]
\[\begin{array}{l} \mathbf{if}\;x \cdot y \leq -\infty:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_0 := \frac{x \cdot y}{z}\\ \mathbf{if}\;x \cdot y \leq -3.7244331968216916 \cdot 10^{-288}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot y \leq 9.72260088070231 \cdot 10^{-305}:\\ \;\;\;\;\frac{\frac{1}{\frac{z}{y}}}{\frac{1}{x}}\\ \mathbf{elif}\;x \cdot y \leq 1.2223870885476119 \cdot 10^{+145}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \end{array}\\ \end{array} \]
\frac{x \cdot y}{z}
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -\infty:\\
\;\;\;\;y \cdot \frac{x}{z}\\

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_0 := \frac{x \cdot y}{z}\\
\mathbf{if}\;x \cdot y \leq -3.7244331968216916 \cdot 10^{-288}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \cdot y \leq 9.72260088070231 \cdot 10^{-305}:\\
\;\;\;\;\frac{\frac{1}{\frac{z}{y}}}{\frac{1}{x}}\\

\mathbf{elif}\;x \cdot y \leq 1.2223870885476119 \cdot 10^{+145}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{z}\\


\end{array}\\


\end{array}
(FPCore (x y z) :precision binary64 (/ (* x y) z))
(FPCore (x y z)
 :precision binary64
 (if (<= (* x y) (- INFINITY))
   (* y (/ x z))
   (let* ((t_0 (/ (* x y) z)))
     (if (<= (* x y) -3.7244331968216916e-288)
       t_0
       (if (<= (* x y) 9.72260088070231e-305)
         (/ (/ 1.0 (/ z y)) (/ 1.0 x))
         (if (<= (* x y) 1.2223870885476119e+145) t_0 (* x (/ y z))))))))
double code(double x, double y, double z) {
	return (x * y) / z;
}
double code(double x, double y, double z) {
	double tmp;
	if ((x * y) <= -((double) INFINITY)) {
		tmp = y * (x / z);
	} else {
		double t_0 = (x * y) / z;
		double tmp_1;
		if ((x * y) <= -3.7244331968216916e-288) {
			tmp_1 = t_0;
		} else if ((x * y) <= 9.72260088070231e-305) {
			tmp_1 = (1.0 / (z / y)) / (1.0 / x);
		} else if ((x * y) <= 1.2223870885476119e+145) {
			tmp_1 = t_0;
		} else {
			tmp_1 = x * (y / z);
		}
		tmp = tmp_1;
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.5
Target6.3
Herbie0.4
\[\begin{array}{l} \mathbf{if}\;z < -4.262230790519429 \cdot 10^{-138}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;z < 1.7042130660650472 \cdot 10^{-164}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} \cdot y\\ \end{array} \]

Derivation

  1. Split input into 4 regimes
  2. if (*.f64 x y) < -inf.0

    1. Initial program 64.0

      \[\frac{x \cdot y}{z} \]
    2. Applied associate-/l*_binary640.3

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{y}}} \]
    3. Applied associate-/r/_binary640.3

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

    if -inf.0 < (*.f64 x y) < -3.7244331968216916e-288 or 9.7226008807023103e-305 < (*.f64 x y) < 1.2223870885476119e145

    1. Initial program 0.2

      \[\frac{x \cdot y}{z} \]

    if -3.7244331968216916e-288 < (*.f64 x y) < 9.7226008807023103e-305

    1. Initial program 17.5

      \[\frac{x \cdot y}{z} \]
    2. Applied associate-/l*_binary640.1

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{y}}} \]
    3. Applied clear-num_binary640.5

      \[\leadsto \color{blue}{\frac{1}{\frac{\frac{z}{y}}{x}}} \]
    4. Applied div-inv_binary640.6

      \[\leadsto \frac{1}{\color{blue}{\frac{z}{y} \cdot \frac{1}{x}}} \]
    5. Applied associate-/r*_binary640.2

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

    if 1.2223870885476119e145 < (*.f64 x y)

    1. Initial program 18.5

      \[\frac{x \cdot y}{z} \]
    2. Applied *-un-lft-identity_binary6418.5

      \[\leadsto \frac{x \cdot y}{\color{blue}{1 \cdot z}} \]
    3. Applied times-frac_binary642.0

      \[\leadsto \color{blue}{\frac{x}{1} \cdot \frac{y}{z}} \]
    4. Simplified2.0

      \[\leadsto \color{blue}{x} \cdot \frac{y}{z} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification0.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \leq -\infty:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;x \cdot y \leq -3.7244331968216916 \cdot 10^{-288}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;x \cdot y \leq 9.72260088070231 \cdot 10^{-305}:\\ \;\;\;\;\frac{\frac{1}{\frac{z}{y}}}{\frac{1}{x}}\\ \mathbf{elif}\;x \cdot y \leq 1.2223870885476119 \cdot 10^{+145}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \end{array} \]

Reproduce

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

  :herbie-target
  (if (< z -4.262230790519429e-138) (/ (* x y) z) (if (< z 1.7042130660650472e-164) (/ x (/ z y)) (* (/ x z) y)))

  (/ (* x y) z))