?

Average Error: 12.0 → 3.8
Time: 12.4s
Precision: binary64
Cost: 1028

?

\[\frac{x \cdot \left(y - z\right)}{y} \]
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y - z\right)}{y} \leq -\infty:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x + \left(-\frac{z \cdot x}{y}\right)\\ \end{array} \]
(FPCore (x y z) :precision binary64 (/ (* x (- y z)) y))
(FPCore (x y z)
 :precision binary64
 (if (<= (/ (* x (- y z)) y) (- INFINITY)) x (+ x (- (/ (* z x) y)))))
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) <= -((double) INFINITY)) {
		tmp = x;
	} else {
		tmp = x + -((z * x) / y);
	}
	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 tmp;
	if (((x * (y - z)) / y) <= -Double.POSITIVE_INFINITY) {
		tmp = x;
	} else {
		tmp = x + -((z * x) / y);
	}
	return tmp;
}
def code(x, y, z):
	return (x * (y - z)) / y
def code(x, y, z):
	tmp = 0
	if ((x * (y - z)) / y) <= -math.inf:
		tmp = x
	else:
		tmp = x + -((z * x) / y)
	return tmp
function code(x, y, z)
	return Float64(Float64(x * Float64(y - z)) / y)
end
function code(x, y, z)
	tmp = 0.0
	if (Float64(Float64(x * Float64(y - z)) / y) <= Float64(-Inf))
		tmp = x;
	else
		tmp = Float64(x + Float64(-Float64(Float64(z * x) / y)));
	end
	return tmp
end
function tmp = code(x, y, z)
	tmp = (x * (y - z)) / y;
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (((x * (y - z)) / y) <= -Inf)
		tmp = x;
	else
		tmp = x + -((z * x) / y);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]
code[x_, y_, z_] := If[LessEqual[N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision], (-Infinity)], x, N[(x + (-N[(N[(z * x), $MachinePrecision] / y), $MachinePrecision])), $MachinePrecision]]
\frac{x \cdot \left(y - z\right)}{y}
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot \left(y - z\right)}{y} \leq -\infty:\\
\;\;\;\;x\\

\mathbf{else}:\\
\;\;\;\;x + \left(-\frac{z \cdot x}{y}\right)\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original12.0
Target3.1
Herbie3.8
\[\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 2 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. Taylor expanded in y around inf 10.5

      \[\leadsto \color{blue}{x} \]

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

    1. Initial program 8.0

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

      \[\leadsto \color{blue}{-1 \cdot \frac{z \cdot x}{y} + x} \]
    3. Simplified3.3

      \[\leadsto \color{blue}{x + \left(-\frac{z \cdot x}{y}\right)} \]
      Proof

      [Start]3.3

      \[ -1 \cdot \frac{z \cdot x}{y} + x \]

      rational.json-simplify-1 [=>]3.3

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

      rational.json-simplify-2 [=>]3.3

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

      rational.json-simplify-9 [=>]3.3

      \[ x + \color{blue}{\left(-\frac{z \cdot x}{y}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification3.8

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

Alternatives

Alternative 1
Error4.7
Cost1480
\[\begin{array}{l} t_0 := \frac{x \cdot \left(y - z\right)}{y}\\ \mathbf{if}\;t_0 \leq -\infty:\\ \;\;\;\;x\\ \mathbf{elif}\;t_0 \leq 10^{+301}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Error19.0
Cost648
\[\begin{array}{l} t_0 := \frac{z \cdot \left(-x\right)}{y}\\ \mathbf{if}\;z \leq -2 \cdot 10^{+41}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 3.2 \cdot 10^{+137}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error26.0
Cost64
\[x \]

Error

Reproduce?

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