Average Error: 14.7 → 1.1
Time: 16.0s
Precision: 64
\[x \cdot \frac{\frac{y}{z} \cdot t}{t}\]
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z} \le -2.588366971627017444543194392656819407323 \cdot 10^{79}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;\frac{y}{z} \le -7.584778841906227496781487885537839730751 \cdot 10^{-279}:\\ \;\;\;\;\frac{y}{z} \cdot x\\ \mathbf{elif}\;\frac{y}{z} \le 0.0:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;\frac{y}{z} \le 1.406079879178553538420301463833789327206 \cdot 10^{177}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \end{array}\]
x \cdot \frac{\frac{y}{z} \cdot t}{t}
\begin{array}{l}
\mathbf{if}\;\frac{y}{z} \le -2.588366971627017444543194392656819407323 \cdot 10^{79}:\\
\;\;\;\;y \cdot \frac{x}{z}\\

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

\mathbf{elif}\;\frac{y}{z} \le 0.0:\\
\;\;\;\;\frac{x \cdot y}{z}\\

\mathbf{elif}\;\frac{y}{z} \le 1.406079879178553538420301463833789327206 \cdot 10^{177}:\\
\;\;\;\;\frac{x}{\frac{z}{y}}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r88929 = x;
        double r88930 = y;
        double r88931 = z;
        double r88932 = r88930 / r88931;
        double r88933 = t;
        double r88934 = r88932 * r88933;
        double r88935 = r88934 / r88933;
        double r88936 = r88929 * r88935;
        return r88936;
}

double f(double x, double y, double z, double __attribute__((unused)) t) {
        double r88937 = y;
        double r88938 = z;
        double r88939 = r88937 / r88938;
        double r88940 = -2.5883669716270174e+79;
        bool r88941 = r88939 <= r88940;
        double r88942 = x;
        double r88943 = r88942 / r88938;
        double r88944 = r88937 * r88943;
        double r88945 = -7.584778841906227e-279;
        bool r88946 = r88939 <= r88945;
        double r88947 = r88939 * r88942;
        double r88948 = 0.0;
        bool r88949 = r88939 <= r88948;
        double r88950 = r88942 * r88937;
        double r88951 = r88950 / r88938;
        double r88952 = 1.4060798791785535e+177;
        bool r88953 = r88939 <= r88952;
        double r88954 = r88938 / r88937;
        double r88955 = r88942 / r88954;
        double r88956 = r88953 ? r88955 : r88944;
        double r88957 = r88949 ? r88951 : r88956;
        double r88958 = r88946 ? r88947 : r88957;
        double r88959 = r88941 ? r88944 : r88958;
        return r88959;
}

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

Derivation

  1. Split input into 4 regimes
  2. if (/ y z) < -2.5883669716270174e+79 or 1.4060798791785535e+177 < (/ y z)

    1. Initial program 31.5

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

      \[\leadsto \color{blue}{\frac{y}{z} \cdot x}\]
    3. Using strategy rm
    4. Applied div-inv16.2

      \[\leadsto \color{blue}{\left(y \cdot \frac{1}{z}\right)} \cdot x\]
    5. Applied associate-*l*4.1

      \[\leadsto \color{blue}{y \cdot \left(\frac{1}{z} \cdot x\right)}\]
    6. Simplified4.0

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

    if -2.5883669716270174e+79 < (/ y z) < -7.584778841906227e-279

    1. Initial program 8.4

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

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

    if -7.584778841906227e-279 < (/ y z) < 0.0

    1. Initial program 18.3

      \[x \cdot \frac{\frac{y}{z} \cdot t}{t}\]
    2. Simplified15.3

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

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

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

    if 0.0 < (/ y z) < 1.4060798791785535e+177

    1. Initial program 10.0

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

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

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

      \[\leadsto \frac{\color{blue}{x \cdot y}}{z}\]
    6. Using strategy rm
    7. Applied associate-/l*3.6

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} \le -2.588366971627017444543194392656819407323 \cdot 10^{79}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;\frac{y}{z} \le -7.584778841906227496781487885537839730751 \cdot 10^{-279}:\\ \;\;\;\;\frac{y}{z} \cdot x\\ \mathbf{elif}\;\frac{y}{z} \le 0.0:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;\frac{y}{z} \le 1.406079879178553538420301463833789327206 \cdot 10^{177}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \end{array}\]

Reproduce

herbie shell --seed 2019351 +o rules:numerics
(FPCore (x y z t)
  :name "Graphics.Rendering.Chart.Backend.Diagrams:calcFontMetrics from Chart-diagrams-1.5.1"
  :precision binary64
  (* x (/ (* (/ y z) t) t)))