Average Error: 6.3 → 1.9
Time: 4.0s
Precision: binary64
\[[x, y] = \mathsf{sort}([x, y]) \\]
\[\frac{x \cdot y}{z} \]
\[\begin{array}{l} \mathbf{if}\;x \cdot y \leq -5.114753924499163 \cdot 10^{+234}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{elif}\;x \cdot y \leq -9.906856645491496 \cdot 10^{-248} \lor \neg \left(x \cdot y \leq 1.937 \cdot 10^{-321}\right):\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \end{array} \]
\frac{x \cdot y}{z}
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -5.114753924499163 \cdot 10^{+234}:\\
\;\;\;\;\frac{x}{\frac{z}{y}}\\

\mathbf{elif}\;x \cdot y \leq -9.906856645491496 \cdot 10^{-248} \lor \neg \left(x \cdot y \leq 1.937 \cdot 10^{-321}\right):\\
\;\;\;\;\frac{x \cdot y}{z}\\

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


\end{array}
(FPCore (x y z) :precision binary64 (/ (* x y) z))
(FPCore (x y z)
 :precision binary64
 (if (<= (* x y) -5.114753924499163e+234)
   (/ x (/ z y))
   (if (or (<= (* x y) -9.906856645491496e-248) (not (<= (* x y) 1.937e-321)))
     (/ (* x y) z)
     (* x (/ y z)))))
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) <= -5.114753924499163e+234) {
		tmp = x / (z / y);
	} else if (((x * y) <= -9.906856645491496e-248) || !((x * y) <= 1.937e-321)) {
		tmp = (x * y) / z;
	} else {
		tmp = x * (y / z);
	}
	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.3
Target6.2
Herbie1.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) < -5.11475392449916302e234

    1. Initial program 35.0

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

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

    if -5.11475392449916302e234 < (*.f64 x y) < -9.9068566454914965e-248 or 1.93674e-321 < (*.f64 x y)

    1. Initial program 2.4

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(x \cdot \frac{\sqrt[3]{y} \cdot \sqrt[3]{y}}{1}\right) \cdot \frac{\sqrt[3]{y}}{z}} \]
    9. Simplified4.1

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

      \[\leadsto \left(x \cdot \left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right)\right) \cdot \color{blue}{{\left(\frac{\sqrt[3]{y}}{z}\right)}^{1}} \]
    11. Applied pow1_binary644.1

      \[\leadsto \left(x \cdot \left(\sqrt[3]{y} \cdot \color{blue}{{\left(\sqrt[3]{y}\right)}^{1}}\right)\right) \cdot {\left(\frac{\sqrt[3]{y}}{z}\right)}^{1} \]
    12. Applied pow1_binary644.1

      \[\leadsto \left(x \cdot \left(\color{blue}{{\left(\sqrt[3]{y}\right)}^{1}} \cdot {\left(\sqrt[3]{y}\right)}^{1}\right)\right) \cdot {\left(\frac{\sqrt[3]{y}}{z}\right)}^{1} \]
    13. Applied pow-prod-down_binary644.1

      \[\leadsto \left(x \cdot \color{blue}{{\left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right)}^{1}}\right) \cdot {\left(\frac{\sqrt[3]{y}}{z}\right)}^{1} \]
    14. Applied pow1_binary644.1

      \[\leadsto \left(\color{blue}{{x}^{1}} \cdot {\left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right)}^{1}\right) \cdot {\left(\frac{\sqrt[3]{y}}{z}\right)}^{1} \]
    15. Applied pow-prod-down_binary644.1

      \[\leadsto \color{blue}{{\left(x \cdot \left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right)\right)}^{1}} \cdot {\left(\frac{\sqrt[3]{y}}{z}\right)}^{1} \]
    16. Applied pow-prod-down_binary644.1

      \[\leadsto \color{blue}{{\left(\left(x \cdot \left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right)\right) \cdot \frac{\sqrt[3]{y}}{z}\right)}^{1}} \]
    17. Simplified2.4

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

    if -9.9068566454914965e-248 < (*.f64 x y) < 1.93674e-321

    1. Initial program 14.8

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \leq -5.114753924499163 \cdot 10^{+234}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{elif}\;x \cdot y \leq -9.906856645491496 \cdot 10^{-248} \lor \neg \left(x \cdot y \leq 1.937 \cdot 10^{-321}\right):\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \end{array} \]

Reproduce

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