Average Error: 6.0 → 0.3
Time: 3.1s
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 -9.542298578082682 \cdot 10^{+195}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_1 := \frac{x \cdot y}{z}\\ \mathbf{if}\;x \cdot y \leq -3.896175260889643 \cdot 10^{-209}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \cdot y \leq 3.456872220211211 \cdot 10^{-262}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;x \cdot y \leq 6.549991231650657 \cdot 10^{+206}:\\ \;\;\;\;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 -9.542298578082682 \cdot 10^{+195}:\\
\;\;\;\;t_0\\

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

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

\mathbf{elif}\;x \cdot y \leq 6.549991231650657 \cdot 10^{+206}:\\
\;\;\;\;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) -9.542298578082682e+195)
     t_0
     (let* ((t_1 (/ (* x y) z)))
       (if (<= (* x y) -3.896175260889643e-209)
         t_1
         (if (<= (* x y) 3.456872220211211e-262)
           (* x (/ y z))
           (if (<= (* x y) 6.549991231650657e+206) 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) <= -9.542298578082682e+195) {
		tmp = t_0;
	} else {
		double t_1 = (x * y) / z;
		double tmp_1;
		if ((x * y) <= -3.896175260889643e-209) {
			tmp_1 = t_1;
		} else if ((x * y) <= 3.456872220211211e-262) {
			tmp_1 = x * (y / z);
		} else if ((x * y) <= 6.549991231650657e+206) {
			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.0
Target6.2
Herbie0.3
\[\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) < -9.542298578082682e195 or 6.5499912316506572e206 < (*.f64 x y)

    1. Initial program 26.5

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

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

    if -9.542298578082682e195 < (*.f64 x y) < -3.8961752608896429e-209 or 3.4568722202112109e-262 < (*.f64 x y) < 6.5499912316506572e206

    1. Initial program 0.2

      \[\frac{x \cdot y}{z} \]
    2. Applied clear-num_binary640.5

      \[\leadsto \color{blue}{\frac{1}{\frac{z}{x \cdot y}}} \]
    3. Applied associate-/r*_binary649.7

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

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

      \[\leadsto \frac{1}{\frac{\frac{z}{\color{blue}{1 \cdot x}}}{1 \cdot y}} \]
    6. Applied *-un-lft-identity_binary649.7

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

      \[\leadsto \frac{1}{\frac{\color{blue}{\frac{1}{1} \cdot \frac{z}{x}}}{1 \cdot y}} \]
    8. Applied times-frac_binary649.7

      \[\leadsto \frac{1}{\color{blue}{\frac{\frac{1}{1}}{1} \cdot \frac{\frac{z}{x}}{y}}} \]
    9. Applied add-cube-cbrt_binary649.7

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{\frac{\frac{1}{1}}{1} \cdot \frac{\frac{z}{x}}{y}} \]
    10. Applied times-frac_binary649.7

      \[\leadsto \color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\frac{\frac{1}{1}}{1}} \cdot \frac{\sqrt[3]{1}}{\frac{\frac{z}{x}}{y}}} \]
    11. Simplified9.7

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

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

    if -3.8961752608896429e-209 < (*.f64 x y) < 3.4568722202112109e-262

    1. Initial program 11.9

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \leq -9.542298578082682 \cdot 10^{+195}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{elif}\;x \cdot y \leq -3.896175260889643 \cdot 10^{-209}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;x \cdot y \leq 3.456872220211211 \cdot 10^{-262}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;x \cdot y \leq 6.549991231650657 \cdot 10^{+206}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \end{array} \]

Reproduce

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