Average Error: 6.0 → 3.4
Time: 2.0s
Precision: 64
\[\frac{x \cdot y}{z}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y \le -2.4829212502580601 \cdot 10^{-130}:\\ \;\;\;\;\left(x \cdot y\right) \cdot \frac{1}{z}\\ \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}:\\ \;\;\;\;\left(x \cdot y\right) \cdot \frac{1}{z}\\ \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}:\\
\;\;\;\;\left(x \cdot y\right) \cdot \frac{1}{z}\\

\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}:\\
\;\;\;\;\left(x \cdot y\right) \cdot \frac{1}{z}\\

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

\end{array}
double f(double x, double y, double z) {
        double r719632 = x;
        double r719633 = y;
        double r719634 = r719632 * r719633;
        double r719635 = z;
        double r719636 = r719634 / r719635;
        return r719636;
}

double f(double x, double y, double z) {
        double r719637 = x;
        double r719638 = y;
        double r719639 = r719637 * r719638;
        double r719640 = -2.48292125025806e-130;
        bool r719641 = r719639 <= r719640;
        double r719642 = 1.0;
        double r719643 = z;
        double r719644 = r719642 / r719643;
        double r719645 = r719639 * r719644;
        double r719646 = 4.093590320564837e-135;
        bool r719647 = r719639 <= r719646;
        double r719648 = r719638 / r719643;
        double r719649 = r719637 * r719648;
        double r719650 = 1.4843668056138444e+38;
        bool r719651 = r719639 <= r719650;
        double r719652 = r719643 / r719638;
        double r719653 = r719637 / r719652;
        double r719654 = r719651 ? r719645 : r719653;
        double r719655 = r719647 ? r719649 : r719654;
        double r719656 = r719641 ? r719645 : r719655;
        return r719656;
}

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 div-inv3.8

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

    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}:\\ \;\;\;\;\left(x \cdot y\right) \cdot \frac{1}{z}\\ \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}:\\ \;\;\;\;\left(x \cdot y\right) \cdot \frac{1}{z}\\ \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))