Average Error: 12.2 → 0.7
Time: 3.0s
Precision: 64
\[\frac{x \cdot \left(y - z\right)}{y}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y - z\right)}{y} = -\infty:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \mathbf{elif}\;\frac{x \cdot \left(y - z\right)}{y} \le -6.9464679095261849 \cdot 10^{107}:\\ \;\;\;\;\frac{x \cdot \left(y - z\right)}{y}\\ \mathbf{elif}\;\frac{x \cdot \left(y - z\right)}{y} \le 1.2751829223193257 \cdot 10^{26}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \mathbf{elif}\;\frac{x \cdot \left(y - z\right)}{y} \le 1.1047641663537662 \cdot 10^{302}:\\ \;\;\;\;\frac{x \cdot \left(y - z\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \sqrt[3]{{\left(1 - \frac{z}{y}\right)}^{3}}\\ \end{array}\]
\frac{x \cdot \left(y - z\right)}{y}
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot \left(y - z\right)}{y} = -\infty:\\
\;\;\;\;\frac{x}{\frac{y}{y - z}}\\

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

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

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

\mathbf{else}:\\
\;\;\;\;x \cdot \sqrt[3]{{\left(1 - \frac{z}{y}\right)}^{3}}\\

\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 ((((x * (y - z)) / y) <= -inf.0)) {
		VAR = (x / (y / (y - z)));
	} else {
		double VAR_1;
		if ((((x * (y - z)) / y) <= -6.946467909526185e+107)) {
			VAR_1 = ((x * (y - z)) / y);
		} else {
			double VAR_2;
			if ((((x * (y - z)) / y) <= 1.2751829223193257e+26)) {
				VAR_2 = (x / (y / (y - z)));
			} else {
				double VAR_3;
				if ((((x * (y - z)) / y) <= 1.1047641663537662e+302)) {
					VAR_3 = ((x * (y - z)) / y);
				} else {
					VAR_3 = (x * cbrt(pow((1.0 - (z / y)), 3.0)));
				}
				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.2
Target3.2
Herbie0.7
\[\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 (- y z)) y) < -inf.0 or -6.946467909526185e+107 < (/ (* x (- y z)) y) < 1.2751829223193257e+26

    1. Initial program 12.3

      \[\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}}}\]

    if -inf.0 < (/ (* x (- y z)) y) < -6.946467909526185e+107 or 1.2751829223193257e+26 < (/ (* x (- y z)) y) < 1.1047641663537662e+302

    1. Initial program 0.2

      \[\frac{x \cdot \left(y - z\right)}{y}\]

    if 1.1047641663537662e+302 < (/ (* x (- y z)) y)

    1. Initial program 61.8

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

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

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

      \[\leadsto \color{blue}{x} \cdot \frac{y - z}{y}\]
    6. Using strategy rm
    7. Applied add-cbrt-cube55.1

      \[\leadsto x \cdot \frac{y - z}{\color{blue}{\sqrt[3]{\left(y \cdot y\right) \cdot y}}}\]
    8. Applied add-cbrt-cube58.9

      \[\leadsto x \cdot \frac{\color{blue}{\sqrt[3]{\left(\left(y - z\right) \cdot \left(y - z\right)\right) \cdot \left(y - z\right)}}}{\sqrt[3]{\left(y \cdot y\right) \cdot y}}\]
    9. Applied cbrt-undiv59.0

      \[\leadsto x \cdot \color{blue}{\sqrt[3]{\frac{\left(\left(y - z\right) \cdot \left(y - z\right)\right) \cdot \left(y - z\right)}{\left(y \cdot y\right) \cdot y}}}\]
    10. Simplified4.9

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y - z\right)}{y} = -\infty:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \mathbf{elif}\;\frac{x \cdot \left(y - z\right)}{y} \le -6.9464679095261849 \cdot 10^{107}:\\ \;\;\;\;\frac{x \cdot \left(y - z\right)}{y}\\ \mathbf{elif}\;\frac{x \cdot \left(y - z\right)}{y} \le 1.2751829223193257 \cdot 10^{26}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \mathbf{elif}\;\frac{x \cdot \left(y - z\right)}{y} \le 1.1047641663537662 \cdot 10^{302}:\\ \;\;\;\;\frac{x \cdot \left(y - z\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \sqrt[3]{{\left(1 - \frac{z}{y}\right)}^{3}}\\ \end{array}\]

Reproduce

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