Average Error: 15.1 → 3.7
Time: 9.9s
Precision: 64
\[x \cdot \frac{\frac{y}{z} \cdot t}{t}\]
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z} \le -1.63086994211637596483956921546385031623 \cdot 10^{66}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \mathbf{elif}\;\frac{y}{z} \le -6.545487680777495021156682531032583832353 \cdot 10^{-230}:\\ \;\;\;\;\frac{y}{z} \cdot x\\ \mathbf{elif}\;\frac{y}{z} \le 4.814036022956164419199695264571075550494 \cdot 10^{-12}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \end{array}\]
x \cdot \frac{\frac{y}{z} \cdot t}{t}
\begin{array}{l}
\mathbf{if}\;\frac{y}{z} \le -1.63086994211637596483956921546385031623 \cdot 10^{66}:\\
\;\;\;\;\frac{y \cdot x}{z}\\

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

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r470223 = x;
        double r470224 = y;
        double r470225 = z;
        double r470226 = r470224 / r470225;
        double r470227 = t;
        double r470228 = r470226 * r470227;
        double r470229 = r470228 / r470227;
        double r470230 = r470223 * r470229;
        return r470230;
}

double f(double x, double y, double z, double __attribute__((unused)) t) {
        double r470231 = y;
        double r470232 = z;
        double r470233 = r470231 / r470232;
        double r470234 = -1.630869942116376e+66;
        bool r470235 = r470233 <= r470234;
        double r470236 = x;
        double r470237 = r470231 * r470236;
        double r470238 = r470237 / r470232;
        double r470239 = -6.545487680777495e-230;
        bool r470240 = r470233 <= r470239;
        double r470241 = r470233 * r470236;
        double r470242 = 4.8140360229561644e-12;
        bool r470243 = r470233 <= r470242;
        double r470244 = r470232 / r470236;
        double r470245 = r470231 / r470244;
        double r470246 = r470243 ? r470238 : r470245;
        double r470247 = r470240 ? r470241 : r470246;
        double r470248 = r470235 ? r470238 : r470247;
        return r470248;
}

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

Original15.1
Target1.6
Herbie3.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 3 regimes
  2. if (/ y z) < -1.630869942116376e+66 or -6.545487680777495e-230 < (/ y z) < 4.8140360229561644e-12

    1. Initial program 17.6

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

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

    if -1.630869942116376e+66 < (/ y z) < -6.545487680777495e-230

    1. Initial program 6.5

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

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

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

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

    if 4.8140360229561644e-12 < (/ y z)

    1. Initial program 18.7

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} \le -1.63086994211637596483956921546385031623 \cdot 10^{66}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \mathbf{elif}\;\frac{y}{z} \le -6.545487680777495021156682531032583832353 \cdot 10^{-230}:\\ \;\;\;\;\frac{y}{z} \cdot x\\ \mathbf{elif}\;\frac{y}{z} \le 4.814036022956164419199695264571075550494 \cdot 10^{-12}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \end{array}\]

Reproduce

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