Average Error: 12.8 → 1.6
Time: 3.2s
Precision: binary64
\[\frac{x \cdot \left(y - z\right)}{y} \]
\[\begin{array}{l} t_0 := \frac{x \cdot \left(y - z\right)}{y}\\ \mathbf{if}\;t_0 \leq -\infty:\\ \;\;\;\;\frac{x}{y \cdot \frac{1}{y - z}}\\ \mathbf{elif}\;t_0 \leq -3.3653612771436557 \cdot 10^{+72}:\\ \;\;\;\;x - \frac{x \cdot z}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \end{array} \]
(FPCore (x y z) :precision binary64 (/ (* x (- y z)) y))
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (/ (* x (- y z)) y)))
   (if (<= t_0 (- INFINITY))
     (/ x (* y (/ 1.0 (- y z))))
     (if (<= t_0 -3.3653612771436557e+72)
       (- x (/ (* x z) y))
       (/ x (/ y (- y z)))))))
double code(double x, double y, double z) {
	return (x * (y - z)) / y;
}
double code(double x, double y, double z) {
	double t_0 = (x * (y - z)) / y;
	double tmp;
	if (t_0 <= -((double) INFINITY)) {
		tmp = x / (y * (1.0 / (y - z)));
	} else if (t_0 <= -3.3653612771436557e+72) {
		tmp = x - ((x * z) / y);
	} else {
		tmp = x / (y / (y - z));
	}
	return tmp;
}
public static double code(double x, double y, double z) {
	return (x * (y - z)) / y;
}
public static double code(double x, double y, double z) {
	double t_0 = (x * (y - z)) / y;
	double tmp;
	if (t_0 <= -Double.POSITIVE_INFINITY) {
		tmp = x / (y * (1.0 / (y - z)));
	} else if (t_0 <= -3.3653612771436557e+72) {
		tmp = x - ((x * z) / y);
	} else {
		tmp = x / (y / (y - z));
	}
	return tmp;
}
def code(x, y, z):
	return (x * (y - z)) / y
def code(x, y, z):
	t_0 = (x * (y - z)) / y
	tmp = 0
	if t_0 <= -math.inf:
		tmp = x / (y * (1.0 / (y - z)))
	elif t_0 <= -3.3653612771436557e+72:
		tmp = x - ((x * z) / y)
	else:
		tmp = x / (y / (y - z))
	return tmp
function code(x, y, z)
	return Float64(Float64(x * Float64(y - z)) / y)
end
function code(x, y, z)
	t_0 = Float64(Float64(x * Float64(y - z)) / y)
	tmp = 0.0
	if (t_0 <= Float64(-Inf))
		tmp = Float64(x / Float64(y * Float64(1.0 / Float64(y - z))));
	elseif (t_0 <= -3.3653612771436557e+72)
		tmp = Float64(x - Float64(Float64(x * z) / y));
	else
		tmp = Float64(x / Float64(y / Float64(y - z)));
	end
	return tmp
end
function tmp = code(x, y, z)
	tmp = (x * (y - z)) / y;
end
function tmp_2 = code(x, y, z)
	t_0 = (x * (y - z)) / y;
	tmp = 0.0;
	if (t_0 <= -Inf)
		tmp = x / (y * (1.0 / (y - z)));
	elseif (t_0 <= -3.3653612771436557e+72)
		tmp = x - ((x * z) / y);
	else
		tmp = x / (y / (y - z));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(x / N[(y * N[(1.0 / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -3.3653612771436557e+72], N[(x - N[(N[(x * z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(x / N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\frac{x \cdot \left(y - z\right)}{y}
\begin{array}{l}
t_0 := \frac{x \cdot \left(y - z\right)}{y}\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;\frac{x}{y \cdot \frac{1}{y - z}}\\

\mathbf{elif}\;t_0 \leq -3.3653612771436557 \cdot 10^{+72}:\\
\;\;\;\;x - \frac{x \cdot z}{y}\\

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


\end{array}

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.8
Target3.2
Herbie1.6
\[\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) < -inf.0

    1. Initial program 64.0

      \[\frac{x \cdot \left(y - z\right)}{y} \]
    2. Applied egg-rr0.0

      \[\leadsto \color{blue}{\frac{x}{1} \cdot \frac{y - z}{y}} \]
    3. Applied egg-rr0.1

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}} \]
    4. Applied egg-rr0.2

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

    if -inf.0 < (/.f64 (*.f64 x (-.f64 y z)) y) < -3.36536127714365572e72

    1. Initial program 0.2

      \[\frac{x \cdot \left(y - z\right)}{y} \]
    2. Taylor expanded in y around 0 0.2

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

    if -3.36536127714365572e72 < (/.f64 (*.f64 x (-.f64 y z)) y)

    1. Initial program 10.3

      \[\frac{x \cdot \left(y - z\right)}{y} \]
    2. Applied egg-rr2.3

      \[\leadsto \color{blue}{\frac{x}{1} \cdot \frac{y - z}{y}} \]
    3. Applied egg-rr2.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y - z\right)}{y} \leq -\infty:\\ \;\;\;\;\frac{x}{y \cdot \frac{1}{y - z}}\\ \mathbf{elif}\;\frac{x \cdot \left(y - z\right)}{y} \leq -3.3653612771436557 \cdot 10^{+72}:\\ \;\;\;\;x - \frac{x \cdot z}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \end{array} \]

Reproduce

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