Average Error: 6.4 → 0.7
Time: 5.6s
Precision: binary64
\[[x, y]=\mathsf{sort}([x, y])\]
\[\frac{x \cdot y}{z} \]
\[\begin{array}{l} \mathbf{if}\;x \cdot y \leq -7.545000424659655 \cdot 10^{+290}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_0 := \frac{x \cdot y}{z}\\ \mathbf{if}\;x \cdot y \leq -2.7643367134265166 \cdot 10^{-163}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot y \leq 5.898011240367938 \cdot 10^{-141}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;x \cdot y \leq 2.231654736492483 \cdot 10^{+178}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \end{array}\\ \end{array} \]
\frac{x \cdot y}{z}
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -7.545000424659655 \cdot 10^{+290}:\\
\;\;\;\;\frac{y}{\frac{z}{x}}\\

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

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

\mathbf{elif}\;x \cdot y \leq 2.231654736492483 \cdot 10^{+178}:\\
\;\;\;\;t_0\\

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


\end{array}\\


\end{array}
(FPCore (x y z) :precision binary64 (/ (* x y) z))
(FPCore (x y z)
 :precision binary64
 (if (<= (* x y) -7.545000424659655e+290)
   (/ y (/ z x))
   (let* ((t_0 (/ (* x y) z)))
     (if (<= (* x y) -2.7643367134265166e-163)
       t_0
       (if (<= (* x y) 5.898011240367938e-141)
         (* x (/ y z))
         (if (<= (* x y) 2.231654736492483e+178) t_0 (/ x (/ z y))))))))
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) <= -7.545000424659655e+290) {
		tmp = y / (z / x);
	} else {
		double t_0 = (x * y) / z;
		double tmp_1;
		if ((x * y) <= -2.7643367134265166e-163) {
			tmp_1 = t_0;
		} else if ((x * y) <= 5.898011240367938e-141) {
			tmp_1 = x * (y / z);
		} else if ((x * y) <= 2.231654736492483e+178) {
			tmp_1 = t_0;
		} else {
			tmp_1 = x / (z / y);
		}
		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.0
Herbie0.7
\[\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) < -7.545000424659655e290

    1. Initial program 55.8

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

      \[\leadsto \frac{x \cdot y}{\color{blue}{\left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \sqrt[3]{z}}} \]
    3. Applied associate-/r*_binary6456.0

      \[\leadsto \color{blue}{\frac{\frac{x \cdot y}{\sqrt[3]{z} \cdot \sqrt[3]{z}}}{\sqrt[3]{z}}} \]
    4. Simplified12.9

      \[\leadsto \frac{\color{blue}{y \cdot \frac{x}{\sqrt[3]{z} \cdot \sqrt[3]{z}}}}{\sqrt[3]{z}} \]
    5. Applied associate-/l*_binary641.2

      \[\leadsto \color{blue}{\frac{y}{\frac{\sqrt[3]{z}}{\frac{x}{\sqrt[3]{z} \cdot \sqrt[3]{z}}}}} \]
    6. Simplified0.2

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

    if -7.545000424659655e290 < (*.f64 x y) < -2.76433671342651659e-163 or 5.898011240367938e-141 < (*.f64 x y) < 2.231654736492483e178

    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 associate-/r*_binary641.3

      \[\leadsto \color{blue}{\frac{\frac{x \cdot y}{\sqrt[3]{z} \cdot \sqrt[3]{z}}}{\sqrt[3]{z}}} \]
    4. Simplified6.5

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

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

    if -2.76433671342651659e-163 < (*.f64 x y) < 5.898011240367938e-141

    1. Initial program 8.4

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

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

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

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

    if 2.231654736492483e178 < (*.f64 x y)

    1. Initial program 22.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \leq -7.545000424659655 \cdot 10^{+290}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;x \cdot y \leq -2.7643367134265166 \cdot 10^{-163}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;x \cdot y \leq 5.898011240367938 \cdot 10^{-141}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;x \cdot y \leq 2.231654736492483 \cdot 10^{+178}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \end{array} \]

Reproduce

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