Average Error: 14.4 → 0.5
Time: 3.7s
Precision: binary64
\[x \cdot \frac{\frac{y}{z} \cdot t}{t}\]
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z} \leq -6.0997181107985366 \cdot 10^{+171}:\\ \;\;\;\;\left(y \cdot x\right) \cdot \frac{1}{z}\\ \mathbf{elif}\;\frac{y}{z} \leq -1.348124329597327 \cdot 10^{-160}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{elif}\;\frac{y}{z} \leq 1.924299285446891 \cdot 10^{-222}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;\frac{y}{z} \leq 1.7647629544811067 \cdot 10^{+232}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{1}{y}}\\ \end{array}\]
x \cdot \frac{\frac{y}{z} \cdot t}{t}
\begin{array}{l}
\mathbf{if}\;\frac{y}{z} \leq -6.0997181107985366 \cdot 10^{+171}:\\
\;\;\;\;\left(y \cdot x\right) \cdot \frac{1}{z}\\

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

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

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

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

\end{array}
(FPCore (x y z t) :precision binary64 (* x (/ (* (/ y z) t) t)))
(FPCore (x y z t)
 :precision binary64
 (if (<= (/ y z) -6.0997181107985366e+171)
   (* (* y x) (/ 1.0 z))
   (if (<= (/ y z) -1.348124329597327e-160)
     (/ x (/ z y))
     (if (<= (/ y z) 1.924299285446891e-222)
       (* y (/ x z))
       (if (<= (/ y z) 1.7647629544811067e+232)
         (/ x (/ z y))
         (/ (/ x z) (/ 1.0 y)))))))
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) <= -6.0997181107985366e+171) {
		tmp = (y * x) * (1.0 / z);
	} else if ((y / z) <= -1.348124329597327e-160) {
		tmp = x / (z / y);
	} else if ((y / z) <= 1.924299285446891e-222) {
		tmp = y * (x / z);
	} else if ((y / z) <= 1.7647629544811067e+232) {
		tmp = x / (z / y);
	} else {
		tmp = (x / z) / (1.0 / y);
	}
	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.4
Target1.3
Herbie0.5
\[\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}\]

Derivation

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

    1. Initial program 36.7

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

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

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

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

    if -6.09971811079853655e171 < (/.f64 y z) < -1.348124329597327e-160 or 1.9242992854468911e-222 < (/.f64 y z) < 1.76476295448110672e232

    1. Initial program 8.2

      \[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_184349.6

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

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

    if -1.348124329597327e-160 < (/.f64 y z) < 1.9242992854468911e-222

    1. Initial program 16.8

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

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

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

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

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

    if 1.76476295448110672e232 < (/.f64 y z)

    1. Initial program 47.2

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

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

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{y}}}\]
    7. Using strategy rm
    8. Applied div-inv_binary64_1848930.0

      \[\leadsto \frac{x}{\color{blue}{z \cdot \frac{1}{y}}}\]
    9. Applied associate-/r*_binary64_184360.6

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} \leq -6.0997181107985366 \cdot 10^{+171}:\\ \;\;\;\;\left(y \cdot x\right) \cdot \frac{1}{z}\\ \mathbf{elif}\;\frac{y}{z} \leq -1.348124329597327 \cdot 10^{-160}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{elif}\;\frac{y}{z} \leq 1.924299285446891 \cdot 10^{-222}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;\frac{y}{z} \leq 1.7647629544811067 \cdot 10^{+232}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{1}{y}}\\ \end{array}\]

Reproduce

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