Average Error: 14.3 → 1.6
Time: 20.2s
Precision: 64
\[x \cdot \frac{\frac{y}{z} \cdot t}{t}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot \frac{\frac{y}{z} \cdot t}{t} = -\infty:\\ \;\;\;\;\frac{1}{z} \cdot \left(x \cdot y\right)\\ \mathbf{elif}\;x \cdot \frac{\frac{y}{z} \cdot t}{t} \le -2.643654455052194 \cdot 10^{-281}:\\ \;\;\;\;x \cdot \frac{\frac{y}{z} \cdot t}{t}\\ \mathbf{elif}\;x \cdot \frac{\frac{y}{z} \cdot t}{t} \le 0.0:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;x \cdot \frac{\frac{y}{z} \cdot t}{t} \le 5.955864120415916 \cdot 10^{+280}:\\ \;\;\;\;x \cdot \frac{\frac{y}{z} \cdot t}{t}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \end{array}\]
x \cdot \frac{\frac{y}{z} \cdot t}{t}
\begin{array}{l}
\mathbf{if}\;x \cdot \frac{\frac{y}{z} \cdot t}{t} = -\infty:\\
\;\;\;\;\frac{1}{z} \cdot \left(x \cdot y\right)\\

\mathbf{elif}\;x \cdot \frac{\frac{y}{z} \cdot t}{t} \le -2.643654455052194 \cdot 10^{-281}:\\
\;\;\;\;x \cdot \frac{\frac{y}{z} \cdot t}{t}\\

\mathbf{elif}\;x \cdot \frac{\frac{y}{z} \cdot t}{t} \le 0.0:\\
\;\;\;\;\frac{x \cdot y}{z}\\

\mathbf{elif}\;x \cdot \frac{\frac{y}{z} \cdot t}{t} \le 5.955864120415916 \cdot 10^{+280}:\\
\;\;\;\;x \cdot \frac{\frac{y}{z} \cdot t}{t}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r27466243 = x;
        double r27466244 = y;
        double r27466245 = z;
        double r27466246 = r27466244 / r27466245;
        double r27466247 = t;
        double r27466248 = r27466246 * r27466247;
        double r27466249 = r27466248 / r27466247;
        double r27466250 = r27466243 * r27466249;
        return r27466250;
}

double f(double x, double y, double z, double t) {
        double r27466251 = x;
        double r27466252 = y;
        double r27466253 = z;
        double r27466254 = r27466252 / r27466253;
        double r27466255 = t;
        double r27466256 = r27466254 * r27466255;
        double r27466257 = r27466256 / r27466255;
        double r27466258 = r27466251 * r27466257;
        double r27466259 = -inf.0;
        bool r27466260 = r27466258 <= r27466259;
        double r27466261 = 1.0;
        double r27466262 = r27466261 / r27466253;
        double r27466263 = r27466251 * r27466252;
        double r27466264 = r27466262 * r27466263;
        double r27466265 = -2.643654455052194e-281;
        bool r27466266 = r27466258 <= r27466265;
        double r27466267 = 0.0;
        bool r27466268 = r27466258 <= r27466267;
        double r27466269 = r27466263 / r27466253;
        double r27466270 = 5.955864120415916e+280;
        bool r27466271 = r27466258 <= r27466270;
        double r27466272 = r27466251 / r27466253;
        double r27466273 = r27466252 * r27466272;
        double r27466274 = r27466271 ? r27466258 : r27466273;
        double r27466275 = r27466268 ? r27466269 : r27466274;
        double r27466276 = r27466266 ? r27466258 : r27466275;
        double r27466277 = r27466260 ? r27466264 : r27466276;
        return r27466277;
}

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.3
Target1.7
Herbie1.6
\[\begin{array}{l} \mathbf{if}\;\frac{\frac{y}{z} \cdot t}{t} \lt -1.20672205123045 \cdot 10^{+245}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;\frac{\frac{y}{z} \cdot t}{t} \lt -5.907522236933906 \cdot 10^{-275}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;\frac{\frac{y}{z} \cdot t}{t} \lt 5.658954423153415 \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 4 regimes
  2. if (* x (/ (* (/ y z) t) t)) < -inf.0

    1. Initial program 60.6

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

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

      \[\leadsto y \cdot \frac{x}{\color{blue}{1 \cdot z}}\]
    5. Applied add-cube-cbrt4.5

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

      \[\leadsto y \cdot \color{blue}{\left(\frac{\sqrt[3]{x} \cdot \sqrt[3]{x}}{1} \cdot \frac{\sqrt[3]{x}}{z}\right)}\]
    7. Applied associate-*r*3.7

      \[\leadsto \color{blue}{\left(y \cdot \frac{\sqrt[3]{x} \cdot \sqrt[3]{x}}{1}\right) \cdot \frac{\sqrt[3]{x}}{z}}\]
    8. Simplified3.7

      \[\leadsto \color{blue}{\left(\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot y\right)} \cdot \frac{\sqrt[3]{x}}{z}\]
    9. Using strategy rm
    10. Applied div-inv3.7

      \[\leadsto \left(\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot y\right) \cdot \color{blue}{\left(\sqrt[3]{x} \cdot \frac{1}{z}\right)}\]
    11. Applied associate-*r*4.2

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

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

    if -inf.0 < (* x (/ (* (/ y z) t) t)) < -2.643654455052194e-281 or 0.0 < (* x (/ (* (/ y z) t) t)) < 5.955864120415916e+280

    1. Initial program 1.0

      \[x \cdot \frac{\frac{y}{z} \cdot t}{t}\]

    if -2.643654455052194e-281 < (* x (/ (* (/ y z) t) t)) < 0.0

    1. Initial program 21.1

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

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

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

    if 5.955864120415916e+280 < (* x (/ (* (/ y z) t) t))

    1. Initial program 53.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot \frac{\frac{y}{z} \cdot t}{t} = -\infty:\\ \;\;\;\;\frac{1}{z} \cdot \left(x \cdot y\right)\\ \mathbf{elif}\;x \cdot \frac{\frac{y}{z} \cdot t}{t} \le -2.643654455052194 \cdot 10^{-281}:\\ \;\;\;\;x \cdot \frac{\frac{y}{z} \cdot t}{t}\\ \mathbf{elif}\;x \cdot \frac{\frac{y}{z} \cdot t}{t} \le 0.0:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;x \cdot \frac{\frac{y}{z} \cdot t}{t} \le 5.955864120415916 \cdot 10^{+280}:\\ \;\;\;\;x \cdot \frac{\frac{y}{z} \cdot t}{t}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \end{array}\]

Reproduce

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