Average Error: 14.7 → 0.3
Time: 10.2s
Precision: 64
\[x \cdot \frac{\frac{y}{z} \cdot t}{t}\]
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z} = -\infty:\\ \;\;\;\;\left(x \cdot y\right) \cdot \frac{1}{z}\\ \mathbf{elif}\;\frac{y}{z} \le -2.260559411855018598510891206887091885181 \cdot 10^{-253}:\\ \;\;\;\;\frac{y}{z} \cdot x\\ \mathbf{elif}\;\frac{y}{z} \le 3.757059281014894097749857788400547545613 \cdot 10^{-220}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;\frac{y}{z} \le 1.409130514825537046443418609777720419861 \cdot 10^{217}:\\ \;\;\;\;\frac{y}{z} \cdot x\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \end{array}\]
x \cdot \frac{\frac{y}{z} \cdot t}{t}
\begin{array}{l}
\mathbf{if}\;\frac{y}{z} = -\infty:\\
\;\;\;\;\left(x \cdot y\right) \cdot \frac{1}{z}\\

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

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

\mathbf{elif}\;\frac{y}{z} \le 1.409130514825537046443418609777720419861 \cdot 10^{217}:\\
\;\;\;\;\frac{y}{z} \cdot x\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r539204 = x;
        double r539205 = y;
        double r539206 = z;
        double r539207 = r539205 / r539206;
        double r539208 = t;
        double r539209 = r539207 * r539208;
        double r539210 = r539209 / r539208;
        double r539211 = r539204 * r539210;
        return r539211;
}

double f(double x, double y, double z, double __attribute__((unused)) t) {
        double r539212 = y;
        double r539213 = z;
        double r539214 = r539212 / r539213;
        double r539215 = -inf.0;
        bool r539216 = r539214 <= r539215;
        double r539217 = x;
        double r539218 = r539217 * r539212;
        double r539219 = 1.0;
        double r539220 = r539219 / r539213;
        double r539221 = r539218 * r539220;
        double r539222 = -2.2605594118550186e-253;
        bool r539223 = r539214 <= r539222;
        double r539224 = r539214 * r539217;
        double r539225 = 3.757059281014894e-220;
        bool r539226 = r539214 <= r539225;
        double r539227 = r539218 / r539213;
        double r539228 = 1.409130514825537e+217;
        bool r539229 = r539214 <= r539228;
        double r539230 = r539217 / r539213;
        double r539231 = r539212 * r539230;
        double r539232 = r539229 ? r539224 : r539231;
        double r539233 = r539226 ? r539227 : r539232;
        double r539234 = r539223 ? r539224 : r539233;
        double r539235 = r539216 ? r539221 : r539234;
        return r539235;
}

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.7
Target1.6
Herbie0.3
\[\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) < -inf.0

    1. Initial program 64.0

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

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

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

    if -inf.0 < (/ y z) < -2.2605594118550186e-253 or 3.757059281014894e-220 < (/ y z) < 1.409130514825537e+217

    1. Initial program 9.5

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

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

      \[\leadsto \frac{x \cdot y}{\color{blue}{1 \cdot z}}\]
    5. Applied times-frac0.2

      \[\leadsto \color{blue}{\frac{x}{1} \cdot \frac{y}{z}}\]
    6. Simplified0.2

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

    if -2.2605594118550186e-253 < (/ y z) < 3.757059281014894e-220

    1. Initial program 18.7

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

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

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

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

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

    if 1.409130514825537e+217 < (/ y z)

    1. Initial program 44.0

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

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

      \[\leadsto \color{blue}{\left(x \cdot y\right) \cdot \frac{1}{z}}\]
    5. Taylor expanded around 0 1.0

      \[\leadsto \color{blue}{\frac{x \cdot y}{z}}\]
    6. Simplified0.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} = -\infty:\\ \;\;\;\;\left(x \cdot y\right) \cdot \frac{1}{z}\\ \mathbf{elif}\;\frac{y}{z} \le -2.260559411855018598510891206887091885181 \cdot 10^{-253}:\\ \;\;\;\;\frac{y}{z} \cdot x\\ \mathbf{elif}\;\frac{y}{z} \le 3.757059281014894097749857788400547545613 \cdot 10^{-220}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;\frac{y}{z} \le 1.409130514825537046443418609777720419861 \cdot 10^{217}:\\ \;\;\;\;\frac{y}{z} \cdot x\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \end{array}\]

Reproduce

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