?

Average Accuracy: 76.8% → 97.0%
Time: 6.6s
Precision: binary64
Cost: 1101

?

\[ \begin{array}{c}[x, y] = \mathsf{sort}([x, y])\\ \end{array} \]
\[x \cdot \frac{\frac{y}{z} \cdot t}{t} \]
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z} \leq -\infty:\\ \;\;\;\;\frac{1}{\frac{\frac{z}{x}}{y}}\\ \mathbf{elif}\;\frac{y}{z} \leq -2 \cdot 10^{-154} \lor \neg \left(\frac{y}{z} \leq 5 \cdot 10^{-231}\right):\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (* x (/ (* (/ y z) t) t)))
(FPCore (x y z t)
 :precision binary64
 (if (<= (/ y z) (- INFINITY))
   (/ 1.0 (/ (/ z x) y))
   (if (or (<= (/ y z) -2e-154) (not (<= (/ y z) 5e-231)))
     (/ x (/ z y))
     (/ (* y x) z))))
double code(double x, double y, double z, double t) {
	return x * (((y / z) * t) / t);
}
double code(double x, double y, double z, double t) {
	double tmp;
	if ((y / z) <= -((double) INFINITY)) {
		tmp = 1.0 / ((z / x) / y);
	} else if (((y / z) <= -2e-154) || !((y / z) <= 5e-231)) {
		tmp = x / (z / y);
	} else {
		tmp = (y * x) / z;
	}
	return tmp;
}
public static double code(double x, double y, double z, double t) {
	return x * (((y / z) * t) / t);
}
public static double code(double x, double y, double z, double t) {
	double tmp;
	if ((y / z) <= -Double.POSITIVE_INFINITY) {
		tmp = 1.0 / ((z / x) / y);
	} else if (((y / z) <= -2e-154) || !((y / z) <= 5e-231)) {
		tmp = x / (z / y);
	} else {
		tmp = (y * x) / z;
	}
	return tmp;
}
def code(x, y, z, t):
	return x * (((y / z) * t) / t)
def code(x, y, z, t):
	tmp = 0
	if (y / z) <= -math.inf:
		tmp = 1.0 / ((z / x) / y)
	elif ((y / z) <= -2e-154) or not ((y / z) <= 5e-231):
		tmp = x / (z / y)
	else:
		tmp = (y * x) / z
	return tmp
function code(x, y, z, t)
	return Float64(x * Float64(Float64(Float64(y / z) * t) / t))
end
function code(x, y, z, t)
	tmp = 0.0
	if (Float64(y / z) <= Float64(-Inf))
		tmp = Float64(1.0 / Float64(Float64(z / x) / y));
	elseif ((Float64(y / z) <= -2e-154) || !(Float64(y / z) <= 5e-231))
		tmp = Float64(x / Float64(z / y));
	else
		tmp = Float64(Float64(y * x) / z);
	end
	return tmp
end
function tmp = code(x, y, z, t)
	tmp = x * (((y / z) * t) / t);
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if ((y / z) <= -Inf)
		tmp = 1.0 / ((z / x) / y);
	elseif (((y / z) <= -2e-154) || ~(((y / z) <= 5e-231)))
		tmp = x / (z / y);
	else
		tmp = (y * x) / z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := N[(x * N[(N[(N[(y / z), $MachinePrecision] * t), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := If[LessEqual[N[(y / z), $MachinePrecision], (-Infinity)], N[(1.0 / N[(N[(z / x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[N[(y / z), $MachinePrecision], -2e-154], N[Not[LessEqual[N[(y / z), $MachinePrecision], 5e-231]], $MachinePrecision]], N[(x / N[(z / y), $MachinePrecision]), $MachinePrecision], N[(N[(y * x), $MachinePrecision] / z), $MachinePrecision]]]
x \cdot \frac{\frac{y}{z} \cdot t}{t}
\begin{array}{l}
\mathbf{if}\;\frac{y}{z} \leq -\infty:\\
\;\;\;\;\frac{1}{\frac{\frac{z}{x}}{y}}\\

\mathbf{elif}\;\frac{y}{z} \leq -2 \cdot 10^{-154} \lor \neg \left(\frac{y}{z} \leq 5 \cdot 10^{-231}\right):\\
\;\;\;\;\frac{x}{\frac{z}{y}}\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original76.8%
Target97.5%
Herbie97.0%
\[\begin{array}{l} \mathbf{if}\;\frac{\frac{y}{z} \cdot t}{t} < -1.20672205123045 \cdot 10^{+245}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;\frac{\frac{y}{z} \cdot t}{t} < -5.907522236933906 \cdot 10^{-275}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;\frac{\frac{y}{z} \cdot t}{t} < 5.658954423153415 \cdot 10^{-65}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;\frac{\frac{y}{z} \cdot t}{t} < 2.0087180502407133 \cdot 10^{+217}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \end{array} \]

Derivation?

  1. Split input into 3 regimes
  2. if (/.f64 y z) < -inf.0

    1. Initial program 0.0%

      \[x \cdot \frac{\frac{y}{z} \cdot t}{t} \]
    2. Simplified99.7%

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

      [Start]0.0

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

      associate-/l* [=>]0.0

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

      *-inverses [=>]0.0

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

      /-rgt-identity [=>]0.0

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

      associate-*r/ [=>]99.6

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

      associate-*l/ [<=]99.7

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

      *-commutative [<=]99.7

      \[ \color{blue}{y \cdot \frac{x}{z}} \]
    3. Applied egg-rr99.4%

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

      [Start]99.7

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

      associate-*r/ [=>]99.6

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

      clear-num [=>]99.4

      \[ \color{blue}{\frac{1}{\frac{z}{y \cdot x}}} \]
    4. Applied egg-rr99.3%

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

      [Start]99.4

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

      *-un-lft-identity [=>]99.4

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

      times-frac [=>]99.3

      \[ \frac{1}{\color{blue}{\frac{1}{y} \cdot \frac{z}{x}}} \]
    5. Applied egg-rr99.4%

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

      [Start]99.3

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

      associate-*l/ [=>]99.4

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

      *-un-lft-identity [<=]99.4

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

    if -inf.0 < (/.f64 y z) < -1.9999999999999999e-154 or 5.00000000000000023e-231 < (/.f64 y z)

    1. Initial program 81.4%

      \[x \cdot \frac{\frac{y}{z} \cdot t}{t} \]
    2. Simplified96.0%

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

      [Start]81.4

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

      associate-/l* [=>]96.0

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

      *-inverses [=>]96.0

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

      /-rgt-identity [=>]96.0

      \[ x \cdot \color{blue}{\frac{y}{z}} \]
    3. Applied egg-rr96.4%

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

      [Start]96.0

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

      associate-*r/ [=>]86.6

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

      associate-/l* [=>]96.4

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

    if -1.9999999999999999e-154 < (/.f64 y z) < 5.00000000000000023e-231

    1. Initial program 72.3%

      \[x \cdot \frac{\frac{y}{z} \cdot t}{t} \]
    2. Simplified83.1%

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

      [Start]72.3

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

      associate-/l* [=>]83.1

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

      *-inverses [=>]83.1

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

      /-rgt-identity [=>]83.1

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

      \[\leadsto \color{blue}{\frac{y \cdot x}{z}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification97.0%

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

Alternatives

Alternative 1
Accuracy97.0%
Cost1101
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z} \leq -2 \cdot 10^{+219} \lor \neg \left(\frac{y}{z} \leq -1 \cdot 10^{-211}\right) \land \frac{y}{z} \leq 10^{-316}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot x\\ \end{array} \]
Alternative 2
Accuracy97.2%
Cost1101
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z} \leq -\infty \lor \neg \left(\frac{y}{z} \leq -1 \cdot 10^{-211}\right) \land \frac{y}{z} \leq 10^{-316}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \end{array} \]
Alternative 3
Accuracy97.2%
Cost1101
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z} \leq -\infty:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;\frac{y}{z} \leq -1 \cdot 10^{-211} \lor \neg \left(\frac{y}{z} \leq 10^{-316}\right):\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \end{array} \]
Alternative 4
Accuracy97.0%
Cost1101
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z} \leq -\infty:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;\frac{y}{z} \leq -2 \cdot 10^{-154} \lor \neg \left(\frac{y}{z} \leq 5 \cdot 10^{-231}\right):\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \end{array} \]
Alternative 5
Accuracy90.1%
Cost320
\[\frac{y}{z} \cdot x \]

Error

Reproduce?

herbie shell --seed 2023138 
(FPCore (x y z t)
  :name "Graphics.Rendering.Chart.Backend.Diagrams:calcFontMetrics from Chart-diagrams-1.5.1, B"
  :precision binary64

  :herbie-target
  (if (< (/ (* (/ y z) t) t) -1.20672205123045e+245) (/ y (/ z x)) (if (< (/ (* (/ y z) t) t) -5.907522236933906e-275) (* x (/ y z)) (if (< (/ (* (/ y z) t) t) 5.658954423153415e-65) (/ y (/ z x)) (if (< (/ (* (/ y z) t) t) 2.0087180502407133e+217) (* x (/ y z)) (/ (* y x) z)))))

  (* x (/ (* (/ y z) t) t)))