Average Error: 14.0 → 0.7
Time: 25.6s
Precision: 64
\[x \cdot \frac{\frac{y}{z} \cdot t}{t}\]
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z} \le -1.009555688743657053093976996432682877192 \cdot 10^{278}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;\frac{y}{z} \le -1.900141742787772715345890115335440787699 \cdot 10^{-270}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{elif}\;\frac{y}{z} \le 4.438182973596565301288302827093808047147 \cdot 10^{-272}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;\frac{y}{z} \le 3.561199608254915194562496763078682553454 \cdot 10^{97}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{1}{y}}\\ \end{array}\]
x \cdot \frac{\frac{y}{z} \cdot t}{t}
\begin{array}{l}
\mathbf{if}\;\frac{y}{z} \le -1.009555688743657053093976996432682877192 \cdot 10^{278}:\\
\;\;\;\;y \cdot \frac{x}{z}\\

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

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

\mathbf{elif}\;\frac{y}{z} \le 3.561199608254915194562496763078682553454 \cdot 10^{97}:\\
\;\;\;\;\frac{x}{\frac{z}{y}}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r350899 = x;
        double r350900 = y;
        double r350901 = z;
        double r350902 = r350900 / r350901;
        double r350903 = t;
        double r350904 = r350902 * r350903;
        double r350905 = r350904 / r350903;
        double r350906 = r350899 * r350905;
        return r350906;
}

double f(double x, double y, double z, double __attribute__((unused)) t) {
        double r350907 = y;
        double r350908 = z;
        double r350909 = r350907 / r350908;
        double r350910 = -1.009555688743657e+278;
        bool r350911 = r350909 <= r350910;
        double r350912 = x;
        double r350913 = r350912 / r350908;
        double r350914 = r350907 * r350913;
        double r350915 = -1.9001417427877727e-270;
        bool r350916 = r350909 <= r350915;
        double r350917 = r350908 / r350907;
        double r350918 = r350912 / r350917;
        double r350919 = 4.438182973596565e-272;
        bool r350920 = r350909 <= r350919;
        double r350921 = r350912 * r350907;
        double r350922 = r350921 / r350908;
        double r350923 = 3.561199608254915e+97;
        bool r350924 = r350909 <= r350923;
        double r350925 = 1.0;
        double r350926 = r350925 / r350907;
        double r350927 = r350913 / r350926;
        double r350928 = r350924 ? r350918 : r350927;
        double r350929 = r350920 ? r350922 : r350928;
        double r350930 = r350916 ? r350918 : r350929;
        double r350931 = r350911 ? r350914 : r350930;
        return r350931;
}

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.0
Target1.4
Herbie0.7
\[\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) < -1.009555688743657e+278

    1. Initial program 54.6

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

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

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

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

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

    if -1.009555688743657e+278 < (/ y z) < -1.9001417427877727e-270 or 4.438182973596565e-272 < (/ y z) < 3.561199608254915e+97

    1. Initial program 8.2

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

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

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

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

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

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

    if -1.9001417427877727e-270 < (/ y z) < 4.438182973596565e-272

    1. Initial program 18.9

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

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

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

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

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

    if 3.561199608254915e+97 < (/ y z)

    1. Initial program 26.4

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

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

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

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

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

      \[\leadsto 1 \cdot \color{blue}{\frac{x}{\frac{z}{y}}}\]
    9. Using strategy rm
    10. Applied div-inv11.8

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} \le -1.009555688743657053093976996432682877192 \cdot 10^{278}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;\frac{y}{z} \le -1.900141742787772715345890115335440787699 \cdot 10^{-270}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{elif}\;\frac{y}{z} \le 4.438182973596565301288302827093808047147 \cdot 10^{-272}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;\frac{y}{z} \le 3.561199608254915194562496763078682553454 \cdot 10^{97}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{1}{y}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019303 +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)))