Average Error: 12.6 → 1.1
Time: 3.2s
Precision: binary64
\[\frac{x \cdot \left(y - z\right)}{y} \]
\[\begin{array}{l} t_0 := x - \frac{x \cdot z}{y}\\ t_1 := \frac{x \cdot \left(y - z\right)}{y}\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;x - z \cdot \frac{x}{y}\\ \mathbf{elif}\;t_1 \leq -4 \cdot 10^{-76}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;t_1 \leq 0:\\ \;\;\;\;x - \frac{z}{\frac{y}{x}}\\ \mathbf{elif}\;t_1 \leq 5 \cdot 10^{+298}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \frac{1}{\frac{-y}{x}}\\ \end{array} \]
(FPCore (x y z) :precision binary64 (/ (* x (- y z)) y))
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (- x (/ (* x z) y))) (t_1 (/ (* x (- y z)) y)))
   (if (<= t_1 (- INFINITY))
     (- x (* z (/ x y)))
     (if (<= t_1 -4e-76)
       t_0
       (if (<= t_1 0.0)
         (- x (/ z (/ y x)))
         (if (<= t_1 5e+298) t_0 (+ x (* z (/ 1.0 (/ (- y) x))))))))))
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 - ((x * z) / y);
	double t_1 = (x * (y - z)) / y;
	double tmp;
	if (t_1 <= -((double) INFINITY)) {
		tmp = x - (z * (x / y));
	} else if (t_1 <= -4e-76) {
		tmp = t_0;
	} else if (t_1 <= 0.0) {
		tmp = x - (z / (y / x));
	} else if (t_1 <= 5e+298) {
		tmp = t_0;
	} else {
		tmp = x + (z * (1.0 / (-y / x)));
	}
	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 - ((x * z) / y);
	double t_1 = (x * (y - z)) / y;
	double tmp;
	if (t_1 <= -Double.POSITIVE_INFINITY) {
		tmp = x - (z * (x / y));
	} else if (t_1 <= -4e-76) {
		tmp = t_0;
	} else if (t_1 <= 0.0) {
		tmp = x - (z / (y / x));
	} else if (t_1 <= 5e+298) {
		tmp = t_0;
	} else {
		tmp = x + (z * (1.0 / (-y / x)));
	}
	return tmp;
}
def code(x, y, z):
	return (x * (y - z)) / y
def code(x, y, z):
	t_0 = x - ((x * z) / y)
	t_1 = (x * (y - z)) / y
	tmp = 0
	if t_1 <= -math.inf:
		tmp = x - (z * (x / y))
	elif t_1 <= -4e-76:
		tmp = t_0
	elif t_1 <= 0.0:
		tmp = x - (z / (y / x))
	elif t_1 <= 5e+298:
		tmp = t_0
	else:
		tmp = x + (z * (1.0 / (-y / x)))
	return tmp
function code(x, y, z)
	return Float64(Float64(x * Float64(y - z)) / y)
end
function code(x, y, z)
	t_0 = Float64(x - Float64(Float64(x * z) / y))
	t_1 = Float64(Float64(x * Float64(y - z)) / y)
	tmp = 0.0
	if (t_1 <= Float64(-Inf))
		tmp = Float64(x - Float64(z * Float64(x / y)));
	elseif (t_1 <= -4e-76)
		tmp = t_0;
	elseif (t_1 <= 0.0)
		tmp = Float64(x - Float64(z / Float64(y / x)));
	elseif (t_1 <= 5e+298)
		tmp = t_0;
	else
		tmp = Float64(x + Float64(z * Float64(1.0 / Float64(Float64(-y) / x))));
	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 - ((x * z) / y);
	t_1 = (x * (y - z)) / y;
	tmp = 0.0;
	if (t_1 <= -Inf)
		tmp = x - (z * (x / y));
	elseif (t_1 <= -4e-76)
		tmp = t_0;
	elseif (t_1 <= 0.0)
		tmp = x - (z / (y / x));
	elseif (t_1 <= 5e+298)
		tmp = t_0;
	else
		tmp = x + (z * (1.0 / (-y / x)));
	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[(x - N[(N[(x * z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(x - N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -4e-76], t$95$0, If[LessEqual[t$95$1, 0.0], N[(x - N[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+298], t$95$0, N[(x + N[(z * N[(1.0 / N[((-y) / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\frac{x \cdot \left(y - z\right)}{y}
\begin{array}{l}
t_0 := x - \frac{x \cdot z}{y}\\
t_1 := \frac{x \cdot \left(y - z\right)}{y}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;x - z \cdot \frac{x}{y}\\

\mathbf{elif}\;t_1 \leq -4 \cdot 10^{-76}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;t_1 \leq 0:\\
\;\;\;\;x - \frac{z}{\frac{y}{x}}\\

\mathbf{elif}\;t_1 \leq 5 \cdot 10^{+298}:\\
\;\;\;\;t_0\\

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original12.6
Target3.3
Herbie1.1
\[\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 4 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. Simplified0.0

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

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

    if -inf.0 < (/.f64 (*.f64 x (-.f64 y z)) y) < -3.99999999999999971e-76 or 0.0 < (/.f64 (*.f64 x (-.f64 y z)) y) < 5.0000000000000003e298

    1. Initial program 0.3

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

      \[\leadsto \color{blue}{x - \frac{z}{\frac{y}{x}}} \]
    3. Taylor expanded in z around 0 0.2

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

    if -3.99999999999999971e-76 < (/.f64 (*.f64 x (-.f64 y z)) y) < 0.0

    1. Initial program 15.5

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

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

    if 5.0000000000000003e298 < (/.f64 (*.f64 x (-.f64 y z)) y)

    1. Initial program 60.8

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

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

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

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

Reproduce

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