Average Error: 14.7 → 3.3
Time: 16.7s
Precision: 64
\[x \cdot \frac{\frac{y}{z} \cdot t}{t}\]
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z} \le -1.245947516265854964311200045000519905686 \cdot 10^{-233}:\\ \;\;\;\;\frac{y}{z} \cdot x\\ \mathbf{elif}\;\frac{y}{z} \le 6.872941476643587911784112841004328702772 \cdot 10^{-272}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \end{array}\]
x \cdot \frac{\frac{y}{z} \cdot t}{t}
\begin{array}{l}
\mathbf{if}\;\frac{y}{z} \le -1.245947516265854964311200045000519905686 \cdot 10^{-233}:\\
\;\;\;\;\frac{y}{z} \cdot x\\

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r23678818 = x;
        double r23678819 = y;
        double r23678820 = z;
        double r23678821 = r23678819 / r23678820;
        double r23678822 = t;
        double r23678823 = r23678821 * r23678822;
        double r23678824 = r23678823 / r23678822;
        double r23678825 = r23678818 * r23678824;
        return r23678825;
}

double f(double x, double y, double z, double __attribute__((unused)) t) {
        double r23678826 = y;
        double r23678827 = z;
        double r23678828 = r23678826 / r23678827;
        double r23678829 = -1.245947516265855e-233;
        bool r23678830 = r23678828 <= r23678829;
        double r23678831 = x;
        double r23678832 = r23678828 * r23678831;
        double r23678833 = 6.872941476643588e-272;
        bool r23678834 = r23678828 <= r23678833;
        double r23678835 = r23678831 * r23678826;
        double r23678836 = r23678835 / r23678827;
        double r23678837 = r23678827 / r23678826;
        double r23678838 = r23678831 / r23678837;
        double r23678839 = r23678834 ? r23678836 : r23678838;
        double r23678840 = r23678830 ? r23678832 : r23678839;
        return r23678840;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original14.7
Target1.4
Herbie3.3
\[\begin{array}{l} \mathbf{if}\;\frac{\frac{y}{z} \cdot t}{t} \lt -1.206722051230450047215521150762600712224 \cdot 10^{245}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;\frac{\frac{y}{z} \cdot t}{t} \lt -5.90752223693390632993316700759382836344 \cdot 10^{-275}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;\frac{\frac{y}{z} \cdot t}{t} \lt 5.658954423153415216825328199697215652986 \cdot 10^{-65}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;\frac{\frac{y}{z} \cdot t}{t} \lt 2.008718050240713347941382056648619307142 \cdot 10^{217}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if (/ y z) < -1.245947516265855e-233

    1. Initial program 13.3

      \[x \cdot \frac{\frac{y}{z} \cdot t}{t}\]
    2. Simplified7.8

      \[\leadsto \color{blue}{\frac{x \cdot y}{z}}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity7.8

      \[\leadsto \frac{x \cdot y}{\color{blue}{1 \cdot z}}\]
    5. Applied times-frac4.3

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

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

    if -1.245947516265855e-233 < (/ y z) < 6.872941476643588e-272

    1. Initial program 18.6

      \[x \cdot \frac{\frac{y}{z} \cdot t}{t}\]
    2. Simplified0.4

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

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

      \[\leadsto \color{blue}{\frac{x}{\sqrt[3]{z} \cdot \sqrt[3]{z}} \cdot \frac{y}{\sqrt[3]{z}}}\]
    6. Using strategy rm
    7. Applied frac-times0.8

      \[\leadsto \color{blue}{\frac{x \cdot y}{\left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \sqrt[3]{z}}}\]
    8. Simplified0.4

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

    if 6.872941476643588e-272 < (/ y z)

    1. Initial program 14.0

      \[x \cdot \frac{\frac{y}{z} \cdot t}{t}\]
    2. Simplified8.0

      \[\leadsto \color{blue}{\frac{x \cdot y}{z}}\]
    3. Using strategy rm
    4. Applied associate-/l*3.8

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} \le -1.245947516265854964311200045000519905686 \cdot 10^{-233}:\\ \;\;\;\;\frac{y}{z} \cdot x\\ \mathbf{elif}\;\frac{y}{z} \le 6.872941476643587911784112841004328702772 \cdot 10^{-272}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019171 +o rules:numerics
(FPCore (x y z t)
  :name "Graphics.Rendering.Chart.Backend.Diagrams:calcFontMetrics from Chart-diagrams-1.5.1, B"

  :herbie-target
  (if (< (/ (* (/ y z) t) t) -1.20672205123045e+245) (/ y (/ z x)) (if (< (/ (* (/ y z) t) t) -5.907522236933906e-275) (* x (/ y z)) (if (< (/ (* (/ y z) t) t) 5.658954423153415e-65) (/ y (/ z x)) (if (< (/ (* (/ y z) t) t) 2.0087180502407133e+217) (* x (/ y z)) (/ (* y x) z)))))

  (* x (/ (* (/ y z) t) t)))