Average Error: 6.2 → 1.3
Time: 1.7s
Precision: 64
\[\frac{x \cdot y}{z}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y \le -4.6140384460535245 \cdot 10^{82}:\\ \;\;\;\;\frac{x \cdot 1}{\frac{z}{y}}\\ \mathbf{elif}\;x \cdot y \le -3.6212587147018839 \cdot 10^{-153}:\\ \;\;\;\;\frac{1}{z} \cdot \left(x \cdot y\right)\\ \mathbf{elif}\;x \cdot y \le 2.936539165865314 \cdot 10^{-207}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;x \cdot y \le 4.3105297737350413 \cdot 10^{140}:\\ \;\;\;\;\frac{1}{z} \cdot \left(x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \end{array}\]
\frac{x \cdot y}{z}
\begin{array}{l}
\mathbf{if}\;x \cdot y \le -4.6140384460535245 \cdot 10^{82}:\\
\;\;\;\;\frac{x \cdot 1}{\frac{z}{y}}\\

\mathbf{elif}\;x \cdot y \le -3.6212587147018839 \cdot 10^{-153}:\\
\;\;\;\;\frac{1}{z} \cdot \left(x \cdot y\right)\\

\mathbf{elif}\;x \cdot y \le 2.936539165865314 \cdot 10^{-207}:\\
\;\;\;\;\frac{y}{\frac{z}{x}}\\

\mathbf{elif}\;x \cdot y \le 4.3105297737350413 \cdot 10^{140}:\\
\;\;\;\;\frac{1}{z} \cdot \left(x \cdot y\right)\\

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

\end{array}
double code(double x, double y, double z) {
	return ((double) (((double) (x * y)) / z));
}
double code(double x, double y, double z) {
	double VAR;
	if ((((double) (x * y)) <= -4.6140384460535245e+82)) {
		VAR = ((double) (((double) (x * 1.0)) / ((double) (z / y))));
	} else {
		double VAR_1;
		if ((((double) (x * y)) <= -3.621258714701884e-153)) {
			VAR_1 = ((double) (((double) (1.0 / z)) * ((double) (x * y))));
		} else {
			double VAR_2;
			if ((((double) (x * y)) <= 2.9365391658653136e-207)) {
				VAR_2 = ((double) (y / ((double) (z / x))));
			} else {
				double VAR_3;
				if ((((double) (x * y)) <= 4.310529773735041e+140)) {
					VAR_3 = ((double) (((double) (1.0 / z)) * ((double) (x * y))));
				} else {
					VAR_3 = ((double) (y / ((double) (z / x))));
				}
				VAR_2 = VAR_3;
			}
			VAR_1 = VAR_2;
		}
		VAR = VAR_1;
	}
	return VAR;
}

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.2
Target6.0
Herbie1.3
\[\begin{array}{l} \mathbf{if}\;z \lt -4.262230790519429 \cdot 10^{-138}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;z \lt 1.70421306606504721 \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 (* x y) < -4.6140384460535245e+82

    1. Initial program 12.7

      \[\frac{x \cdot y}{z}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity12.7

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

      \[\leadsto \frac{\color{blue}{\left(x \cdot 1\right) \cdot y}}{z}\]
    5. Applied associate-/l*4.6

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

    if -4.6140384460535245e+82 < (* x y) < -3.621258714701884e-153 or 2.9365391658653136e-207 < (* x y) < 4.310529773735041e+140

    1. Initial program 0.2

      \[\frac{x \cdot y}{z}\]
    2. Using strategy rm
    3. Applied *-commutative0.2

      \[\leadsto \frac{\color{blue}{y \cdot x}}{z}\]
    4. Applied associate-/l*10.4

      \[\leadsto \color{blue}{\frac{y}{\frac{z}{x}}}\]
    5. Using strategy rm
    6. Applied div-inv10.5

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

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

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

      \[\leadsto \frac{1}{z} \cdot \color{blue}{\left(x \cdot y\right)}\]

    if -3.621258714701884e-153 < (* x y) < 2.9365391658653136e-207 or 4.310529773735041e+140 < (* x y)

    1. Initial program 11.1

      \[\frac{x \cdot y}{z}\]
    2. Using strategy rm
    3. Applied *-commutative11.1

      \[\leadsto \frac{\color{blue}{y \cdot x}}{z}\]
    4. Applied associate-/l*1.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \le -4.6140384460535245 \cdot 10^{82}:\\ \;\;\;\;\frac{x \cdot 1}{\frac{z}{y}}\\ \mathbf{elif}\;x \cdot y \le -3.6212587147018839 \cdot 10^{-153}:\\ \;\;\;\;\frac{1}{z} \cdot \left(x \cdot y\right)\\ \mathbf{elif}\;x \cdot y \le 2.936539165865314 \cdot 10^{-207}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;x \cdot y \le 4.3105297737350413 \cdot 10^{140}:\\ \;\;\;\;\frac{1}{z} \cdot \left(x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \end{array}\]

Reproduce

herbie shell --seed 2020113 +o rules:numerics
(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))