Average Error: 6.0 → 1.4
Time: 19.5s
Precision: 64
\[\frac{x \cdot y}{z}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y \le -1.005819449333334765447075052665383266355 \cdot 10^{141}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{elif}\;x \cdot y \le -6.34222541448496204100028812111103077968 \cdot 10^{-175}:\\ \;\;\;\;\frac{1}{z \cdot \frac{1}{x \cdot y}}\\ \mathbf{elif}\;x \cdot y \le 1.973790963784374190322581308699654202128 \cdot 10^{-123}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;x \cdot y \le 2.652501867890780483390436172253209237796 \cdot 10^{102}:\\ \;\;\;\;\frac{1}{z \cdot \frac{1}{x \cdot y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \end{array}\]
\frac{x \cdot y}{z}
\begin{array}{l}
\mathbf{if}\;x \cdot y \le -1.005819449333334765447075052665383266355 \cdot 10^{141}:\\
\;\;\;\;\frac{x}{\frac{z}{y}}\\

\mathbf{elif}\;x \cdot y \le -6.34222541448496204100028812111103077968 \cdot 10^{-175}:\\
\;\;\;\;\frac{1}{z \cdot \frac{1}{x \cdot y}}\\

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

\mathbf{elif}\;x \cdot y \le 2.652501867890780483390436172253209237796 \cdot 10^{102}:\\
\;\;\;\;\frac{1}{z \cdot \frac{1}{x \cdot y}}\\

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

\end{array}
double f(double x, double y, double z) {
        double r471426 = x;
        double r471427 = y;
        double r471428 = r471426 * r471427;
        double r471429 = z;
        double r471430 = r471428 / r471429;
        return r471430;
}

double f(double x, double y, double z) {
        double r471431 = x;
        double r471432 = y;
        double r471433 = r471431 * r471432;
        double r471434 = -1.0058194493333348e+141;
        bool r471435 = r471433 <= r471434;
        double r471436 = z;
        double r471437 = r471436 / r471432;
        double r471438 = r471431 / r471437;
        double r471439 = -6.342225414484962e-175;
        bool r471440 = r471433 <= r471439;
        double r471441 = 1.0;
        double r471442 = r471441 / r471433;
        double r471443 = r471436 * r471442;
        double r471444 = r471441 / r471443;
        double r471445 = 1.9737909637843742e-123;
        bool r471446 = r471433 <= r471445;
        double r471447 = r471436 / r471431;
        double r471448 = r471432 / r471447;
        double r471449 = 2.6525018678907805e+102;
        bool r471450 = r471433 <= r471449;
        double r471451 = r471450 ? r471444 : r471438;
        double r471452 = r471446 ? r471448 : r471451;
        double r471453 = r471440 ? r471444 : r471452;
        double r471454 = r471435 ? r471438 : r471453;
        return r471454;
}

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.5
Herbie1.4
\[\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.0058194493333348e+141 or 2.6525018678907805e+102 < (* x y)

    1. Initial program 15.3

      \[\frac{x \cdot y}{z}\]
    2. Using strategy rm
    3. Applied clear-num15.4

      \[\leadsto \color{blue}{\frac{1}{\frac{z}{x \cdot y}}}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity15.4

      \[\leadsto \frac{1}{\color{blue}{1 \cdot \frac{z}{x \cdot y}}}\]
    6. Applied add-cube-cbrt15.4

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

      \[\leadsto \color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{1} \cdot \frac{\sqrt[3]{1}}{\frac{z}{x \cdot y}}}\]
    8. Simplified15.4

      \[\leadsto \color{blue}{1} \cdot \frac{\sqrt[3]{1}}{\frac{z}{x \cdot y}}\]
    9. Simplified2.7

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

    if -1.0058194493333348e+141 < (* x y) < -6.342225414484962e-175 or 1.9737909637843742e-123 < (* x y) < 2.6525018678907805e+102

    1. Initial program 0.3

      \[\frac{x \cdot y}{z}\]
    2. Using strategy rm
    3. Applied clear-num0.6

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

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

    if -6.342225414484962e-175 < (* x y) < 1.9737909637843742e-123

    1. Initial program 7.9

      \[\frac{x \cdot y}{z}\]
    2. Using strategy rm
    3. Applied clear-num8.3

      \[\leadsto \color{blue}{\frac{1}{\frac{z}{x \cdot y}}}\]
    4. Using strategy rm
    5. Applied div-inv8.9

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \le -1.005819449333334765447075052665383266355 \cdot 10^{141}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{elif}\;x \cdot y \le -6.34222541448496204100028812111103077968 \cdot 10^{-175}:\\ \;\;\;\;\frac{1}{z \cdot \frac{1}{x \cdot y}}\\ \mathbf{elif}\;x \cdot y \le 1.973790963784374190322581308699654202128 \cdot 10^{-123}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;x \cdot y \le 2.652501867890780483390436172253209237796 \cdot 10^{102}:\\ \;\;\;\;\frac{1}{z \cdot \frac{1}{x \cdot y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \end{array}\]

Reproduce

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