Average Error: 14.3 → 0.3
Time: 15.2s
Precision: 64
\[x \cdot \frac{\frac{y}{z} \cdot t}{t}\]
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z} \le -5.49778287371169 \cdot 10^{+261}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;\frac{y}{z} \le -1.983516013696309 \cdot 10^{-226}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{elif}\;\frac{y}{z} \le 9.35914650043368 \cdot 10^{-309}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;\frac{y}{z} \le 8.460748976825988 \cdot 10^{+248}:\\ \;\;\;\;\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 -5.49778287371169 \cdot 10^{+261}:\\
\;\;\;\;\frac{x \cdot y}{z}\\

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

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

\mathbf{elif}\;\frac{y}{z} \le 8.460748976825988 \cdot 10^{+248}:\\
\;\;\;\;\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 r17087302 = x;
        double r17087303 = y;
        double r17087304 = z;
        double r17087305 = r17087303 / r17087304;
        double r17087306 = t;
        double r17087307 = r17087305 * r17087306;
        double r17087308 = r17087307 / r17087306;
        double r17087309 = r17087302 * r17087308;
        return r17087309;
}

double f(double x, double y, double z, double __attribute__((unused)) t) {
        double r17087310 = y;
        double r17087311 = z;
        double r17087312 = r17087310 / r17087311;
        double r17087313 = -5.49778287371169e+261;
        bool r17087314 = r17087312 <= r17087313;
        double r17087315 = x;
        double r17087316 = r17087315 * r17087310;
        double r17087317 = r17087316 / r17087311;
        double r17087318 = -1.983516013696309e-226;
        bool r17087319 = r17087312 <= r17087318;
        double r17087320 = r17087311 / r17087310;
        double r17087321 = r17087315 / r17087320;
        double r17087322 = 9.35914650043368e-309;
        bool r17087323 = r17087312 <= r17087322;
        double r17087324 = r17087315 / r17087311;
        double r17087325 = r17087310 * r17087324;
        double r17087326 = 8.460748976825988e+248;
        bool r17087327 = r17087312 <= r17087326;
        double r17087328 = r17087327 ? r17087321 : r17087317;
        double r17087329 = r17087323 ? r17087325 : r17087328;
        double r17087330 = r17087319 ? r17087321 : r17087329;
        double r17087331 = r17087314 ? r17087317 : r17087330;
        return r17087331;
}

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
Herbie0.3
\[\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 3 regimes
  2. if (/ y z) < -5.49778287371169e+261 or 8.460748976825988e+248 < (/ y z)

    1. Initial program 48.9

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

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

      \[\leadsto y \cdot \frac{x}{\color{blue}{1 \cdot z}}\]
    5. Applied add-cube-cbrt1.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-frac1.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*1.4

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

      \[\leadsto \color{blue}{\left(\left(y \cdot \sqrt[3]{x}\right) \cdot \sqrt[3]{x}\right)} \cdot \frac{\sqrt[3]{x}}{z}\]
    9. Using strategy rm
    10. Applied associate-*r/1.5

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

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

    if -5.49778287371169e+261 < (/ y z) < -1.983516013696309e-226 or 9.35914650043368e-309 < (/ y z) < 8.460748976825988e+248

    1. Initial program 9.5

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

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

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

      \[\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-frac9.3

      \[\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*7.2

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

      \[\leadsto \color{blue}{\left(\left(y \cdot \sqrt[3]{x}\right) \cdot \sqrt[3]{x}\right)} \cdot \frac{\sqrt[3]{x}}{z}\]
    9. Using strategy rm
    10. Applied associate-*r/9.0

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

      \[\leadsto \frac{\color{blue}{x \cdot y}}{z}\]
    12. Using strategy rm
    13. Applied associate-/l*0.2

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

    if -1.983516013696309e-226 < (/ y z) < 9.35914650043368e-309

    1. Initial program 17.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} \le -5.49778287371169 \cdot 10^{+261}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;\frac{y}{z} \le -1.983516013696309 \cdot 10^{-226}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{elif}\;\frac{y}{z} \le 9.35914650043368 \cdot 10^{-309}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;\frac{y}{z} \le 8.460748976825988 \cdot 10^{+248}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{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)))