Average Error: 6.2 → 1.1
Time: 10.4s
Precision: 64
\[\frac{x \cdot y}{z}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y \le -1.7213465425126525 \cdot 10^{+172}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;x \cdot y \le -3.4578769880757935 \cdot 10^{-115}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;x \cdot y \le 1.3508925074839404 \cdot 10^{-153}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;x \cdot y \le 6.859366357865012 \cdot 10^{+120}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} \cdot y\\ \end{array}\]
\frac{x \cdot y}{z}
\begin{array}{l}
\mathbf{if}\;x \cdot y \le -1.7213465425126525 \cdot 10^{+172}:\\
\;\;\;\;x \cdot \frac{y}{z}\\

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

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

\mathbf{elif}\;x \cdot y \le 6.859366357865012 \cdot 10^{+120}:\\
\;\;\;\;\frac{x \cdot y}{z}\\

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

\end{array}
double f(double x, double y, double z) {
        double r19858635 = x;
        double r19858636 = y;
        double r19858637 = r19858635 * r19858636;
        double r19858638 = z;
        double r19858639 = r19858637 / r19858638;
        return r19858639;
}

double f(double x, double y, double z) {
        double r19858640 = x;
        double r19858641 = y;
        double r19858642 = r19858640 * r19858641;
        double r19858643 = -1.7213465425126525e+172;
        bool r19858644 = r19858642 <= r19858643;
        double r19858645 = z;
        double r19858646 = r19858641 / r19858645;
        double r19858647 = r19858640 * r19858646;
        double r19858648 = -3.4578769880757935e-115;
        bool r19858649 = r19858642 <= r19858648;
        double r19858650 = r19858642 / r19858645;
        double r19858651 = 1.3508925074839404e-153;
        bool r19858652 = r19858642 <= r19858651;
        double r19858653 = 6.859366357865012e+120;
        bool r19858654 = r19858642 <= r19858653;
        double r19858655 = r19858640 / r19858645;
        double r19858656 = r19858655 * r19858641;
        double r19858657 = r19858654 ? r19858650 : r19858656;
        double r19858658 = r19858652 ? r19858647 : r19858657;
        double r19858659 = r19858649 ? r19858650 : r19858658;
        double r19858660 = r19858644 ? r19858647 : r19858659;
        return r19858660;
}

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.2
Target5.9
Herbie1.1
\[\begin{array}{l} \mathbf{if}\;z \lt -4.262230790519429 \cdot 10^{-138}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;z \lt 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 (* x y) < -1.7213465425126525e+172 or -3.4578769880757935e-115 < (* x y) < 1.3508925074839404e-153

    1. Initial program 10.2

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

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

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

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

    if -1.7213465425126525e+172 < (* x y) < -3.4578769880757935e-115 or 1.3508925074839404e-153 < (* x y) < 6.859366357865012e+120

    1. Initial program 0.2

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

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

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

      \[\leadsto \color{blue}{x} \cdot \frac{y}{z}\]
    6. Using strategy rm
    7. Applied associate-*r/0.2

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

    if 6.859366357865012e+120 < (* x y)

    1. Initial program 15.6

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \le -1.7213465425126525 \cdot 10^{+172}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;x \cdot y \le -3.4578769880757935 \cdot 10^{-115}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;x \cdot y \le 1.3508925074839404 \cdot 10^{-153}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;x \cdot y \le 6.859366357865012 \cdot 10^{+120}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} \cdot y\\ \end{array}\]

Reproduce

herbie shell --seed 2019163 +o rules:numerics
(FPCore (x y z)
  :name "Diagrams.Solve.Tridiagonal:solveCyclicTriDiagonal from diagrams-solve-0.1, A"

  :herbie-target
  (if (< z -4.262230790519429e-138) (/ (* x y) z) (if (< z 1.7042130660650472e-164) (/ x (/ z y)) (* (/ x z) y)))

  (/ (* x y) z))