Average Error: 14.8 → 1.9
Time: 9.0s
Precision: 64
\[x \cdot \frac{\frac{y}{z} \cdot t}{t}\]
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z} \le -2.1216973775124759 \cdot 10^{253}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;\frac{y}{z} \le -1.58981900482305871 \cdot 10^{-298} \lor \neg \left(\frac{y}{z} \le 1.0873747502010816 \cdot 10^{-201}\right):\\ \;\;\;\;\frac{y}{z} \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{z} \cdot \left(y \cdot x\right)\\ \end{array}\]
x \cdot \frac{\frac{y}{z} \cdot t}{t}
\begin{array}{l}
\mathbf{if}\;\frac{y}{z} \le -2.1216973775124759 \cdot 10^{253}:\\
\;\;\;\;\frac{y}{\frac{z}{x}}\\

\mathbf{elif}\;\frac{y}{z} \le -1.58981900482305871 \cdot 10^{-298} \lor \neg \left(\frac{y}{z} \le 1.0873747502010816 \cdot 10^{-201}\right):\\
\;\;\;\;\frac{y}{z} \cdot x\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{z} \cdot \left(y \cdot x\right)\\

\end{array}
double f(double x, double y, double z, double t) {
        double r449965 = x;
        double r449966 = y;
        double r449967 = z;
        double r449968 = r449966 / r449967;
        double r449969 = t;
        double r449970 = r449968 * r449969;
        double r449971 = r449970 / r449969;
        double r449972 = r449965 * r449971;
        return r449972;
}

double f(double x, double y, double z, double __attribute__((unused)) t) {
        double r449973 = y;
        double r449974 = z;
        double r449975 = r449973 / r449974;
        double r449976 = -2.121697377512476e+253;
        bool r449977 = r449975 <= r449976;
        double r449978 = x;
        double r449979 = r449974 / r449978;
        double r449980 = r449973 / r449979;
        double r449981 = -1.5898190048230587e-298;
        bool r449982 = r449975 <= r449981;
        double r449983 = 1.0873747502010816e-201;
        bool r449984 = r449975 <= r449983;
        double r449985 = !r449984;
        bool r449986 = r449982 || r449985;
        double r449987 = r449975 * r449978;
        double r449988 = 1.0;
        double r449989 = r449988 / r449974;
        double r449990 = r449973 * r449978;
        double r449991 = r449989 * r449990;
        double r449992 = r449986 ? r449987 : r449991;
        double r449993 = r449977 ? r449980 : r449992;
        return r449993;
}

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.8
Target1.7
Herbie1.9
\[\begin{array}{l} \mathbf{if}\;\frac{\frac{y}{z} \cdot t}{t} \lt -1.20672205123045005 \cdot 10^{245}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;\frac{\frac{y}{z} \cdot t}{t} \lt -5.90752223693390633 \cdot 10^{-275}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;\frac{\frac{y}{z} \cdot t}{t} \lt 5.65895442315341522 \cdot 10^{-65}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;\frac{\frac{y}{z} \cdot t}{t} \lt 2.0087180502407133 \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) < -2.121697377512476e+253

    1. Initial program 50.4

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

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

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

    if -2.121697377512476e+253 < (/ y z) < -1.5898190048230587e-298 or 1.0873747502010816e-201 < (/ y z)

    1. Initial program 12.1

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

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

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

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

    if -1.5898190048230587e-298 < (/ y z) < 1.0873747502010816e-201

    1. Initial program 17.8

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

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

      \[\leadsto \color{blue}{\frac{y}{\frac{z}{x}}}\]
    5. Using strategy rm
    6. Applied div-inv0.4

      \[\leadsto \frac{y}{\color{blue}{z \cdot \frac{1}{x}}}\]
    7. Applied *-un-lft-identity0.4

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

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

      \[\leadsto \frac{1}{z} \cdot \color{blue}{\left(y \cdot x\right)}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification1.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} \le -2.1216973775124759 \cdot 10^{253}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;\frac{y}{z} \le -1.58981900482305871 \cdot 10^{-298} \lor \neg \left(\frac{y}{z} \le 1.0873747502010816 \cdot 10^{-201}\right):\\ \;\;\;\;\frac{y}{z} \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{z} \cdot \left(y \cdot x\right)\\ \end{array}\]

Reproduce

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