Average Error: 6.2 → 1.1
Time: 12.1s
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 r32112801 = x;
        double r32112802 = y;
        double r32112803 = r32112801 * r32112802;
        double r32112804 = z;
        double r32112805 = r32112803 / r32112804;
        return r32112805;
}

double f(double x, double y, double z) {
        double r32112806 = x;
        double r32112807 = y;
        double r32112808 = r32112806 * r32112807;
        double r32112809 = -1.7213465425126525e+172;
        bool r32112810 = r32112808 <= r32112809;
        double r32112811 = z;
        double r32112812 = r32112807 / r32112811;
        double r32112813 = r32112806 * r32112812;
        double r32112814 = -3.4578769880757935e-115;
        bool r32112815 = r32112808 <= r32112814;
        double r32112816 = r32112808 / r32112811;
        double r32112817 = 1.3508925074839404e-153;
        bool r32112818 = r32112808 <= r32112817;
        double r32112819 = 6.859366357865012e+120;
        bool r32112820 = r32112808 <= r32112819;
        double r32112821 = r32112806 / r32112811;
        double r32112822 = r32112821 * r32112807;
        double r32112823 = r32112820 ? r32112816 : r32112822;
        double r32112824 = r32112818 ? r32112813 : r32112823;
        double r32112825 = r32112815 ? r32112816 : r32112824;
        double r32112826 = r32112810 ? r32112813 : r32112825;
        return r32112826;
}

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))