Average Error: 14.6 → 5.7
Time: 9.6s
Precision: 64
\[x \cdot \frac{\frac{y}{z} \cdot t}{t}\]
\[\begin{array}{l} \mathbf{if}\;t \le -9.926373121714999364733704764752531243436 \cdot 10^{-253}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;t \le 602927915546591127029321564160:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \end{array}\]
x \cdot \frac{\frac{y}{z} \cdot t}{t}
\begin{array}{l}
\mathbf{if}\;t \le -9.926373121714999364733704764752531243436 \cdot 10^{-253}:\\
\;\;\;\;\frac{y}{\frac{z}{x}}\\

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r353285 = x;
        double r353286 = y;
        double r353287 = z;
        double r353288 = r353286 / r353287;
        double r353289 = t;
        double r353290 = r353288 * r353289;
        double r353291 = r353290 / r353289;
        double r353292 = r353285 * r353291;
        return r353292;
}

double f(double x, double y, double z, double t) {
        double r353293 = t;
        double r353294 = -9.926373121714999e-253;
        bool r353295 = r353293 <= r353294;
        double r353296 = y;
        double r353297 = z;
        double r353298 = x;
        double r353299 = r353297 / r353298;
        double r353300 = r353296 / r353299;
        double r353301 = 6.029279155465911e+29;
        bool r353302 = r353293 <= r353301;
        double r353303 = r353297 / r353296;
        double r353304 = r353298 / r353303;
        double r353305 = r353296 * r353298;
        double r353306 = r353305 / r353297;
        double r353307 = r353302 ? r353304 : r353306;
        double r353308 = r353295 ? r353300 : r353307;
        return r353308;
}

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.6
Target1.5
Herbie5.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 t < -9.926373121714999e-253

    1. Initial program 13.5

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

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

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

    if -9.926373121714999e-253 < t < 6.029279155465911e+29

    1. Initial program 15.6

      \[x \cdot \frac{\frac{y}{z} \cdot t}{t}\]
    2. Simplified6.0

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

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

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

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

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

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

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

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

    if 6.029279155465911e+29 < t

    1. Initial program 15.4

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

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

      \[\leadsto \color{blue}{\left(y \cdot x\right) \cdot \frac{1}{z}}\]
    5. Using strategy rm
    6. Applied un-div-inv5.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -9.926373121714999364733704764752531243436 \cdot 10^{-253}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;t \le 602927915546591127029321564160:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \end{array}\]

Reproduce

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