Average Error: 6.4 → 0.7
Time: 1.4s
Precision: 64
\[\frac{x \cdot y}{z}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y \le -2.660334377031037045555521559723161789378 \cdot 10^{252}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{elif}\;x \cdot y \le -1.533860280421558737181762286612661859257 \cdot 10^{-148}:\\ \;\;\;\;1 \cdot \frac{x \cdot y}{z}\\ \mathbf{elif}\;x \cdot y \le 3.4301204436228912587238482013946693466 \cdot 10^{-295}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{elif}\;x \cdot y \le 3.360470352442305791587918027875262440495 \cdot 10^{146}:\\ \;\;\;\;1 \cdot \frac{x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \end{array}\]
\frac{x \cdot y}{z}
\begin{array}{l}
\mathbf{if}\;x \cdot y \le -2.660334377031037045555521559723161789378 \cdot 10^{252}:\\
\;\;\;\;\frac{x}{\frac{z}{y}}\\

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

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

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

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

\end{array}
double f(double x, double y, double z) {
        double r701843 = x;
        double r701844 = y;
        double r701845 = r701843 * r701844;
        double r701846 = z;
        double r701847 = r701845 / r701846;
        return r701847;
}

double f(double x, double y, double z) {
        double r701848 = x;
        double r701849 = y;
        double r701850 = r701848 * r701849;
        double r701851 = -2.660334377031037e+252;
        bool r701852 = r701850 <= r701851;
        double r701853 = z;
        double r701854 = r701853 / r701849;
        double r701855 = r701848 / r701854;
        double r701856 = -1.5338602804215587e-148;
        bool r701857 = r701850 <= r701856;
        double r701858 = 1.0;
        double r701859 = r701850 / r701853;
        double r701860 = r701858 * r701859;
        double r701861 = 3.4301204436228913e-295;
        bool r701862 = r701850 <= r701861;
        double r701863 = 3.360470352442306e+146;
        bool r701864 = r701850 <= r701863;
        double r701865 = r701849 / r701853;
        double r701866 = r701848 * r701865;
        double r701867 = r701864 ? r701860 : r701866;
        double r701868 = r701862 ? r701855 : r701867;
        double r701869 = r701857 ? r701860 : r701868;
        double r701870 = r701852 ? r701855 : r701869;
        return r701870;
}

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.4
Target6.4
Herbie0.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) < -2.660334377031037e+252 or -1.5338602804215587e-148 < (* x y) < 3.4301204436228913e-295

    1. Initial program 15.8

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

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

    if -2.660334377031037e+252 < (* x y) < -1.5338602804215587e-148 or 3.4301204436228913e-295 < (* x y) < 3.360470352442306e+146

    1. Initial program 0.2

      \[\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 *-un-lft-identity0.6

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

      \[\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-frac0.6

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

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

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

    if 3.360470352442306e+146 < (* x y)

    1. Initial program 18.7

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \le -2.660334377031037045555521559723161789378 \cdot 10^{252}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{elif}\;x \cdot y \le -1.533860280421558737181762286612661859257 \cdot 10^{-148}:\\ \;\;\;\;1 \cdot \frac{x \cdot y}{z}\\ \mathbf{elif}\;x \cdot y \le 3.4301204436228912587238482013946693466 \cdot 10^{-295}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{elif}\;x \cdot y \le 3.360470352442305791587918027875262440495 \cdot 10^{146}:\\ \;\;\;\;1 \cdot \frac{x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \end{array}\]

Reproduce

herbie shell --seed 2019356 
(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))