Average Error: 6.4 → 0.8
Time: 3.0s
Precision: binary64
\[[x, y] = \mathsf{sort}([x, y]) \\]
\[\frac{x \cdot y}{z} \]
\[\begin{array}{l} t_0 := \frac{x}{\frac{z}{y}}\\ \mathbf{if}\;x \cdot y \leq -\infty:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_1 := \frac{x \cdot y}{z}\\ \mathbf{if}\;x \cdot y \leq -7.01133933954049 \cdot 10^{-133}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \cdot y \leq 4.6898775201 \cdot 10^{-313}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;x \cdot y \leq 6.9663080033419285 \cdot 10^{+134}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array}\\ \end{array} \]
\frac{x \cdot y}{z}
\begin{array}{l}
t_0 := \frac{x}{\frac{z}{y}}\\
\mathbf{if}\;x \cdot y \leq -\infty:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_1 := \frac{x \cdot y}{z}\\
\mathbf{if}\;x \cdot y \leq -7.01133933954049 \cdot 10^{-133}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \cdot y \leq 4.6898775201 \cdot 10^{-313}:\\
\;\;\;\;y \cdot \frac{x}{z}\\

\mathbf{elif}\;x \cdot y \leq 6.9663080033419285 \cdot 10^{+134}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}\\


\end{array}
(FPCore (x y z) :precision binary64 (/ (* x y) z))
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (/ x (/ z y))))
   (if (<= (* x y) (- INFINITY))
     t_0
     (let* ((t_1 (/ (* x y) z)))
       (if (<= (* x y) -7.01133933954049e-133)
         t_1
         (if (<= (* x y) 4.6898775201e-313)
           (* y (/ x z))
           (if (<= (* x y) 6.9663080033419285e+134) t_1 t_0)))))))
double code(double x, double y, double z) {
	return (x * y) / z;
}
double code(double x, double y, double z) {
	double t_0 = x / (z / y);
	double tmp;
	if ((x * y) <= -((double) INFINITY)) {
		tmp = t_0;
	} else {
		double t_1 = (x * y) / z;
		double tmp_1;
		if ((x * y) <= -7.01133933954049e-133) {
			tmp_1 = t_1;
		} else if ((x * y) <= 4.6898775201e-313) {
			tmp_1 = y * (x / z);
		} else if ((x * y) <= 6.9663080033419285e+134) {
			tmp_1 = t_1;
		} else {
			tmp_1 = t_0;
		}
		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.4
Target6.3
Herbie0.8
\[\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 3 regimes
  2. if (*.f64 x y) < -inf.0 or 6.9663080033419285e134 < (*.f64 x y)

    1. Initial program 27.8

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

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

    if -inf.0 < (*.f64 x y) < -7.01133933954049005e-133 or 4.68987752008e-313 < (*.f64 x y) < 6.9663080033419285e134

    1. Initial program 0.2

      \[\frac{x \cdot y}{z} \]
    2. Applied add-cube-cbrt_binary641.3

      \[\leadsto \frac{x \cdot y}{\color{blue}{\left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \sqrt[3]{z}}} \]
    3. Applied times-frac_binary647.5

      \[\leadsto \color{blue}{\frac{x}{\sqrt[3]{z} \cdot \sqrt[3]{z}} \cdot \frac{y}{\sqrt[3]{z}}} \]
    4. Taylor expanded in x around 0 0.2

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

    if -7.01133933954049005e-133 < (*.f64 x y) < 4.68987752008e-313

    1. Initial program 11.2

      \[\frac{x \cdot y}{z} \]
    2. Applied add-cube-cbrt_binary6411.6

      \[\leadsto \frac{x \cdot y}{\color{blue}{\left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \sqrt[3]{z}}} \]
    3. Applied times-frac_binary641.0

      \[\leadsto \color{blue}{\frac{x}{\sqrt[3]{z} \cdot \sqrt[3]{z}} \cdot \frac{y}{\sqrt[3]{z}}} \]
    4. Taylor expanded in x around 0 11.2

      \[\leadsto \color{blue}{\frac{y \cdot x}{z}} \]
    5. Applied *-un-lft-identity_binary6411.2

      \[\leadsto \frac{y \cdot x}{\color{blue}{1 \cdot z}} \]
    6. Applied times-frac_binary641.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \leq -\infty:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{elif}\;x \cdot y \leq -7.01133933954049 \cdot 10^{-133}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;x \cdot y \leq 4.6898775201 \cdot 10^{-313}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;x \cdot y \leq 6.9663080033419285 \cdot 10^{+134}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \end{array} \]

Reproduce

herbie shell --seed 2022077 
(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))