Average Error: 6.4 → 0.4
Time: 10.6s
Precision: 64
\[\frac{x \cdot y}{z}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y = -\infty:\\ \;\;\;\;\frac{x}{z} \cdot y\\ \mathbf{elif}\;x \cdot y \le -8.33671520602323282 \cdot 10^{-240}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;x \cdot y \le 0.0:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;x \cdot y \le 4.84544495544772851 \cdot 10^{177}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \end{array}\]
\frac{x \cdot y}{z}
\begin{array}{l}
\mathbf{if}\;x \cdot y = -\infty:\\
\;\;\;\;\frac{x}{z} \cdot y\\

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

\mathbf{elif}\;x \cdot y \le 0.0:\\
\;\;\;\;x \cdot \frac{y}{z}\\

\mathbf{elif}\;x \cdot y \le 4.84544495544772851 \cdot 10^{177}:\\
\;\;\;\;\frac{x \cdot y}{z}\\

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

\end{array}
double f(double x, double y, double z) {
        double r790931 = x;
        double r790932 = y;
        double r790933 = r790931 * r790932;
        double r790934 = z;
        double r790935 = r790933 / r790934;
        return r790935;
}

double f(double x, double y, double z) {
        double r790936 = x;
        double r790937 = y;
        double r790938 = r790936 * r790937;
        double r790939 = -inf.0;
        bool r790940 = r790938 <= r790939;
        double r790941 = z;
        double r790942 = r790936 / r790941;
        double r790943 = r790942 * r790937;
        double r790944 = -8.336715206023233e-240;
        bool r790945 = r790938 <= r790944;
        double r790946 = r790938 / r790941;
        double r790947 = 0.0;
        bool r790948 = r790938 <= r790947;
        double r790949 = r790937 / r790941;
        double r790950 = r790936 * r790949;
        double r790951 = 4.8454449554477285e+177;
        bool r790952 = r790938 <= r790951;
        double r790953 = r790941 / r790937;
        double r790954 = r790936 / r790953;
        double r790955 = r790952 ? r790946 : r790954;
        double r790956 = r790948 ? r790950 : r790955;
        double r790957 = r790945 ? r790946 : r790956;
        double r790958 = r790940 ? r790943 : r790957;
        return r790958;
}

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.4
Target6.4
Herbie0.4
\[\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 4 regimes
  2. if (* x y) < -inf.0

    1. Initial program 64.0

      \[\frac{x \cdot y}{z}\]
    2. Using strategy rm
    3. Applied associate-/l*0.3

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{y}}}\]
    4. Using strategy rm
    5. Applied associate-/r/0.3

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

    if -inf.0 < (* x y) < -8.336715206023233e-240 or 0.0 < (* x y) < 4.8454449554477285e+177

    1. Initial program 0.4

      \[\frac{x \cdot y}{z}\]

    if -8.336715206023233e-240 < (* x y) < 0.0

    1. Initial program 16.4

      \[\frac{x \cdot y}{z}\]
    2. Using strategy rm
    3. Applied associate-/l*0.2

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{y}}}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity0.2

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

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

      \[\leadsto \frac{x}{\color{blue}{\frac{1}{1} \cdot \frac{z}{y}}}\]
    8. Applied *-un-lft-identity0.2

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

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

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

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

    if 4.8454449554477285e+177 < (* x y)

    1. Initial program 20.2

      \[\frac{x \cdot y}{z}\]
    2. Using strategy rm
    3. Applied associate-/l*1.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y = -\infty:\\ \;\;\;\;\frac{x}{z} \cdot y\\ \mathbf{elif}\;x \cdot y \le -8.33671520602323282 \cdot 10^{-240}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;x \cdot y \le 0.0:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;x \cdot y \le 4.84544495544772851 \cdot 10^{177}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \end{array}\]

Reproduce

herbie shell --seed 2020043 +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))