Average Error: 14.9 → 0.8
Time: 8.2s
Precision: 64
\[x \cdot \frac{\frac{y}{z} \cdot t}{t}\]
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z} \le -5.336855438751845253690247898530172235276 \cdot 10^{200}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;\frac{y}{z} \le -1.140183350781710951892007925496689372501 \cdot 10^{-100}:\\ \;\;\;\;\frac{y}{z} \cdot x\\ \mathbf{elif}\;\frac{y}{z} \le 8.498087209476109758731119739347125435518 \cdot 10^{-318}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \mathbf{elif}\;\frac{y}{z} \le 6.962111496293719814616574831940399431433 \cdot 10^{307}:\\ \;\;\;\;\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 -5.336855438751845253690247898530172235276 \cdot 10^{200}:\\
\;\;\;\;y \cdot \frac{x}{z}\\

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

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

\mathbf{elif}\;\frac{y}{z} \le 6.962111496293719814616574831940399431433 \cdot 10^{307}:\\
\;\;\;\;\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 r385906 = x;
        double r385907 = y;
        double r385908 = z;
        double r385909 = r385907 / r385908;
        double r385910 = t;
        double r385911 = r385909 * r385910;
        double r385912 = r385911 / r385910;
        double r385913 = r385906 * r385912;
        return r385913;
}

double f(double x, double y, double z, double __attribute__((unused)) t) {
        double r385914 = y;
        double r385915 = z;
        double r385916 = r385914 / r385915;
        double r385917 = -5.336855438751845e+200;
        bool r385918 = r385916 <= r385917;
        double r385919 = x;
        double r385920 = r385919 / r385915;
        double r385921 = r385914 * r385920;
        double r385922 = -1.140183350781711e-100;
        bool r385923 = r385916 <= r385922;
        double r385924 = r385916 * r385919;
        double r385925 = 8.4980872094761e-318;
        bool r385926 = r385916 <= r385925;
        double r385927 = r385914 * r385919;
        double r385928 = r385927 / r385915;
        double r385929 = 6.96211149629372e+307;
        bool r385930 = r385916 <= r385929;
        double r385931 = r385915 / r385914;
        double r385932 = r385919 / r385931;
        double r385933 = r385930 ? r385932 : r385921;
        double r385934 = r385926 ? r385928 : r385933;
        double r385935 = r385923 ? r385924 : r385934;
        double r385936 = r385918 ? r385921 : r385935;
        return r385936;
}

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.9
Target1.6
Herbie0.8
\[\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 4 regimes
  2. if (/ y z) < -5.336855438751845e+200 or 6.96211149629372e+307 < (/ y z)

    1. Initial program 46.8

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

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

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

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

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

    if -5.336855438751845e+200 < (/ y z) < -1.140183350781711e-100

    1. Initial program 7.1

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

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

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

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

    if -1.140183350781711e-100 < (/ y z) < 8.4980872094761e-318

    1. Initial program 16.3

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

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

    if 8.4980872094761e-318 < (/ y z) < 6.96211149629372e+307

    1. Initial program 11.3

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

      \[\leadsto \color{blue}{\frac{y \cdot x}{z}}\]
    3. Using strategy rm
    4. Applied clear-num7.9

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

      \[\leadsto \frac{1}{\color{blue}{\frac{z}{x \cdot y}}}\]
    6. Using strategy rm
    7. Applied *-un-lft-identity7.9

      \[\leadsto \frac{1}{\frac{\color{blue}{1 \cdot z}}{x \cdot y}}\]
    8. Applied times-frac1.0

      \[\leadsto \frac{1}{\color{blue}{\frac{1}{x} \cdot \frac{z}{y}}}\]
    9. Applied associate-/r*0.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} \le -5.336855438751845253690247898530172235276 \cdot 10^{200}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;\frac{y}{z} \le -1.140183350781710951892007925496689372501 \cdot 10^{-100}:\\ \;\;\;\;\frac{y}{z} \cdot x\\ \mathbf{elif}\;\frac{y}{z} \le 8.498087209476109758731119739347125435518 \cdot 10^{-318}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \mathbf{elif}\;\frac{y}{z} \le 6.962111496293719814616574831940399431433 \cdot 10^{307}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \end{array}\]

Reproduce

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

  :herbie-target
  (if (< (/ (* (/ y z) t) t) -1.20672205123045005e245) (/ y (/ z x)) (if (< (/ (* (/ y z) t) t) -5.90752223693390633e-275) (* x (/ y z)) (if (< (/ (* (/ y z) t) t) 5.65895442315341522e-65) (/ y (/ z x)) (if (< (/ (* (/ y z) t) t) 2.0087180502407133e217) (* x (/ y z)) (/ (* y x) z)))))

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