Average Error: 15.2 → 3.5
Time: 13.9s
Precision: 64
\[x \cdot \frac{\frac{y}{z} \cdot t}{t}\]
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z} \le 1.33272593359145646097923062849387621848 \cdot 10^{-315}:\\ \;\;\;\;y \cdot \left(x \cdot \frac{1}{z}\right)\\ \mathbf{elif}\;\frac{y}{z} \le 5.677676213585449009539499455320000877411 \cdot 10^{146}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \end{array}\]
x \cdot \frac{\frac{y}{z} \cdot t}{t}
\begin{array}{l}
\mathbf{if}\;\frac{y}{z} \le 1.33272593359145646097923062849387621848 \cdot 10^{-315}:\\
\;\;\;\;y \cdot \left(x \cdot \frac{1}{z}\right)\\

\mathbf{elif}\;\frac{y}{z} \le 5.677676213585449009539499455320000877411 \cdot 10^{146}:\\
\;\;\;\;x \cdot \frac{y}{z}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r519216 = x;
        double r519217 = y;
        double r519218 = z;
        double r519219 = r519217 / r519218;
        double r519220 = t;
        double r519221 = r519219 * r519220;
        double r519222 = r519221 / r519220;
        double r519223 = r519216 * r519222;
        return r519223;
}

double f(double x, double y, double z, double __attribute__((unused)) t) {
        double r519224 = y;
        double r519225 = z;
        double r519226 = r519224 / r519225;
        double r519227 = 1.3327259335915e-315;
        bool r519228 = r519226 <= r519227;
        double r519229 = x;
        double r519230 = 1.0;
        double r519231 = r519230 / r519225;
        double r519232 = r519229 * r519231;
        double r519233 = r519224 * r519232;
        double r519234 = 5.677676213585449e+146;
        bool r519235 = r519226 <= r519234;
        double r519236 = r519229 * r519226;
        double r519237 = r519229 * r519224;
        double r519238 = r519237 / r519225;
        double r519239 = r519235 ? r519236 : r519238;
        double r519240 = r519228 ? r519233 : r519239;
        return r519240;
}

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.2
Target1.6
Herbie3.5
\[\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.3327259335915e-315

    1. Initial program 15.7

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

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

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

      \[\leadsto \frac{1}{\color{blue}{\frac{\frac{z}{x}}{y}}}\]
    6. Using strategy rm
    7. Applied div-inv6.0

      \[\leadsto \frac{1}{\color{blue}{\frac{z}{x} \cdot \frac{1}{y}}}\]
    8. Applied add-cube-cbrt6.0

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{\frac{z}{x} \cdot \frac{1}{y}}\]
    9. Applied times-frac5.9

      \[\leadsto \color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\frac{z}{x}} \cdot \frac{\sqrt[3]{1}}{\frac{1}{y}}}\]
    10. Simplified5.7

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

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

    if 1.3327259335915e-315 < (/ y z) < 5.677676213585449e+146

    1. Initial program 8.8

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

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

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

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

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

    if 5.677676213585449e+146 < (/ y z)

    1. Initial program 35.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} \le 1.33272593359145646097923062849387621848 \cdot 10^{-315}:\\ \;\;\;\;y \cdot \left(x \cdot \frac{1}{z}\right)\\ \mathbf{elif}\;\frac{y}{z} \le 5.677676213585449009539499455320000877411 \cdot 10^{146}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \end{array}\]

Reproduce

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