Average Error: 6.1 → 0.2
Time: 2.8s
Precision: binary64
\[[x, y]=\mathsf{sort}([x, y])\]
\[\frac{x \cdot y}{z}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y \leq -9.045700272126931 \cdot 10^{+266}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;x \cdot y \leq -2.9445408273232094 \cdot 10^{-289}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;x \cdot y \leq 1.781848335493602 \cdot 10^{-255}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;x \cdot y \leq 5.856676942585101 \cdot 10^{+246}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{\frac{z}{x}}{y}}\\ \end{array}\]
\frac{x \cdot y}{z}
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -9.045700272126931 \cdot 10^{+266}:\\
\;\;\;\;x \cdot \frac{y}{z}\\

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

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

\mathbf{elif}\;x \cdot y \leq 5.856676942585101 \cdot 10^{+246}:\\
\;\;\;\;\frac{x \cdot y}{z}\\

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

\end{array}
(FPCore (x y z) :precision binary64 (/ (* x y) z))
(FPCore (x y z)
 :precision binary64
 (if (<= (* x y) -9.045700272126931e+266)
   (* x (/ y z))
   (if (<= (* x y) -2.9445408273232094e-289)
     (/ (* x y) z)
     (if (<= (* x y) 1.781848335493602e-255)
       (* x (/ y z))
       (if (<= (* x y) 5.856676942585101e+246)
         (/ (* x y) z)
         (/ 1.0 (/ (/ z x) 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) <= -9.045700272126931e+266) {
		tmp = x * (y / z);
	} else if ((x * y) <= -2.9445408273232094e-289) {
		tmp = (x * y) / z;
	} else if ((x * y) <= 1.781848335493602e-255) {
		tmp = x * (y / z);
	} else if ((x * y) <= 5.856676942585101e+246) {
		tmp = (x * y) / z;
	} else {
		tmp = 1.0 / ((z / x) / y);
	}
	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.1
Target6.3
Herbie0.2
\[\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.0457002721269307e266 or -2.9445408273232094e-289 < (*.f64 x y) < 1.781848335493602e-255

    1. Initial program 19.5

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

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

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

    if -9.0457002721269307e266 < (*.f64 x y) < -2.9445408273232094e-289 or 1.781848335493602e-255 < (*.f64 x y) < 5.85667694258510118e246

    1. Initial program 0.2

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

      \[\leadsto \frac{x \cdot y}{\color{blue}{1 \cdot z}}\]
    4. Applied associate-/r*_binary640.2

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

    if 5.85667694258510118e246 < (*.f64 x y)

    1. Initial program 36.6

      \[\frac{x \cdot y}{z}\]
    2. Using strategy rm
    3. Applied add-cube-cbrt_binary6437.1

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

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

      \[\leadsto \frac{\color{blue}{y \cdot \frac{x}{\sqrt[3]{z} \cdot \sqrt[3]{z}}}}{\sqrt[3]{z}}\]
    6. Using strategy rm
    7. Applied clear-num_binary649.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \leq -9.045700272126931 \cdot 10^{+266}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;x \cdot y \leq -2.9445408273232094 \cdot 10^{-289}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;x \cdot y \leq 1.781848335493602 \cdot 10^{-255}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;x \cdot y \leq 5.856676942585101 \cdot 10^{+246}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{\frac{z}{x}}{y}}\\ \end{array}\]

Alternatives

Reproduce

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