Average Error: 12.4 → 0.9
Time: 3.4s
Precision: 64
\[\frac{x \cdot \left(y - z\right)}{y}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y - z\right)}{y} \le -1.37307015920405691 \cdot 10^{290} \lor \neg \left(\frac{x \cdot \left(y - z\right)}{y} \le -1.0746977451131761 \cdot 10^{-57} \lor \neg \left(\frac{x \cdot \left(y - z\right)}{y} \le 3.59502880248723362 \cdot 10^{-108} \lor \neg \left(\frac{x \cdot \left(y - z\right)}{y} \le 1.74180625989322971 \cdot 10^{238}\right)\right)\right):\\ \;\;\;\;\frac{y - z}{y} \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \left(y - z\right)}{y}\\ \end{array}\]
\frac{x \cdot \left(y - z\right)}{y}
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot \left(y - z\right)}{y} \le -1.37307015920405691 \cdot 10^{290} \lor \neg \left(\frac{x \cdot \left(y - z\right)}{y} \le -1.0746977451131761 \cdot 10^{-57} \lor \neg \left(\frac{x \cdot \left(y - z\right)}{y} \le 3.59502880248723362 \cdot 10^{-108} \lor \neg \left(\frac{x \cdot \left(y - z\right)}{y} \le 1.74180625989322971 \cdot 10^{238}\right)\right)\right):\\
\;\;\;\;\frac{y - z}{y} \cdot x\\

\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(y - z\right)}{y}\\

\end{array}
double code(double x, double y, double z) {
	return ((x * (y - z)) / y);
}
double code(double x, double y, double z) {
	double temp;
	if (((((x * (y - z)) / y) <= -1.3730701592040569e+290) || !((((x * (y - z)) / y) <= -1.0746977451131761e-57) || !((((x * (y - z)) / y) <= 3.5950288024872336e-108) || !(((x * (y - z)) / y) <= 1.7418062598932297e+238))))) {
		temp = (((y - z) / y) * x);
	} else {
		temp = ((x * (y - z)) / y);
	}
	return temp;
}

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.4
Target3.1
Herbie0.9
\[\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 2 regimes
  2. if (/ (* x (- y z)) y) < -1.3730701592040569e+290 or -1.0746977451131761e-57 < (/ (* x (- y z)) y) < 3.5950288024872336e-108 or 1.7418062598932297e+238 < (/ (* x (- y z)) y)

    1. Initial program 25.1

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

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

      \[\leadsto \color{blue}{\frac{1}{\frac{\frac{y}{y - z}}{x}}}\]
    6. Using strategy rm
    7. Applied div-inv1.6

      \[\leadsto \frac{1}{\color{blue}{\frac{y}{y - z} \cdot \frac{1}{x}}}\]
    8. Applied add-sqr-sqrt1.6

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

      \[\leadsto \color{blue}{\frac{\sqrt{1}}{\frac{y}{y - z}} \cdot \frac{\sqrt{1}}{\frac{1}{x}}}\]
    10. Simplified1.7

      \[\leadsto \color{blue}{\frac{y - z}{y}} \cdot \frac{\sqrt{1}}{\frac{1}{x}}\]
    11. Simplified1.6

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

    if -1.3730701592040569e+290 < (/ (* x (- y z)) y) < -1.0746977451131761e-57 or 3.5950288024872336e-108 < (/ (* x (- y z)) y) < 1.7418062598932297e+238

    1. Initial program 0.2

      \[\frac{x \cdot \left(y - z\right)}{y}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y - z\right)}{y} \le -1.37307015920405691 \cdot 10^{290} \lor \neg \left(\frac{x \cdot \left(y - z\right)}{y} \le -1.0746977451131761 \cdot 10^{-57} \lor \neg \left(\frac{x \cdot \left(y - z\right)}{y} \le 3.59502880248723362 \cdot 10^{-108} \lor \neg \left(\frac{x \cdot \left(y - z\right)}{y} \le 1.74180625989322971 \cdot 10^{238}\right)\right)\right):\\ \;\;\;\;\frac{y - z}{y} \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \left(y - z\right)}{y}\\ \end{array}\]

Reproduce

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