Average Error: 15.1 → 6.0
Time: 12.7s
Precision: 64
\[x \cdot \frac{\frac{y}{z} \cdot t}{t}\]
\[\begin{array}{l} \mathbf{if}\;z \le -5.456893094179093804320322909204701959778 \cdot 10^{-222}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;z \le -1.998153801628733335171500404420370674566 \cdot 10^{-247}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;z \le 8.447680461540099603836085647567339379828 \cdot 10^{-193}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;z \le 1.21944214684399880068881121045408236628 \cdot 10^{120}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \end{array}\]
x \cdot \frac{\frac{y}{z} \cdot t}{t}
\begin{array}{l}
\mathbf{if}\;z \le -5.456893094179093804320322909204701959778 \cdot 10^{-222}:\\
\;\;\;\;\frac{x \cdot y}{z}\\

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

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

\mathbf{elif}\;z \le 1.21944214684399880068881121045408236628 \cdot 10^{120}:\\
\;\;\;\;\frac{y}{\frac{z}{x}}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r25276231 = x;
        double r25276232 = y;
        double r25276233 = z;
        double r25276234 = r25276232 / r25276233;
        double r25276235 = t;
        double r25276236 = r25276234 * r25276235;
        double r25276237 = r25276236 / r25276235;
        double r25276238 = r25276231 * r25276237;
        return r25276238;
}

double f(double x, double y, double z, double __attribute__((unused)) t) {
        double r25276239 = z;
        double r25276240 = -5.456893094179094e-222;
        bool r25276241 = r25276239 <= r25276240;
        double r25276242 = x;
        double r25276243 = y;
        double r25276244 = r25276242 * r25276243;
        double r25276245 = r25276244 / r25276239;
        double r25276246 = -1.9981538016287333e-247;
        bool r25276247 = r25276239 <= r25276246;
        double r25276248 = r25276242 / r25276239;
        double r25276249 = r25276243 * r25276248;
        double r25276250 = 8.4476804615401e-193;
        bool r25276251 = r25276239 <= r25276250;
        double r25276252 = 1.2194421468439988e+120;
        bool r25276253 = r25276239 <= r25276252;
        double r25276254 = r25276239 / r25276242;
        double r25276255 = r25276243 / r25276254;
        double r25276256 = r25276253 ? r25276255 : r25276245;
        double r25276257 = r25276251 ? r25276245 : r25276256;
        double r25276258 = r25276247 ? r25276249 : r25276257;
        double r25276259 = r25276241 ? r25276245 : r25276258;
        return r25276259;
}

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.1
Target1.8
Herbie6.0
\[\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 z < -5.456893094179094e-222 or -1.9981538016287333e-247 < z < 8.4476804615401e-193 or 1.2194421468439988e+120 < z

    1. Initial program 15.2

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

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

    if -5.456893094179094e-222 < z < -1.9981538016287333e-247

    1. Initial program 23.4

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

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{y}}}\]
    5. Using strategy rm
    6. Applied associate-/r/8.7

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

    if 8.4476804615401e-193 < z < 1.2194421468439988e+120

    1. Initial program 14.4

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

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

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

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

      \[\leadsto \frac{\frac{x \cdot y}{\sqrt[3]{z} \cdot \sqrt[3]{z}}}{\sqrt[3]{\color{blue}{1 \cdot z}}}\]
    8. Applied cbrt-prod5.4

      \[\leadsto \frac{\frac{x \cdot y}{\sqrt[3]{z} \cdot \sqrt[3]{z}}}{\color{blue}{\sqrt[3]{1} \cdot \sqrt[3]{z}}}\]
    9. Applied *-un-lft-identity5.4

      \[\leadsto \frac{\color{blue}{1 \cdot \frac{x \cdot y}{\sqrt[3]{z} \cdot \sqrt[3]{z}}}}{\sqrt[3]{1} \cdot \sqrt[3]{z}}\]
    10. Applied times-frac5.4

      \[\leadsto \color{blue}{\frac{1}{\sqrt[3]{1}} \cdot \frac{\frac{x \cdot y}{\sqrt[3]{z} \cdot \sqrt[3]{z}}}{\sqrt[3]{z}}}\]
    11. Simplified5.4

      \[\leadsto \color{blue}{1} \cdot \frac{\frac{x \cdot y}{\sqrt[3]{z} \cdot \sqrt[3]{z}}}{\sqrt[3]{z}}\]
    12. Simplified3.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -5.456893094179093804320322909204701959778 \cdot 10^{-222}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;z \le -1.998153801628733335171500404420370674566 \cdot 10^{-247}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;z \le 8.447680461540099603836085647567339379828 \cdot 10^{-193}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;z \le 1.21944214684399880068881121045408236628 \cdot 10^{120}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \end{array}\]

Reproduce

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