Average Error: 14.4 → 1.8
Time: 7.2s
Precision: 64
\[x \cdot \frac{\frac{y}{z} \cdot t}{t}\]
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z} = -\infty:\\ \;\;\;\;\frac{1}{\frac{z}{y \cdot x}}\\ \mathbf{elif}\;\frac{y}{z} \le -1.277987902397856 \cdot 10^{-271}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;\frac{y}{z} \le 1.484083870392539 \cdot 10^{-222}:\\ \;\;\;\;\left(y \cdot x\right) \cdot \frac{1}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \end{array}\]
x \cdot \frac{\frac{y}{z} \cdot t}{t}
\begin{array}{l}
\mathbf{if}\;\frac{y}{z} = -\infty:\\
\;\;\;\;\frac{1}{\frac{z}{y \cdot x}}\\

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

\mathbf{elif}\;\frac{y}{z} \le 1.484083870392539 \cdot 10^{-222}:\\
\;\;\;\;\left(y \cdot x\right) \cdot \frac{1}{z}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r10125326 = x;
        double r10125327 = y;
        double r10125328 = z;
        double r10125329 = r10125327 / r10125328;
        double r10125330 = t;
        double r10125331 = r10125329 * r10125330;
        double r10125332 = r10125331 / r10125330;
        double r10125333 = r10125326 * r10125332;
        return r10125333;
}

double f(double x, double y, double z, double __attribute__((unused)) t) {
        double r10125334 = y;
        double r10125335 = z;
        double r10125336 = r10125334 / r10125335;
        double r10125337 = -inf.0;
        bool r10125338 = r10125336 <= r10125337;
        double r10125339 = 1.0;
        double r10125340 = x;
        double r10125341 = r10125334 * r10125340;
        double r10125342 = r10125335 / r10125341;
        double r10125343 = r10125339 / r10125342;
        double r10125344 = -1.277987902397856e-271;
        bool r10125345 = r10125336 <= r10125344;
        double r10125346 = r10125340 * r10125336;
        double r10125347 = 1.484083870392539e-222;
        bool r10125348 = r10125336 <= r10125347;
        double r10125349 = r10125339 / r10125335;
        double r10125350 = r10125341 * r10125349;
        double r10125351 = r10125348 ? r10125350 : r10125346;
        double r10125352 = r10125345 ? r10125346 : r10125351;
        double r10125353 = r10125338 ? r10125343 : r10125352;
        return r10125353;
}

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.4
Target1.4
Herbie1.8
\[\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) < -inf.0

    1. Initial program 60.1

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

      \[\leadsto \color{blue}{y \cdot \frac{x}{z}}\]
    3. Taylor expanded around 0 0.3

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

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

    if -inf.0 < (/ y z) < -1.277987902397856e-271 or 1.484083870392539e-222 < (/ y z)

    1. Initial program 11.9

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

      \[\leadsto \color{blue}{y \cdot \frac{x}{z}}\]
    3. Taylor expanded around 0 8.2

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

      \[\leadsto \frac{x \cdot y}{\color{blue}{1 \cdot z}}\]
    6. Applied times-frac2.3

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

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

    if -1.277987902397856e-271 < (/ y z) < 1.484083870392539e-222

    1. Initial program 18.0

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} = -\infty:\\ \;\;\;\;\frac{1}{\frac{z}{y \cdot x}}\\ \mathbf{elif}\;\frac{y}{z} \le -1.277987902397856 \cdot 10^{-271}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;\frac{y}{z} \le 1.484083870392539 \cdot 10^{-222}:\\ \;\;\;\;\left(y \cdot x\right) \cdot \frac{1}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \end{array}\]

Reproduce

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