Average Error: 6.1 → 0.9
Time: 3.3s
Precision: binary64
\[[x, y] = \mathsf{sort}([x, y]) \\]
\[\frac{x \cdot y}{z} \]
\[\begin{array}{l} t_0 := \frac{x \cdot y}{z}\\ t_1 := \frac{y}{\frac{z}{x}}\\ \mathbf{if}\;x \cdot y \leq -\infty:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \cdot y \leq -1.6601695723168201 \cdot 10^{-80}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot y \leq 3.6864798105561816 \cdot 10^{-255}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;x \cdot y \leq 8.68692735132234 \cdot 10^{+172}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
(FPCore (x y z) :precision binary64 (/ (* x y) z))
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (/ (* x y) z)) (t_1 (/ y (/ z x))))
   (if (<= (* x y) (- INFINITY))
     t_1
     (if (<= (* x y) -1.6601695723168201e-80)
       t_0
       (if (<= (* x y) 3.6864798105561816e-255)
         (* y (/ x z))
         (if (<= (* x y) 8.68692735132234e+172) t_0 t_1))))))
double code(double x, double y, double z) {
	return (x * y) / z;
}
double code(double x, double y, double z) {
	double t_0 = (x * y) / z;
	double t_1 = y / (z / x);
	double tmp;
	if ((x * y) <= -((double) INFINITY)) {
		tmp = t_1;
	} else if ((x * y) <= -1.6601695723168201e-80) {
		tmp = t_0;
	} else if ((x * y) <= 3.6864798105561816e-255) {
		tmp = y * (x / z);
	} else if ((x * y) <= 8.68692735132234e+172) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
public static double code(double x, double y, double z) {
	return (x * y) / z;
}
public static double code(double x, double y, double z) {
	double t_0 = (x * y) / z;
	double t_1 = y / (z / x);
	double tmp;
	if ((x * y) <= -Double.POSITIVE_INFINITY) {
		tmp = t_1;
	} else if ((x * y) <= -1.6601695723168201e-80) {
		tmp = t_0;
	} else if ((x * y) <= 3.6864798105561816e-255) {
		tmp = y * (x / z);
	} else if ((x * y) <= 8.68692735132234e+172) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z):
	return (x * y) / z
def code(x, y, z):
	t_0 = (x * y) / z
	t_1 = y / (z / x)
	tmp = 0
	if (x * y) <= -math.inf:
		tmp = t_1
	elif (x * y) <= -1.6601695723168201e-80:
		tmp = t_0
	elif (x * y) <= 3.6864798105561816e-255:
		tmp = y * (x / z)
	elif (x * y) <= 8.68692735132234e+172:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(x, y, z)
	return Float64(Float64(x * y) / z)
end
function code(x, y, z)
	t_0 = Float64(Float64(x * y) / z)
	t_1 = Float64(y / Float64(z / x))
	tmp = 0.0
	if (Float64(x * y) <= Float64(-Inf))
		tmp = t_1;
	elseif (Float64(x * y) <= -1.6601695723168201e-80)
		tmp = t_0;
	elseif (Float64(x * y) <= 3.6864798105561816e-255)
		tmp = Float64(y * Float64(x / z));
	elseif (Float64(x * y) <= 8.68692735132234e+172)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp = code(x, y, z)
	tmp = (x * y) / z;
end
function tmp_2 = code(x, y, z)
	t_0 = (x * y) / z;
	t_1 = y / (z / x);
	tmp = 0.0;
	if ((x * y) <= -Inf)
		tmp = t_1;
	elseif ((x * y) <= -1.6601695723168201e-80)
		tmp = t_0;
	elseif ((x * y) <= 3.6864798105561816e-255)
		tmp = y * (x / z);
	elseif ((x * y) <= 8.68692735132234e+172)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision]
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision]}, Block[{t$95$1 = N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * y), $MachinePrecision], (-Infinity)], t$95$1, If[LessEqual[N[(x * y), $MachinePrecision], -1.6601695723168201e-80], t$95$0, If[LessEqual[N[(x * y), $MachinePrecision], 3.6864798105561816e-255], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 8.68692735132234e+172], t$95$0, t$95$1]]]]]]
\frac{x \cdot y}{z}
\begin{array}{l}
t_0 := \frac{x \cdot y}{z}\\
t_1 := \frac{y}{\frac{z}{x}}\\
\mathbf{if}\;x \cdot y \leq -\infty:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \cdot y \leq -1.6601695723168201 \cdot 10^{-80}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;x \cdot y \leq 8.68692735132234 \cdot 10^{+172}:\\
\;\;\;\;t_0\\

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


\end{array}

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.1
Target6.4
Herbie0.9
\[\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 8.68692735132233945e172 < (*.f64 x y)

    1. Initial program 32.5

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

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

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

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

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

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

    if -inf.0 < (*.f64 x y) < -1.6601695723168201e-80 or 3.6864798105561816e-255 < (*.f64 x y) < 8.68692735132233945e172

    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.6

      \[\leadsto \frac{\color{blue}{y \cdot \frac{x}{\sqrt[3]{z} \cdot \sqrt[3]{z}}}}{\sqrt[3]{z}} \]
    5. Applied *-un-lft-identity_binary646.6

      \[\leadsto \frac{y \cdot \frac{x}{\sqrt[3]{z} \cdot \sqrt[3]{z}}}{\sqrt[3]{\color{blue}{1 \cdot z}}} \]
    6. Applied cbrt-prod_binary646.6

      \[\leadsto \frac{y \cdot \frac{x}{\sqrt[3]{z} \cdot \sqrt[3]{z}}}{\color{blue}{\sqrt[3]{1} \cdot \sqrt[3]{z}}} \]
    7. Applied times-frac_binary6410.4

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

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

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

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

    if -1.6601695723168201e-80 < (*.f64 x y) < 3.6864798105561816e-255

    1. Initial program 8.3

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

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

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

      \[\leadsto \frac{\color{blue}{y \cdot \frac{x}{\sqrt[3]{z} \cdot \sqrt[3]{z}}}}{\sqrt[3]{z}} \]
    5. Applied *-un-lft-identity_binary643.0

      \[\leadsto \frac{y \cdot \frac{x}{\sqrt[3]{z} \cdot \sqrt[3]{z}}}{\sqrt[3]{\color{blue}{1 \cdot z}}} \]
    6. Applied cbrt-prod_binary643.0

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

      \[\leadsto \color{blue}{\frac{y}{\sqrt[3]{1}} \cdot \frac{\frac{x}{\sqrt[3]{z} \cdot \sqrt[3]{z}}}{\sqrt[3]{z}}} \]
    8. Simplified2.5

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \leq -\infty:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;x \cdot y \leq -1.6601695723168201 \cdot 10^{-80}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;x \cdot y \leq 3.6864798105561816 \cdot 10^{-255}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;x \cdot y \leq 8.68692735132234 \cdot 10^{+172}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \end{array} \]

Reproduce

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