Average Error: 11.8 → 0.9
Time: 4.8s
Precision: binary64
Cost: 2512
\[\frac{x \cdot \left(y - z\right)}{y} \]
\[\begin{array}{l} t_0 := \frac{x \cdot \left(y - z\right)}{y}\\ t_1 := \frac{x}{\frac{y}{y - z}}\\ \mathbf{if}\;t_0 \leq -\infty:\\ \;\;\;\;x \cdot \frac{y - z}{y}\\ \mathbf{elif}\;t_0 \leq -1 \cdot 10^{+126}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;t_0 \leq 2 \cdot 10^{+68}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_0 \leq 2 \cdot 10^{+261}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \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)) (t_1 (/ x (/ y (- y z)))))
   (if (<= t_0 (- INFINITY))
     (* x (/ (- y z) y))
     (if (<= t_0 -1e+126)
       t_0
       (if (<= t_0 2e+68) t_1 (if (<= t_0 2e+261) t_0 t_1))))))
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 t_1 = x / (y / (y - z));
	double tmp;
	if (t_0 <= -((double) INFINITY)) {
		tmp = x * ((y - z) / y);
	} else if (t_0 <= -1e+126) {
		tmp = t_0;
	} else if (t_0 <= 2e+68) {
		tmp = t_1;
	} else if (t_0 <= 2e+261) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	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 t_1 = x / (y / (y - z));
	double tmp;
	if (t_0 <= -Double.POSITIVE_INFINITY) {
		tmp = x * ((y - z) / y);
	} else if (t_0 <= -1e+126) {
		tmp = t_0;
	} else if (t_0 <= 2e+68) {
		tmp = t_1;
	} else if (t_0 <= 2e+261) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z):
	return (x * (y - z)) / y
def code(x, y, z):
	t_0 = (x * (y - z)) / y
	t_1 = x / (y / (y - z))
	tmp = 0
	if t_0 <= -math.inf:
		tmp = x * ((y - z) / y)
	elif t_0 <= -1e+126:
		tmp = t_0
	elif t_0 <= 2e+68:
		tmp = t_1
	elif t_0 <= 2e+261:
		tmp = t_0
	else:
		tmp = t_1
	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)
	t_1 = Float64(x / Float64(y / Float64(y - z)))
	tmp = 0.0
	if (t_0 <= Float64(-Inf))
		tmp = Float64(x * Float64(Float64(y - z) / y));
	elseif (t_0 <= -1e+126)
		tmp = t_0;
	elseif (t_0 <= 2e+68)
		tmp = t_1;
	elseif (t_0 <= 2e+261)
		tmp = t_0;
	else
		tmp = t_1;
	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;
	t_1 = x / (y / (y - z));
	tmp = 0.0;
	if (t_0 <= -Inf)
		tmp = x * ((y - z) / y);
	elseif (t_0 <= -1e+126)
		tmp = t_0;
	elseif (t_0 <= 2e+68)
		tmp = t_1;
	elseif (t_0 <= 2e+261)
		tmp = t_0;
	else
		tmp = t_1;
	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]}, Block[{t$95$1 = N[(x / N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(x * N[(N[(y - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -1e+126], t$95$0, If[LessEqual[t$95$0, 2e+68], t$95$1, If[LessEqual[t$95$0, 2e+261], t$95$0, t$95$1]]]]]]
\frac{x \cdot \left(y - z\right)}{y}
\begin{array}{l}
t_0 := \frac{x \cdot \left(y - z\right)}{y}\\
t_1 := \frac{x}{\frac{y}{y - z}}\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;x \cdot \frac{y - z}{y}\\

\mathbf{elif}\;t_0 \leq -1 \cdot 10^{+126}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;t_0 \leq 2 \cdot 10^{+68}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t_0 \leq 2 \cdot 10^{+261}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original11.8
Target3.1
Herbie0.9
\[\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. Simplified0.0

      \[\leadsto \color{blue}{x \cdot \frac{y - z}{y}} \]
      Proof
      (*.f64 x (/.f64 (-.f64 y z) y)): 0 points increase in error, 0 points decrease in error
      (Rewrite=> associate-*r/_binary64 (/.f64 (*.f64 x (-.f64 y z)) y)): 77 points increase in error, 36 points decrease in error

    if -inf.0 < (/.f64 (*.f64 x (-.f64 y z)) y) < -9.99999999999999925e125 or 1.99999999999999991e68 < (/.f64 (*.f64 x (-.f64 y z)) y) < 1.9999999999999999e261

    1. Initial program 0.2

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

    if -9.99999999999999925e125 < (/.f64 (*.f64 x (-.f64 y z)) y) < 1.99999999999999991e68 or 1.9999999999999999e261 < (/.f64 (*.f64 x (-.f64 y z)) y)

    1. Initial program 10.7

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

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}} \]
      Proof
      (/.f64 x (/.f64 y (-.f64 y z))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 x (-.f64 y z)) y)): 78 points increase in error, 27 points decrease in error
  3. Recombined 3 regimes into one program.
  4. Final simplification0.9

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

Alternatives

Alternative 1
Error4.5
Cost712
\[\begin{array}{l} t_0 := x \cdot \frac{y - z}{y}\\ \mathbf{if}\;y \leq -2.55 \cdot 10^{-135}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 4.4 \cdot 10^{-243}:\\ \;\;\;\;\frac{z \cdot \left(-x\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error1.7
Cost712
\[\begin{array}{l} t_0 := x \cdot \frac{y - z}{y}\\ \mathbf{if}\;x \leq -100000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2:\\ \;\;\;\;x - z \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error2.0
Cost712
\[\begin{array}{l} t_0 := \frac{x}{\frac{y}{y - z}}\\ \mathbf{if}\;x \leq -200000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.25 \cdot 10^{-151}:\\ \;\;\;\;x - z \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error19.0
Cost648
\[\begin{array}{l} \mathbf{if}\;y \leq -1.6 \cdot 10^{-112}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 7.6 \cdot 10^{-33}:\\ \;\;\;\;z \cdot \left(-\frac{x}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error18.9
Cost648
\[\begin{array}{l} \mathbf{if}\;y \leq -4.6 \cdot 10^{-114}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.65 \cdot 10^{-31}:\\ \;\;\;\;\frac{-z}{\frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Error18.8
Cost648
\[\begin{array}{l} \mathbf{if}\;y \leq -5.6 \cdot 10^{-114}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.05 \cdot 10^{-32}:\\ \;\;\;\;\frac{z \cdot \left(-x\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 7
Error25.7
Cost64
\[x \]

Error

Reproduce

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