Average Error: 14.8 → 1.0
Time: 3.5s
Precision: binary64
\[[x, y] = \mathsf{sort}([x, y]) \\]
\[x \cdot \frac{\frac{y}{z} \cdot t}{t} \]
\[\begin{array}{l} t_1 := \frac{x}{\frac{z}{y}}\\ \mathbf{if}\;\frac{y}{z} \leq -3.0717914688874457 \cdot 10^{+214}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;\frac{y}{z} \leq -5.886782599650217 \cdot 10^{-117}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{y}{z} \leq 6.406396545967077 \cdot 10^{-145}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \mathbf{elif}\;\frac{y}{z} \leq 1.2888889004451218 \cdot 10^{+160}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{z}{y \cdot x}}\\ \end{array} \]
x \cdot \frac{\frac{y}{z} \cdot t}{t}
\begin{array}{l}
t_1 := \frac{x}{\frac{z}{y}}\\
\mathbf{if}\;\frac{y}{z} \leq -3.0717914688874457 \cdot 10^{+214}:\\
\;\;\;\;\frac{y}{\frac{z}{x}}\\

\mathbf{elif}\;\frac{y}{z} \leq -5.886782599650217 \cdot 10^{-117}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;\frac{y}{z} \leq 1.2888889004451218 \cdot 10^{+160}:\\
\;\;\;\;t_1\\

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


\end{array}
(FPCore (x y z t) :precision binary64 (* x (/ (* (/ y z) t) t)))
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (/ x (/ z y))))
   (if (<= (/ y z) -3.0717914688874457e+214)
     (/ y (/ z x))
     (if (<= (/ y z) -5.886782599650217e-117)
       t_1
       (if (<= (/ y z) 6.406396545967077e-145)
         (/ (* y x) z)
         (if (<= (/ y z) 1.2888889004451218e+160)
           t_1
           (/ 1.0 (/ z (* y x)))))))))
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 t_1 = x / (z / y);
	double tmp;
	if ((y / z) <= -3.0717914688874457e+214) {
		tmp = y / (z / x);
	} else if ((y / z) <= -5.886782599650217e-117) {
		tmp = t_1;
	} else if ((y / z) <= 6.406396545967077e-145) {
		tmp = (y * x) / z;
	} else if ((y / z) <= 1.2888889004451218e+160) {
		tmp = t_1;
	} else {
		tmp = 1.0 / (z / (y * x));
	}
	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.8
Target1.6
Herbie1.0
\[\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) < -3.0717914688874457e214

    1. Initial program 43.5

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

      \[\leadsto \color{blue}{x \cdot \frac{y}{z}} \]
    3. Applied egg-rr25.5

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{y}}} \]
    4. Applied egg-rr0.8

      \[\leadsto \color{blue}{y \cdot \frac{x}{z}} \]
    5. Applied egg-rr0.9

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

    if -3.0717914688874457e214 < (/.f64 y z) < -5.8867825996502169e-117 or 6.40639654596707673e-145 < (/.f64 y z) < 1.2888889004451218e160

    1. Initial program 7.4

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

      \[\leadsto \color{blue}{x \cdot \frac{y}{z}} \]
    3. Applied egg-rr0.3

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

    if -5.8867825996502169e-117 < (/.f64 y z) < 6.40639654596707673e-145

    1. Initial program 15.4

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

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

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

    if 1.2888889004451218e160 < (/.f64 y z)

    1. Initial program 36.2

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

      \[\leadsto \color{blue}{x \cdot \frac{y}{z}} \]
    3. Applied egg-rr2.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} \leq -3.0717914688874457 \cdot 10^{+214}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;\frac{y}{z} \leq -5.886782599650217 \cdot 10^{-117}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{elif}\;\frac{y}{z} \leq 6.406396545967077 \cdot 10^{-145}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \mathbf{elif}\;\frac{y}{z} \leq 1.2888889004451218 \cdot 10^{+160}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{z}{y \cdot x}}\\ \end{array} \]

Reproduce

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