?

Average Accuracy: 80.5% → 99.2%
Time: 7.4s
Precision: binary64
Cost: 2513

?

\[\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:\\ \;\;\;\;x - \frac{x}{\frac{y}{z}}\\ \mathbf{elif}\;t_0 \leq -2 \cdot 10^{-63} \lor \neg \left(t_0 \leq 10^{-24}\right) \land t_0 \leq 10^{+260}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x - x \cdot \frac{z}{y}\\ \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 (<= t_0 (- INFINITY))
     (- x (/ x (/ y z)))
     (if (or (<= t_0 -2e-63) (and (not (<= t_0 1e-24)) (<= t_0 1e+260)))
       t_0
       (- x (* x (/ z y)))))))
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)) {
		tmp = x - (x / (y / z));
	} else if ((t_0 <= -2e-63) || (!(t_0 <= 1e-24) && (t_0 <= 1e+260))) {
		tmp = t_0;
	} else {
		tmp = x - (x * (z / 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 t_0 = (x * (y - z)) / y;
	double tmp;
	if (t_0 <= -Double.POSITIVE_INFINITY) {
		tmp = x - (x / (y / z));
	} else if ((t_0 <= -2e-63) || (!(t_0 <= 1e-24) && (t_0 <= 1e+260))) {
		tmp = t_0;
	} else {
		tmp = x - (x * (z / y));
	}
	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:
		tmp = x - (x / (y / z))
	elif (t_0 <= -2e-63) or (not (t_0 <= 1e-24) and (t_0 <= 1e+260)):
		tmp = t_0
	else:
		tmp = x - (x * (z / y))
	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))
		tmp = Float64(x - Float64(x / Float64(y / z)));
	elseif ((t_0 <= -2e-63) || (!(t_0 <= 1e-24) && (t_0 <= 1e+260)))
		tmp = t_0;
	else
		tmp = Float64(x - Float64(x * Float64(z / y)));
	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)
		tmp = x - (x / (y / z));
	elseif ((t_0 <= -2e-63) || (~((t_0 <= 1e-24)) && (t_0 <= 1e+260)))
		tmp = t_0;
	else
		tmp = x - (x * (z / y));
	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[LessEqual[t$95$0, (-Infinity)], N[(x - N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[t$95$0, -2e-63], And[N[Not[LessEqual[t$95$0, 1e-24]], $MachinePrecision], LessEqual[t$95$0, 1e+260]]], t$95$0, N[(x - N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\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:\\
\;\;\;\;x - \frac{x}{\frac{y}{z}}\\

\mathbf{elif}\;t_0 \leq -2 \cdot 10^{-63} \lor \neg \left(t_0 \leq 10^{-24}\right) \land t_0 \leq 10^{+260}:\\
\;\;\;\;t_0\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original80.5%
Target95.2%
Herbie99.2%
\[\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 0.0%

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

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

      [Start]0.0

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

      associate-*l/ [<=]99.7

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

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

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

      associate-*r/ [=>]9.4

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

      associate-*l/ [<=]99.9

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

      *-inverses [=>]99.9

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

      *-lft-identity [=>]99.9

      \[ \color{blue}{x} - z \cdot \frac{x}{y} \]
    3. Taylor expanded in z around 0 65.1%

      \[\leadsto x - \color{blue}{\frac{z \cdot x}{y}} \]
    4. Simplified99.9%

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

      [Start]65.1

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

      *-commutative [=>]65.1

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

      associate-/l* [=>]99.9

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

    if -inf.0 < (/.f64 (*.f64 x (-.f64 y z)) y) < -2.00000000000000013e-63 or 9.99999999999999924e-25 < (/.f64 (*.f64 x (-.f64 y z)) y) < 1.00000000000000007e260

    1. Initial program 99.6%

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

    if -2.00000000000000013e-63 < (/.f64 (*.f64 x (-.f64 y z)) y) < 9.99999999999999924e-25 or 1.00000000000000007e260 < (/.f64 (*.f64 x (-.f64 y z)) y)

    1. Initial program 72.8%

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

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

      [Start]72.8

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

      associate-*l/ [<=]69.9

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

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

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

      associate-*r/ [=>]71.4

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

      associate-*l/ [<=]93.1

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

      *-inverses [=>]93.1

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

      *-lft-identity [=>]93.1

      \[ \color{blue}{x} - z \cdot \frac{x}{y} \]
    3. Taylor expanded in z around 0 89.9%

      \[\leadsto x - \color{blue}{\frac{z \cdot x}{y}} \]
    4. Simplified98.6%

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

      [Start]89.9

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

      associate-*l/ [<=]98.6

      \[ x - \color{blue}{\frac{z}{y} \cdot x} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification99.2%

    \[\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 -2 \cdot 10^{-63} \lor \neg \left(\frac{x \cdot \left(y - z\right)}{y} \leq 10^{-24}\right) \land \frac{x \cdot \left(y - z\right)}{y} \leq 10^{+260}:\\ \;\;\;\;\frac{x \cdot \left(y - z\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;x - x \cdot \frac{z}{y}\\ \end{array} \]

Alternatives

Alternative 1
Accuracy85.6%
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -2.5 \cdot 10^{-140} \lor \neg \left(z \leq 1.08 \cdot 10^{-172}\right):\\ \;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Accuracy93.4%
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -9.6 \cdot 10^{-166} \lor \neg \left(z \leq 5 \cdot 10^{-237}\right):\\ \;\;\;\;x - z \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Accuracy97.4%
Cost713
\[\begin{array}{l} \mathbf{if}\;x \leq -5 \cdot 10^{+33} \lor \neg \left(x \leq 1.5 \cdot 10^{+99}\right):\\ \;\;\;\;x - x \cdot \frac{z}{y}\\ \mathbf{else}:\\ \;\;\;\;x - z \cdot \frac{x}{y}\\ \end{array} \]
Alternative 4
Accuracy97.0%
Cost712
\[\begin{array}{l} \mathbf{if}\;x \leq -2 \cdot 10^{+33}:\\ \;\;\;\;x - x \cdot \frac{z}{y}\\ \mathbf{elif}\;x \leq 2 \cdot 10^{+157}:\\ \;\;\;\;x - z \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{x}{\frac{y}{z}}\\ \end{array} \]
Alternative 5
Accuracy70.9%
Cost648
\[\begin{array}{l} \mathbf{if}\;y \leq -6.6 \cdot 10^{-90}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 5.2 \cdot 10^{-34}:\\ \;\;\;\;\frac{x}{y} \cdot \left(-z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Accuracy70.9%
Cost648
\[\begin{array}{l} \mathbf{if}\;y \leq -5.2 \cdot 10^{-103}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 7.2 \cdot 10^{-33}:\\ \;\;\;\;\frac{-z}{\frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 7
Accuracy71.3%
Cost648
\[\begin{array}{l} \mathbf{if}\;y \leq -4 \cdot 10^{-93}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.9 \cdot 10^{-30}:\\ \;\;\;\;\frac{x \cdot \left(-z\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 8
Accuracy61.3%
Cost64
\[x \]

Error

Reproduce?

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