Average Error: 12.6 → 3.1
Time: 2.3s
Precision: 64
\[\frac{x \cdot \left(y - z\right)}{y}\]
\[\begin{array}{l} \mathbf{if}\;z \le -7.00973560583033179 \cdot 10^{117}:\\ \;\;\;\;\frac{\frac{x}{y}}{\frac{1}{y - z}}\\ \mathbf{elif}\;z \le 3.9649337337447664 \cdot 10^{110}:\\ \;\;\;\;x - x \cdot \frac{z}{y}\\ \mathbf{elif}\;z \le 7.32628982310973931 \cdot 10^{217}:\\ \;\;\;\;x - \frac{1}{\frac{y}{x \cdot z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{y}}{\frac{1}{y - z}}\\ \end{array}\]
\frac{x \cdot \left(y - z\right)}{y}
\begin{array}{l}
\mathbf{if}\;z \le -7.00973560583033179 \cdot 10^{117}:\\
\;\;\;\;\frac{\frac{x}{y}}{\frac{1}{y - z}}\\

\mathbf{elif}\;z \le 3.9649337337447664 \cdot 10^{110}:\\
\;\;\;\;x - x \cdot \frac{z}{y}\\

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

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

\end{array}
double code(double x, double y, double z) {
	return ((x * (y - z)) / y);
}
double code(double x, double y, double z) {
	double VAR;
	if ((z <= -7.009735605830332e+117)) {
		VAR = ((x / y) / (1.0 / (y - z)));
	} else {
		double VAR_1;
		if ((z <= 3.9649337337447664e+110)) {
			VAR_1 = (x - (x * (z / y)));
		} else {
			double VAR_2;
			if ((z <= 7.326289823109739e+217)) {
				VAR_2 = (x - (1.0 / (y / (x * z))));
			} else {
				VAR_2 = ((x / y) / (1.0 / (y - z)));
			}
			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.6
Target2.8
Herbie3.1
\[\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 z < -7.009735605830332e+117 or 7.326289823109739e+217 < z

    1. Initial program 12.6

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

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}}\]
    4. Using strategy rm
    5. Applied div-inv11.2

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

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

    if -7.009735605830332e+117 < z < 3.9649337337447664e+110

    1. Initial program 12.7

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

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}}\]
    4. Taylor expanded around 0 2.8

      \[\leadsto \color{blue}{x - \frac{x \cdot z}{y}}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity2.8

      \[\leadsto x - \frac{x \cdot z}{\color{blue}{1 \cdot y}}\]
    7. Applied times-frac0.7

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

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

    if 3.9649337337447664e+110 < z < 7.326289823109739e+217

    1. Initial program 11.6

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

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}}\]
    4. Taylor expanded around 0 9.2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -7.00973560583033179 \cdot 10^{117}:\\ \;\;\;\;\frac{\frac{x}{y}}{\frac{1}{y - z}}\\ \mathbf{elif}\;z \le 3.9649337337447664 \cdot 10^{110}:\\ \;\;\;\;x - x \cdot \frac{z}{y}\\ \mathbf{elif}\;z \le 7.32628982310973931 \cdot 10^{217}:\\ \;\;\;\;x - \frac{1}{\frac{y}{x \cdot z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{y}}{\frac{1}{y - z}}\\ \end{array}\]

Reproduce

herbie shell --seed 2020078 +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))