Average Error: 14.9 → 0.3
Time: 4.6s
Precision: binary64
\[x \cdot \frac{\frac{y}{z} \cdot t}{t}\]
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z} \leq -1.8014985415048463 \cdot 10^{+265}:\\ \;\;\;\;\frac{1}{\frac{z}{y \cdot x}}\\ \mathbf{elif}\;\frac{y}{z} \leq -1.007470215926991 \cdot 10^{-214} \lor \neg \left(\frac{y}{z} \leq 2.548281042717656 \cdot 10^{-265}\right) \land \frac{y}{z} \leq 1.4515679178157475 \cdot 10^{+186}:\\ \;\;\;\;\frac{y}{z} \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \end{array}\]
x \cdot \frac{\frac{y}{z} \cdot t}{t}
\begin{array}{l}
\mathbf{if}\;\frac{y}{z} \leq -1.8014985415048463 \cdot 10^{+265}:\\
\;\;\;\;\frac{1}{\frac{z}{y \cdot x}}\\

\mathbf{elif}\;\frac{y}{z} \leq -1.007470215926991 \cdot 10^{-214} \lor \neg \left(\frac{y}{z} \leq 2.548281042717656 \cdot 10^{-265}\right) \land \frac{y}{z} \leq 1.4515679178157475 \cdot 10^{+186}:\\
\;\;\;\;\frac{y}{z} \cdot x\\

\mathbf{else}:\\
\;\;\;\;\frac{y \cdot 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) -1.8014985415048463e+265)
   (/ 1.0 (/ z (* y x)))
   (if (or (<= (/ y z) -1.007470215926991e-214)
           (and (not (<= (/ y z) 2.548281042717656e-265))
                (<= (/ y z) 1.4515679178157475e+186)))
     (* (/ y z) x)
     (/ (* 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) <= -1.8014985415048463e+265) {
		tmp = 1.0 / (z / (y * x));
	} else if (((y / z) <= -1.007470215926991e-214) || (!((y / z) <= 2.548281042717656e-265) && ((y / z) <= 1.4515679178157475e+186))) {
		tmp = (y / z) * x;
	} 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.9
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}\]

Derivation

  1. Split input into 3 regimes
  2. if (/.f64 y z) < -1.80149854150484626e265

    1. Initial program 51.7

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

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

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

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

    if -1.80149854150484626e265 < (/.f64 y z) < -1.00747021592699109e-214 or 2.5482810427176557e-265 < (/.f64 y z) < 1.4515679178157475e186

    1. Initial program 9.2

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

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

    if -1.00747021592699109e-214 < (/.f64 y z) < 2.5482810427176557e-265 or 1.4515679178157475e186 < (/.f64 y z)

    1. Initial program 23.0

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} \leq -1.8014985415048463 \cdot 10^{+265}:\\ \;\;\;\;\frac{1}{\frac{z}{y \cdot x}}\\ \mathbf{elif}\;\frac{y}{z} \leq -1.007470215926991 \cdot 10^{-214} \lor \neg \left(\frac{y}{z} \leq 2.548281042717656 \cdot 10^{-265}\right) \land \frac{y}{z} \leq 1.4515679178157475 \cdot 10^{+186}:\\ \;\;\;\;\frac{y}{z} \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \end{array}\]

Reproduce

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