Average Error: 14.8 → 0.5
Time: 15.4s
Precision: 64
\[x \cdot \frac{\frac{y}{z} \cdot t}{t}\]
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z} \le -5.422773879432081316361824486038416445882 \cdot 10^{151}:\\ \;\;\;\;\frac{1}{\frac{z}{y \cdot x}}\\ \mathbf{elif}\;\frac{y}{z} \le -5.10484190542812669037692225063426301177 \cdot 10^{-201}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;\frac{y}{z} \le 2.774265247967482801945189091940352026471 \cdot 10^{-185}:\\ \;\;\;\;\frac{x}{z} \cdot y\\ \mathbf{elif}\;\frac{y}{z} \le 2.981277762077973021880053045655171198882 \cdot 10^{261}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} \cdot y\\ \end{array}\]
x \cdot \frac{\frac{y}{z} \cdot t}{t}
\begin{array}{l}
\mathbf{if}\;\frac{y}{z} \le -5.422773879432081316361824486038416445882 \cdot 10^{151}:\\
\;\;\;\;\frac{1}{\frac{z}{y \cdot x}}\\

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

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

\mathbf{elif}\;\frac{y}{z} \le 2.981277762077973021880053045655171198882 \cdot 10^{261}:\\
\;\;\;\;x \cdot \frac{y}{z}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r14901453 = x;
        double r14901454 = y;
        double r14901455 = z;
        double r14901456 = r14901454 / r14901455;
        double r14901457 = t;
        double r14901458 = r14901456 * r14901457;
        double r14901459 = r14901458 / r14901457;
        double r14901460 = r14901453 * r14901459;
        return r14901460;
}

double f(double x, double y, double z, double __attribute__((unused)) t) {
        double r14901461 = y;
        double r14901462 = z;
        double r14901463 = r14901461 / r14901462;
        double r14901464 = -5.422773879432081e+151;
        bool r14901465 = r14901463 <= r14901464;
        double r14901466 = 1.0;
        double r14901467 = x;
        double r14901468 = r14901461 * r14901467;
        double r14901469 = r14901462 / r14901468;
        double r14901470 = r14901466 / r14901469;
        double r14901471 = -5.104841905428127e-201;
        bool r14901472 = r14901463 <= r14901471;
        double r14901473 = r14901467 * r14901463;
        double r14901474 = 2.7742652479674828e-185;
        bool r14901475 = r14901463 <= r14901474;
        double r14901476 = r14901467 / r14901462;
        double r14901477 = r14901476 * r14901461;
        double r14901478 = 2.981277762077973e+261;
        bool r14901479 = r14901463 <= r14901478;
        double r14901480 = r14901479 ? r14901473 : r14901477;
        double r14901481 = r14901475 ? r14901477 : r14901480;
        double r14901482 = r14901472 ? r14901473 : r14901481;
        double r14901483 = r14901465 ? r14901470 : r14901482;
        return r14901483;
}

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.6
Herbie0.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) < -5.422773879432081e+151

    1. Initial program 36.5

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

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

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

    if -5.422773879432081e+151 < (/ y z) < -5.104841905428127e-201 or 2.7742652479674828e-185 < (/ y z) < 2.981277762077973e+261

    1. Initial program 8.2

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

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

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

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

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

    if -5.104841905428127e-201 < (/ y z) < 2.7742652479674828e-185 or 2.981277762077973e+261 < (/ y z)

    1. Initial program 21.4

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

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

      \[\leadsto \color{blue}{\left(x \cdot y\right) \cdot \frac{1}{z}}\]
    5. Using strategy rm
    6. Applied pow10.4

      \[\leadsto \left(x \cdot y\right) \cdot \color{blue}{{\left(\frac{1}{z}\right)}^{1}}\]
    7. Applied pow10.4

      \[\leadsto \left(x \cdot \color{blue}{{y}^{1}}\right) \cdot {\left(\frac{1}{z}\right)}^{1}\]
    8. Applied pow10.4

      \[\leadsto \left(\color{blue}{{x}^{1}} \cdot {y}^{1}\right) \cdot {\left(\frac{1}{z}\right)}^{1}\]
    9. Applied pow-prod-down0.4

      \[\leadsto \color{blue}{{\left(x \cdot y\right)}^{1}} \cdot {\left(\frac{1}{z}\right)}^{1}\]
    10. Applied pow-prod-down0.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} \le -5.422773879432081316361824486038416445882 \cdot 10^{151}:\\ \;\;\;\;\frac{1}{\frac{z}{y \cdot x}}\\ \mathbf{elif}\;\frac{y}{z} \le -5.10484190542812669037692225063426301177 \cdot 10^{-201}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;\frac{y}{z} \le 2.774265247967482801945189091940352026471 \cdot 10^{-185}:\\ \;\;\;\;\frac{x}{z} \cdot y\\ \mathbf{elif}\;\frac{y}{z} \le 2.981277762077973021880053045655171198882 \cdot 10^{261}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} \cdot y\\ \end{array}\]

Reproduce

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