Average Error: 6.0 → 3.4
Time: 6.8s
Precision: 64
\[\frac{x \cdot y}{z}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y \le -2.4829212502580601 \cdot 10^{-130}:\\ \;\;\;\;\frac{1}{z} \cdot \left(x \cdot y\right)\\ \mathbf{elif}\;x \cdot y \le 4.09359032056483698 \cdot 10^{-135}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;x \cdot y \le 1.48436680561384441 \cdot 10^{38}:\\ \;\;\;\;\frac{1}{z} \cdot \left(x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \end{array}\]
\frac{x \cdot y}{z}
\begin{array}{l}
\mathbf{if}\;x \cdot y \le -2.4829212502580601 \cdot 10^{-130}:\\
\;\;\;\;\frac{1}{z} \cdot \left(x \cdot y\right)\\

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

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

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

\end{array}
double f(double x, double y, double z) {
        double r769059 = x;
        double r769060 = y;
        double r769061 = r769059 * r769060;
        double r769062 = z;
        double r769063 = r769061 / r769062;
        return r769063;
}

double f(double x, double y, double z) {
        double r769064 = x;
        double r769065 = y;
        double r769066 = r769064 * r769065;
        double r769067 = -2.48292125025806e-130;
        bool r769068 = r769066 <= r769067;
        double r769069 = 1.0;
        double r769070 = z;
        double r769071 = r769069 / r769070;
        double r769072 = r769071 * r769066;
        double r769073 = 4.093590320564837e-135;
        bool r769074 = r769066 <= r769073;
        double r769075 = r769065 / r769070;
        double r769076 = r769064 * r769075;
        double r769077 = 1.4843668056138444e+38;
        bool r769078 = r769066 <= r769077;
        double r769079 = r769070 / r769065;
        double r769080 = r769064 / r769079;
        double r769081 = r769078 ? r769072 : r769080;
        double r769082 = r769074 ? r769076 : r769081;
        double r769083 = r769068 ? r769072 : r769082;
        return r769083;
}

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.0
Target6.6
Herbie3.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 3 regimes
  2. if (* x y) < -2.48292125025806e-130 or 4.093590320564837e-135 < (* x y) < 1.4843668056138444e+38

    1. Initial program 3.7

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

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

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

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

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

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

    if -2.48292125025806e-130 < (* x y) < 4.093590320564837e-135

    1. Initial program 7.5

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

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

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

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

    if 1.4843668056138444e+38 < (* x y)

    1. Initial program 9.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \le -2.4829212502580601 \cdot 10^{-130}:\\ \;\;\;\;\frac{1}{z} \cdot \left(x \cdot y\right)\\ \mathbf{elif}\;x \cdot y \le 4.09359032056483698 \cdot 10^{-135}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;x \cdot y \le 1.48436680561384441 \cdot 10^{38}:\\ \;\;\;\;\frac{1}{z} \cdot \left(x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \end{array}\]

Reproduce

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