Average Error: 6.4 → 2.2
Time: 9.0s
Precision: 64
\[\frac{x \cdot y}{z}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y = -\infty:\\ \;\;\;\;\frac{x}{z} \cdot y\\ \mathbf{elif}\;x \cdot y \le -1.441956668272939099348463004765207941311 \cdot 10^{-215} \lor \neg \left(x \cdot y \le 3.896140158292728048846350005738913745263 \cdot 10^{-268}\right):\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \end{array}\]
\frac{x \cdot y}{z}
\begin{array}{l}
\mathbf{if}\;x \cdot y = -\infty:\\
\;\;\;\;\frac{x}{z} \cdot y\\

\mathbf{elif}\;x \cdot y \le -1.441956668272939099348463004765207941311 \cdot 10^{-215} \lor \neg \left(x \cdot y \le 3.896140158292728048846350005738913745263 \cdot 10^{-268}\right):\\
\;\;\;\;\frac{x \cdot y}{z}\\

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

\end{array}
double f(double x, double y, double z) {
        double r441795 = x;
        double r441796 = y;
        double r441797 = r441795 * r441796;
        double r441798 = z;
        double r441799 = r441797 / r441798;
        return r441799;
}

double f(double x, double y, double z) {
        double r441800 = x;
        double r441801 = y;
        double r441802 = r441800 * r441801;
        double r441803 = -inf.0;
        bool r441804 = r441802 <= r441803;
        double r441805 = z;
        double r441806 = r441800 / r441805;
        double r441807 = r441806 * r441801;
        double r441808 = -1.441956668272939e-215;
        bool r441809 = r441802 <= r441808;
        double r441810 = 3.896140158292728e-268;
        bool r441811 = r441802 <= r441810;
        double r441812 = !r441811;
        bool r441813 = r441809 || r441812;
        double r441814 = r441802 / r441805;
        double r441815 = r441805 / r441800;
        double r441816 = r441801 / r441815;
        double r441817 = r441813 ? r441814 : r441816;
        double r441818 = r441804 ? r441807 : r441817;
        return r441818;
}

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.5
Herbie2.2
\[\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

    1. Initial program 64.0

      \[\frac{x \cdot y}{z}\]
    2. Using strategy rm
    3. Applied div-inv64.0

      \[\leadsto \color{blue}{\left(x \cdot y\right) \cdot \frac{1}{z}}\]
    4. Taylor expanded around 0 64.0

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

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

    if -inf.0 < (* x y) < -1.441956668272939e-215 or 3.896140158292728e-268 < (* x y)

    1. Initial program 2.8

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

    if -1.441956668272939e-215 < (* x y) < 3.896140158292728e-268

    1. Initial program 11.5

      \[\frac{x \cdot y}{z}\]
    2. Using strategy rm
    3. Applied div-inv11.5

      \[\leadsto \color{blue}{\left(x \cdot y\right) \cdot \frac{1}{z}}\]
    4. Taylor expanded around 0 11.5

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

      \[\leadsto \color{blue}{\frac{x}{z} \cdot y}\]
    6. Using strategy rm
    7. Applied add-cube-cbrt0.8

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

      \[\leadsto \color{blue}{\left(\frac{x}{z} \cdot \left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right)\right) \cdot \sqrt[3]{y}}\]
    9. Simplified6.2

      \[\leadsto \color{blue}{\frac{\sqrt[3]{y} \cdot \left(\sqrt[3]{y} \cdot x\right)}{z}} \cdot \sqrt[3]{y}\]
    10. Taylor expanded around 0 11.5

      \[\leadsto \color{blue}{\frac{x \cdot y}{z}}\]
    11. Simplified0.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y = -\infty:\\ \;\;\;\;\frac{x}{z} \cdot y\\ \mathbf{elif}\;x \cdot y \le -1.441956668272939099348463004765207941311 \cdot 10^{-215} \lor \neg \left(x \cdot y \le 3.896140158292728048846350005738913745263 \cdot 10^{-268}\right):\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019174 +o rules:numerics
(FPCore (x y z)
  :name "Diagrams.Solve.Tridiagonal:solveCyclicTriDiagonal from diagrams-solve-0.1, A"

  :herbie-target
  (if (< z -4.262230790519429e-138) (/ (* x y) z) (if (< z 1.7042130660650472e-164) (/ x (/ z y)) (* (/ x z) y)))

  (/ (* x y) z))