Average Error: 12.9 → 2.8
Time: 2.7s
Precision: binary64
\[\frac{x \cdot \left(y - z\right)}{y}\]
\[\begin{array}{l} \mathbf{if}\;y \leq -3.6981446179524545 \cdot 10^{-179}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \mathbf{elif}\;y \leq 8.01620173754629 \cdot 10^{-48}:\\ \;\;\;\;\left(x \cdot \left(y - z\right)\right) \cdot \frac{1}{y}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y - z}{y}\\ \end{array}\]
\frac{x \cdot \left(y - z\right)}{y}
\begin{array}{l}
\mathbf{if}\;y \leq -3.6981446179524545 \cdot 10^{-179}:\\
\;\;\;\;\frac{x}{\frac{y}{y - z}}\\

\mathbf{elif}\;y \leq 8.01620173754629 \cdot 10^{-48}:\\
\;\;\;\;\left(x \cdot \left(y - z\right)\right) \cdot \frac{1}{y}\\

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

\end{array}
(FPCore (x y z) :precision binary64 (/ (* x (- y z)) y))
(FPCore (x y z)
 :precision binary64
 (if (<= y -3.6981446179524545e-179)
   (/ x (/ y (- y z)))
   (if (<= y 8.01620173754629e-48)
     (* (* x (- y z)) (/ 1.0 y))
     (* x (/ (- y z) y)))))
double code(double x, double y, double z) {
	return (((double) (x * ((double) (y - z)))) / y);
}
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -3.6981446179524545e-179)) {
		tmp = (x / (y / ((double) (y - z))));
	} else {
		double tmp_1;
		if ((y <= 8.01620173754629e-48)) {
			tmp_1 = ((double) (((double) (x * ((double) (y - z)))) * (1.0 / y)));
		} else {
			tmp_1 = ((double) (x * (((double) (y - z)) / y)));
		}
		tmp = tmp_1;
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original12.9
Target3.4
Herbie2.8
\[\begin{array}{l} \mathbf{if}\;z < -2.060202331921739 \cdot 10^{+104}:\\ \;\;\;\;x - \frac{z \cdot x}{y}\\ \mathbf{elif}\;z < 1.6939766013828526 \cdot 10^{+213}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \mathbf{else}:\\ \;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if y < -3.6981446179524545e-179

    1. Initial program 13.5

      \[\frac{x \cdot \left(y - z\right)}{y}\]
    2. Using strategy rm
    3. Applied associate-/l*_binary641.2

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

    if -3.6981446179524545e-179 < y < 8.01620173754628962e-48

    1. Initial program 8.6

      \[\frac{x \cdot \left(y - z\right)}{y}\]
    2. Using strategy rm
    3. Applied div-inv_binary648.8

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

    if 8.01620173754628962e-48 < y

    1. Initial program 15.2

      \[\frac{x \cdot \left(y - z\right)}{y}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity_binary6415.2

      \[\leadsto \frac{x \cdot \left(y - z\right)}{\color{blue}{1 \cdot y}}\]
    4. Applied times-frac_binary640.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.6981446179524545 \cdot 10^{-179}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \mathbf{elif}\;y \leq 8.01620173754629 \cdot 10^{-48}:\\ \;\;\;\;\left(x \cdot \left(y - z\right)\right) \cdot \frac{1}{y}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y - z}{y}\\ \end{array}\]

Reproduce

herbie shell --seed 2020210 
(FPCore (x y z)
  :name "Diagrams.Backend.Cairo.Internal:setTexture from diagrams-cairo-1.3.0.3"
  :precision binary64

  :herbie-target
  (if (< z -2.060202331921739e+104) (- x (/ (* z x) y)) (if (< z 1.6939766013828526e+213) (/ x (/ y (- y z))) (* (- y z) (/ x y))))

  (/ (* x (- y z)) y))