Average Error: 12.7 → 2.0
Time: 10.2s
Precision: binary64
\[\frac{x \cdot \left(y - z\right)}{y}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y - z\right)}{y} \leq 1.784179993447873 \cdot 10^{+18}:\\ \;\;\;\;x - x \cdot \frac{z}{y}\\ \mathbf{elif}\;\frac{x \cdot \left(y - z\right)}{y} \leq 6.228592245523279 \cdot 10^{+296}:\\ \;\;\;\;\frac{x \cdot \left(y - z\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{z}{\frac{y}{x}}\\ \end{array}\]
\frac{x \cdot \left(y - z\right)}{y}
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot \left(y - z\right)}{y} \leq 1.784179993447873 \cdot 10^{+18}:\\
\;\;\;\;x - x \cdot \frac{z}{y}\\

\mathbf{elif}\;\frac{x \cdot \left(y - z\right)}{y} \leq 6.228592245523279 \cdot 10^{+296}:\\
\;\;\;\;\frac{x \cdot \left(y - z\right)}{y}\\

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

\end{array}
(FPCore (x y z) :precision binary64 (/ (* x (- y z)) y))
(FPCore (x y z)
 :precision binary64
 (if (<= (/ (* x (- y z)) y) 1.784179993447873e+18)
   (- x (* x (/ z y)))
   (if (<= (/ (* x (- y z)) y) 6.228592245523279e+296)
     (/ (* x (- y z)) y)
     (- x (/ z (/ y x))))))
double code(double x, double y, double z) {
	return (x * (y - z)) / y;
}
double code(double x, double y, double z) {
	double tmp;
	if (((x * (y - z)) / y) <= 1.784179993447873e+18) {
		tmp = x - (x * (z / y));
	} else if (((x * (y - z)) / y) <= 6.228592245523279e+296) {
		tmp = (x * (y - z)) / y;
	} else {
		tmp = x - (z / (y / x));
	}
	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.7
Target3.1
Herbie2.0
\[\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 (/.f64 (*.f64 x (-.f64 y z)) y) < 1784179993447873000

    1. Initial program 10.7

      \[\frac{x \cdot \left(y - z\right)}{y}\]
    2. Simplified2.4

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

    if 1784179993447873000 < (/.f64 (*.f64 x (-.f64 y z)) y) < 6.2285922455232793e296

    1. Initial program 0.2

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

    if 6.2285922455232793e296 < (/.f64 (*.f64 x (-.f64 y z)) y)

    1. Initial program 59.6

      \[\frac{x \cdot \left(y - z\right)}{y}\]
    2. Simplified2.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y - z\right)}{y} \leq 1.784179993447873 \cdot 10^{+18}:\\ \;\;\;\;x - x \cdot \frac{z}{y}\\ \mathbf{elif}\;\frac{x \cdot \left(y - z\right)}{y} \leq 6.228592245523279 \cdot 10^{+296}:\\ \;\;\;\;\frac{x \cdot \left(y - z\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{z}{\frac{y}{x}}\\ \end{array}\]

Reproduce

herbie shell --seed 2021176 
(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))