Average Error: 15.3 → 0.7
Time: 11.7s
Precision: 64
\[x \cdot \frac{\frac{y}{z} \cdot t}{t}\]
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z} \le -1.548240730790440881436662006949490760264 \cdot 10^{219}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;\frac{y}{z} \le -1.442433262831919710603838797359517016977 \cdot 10^{-140}:\\ \;\;\;\;\frac{y}{z} \cdot x\\ \mathbf{elif}\;\frac{y}{z} \le -0.0:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;\frac{y}{z} \le 9.193416187857939378229423416553993724805 \cdot 10^{231}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \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.548240730790440881436662006949490760264 \cdot 10^{219}:\\
\;\;\;\;y \cdot \frac{x}{z}\\

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

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

\mathbf{elif}\;\frac{y}{z} \le 9.193416187857939378229423416553993724805 \cdot 10^{231}:\\
\;\;\;\;\frac{x}{\frac{z}{y}}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r23839111 = x;
        double r23839112 = y;
        double r23839113 = z;
        double r23839114 = r23839112 / r23839113;
        double r23839115 = t;
        double r23839116 = r23839114 * r23839115;
        double r23839117 = r23839116 / r23839115;
        double r23839118 = r23839111 * r23839117;
        return r23839118;
}

double f(double x, double y, double z, double __attribute__((unused)) t) {
        double r23839119 = y;
        double r23839120 = z;
        double r23839121 = r23839119 / r23839120;
        double r23839122 = -1.548240730790441e+219;
        bool r23839123 = r23839121 <= r23839122;
        double r23839124 = x;
        double r23839125 = r23839124 / r23839120;
        double r23839126 = r23839119 * r23839125;
        double r23839127 = -1.4424332628319197e-140;
        bool r23839128 = r23839121 <= r23839127;
        double r23839129 = r23839121 * r23839124;
        double r23839130 = -0.0;
        bool r23839131 = r23839121 <= r23839130;
        double r23839132 = 9.19341618785794e+231;
        bool r23839133 = r23839121 <= r23839132;
        double r23839134 = r23839120 / r23839119;
        double r23839135 = r23839124 / r23839134;
        double r23839136 = r23839124 * r23839119;
        double r23839137 = r23839136 / r23839120;
        double r23839138 = r23839133 ? r23839135 : r23839137;
        double r23839139 = r23839131 ? r23839126 : r23839138;
        double r23839140 = r23839128 ? r23839129 : r23839139;
        double r23839141 = r23839123 ? r23839126 : r23839140;
        return r23839141;
}

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.3
Target1.6
Herbie0.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 4 regimes
  2. if (/ y z) < -1.548240730790441e+219 or -1.4424332628319197e-140 < (/ y z) < -0.0

    1. Initial program 22.6

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

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

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

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

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

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

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

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

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

    if -1.548240730790441e+219 < (/ y z) < -1.4424332628319197e-140

    1. Initial program 8.5

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

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

      \[\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 -0.0 < (/ y z) < 9.19341618785794e+231

    1. Initial program 10.8

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

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

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

    if 9.19341618785794e+231 < (/ y z)

    1. Initial program 45.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} \le -1.548240730790440881436662006949490760264 \cdot 10^{219}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;\frac{y}{z} \le -1.442433262831919710603838797359517016977 \cdot 10^{-140}:\\ \;\;\;\;\frac{y}{z} \cdot x\\ \mathbf{elif}\;\frac{y}{z} \le -0.0:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;\frac{y}{z} \le 9.193416187857939378229423416553993724805 \cdot 10^{231}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \end{array}\]

Reproduce

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