?

Average Error: 18.92% → 2.8%
Time: 6.7s
Precision: binary64
Cost: 1481

?

\[\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 \lor \neg \left(t_0 \leq -5 \cdot 10^{-163}\right):\\ \;\;\;\;x - \frac{x}{\frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \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 (or (<= t_0 (- INFINITY)) (not (<= t_0 -5e-163)))
     (- x (/ x (/ y z)))
     t_0)))
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)) || !(t_0 <= -5e-163)) {
		tmp = x - (x / (y / z));
	} else {
		tmp = t_0;
	}
	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) || !(t_0 <= -5e-163)) {
		tmp = x - (x / (y / z));
	} else {
		tmp = t_0;
	}
	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) or not (t_0 <= -5e-163):
		tmp = x - (x / (y / z))
	else:
		tmp = t_0
	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)) || !(t_0 <= -5e-163))
		tmp = Float64(x - Float64(x / Float64(y / z)));
	else
		tmp = t_0;
	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) || ~((t_0 <= -5e-163)))
		tmp = x - (x / (y / z));
	else
		tmp = t_0;
	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[Or[LessEqual[t$95$0, (-Infinity)], N[Not[LessEqual[t$95$0, -5e-163]], $MachinePrecision]], N[(x - N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]
\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 \lor \neg \left(t_0 \leq -5 \cdot 10^{-163}\right):\\
\;\;\;\;x - \frac{x}{\frac{y}{z}}\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original18.92%
Target4.73%
Herbie2.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 or -4.99999999999999977e-163 < (/.f64 (*.f64 x (-.f64 y z)) y)

    1. Initial program 28.15

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

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

      [Start]28.15

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

      associate-*r/ [<=]4.26

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

      div-sub [=>]4.25

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

      distribute-rgt-out-- [<=]4.25

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

      *-inverses [=>]4.25

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

      *-lft-identity [=>]4.25

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

      associate-*l/ [=>]10.84

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

      *-commutative [<=]10.84

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

      associate-/l* [=>]3.93

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

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

    1. Initial program 0.54

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y - z\right)}{y} \leq -\infty \lor \neg \left(\frac{x \cdot \left(y - z\right)}{y} \leq -5 \cdot 10^{-163}\right):\\ \;\;\;\;x - \frac{x}{\frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \left(y - z\right)}{y}\\ \end{array} \]

Alternatives

Alternative 1
Error30.33%
Cost914
\[\begin{array}{l} \mathbf{if}\;z \leq -7.8 \cdot 10^{+35} \lor \neg \left(z \leq -30000000 \lor \neg \left(z \leq -1.7 \cdot 10^{-44}\right) \land z \leq 5.5 \cdot 10^{-35}\right):\\ \;\;\;\;z \cdot \frac{-x}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Error31.73%
Cost912
\[\begin{array}{l} t_0 := z \cdot \frac{-x}{y}\\ \mathbf{if}\;z \leq -1.4 \cdot 10^{+36}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -230000000000:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -6.5 \cdot 10^{-45}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 5.8 \cdot 10^{-35}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(-\frac{z}{y}\right)\\ \end{array} \]
Alternative 3
Error31.68%
Cost912
\[\begin{array}{l} \mathbf{if}\;z \leq -4.5 \cdot 10^{+32}:\\ \;\;\;\;z \cdot \frac{-x}{y}\\ \mathbf{elif}\;z \leq -102000000000:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -3.7 \cdot 10^{-44}:\\ \;\;\;\;\frac{-z}{\frac{y}{x}}\\ \mathbf{elif}\;z \leq 6.5 \cdot 10^{-35}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(-\frac{z}{y}\right)\\ \end{array} \]
Alternative 4
Error31.81%
Cost912
\[\begin{array}{l} \mathbf{if}\;z \leq -4.5 \cdot 10^{+37}:\\ \;\;\;\;\frac{x \cdot \left(-z\right)}{y}\\ \mathbf{elif}\;z \leq -23500000:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -3.6 \cdot 10^{-44}:\\ \;\;\;\;\frac{-z}{\frac{y}{x}}\\ \mathbf{elif}\;z \leq 6 \cdot 10^{-35}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(-\frac{z}{y}\right)\\ \end{array} \]
Alternative 5
Error5.21%
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -1 \cdot 10^{-161} \lor \neg \left(y \leq 2.3 \cdot 10^{-158}\right):\\ \;\;\;\;x - \frac{x}{\frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\ \end{array} \]
Alternative 6
Error12.34%
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -2.6 \cdot 10^{+179}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 3 \cdot 10^{+193}:\\ \;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 7
Error5.23%
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -2 \cdot 10^{-163}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \mathbf{elif}\;y \leq 2 \cdot 10^{-158}:\\ \;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{x}{\frac{y}{z}}\\ \end{array} \]
Alternative 8
Error40.74%
Cost64
\[x \]

Error

Reproduce?

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