Average Error: 14.5 → 0.3
Time: 12.6s
Precision: 64
\[x \cdot \frac{\frac{y}{z} \cdot t}{t}\]
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z} \le -2.2592621423955549 \cdot 10^{306}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;\frac{y}{z} \le -1.8557707244669514 \cdot 10^{-271}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;\frac{y}{z} \le 6.22729521642663493 \cdot 10^{-190}:\\ \;\;\;\;\left(x \cdot y\right) \cdot \frac{1}{z}\\ \mathbf{elif}\;\frac{y}{z} \le 6.2094051295440155 \cdot 10^{253}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \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 -2.2592621423955549 \cdot 10^{306}:\\
\;\;\;\;\frac{x \cdot y}{z}\\

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

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

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r657182 = x;
        double r657183 = y;
        double r657184 = z;
        double r657185 = r657183 / r657184;
        double r657186 = t;
        double r657187 = r657185 * r657186;
        double r657188 = r657187 / r657186;
        double r657189 = r657182 * r657188;
        return r657189;
}

double f(double x, double y, double z, double __attribute__((unused)) t) {
        double r657190 = y;
        double r657191 = z;
        double r657192 = r657190 / r657191;
        double r657193 = -2.259262142395555e+306;
        bool r657194 = r657192 <= r657193;
        double r657195 = x;
        double r657196 = r657195 * r657190;
        double r657197 = r657196 / r657191;
        double r657198 = -1.8557707244669514e-271;
        bool r657199 = r657192 <= r657198;
        double r657200 = r657195 * r657192;
        double r657201 = 6.227295216426635e-190;
        bool r657202 = r657192 <= r657201;
        double r657203 = 1.0;
        double r657204 = r657203 / r657191;
        double r657205 = r657196 * r657204;
        double r657206 = 6.209405129544016e+253;
        bool r657207 = r657192 <= r657206;
        double r657208 = r657207 ? r657200 : r657197;
        double r657209 = r657202 ? r657205 : r657208;
        double r657210 = r657199 ? r657200 : r657209;
        double r657211 = r657194 ? r657197 : r657210;
        return r657211;
}

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.5
Target1.3
Herbie0.3
\[\begin{array}{l} \mathbf{if}\;\frac{\frac{y}{z} \cdot t}{t} \lt -1.20672205123045005 \cdot 10^{245}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;\frac{\frac{y}{z} \cdot t}{t} \lt -5.90752223693390633 \cdot 10^{-275}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;\frac{\frac{y}{z} \cdot t}{t} \lt 5.65895442315341522 \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) < -2.259262142395555e+306 or 6.209405129544016e+253 < (/ y z)

    1. Initial program 56.0

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

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

      \[\leadsto x \cdot \frac{y}{\color{blue}{\left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \sqrt[3]{z}}}\]
    5. Applied *-un-lft-identity49.7

      \[\leadsto x \cdot \frac{\color{blue}{1 \cdot y}}{\left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \sqrt[3]{z}}\]
    6. Applied times-frac49.7

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

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

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

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

    if -2.259262142395555e+306 < (/ y z) < -1.8557707244669514e-271 or 6.227295216426635e-190 < (/ y z) < 6.209405129544016e+253

    1. Initial program 9.3

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

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

    if -1.8557707244669514e-271 < (/ y z) < 6.227295216426635e-190

    1. Initial program 17.3

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} \le -2.2592621423955549 \cdot 10^{306}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;\frac{y}{z} \le -1.8557707244669514 \cdot 10^{-271}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;\frac{y}{z} \le 6.22729521642663493 \cdot 10^{-190}:\\ \;\;\;\;\left(x \cdot y\right) \cdot \frac{1}{z}\\ \mathbf{elif}\;\frac{y}{z} \le 6.2094051295440155 \cdot 10^{253}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \end{array}\]

Reproduce

herbie shell --seed 2020046 +o rules:numerics
(FPCore (x y z t)
  :name "Graphics.Rendering.Chart.Backend.Diagrams:calcFontMetrics from Chart-diagrams-1.5.1, B"
  :precision binary64

  :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)))