Average Error: 6.0 → 3.4
Time: 1.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 r697106 = x;
        double r697107 = y;
        double r697108 = r697106 * r697107;
        double r697109 = z;
        double r697110 = r697108 / r697109;
        return r697110;
}

double f(double x, double y, double z) {
        double r697111 = x;
        double r697112 = y;
        double r697113 = r697111 * r697112;
        double r697114 = -2.48292125025806e-130;
        bool r697115 = r697113 <= r697114;
        double r697116 = 1.0;
        double r697117 = z;
        double r697118 = r697116 / r697117;
        double r697119 = r697118 * r697113;
        double r697120 = 4.093590320564837e-135;
        bool r697121 = r697113 <= r697120;
        double r697122 = r697112 / r697117;
        double r697123 = r697111 * r697122;
        double r697124 = 1.4843668056138444e+38;
        bool r697125 = r697113 <= r697124;
        double r697126 = r697117 / r697112;
        double r697127 = r697111 / r697126;
        double r697128 = r697125 ? r697119 : r697127;
        double r697129 = r697121 ? r697123 : r697128;
        double r697130 = r697115 ? r697119 : r697129;
        return r697130;
}

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 clear-num10.5

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

      \[\leadsto \frac{1}{\frac{\frac{z}{y}}{\color{blue}{1 \cdot x}}}\]
    8. Applied div-inv10.5

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

      \[\leadsto \frac{1}{\color{blue}{\frac{z}{1} \cdot \frac{\frac{1}{y}}{x}}}\]
    10. Applied add-cube-cbrt3.8

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

      \[\leadsto \color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\frac{z}{1}} \cdot \frac{\sqrt[3]{1}}{\frac{\frac{1}{y}}{x}}}\]
    12. Simplified4.0

      \[\leadsto \color{blue}{\frac{1}{z}} \cdot \frac{\sqrt[3]{1}}{\frac{\frac{1}{y}}{x}}\]
    13. 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 
(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))