Average Error: 6.3 → 2.7
Time: 18.4s
Precision: 64
\[\frac{x \cdot y}{z}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y \le -1.479973884495300604070714800261381475132 \cdot 10^{167}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;x \cdot y \le -1.416209028111420696434446461734804676286 \cdot 10^{-165} \lor \neg \left(x \cdot y \le 6.735758574504119133242399316181506457656 \cdot 10^{-122}\right):\\ \;\;\;\;\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 -1.479973884495300604070714800261381475132 \cdot 10^{167}:\\
\;\;\;\;y \cdot \frac{x}{z}\\

\mathbf{elif}\;x \cdot y \le -1.416209028111420696434446461734804676286 \cdot 10^{-165} \lor \neg \left(x \cdot y \le 6.735758574504119133242399316181506457656 \cdot 10^{-122}\right):\\
\;\;\;\;\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 r424760 = x;
        double r424761 = y;
        double r424762 = r424760 * r424761;
        double r424763 = z;
        double r424764 = r424762 / r424763;
        return r424764;
}

double f(double x, double y, double z) {
        double r424765 = x;
        double r424766 = y;
        double r424767 = r424765 * r424766;
        double r424768 = -1.4799738844953006e+167;
        bool r424769 = r424767 <= r424768;
        double r424770 = z;
        double r424771 = r424765 / r424770;
        double r424772 = r424766 * r424771;
        double r424773 = -1.4162090281114207e-165;
        bool r424774 = r424767 <= r424773;
        double r424775 = 6.735758574504119e-122;
        bool r424776 = r424767 <= r424775;
        double r424777 = !r424776;
        bool r424778 = r424774 || r424777;
        double r424779 = 1.0;
        double r424780 = r424779 / r424770;
        double r424781 = r424767 * r424780;
        double r424782 = r424770 / r424766;
        double r424783 = r424765 / r424782;
        double r424784 = r424778 ? r424781 : r424783;
        double r424785 = r424769 ? r424772 : r424784;
        return r424785;
}

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.3
Target6.3
Herbie2.7
\[\begin{array}{l} \mathbf{if}\;z \lt -4.262230790519428958560619200129306371776 \cdot 10^{-138}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;z \lt 1.704213066065047207696571404603247573308 \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.4799738844953006e+167

    1. Initial program 19.6

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{y}}}\]
    4. Using strategy rm
    5. Applied clear-num1.7

      \[\leadsto \color{blue}{\frac{1}{\frac{\frac{z}{y}}{x}}}\]
    6. Taylor expanded around 0 19.6

      \[\leadsto \color{blue}{\frac{x \cdot y}{z}}\]
    7. Simplified2.4

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

    if -1.4799738844953006e+167 < (* x y) < -1.4162090281114207e-165 or 6.735758574504119e-122 < (* x y)

    1. Initial program 3.2

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

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

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

      \[\leadsto \color{blue}{x} \cdot \frac{y}{z}\]
    6. Using strategy rm
    7. Applied div-inv10.1

      \[\leadsto x \cdot \color{blue}{\left(y \cdot \frac{1}{z}\right)}\]
    8. Applied associate-*r*3.3

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

    if -1.4162090281114207e-165 < (* x y) < 6.735758574504119e-122

    1. Initial program 8.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \le -1.479973884495300604070714800261381475132 \cdot 10^{167}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;x \cdot y \le -1.416209028111420696434446461734804676286 \cdot 10^{-165} \lor \neg \left(x \cdot y \le 6.735758574504119133242399316181506457656 \cdot 10^{-122}\right):\\ \;\;\;\;\left(x \cdot y\right) \cdot \frac{1}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \end{array}\]

Reproduce

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