Average Error: 12.3 → 0.6
Time: 5.3s
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 := x - \frac{x}{\frac{y}{z}}\\ \mathbf{if}\;t_0 \leq -\infty:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_0 \leq -4 \cdot 10^{+142}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;t_0 \leq 2 \cdot 10^{-117}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_0 \leq 5 \cdot 10^{+293}:\\ \;\;\;\;t_0\\ \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)) (t_1 (- x (/ x (/ y z)))))
   (if (<= t_0 (- INFINITY))
     t_1
     (if (<= t_0 -4e+142)
       t_0
       (if (<= t_0 2e-117)
         t_1
         (if (<= t_0 5e+293) t_0 (/ 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 t_1 = x - (x / (y / z));
	double tmp;
	if (t_0 <= -((double) INFINITY)) {
		tmp = t_1;
	} else if (t_0 <= -4e+142) {
		tmp = t_0;
	} else if (t_0 <= 2e-117) {
		tmp = t_1;
	} else if (t_0 <= 5e+293) {
		tmp = t_0;
	} 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 t_1 = x - (x / (y / z));
	double tmp;
	if (t_0 <= -Double.POSITIVE_INFINITY) {
		tmp = t_1;
	} else if (t_0 <= -4e+142) {
		tmp = t_0;
	} else if (t_0 <= 2e-117) {
		tmp = t_1;
	} else if (t_0 <= 5e+293) {
		tmp = t_0;
	} 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
	t_1 = x - (x / (y / z))
	tmp = 0
	if t_0 <= -math.inf:
		tmp = t_1
	elif t_0 <= -4e+142:
		tmp = t_0
	elif t_0 <= 2e-117:
		tmp = t_1
	elif t_0 <= 5e+293:
		tmp = t_0
	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)
	t_1 = Float64(x - Float64(x / Float64(y / z)))
	tmp = 0.0
	if (t_0 <= Float64(-Inf))
		tmp = t_1;
	elseif (t_0 <= -4e+142)
		tmp = t_0;
	elseif (t_0 <= 2e-117)
		tmp = t_1;
	elseif (t_0 <= 5e+293)
		tmp = t_0;
	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;
	t_1 = x - (x / (y / z));
	tmp = 0.0;
	if (t_0 <= -Inf)
		tmp = t_1;
	elseif (t_0 <= -4e+142)
		tmp = t_0;
	elseif (t_0 <= 2e-117)
		tmp = t_1;
	elseif (t_0 <= 5e+293)
		tmp = t_0;
	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]}, Block[{t$95$1 = N[(x - N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], t$95$1, If[LessEqual[t$95$0, -4e+142], t$95$0, If[LessEqual[t$95$0, 2e-117], t$95$1, If[LessEqual[t$95$0, 5e+293], t$95$0, 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}\\
t_1 := x - \frac{x}{\frac{y}{z}}\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t_0 \leq -4 \cdot 10^{+142}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;t_0 \leq 2 \cdot 10^{-117}:\\
\;\;\;\;t_1\\

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

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original12.3
Target2.8
Herbie0.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 or -4.0000000000000002e142 < (/.f64 (*.f64 x (-.f64 y z)) y) < 2.00000000000000006e-117

    1. Initial program 14.4

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

      \[\leadsto \color{blue}{x - \frac{x}{\frac{y}{z}}} \]
      Proof
      (-.f64 x (/.f64 x (/.f64 y z))): 0 points increase in error, 0 points decrease in error
      (-.f64 x (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 x z) y))): 1 points increase in error, 0 points decrease in error
      (-.f64 x (/.f64 (Rewrite=> *-commutative_binary64 (*.f64 z x)) y)): 0 points increase in error, 1 points decrease in error
      (-.f64 x (Rewrite<= associate-*l/_binary64 (*.f64 (/.f64 z y) x))): 0 points increase in error, 0 points decrease in error
      (-.f64 (Rewrite<= *-lft-identity_binary64 (*.f64 1 x)) (*.f64 (/.f64 z y) x)): 1 points increase in error, 0 points decrease in error
      (-.f64 (*.f64 (Rewrite<= *-inverses_binary64 (/.f64 y y)) x) (*.f64 (/.f64 z y) x)): 0 points increase in error, 1 points decrease in error
      (Rewrite=> distribute-rgt-out--_binary64 (*.f64 x (-.f64 (/.f64 y y) (/.f64 z y)))): 4 points increase in error, 0 points decrease in error
      (*.f64 x (Rewrite<= div-sub_binary64 (/.f64 (-.f64 y z) y))): 0 points increase in error, 4 points decrease in error
      (Rewrite=> associate-*r/_binary64 (/.f64 (*.f64 x (-.f64 y z)) y)): 0 points increase in error, 0 points decrease in error

    if -inf.0 < (/.f64 (*.f64 x (-.f64 y z)) y) < -4.0000000000000002e142 or 2.00000000000000006e-117 < (/.f64 (*.f64 x (-.f64 y z)) y) < 5.00000000000000033e293

    1. Initial program 0.3

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

    if 5.00000000000000033e293 < (/.f64 (*.f64 x (-.f64 y z)) y)

    1. Initial program 58.5

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

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}} \]
      Proof
      (-.f64 x (/.f64 x (/.f64 y z))): 0 points increase in error, 0 points decrease in error
      (-.f64 x (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 x z) y))): 1 points increase in error, 0 points decrease in error
      (-.f64 x (/.f64 (Rewrite=> *-commutative_binary64 (*.f64 z x)) y)): 0 points increase in error, 1 points decrease in error
      (-.f64 x (Rewrite<= associate-*l/_binary64 (*.f64 (/.f64 z y) x))): 0 points increase in error, 0 points decrease in error
      (-.f64 (Rewrite<= *-lft-identity_binary64 (*.f64 1 x)) (*.f64 (/.f64 z y) x)): 1 points increase in error, 0 points decrease in error
      (-.f64 (*.f64 (Rewrite<= *-inverses_binary64 (/.f64 y y)) x) (*.f64 (/.f64 z y) x)): 0 points increase in error, 1 points decrease in error
      (Rewrite=> distribute-rgt-out--_binary64 (*.f64 x (-.f64 (/.f64 y y) (/.f64 z y)))): 4 points increase in error, 0 points decrease in error
      (*.f64 x (Rewrite<= div-sub_binary64 (/.f64 (-.f64 y z) y))): 0 points increase in error, 4 points decrease in error
      (Rewrite=> associate-*r/_binary64 (/.f64 (*.f64 x (-.f64 y z)) y)): 0 points increase in error, 0 points decrease in error
  3. Recombined 3 regimes into one program.
  4. Final simplification0.6

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

Alternatives

Alternative 1
Error8.8
Cost977
\[\begin{array}{l} \mathbf{if}\;y \leq -3.65 \cdot 10^{+224}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 9 \cdot 10^{+80} \lor \neg \left(y \leq 3.3 \cdot 10^{+182}\right) \land y \leq 8.5 \cdot 10^{+219}:\\ \;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Error19.1
Cost912
\[\begin{array}{l} t_0 := \frac{x}{y} \cdot \left(-z\right)\\ \mathbf{if}\;z \leq -4.5 \cdot 10^{-24}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 4.2 \cdot 10^{-148}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 3.1 \cdot 10^{-135}:\\ \;\;\;\;\frac{x}{-\frac{y}{z}}\\ \mathbf{elif}\;z \leq 1.22 \cdot 10^{-17}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error3.5
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -7.8 \cdot 10^{-237} \lor \neg \left(y \leq 3.6 \cdot 10^{-199}\right):\\ \;\;\;\;x - \frac{x}{\frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;-\frac{x \cdot z}{y}\\ \end{array} \]
Alternative 4
Error3.5
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -2 \cdot 10^{-237}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \mathbf{elif}\;y \leq 2 \cdot 10^{-198}:\\ \;\;\;\;-\frac{x \cdot z}{y}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{x}{\frac{y}{z}}\\ \end{array} \]
Alternative 5
Error19.0
Cost649
\[\begin{array}{l} \mathbf{if}\;z \leq -3.8 \cdot 10^{-28} \lor \neg \left(z \leq 5.5 \cdot 10^{-20}\right):\\ \;\;\;\;\frac{-z}{\frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Error18.8
Cost649
\[\begin{array}{l} \mathbf{if}\;z \leq -9.2 \cdot 10^{-25} \lor \neg \left(z \leq 1.22 \cdot 10^{-17}\right):\\ \;\;\;\;\frac{x}{y} \cdot \left(-z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 7
Error24.9
Cost64
\[x \]

Error

Reproduce

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