Average Error: 6.1 → 0.5
Time: 10.3s
Precision: 64
\[\frac{x \cdot y}{z}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y = -\infty:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;x \cdot y \le -1.509969006318767476076503535983239829581 \cdot 10^{-153}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;x \cdot y \le 5.88065538335666025342643040475244053333 \cdot 10^{-283}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;x \cdot y \le 1.984690863720470523745396250756862977108 \cdot 10^{170}:\\ \;\;\;\;\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 = -\infty:\\
\;\;\;\;x \cdot \frac{y}{z}\\

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

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

\mathbf{elif}\;x \cdot y \le 1.984690863720470523745396250756862977108 \cdot 10^{170}:\\
\;\;\;\;\frac{x \cdot y}{z}\\

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

\end{array}
double f(double x, double y, double z) {
        double r459827 = x;
        double r459828 = y;
        double r459829 = r459827 * r459828;
        double r459830 = z;
        double r459831 = r459829 / r459830;
        return r459831;
}

double f(double x, double y, double z) {
        double r459832 = x;
        double r459833 = y;
        double r459834 = r459832 * r459833;
        double r459835 = -inf.0;
        bool r459836 = r459834 <= r459835;
        double r459837 = z;
        double r459838 = r459833 / r459837;
        double r459839 = r459832 * r459838;
        double r459840 = -1.5099690063187675e-153;
        bool r459841 = r459834 <= r459840;
        double r459842 = r459834 / r459837;
        double r459843 = 5.88065538335666e-283;
        bool r459844 = r459834 <= r459843;
        double r459845 = 1.9846908637204705e+170;
        bool r459846 = r459834 <= r459845;
        double r459847 = r459832 / r459837;
        double r459848 = r459847 * r459833;
        double r459849 = r459846 ? r459842 : r459848;
        double r459850 = r459844 ? r459839 : r459849;
        double r459851 = r459841 ? r459842 : r459850;
        double r459852 = r459836 ? r459839 : r459851;
        return r459852;
}

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.1
Target6.1
Herbie0.5
\[\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) < -inf.0 or -1.5099690063187675e-153 < (* x y) < 5.88065538335666e-283

    1. Initial program 15.2

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

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

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

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

    if -inf.0 < (* x y) < -1.5099690063187675e-153 or 5.88065538335666e-283 < (* x y) < 1.9846908637204705e+170

    1. Initial program 0.2

      \[\frac{x \cdot y}{z}\]

    if 1.9846908637204705e+170 < (* x y)

    1. Initial program 22.2

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y = -\infty:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;x \cdot y \le -1.509969006318767476076503535983239829581 \cdot 10^{-153}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;x \cdot y \le 5.88065538335666025342643040475244053333 \cdot 10^{-283}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;x \cdot y \le 1.984690863720470523745396250756862977108 \cdot 10^{170}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} \cdot y\\ \end{array}\]

Reproduce

herbie shell --seed 2019305 +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.70421306606504721e-164) (/ x (/ z y)) (* (/ x z) y)))

  (/ (* x y) z))