Average Error: 12.5 → 2.2
Time: 2.4s
Precision: 64
\[\frac{x \cdot \left(y - z\right)}{y}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.0031241993131199291:\\ \;\;\;\;\frac{x \cdot 1}{\frac{y}{y - z}}\\ \mathbf{elif}\;x \le -2.5442428760867874 \cdot 10^{-218}:\\ \;\;\;\;\left(x \cdot \left(y - z\right)\right) \cdot \frac{1}{y}\\ \mathbf{elif}\;x \le 3.83253612891536641 \cdot 10^{-156}:\\ \;\;\;\;\frac{x \cdot 1}{\frac{y}{y - z}}\\ \mathbf{elif}\;x \le 2.91543650117718941 \cdot 10^{-52}:\\ \;\;\;\;\frac{1}{\frac{y}{x \cdot \left(y - z\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 1}{\frac{y}{y - z}}\\ \end{array}\]
\frac{x \cdot \left(y - z\right)}{y}
\begin{array}{l}
\mathbf{if}\;x \le -0.0031241993131199291:\\
\;\;\;\;\frac{x \cdot 1}{\frac{y}{y - z}}\\

\mathbf{elif}\;x \le -2.5442428760867874 \cdot 10^{-218}:\\
\;\;\;\;\left(x \cdot \left(y - z\right)\right) \cdot \frac{1}{y}\\

\mathbf{elif}\;x \le 3.83253612891536641 \cdot 10^{-156}:\\
\;\;\;\;\frac{x \cdot 1}{\frac{y}{y - z}}\\

\mathbf{elif}\;x \le 2.91543650117718941 \cdot 10^{-52}:\\
\;\;\;\;\frac{1}{\frac{y}{x \cdot \left(y - z\right)}}\\

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

\end{array}
double code(double x, double y, double z) {
	return ((double) (((double) (x * ((double) (y - z)))) / y));
}
double code(double x, double y, double z) {
	double VAR;
	if ((x <= -0.003124199313119929)) {
		VAR = ((double) (((double) (x * 1.0)) / ((double) (y / ((double) (y - z))))));
	} else {
		double VAR_1;
		if ((x <= -2.5442428760867874e-218)) {
			VAR_1 = ((double) (((double) (x * ((double) (y - z)))) * ((double) (1.0 / y))));
		} else {
			double VAR_2;
			if ((x <= 3.8325361289153664e-156)) {
				VAR_2 = ((double) (((double) (x * 1.0)) / ((double) (y / ((double) (y - z))))));
			} else {
				double VAR_3;
				if ((x <= 2.9154365011771894e-52)) {
					VAR_3 = ((double) (1.0 / ((double) (y / ((double) (x * ((double) (y - z))))))));
				} else {
					VAR_3 = ((double) (((double) (x * 1.0)) / ((double) (y / ((double) (y - z))))));
				}
				VAR_2 = VAR_3;
			}
			VAR_1 = VAR_2;
		}
		VAR = VAR_1;
	}
	return VAR;
}

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.5
Target3.1
Herbie2.2
\[\begin{array}{l} \mathbf{if}\;z \lt -2.060202331921739 \cdot 10^{104}:\\ \;\;\;\;x - \frac{z \cdot x}{y}\\ \mathbf{elif}\;z \lt 1.69397660138285259 \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 x < -0.003124199313119929 or -2.5442428760867874e-218 < x < 3.8325361289153664e-156 or 2.9154365011771894e-52 < x

    1. Initial program 16.9

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

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

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

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

    if -0.003124199313119929 < x < -2.5442428760867874e-218

    1. Initial program 2.2

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

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

    if 3.8325361289153664e-156 < x < 2.9154365011771894e-52

    1. Initial program 1.7

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

      \[\leadsto \color{blue}{\frac{1}{\frac{y}{x \cdot \left(y - z\right)}}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification2.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -0.0031241993131199291:\\ \;\;\;\;\frac{x \cdot 1}{\frac{y}{y - z}}\\ \mathbf{elif}\;x \le -2.5442428760867874 \cdot 10^{-218}:\\ \;\;\;\;\left(x \cdot \left(y - z\right)\right) \cdot \frac{1}{y}\\ \mathbf{elif}\;x \le 3.83253612891536641 \cdot 10^{-156}:\\ \;\;\;\;\frac{x \cdot 1}{\frac{y}{y - z}}\\ \mathbf{elif}\;x \le 2.91543650117718941 \cdot 10^{-52}:\\ \;\;\;\;\frac{1}{\frac{y}{x \cdot \left(y - z\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 1}{\frac{y}{y - z}}\\ \end{array}\]

Reproduce

herbie shell --seed 2020114 +o rules:numerics
(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))