Average Error: 14.3 → 0.3
Time: 4.4s
Precision: binary64
Cost: 2116
\[x \cdot \frac{\frac{y}{z} \cdot t}{t}\]
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z} \leq -\infty:\\ \;\;\;\;\frac{1}{\frac{z}{y \cdot x}}\\ \mathbf{elif}\;\frac{y}{z} \leq -3.1180330985036686 \cdot 10^{-216}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{elif}\;\frac{y}{z} \leq 4.9952376169741 \cdot 10^{-312}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \mathbf{elif}\;\frac{y}{z} \leq 4.684813618637737 \cdot 10^{+228}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \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} \leq -\infty:\\
\;\;\;\;\frac{1}{\frac{z}{y \cdot x}}\\

\mathbf{elif}\;\frac{y}{z} \leq -3.1180330985036686 \cdot 10^{-216}:\\
\;\;\;\;\frac{x}{\frac{z}{y}}\\

\mathbf{elif}\;\frac{y}{z} \leq 4.9952376169741 \cdot 10^{-312}:\\
\;\;\;\;\frac{y \cdot x}{z}\\

\mathbf{elif}\;\frac{y}{z} \leq 4.684813618637737 \cdot 10^{+228}:\\
\;\;\;\;\frac{x}{\frac{z}{y}}\\

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

\end{array}
(FPCore (x y z t) :precision binary64 (* x (/ (* (/ y z) t) t)))
(FPCore (x y z t)
 :precision binary64
 (if (<= (/ y z) (- INFINITY))
   (/ 1.0 (/ z (* y x)))
   (if (<= (/ y z) -3.1180330985036686e-216)
     (/ x (/ z y))
     (if (<= (/ y z) 4.9952376169741e-312)
       (/ (* y x) z)
       (if (<= (/ y z) 4.684813618637737e+228) (/ x (/ z y)) (* y (/ x z)))))))
double code(double x, double y, double z, double t) {
	return x * (((y / z) * t) / t);
}
double code(double x, double y, double z, double t) {
	double tmp;
	if ((y / z) <= -((double) INFINITY)) {
		tmp = 1.0 / (z / (y * x));
	} else if ((y / z) <= -3.1180330985036686e-216) {
		tmp = x / (z / y);
	} else if ((y / z) <= 4.9952376169741e-312) {
		tmp = (y * x) / z;
	} else if ((y / z) <= 4.684813618637737e+228) {
		tmp = x / (z / y);
	} else {
		tmp = y * (x / z);
	}
	return tmp;
}

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.5
Herbie0.3
\[\begin{array}{l} \mathbf{if}\;\frac{\frac{y}{z} \cdot t}{t} < -1.20672205123045 \cdot 10^{+245}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;\frac{\frac{y}{z} \cdot t}{t} < -5.907522236933906 \cdot 10^{-275}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;\frac{\frac{y}{z} \cdot t}{t} < 5.658954423153415 \cdot 10^{-65}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;\frac{\frac{y}{z} \cdot t}{t} < 2.0087180502407133 \cdot 10^{+217}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \end{array}\]

Alternatives

Alternative 1
Error0.3
Cost2116
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z} \leq -3.431472775525451 \cdot 10^{+259}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;\frac{y}{z} \leq -3.1180330985036686 \cdot 10^{-216}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{elif}\;\frac{y}{z} \leq 4.9952376169741 \cdot 10^{-312}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \mathbf{elif}\;\frac{y}{z} \leq 4.684813618637737 \cdot 10^{+228}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \end{array}\]
Alternative 2
Error5.8
Cost780
\[\begin{array}{l} \mathbf{if}\;x \leq -3.3691295266296924 \cdot 10^{+156} \lor \neg \left(x \leq -1.3557895013828875 \cdot 10^{-211}\right) \land x \leq 8.926094127391968 \cdot 10^{+162}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \end{array}\]
Alternative 3
Error5.8
Cost320
\[y \cdot \frac{x}{z}\]
Alternative 4
Error49.3
Cost64
\[0\]
Alternative 5
Error61.7
Cost64
\[1\]

Error

Derivation

  1. Split input into 4 regimes
  2. if (/.f64 y z) < -inf.0

    1. Initial program 64.0

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

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

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

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

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

    if -inf.0 < (/.f64 y z) < -3.1180330985036686e-216 or 4.9952376169741e-312 < (/.f64 y z) < 4.6848136186377372e228

    1. Initial program 9.4

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

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

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{y}}}\]
    7. Simplified0.3

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

    if -3.1180330985036686e-216 < (/.f64 y z) < 4.9952376169741e-312

    1. Initial program 17.7

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

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

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

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

    if 4.6848136186377372e228 < (/.f64 y z)

    1. Initial program 46.0

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

      \[\leadsto \color{blue}{x \cdot \frac{y}{z}}\]
    3. Using strategy rm
    4. Applied add-cube-cbrt_binary64_1784533.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-identity_binary64_1781033.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-frac_binary64_1781633.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*_binary64_177509.1

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

      \[\leadsto \color{blue}{\frac{x}{\sqrt[3]{z} \cdot \sqrt[3]{z}}} \cdot \frac{y}{\sqrt[3]{z}}\]
    9. Using strategy rm
    10. Applied pow1_binary64_178719.1

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

      \[\leadsto \color{blue}{{\left(\frac{x}{\sqrt[3]{z} \cdot \sqrt[3]{z}}\right)}^{1}} \cdot {\left(\frac{y}{\sqrt[3]{z}}\right)}^{1}\]
    12. Applied pow-prod-down_binary64_178819.1

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} \leq -\infty:\\ \;\;\;\;\frac{1}{\frac{z}{y \cdot x}}\\ \mathbf{elif}\;\frac{y}{z} \leq -3.1180330985036686 \cdot 10^{-216}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{elif}\;\frac{y}{z} \leq 4.9952376169741 \cdot 10^{-312}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \mathbf{elif}\;\frac{y}{z} \leq 4.684813618637737 \cdot 10^{+228}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \end{array}\]

Reproduce

herbie shell --seed 2021044 
(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)))