?

Average Accuracy: 76.9% → 97.6%
Time: 7.4s
Precision: binary64
Cost: 3024

?

\[ \begin{array}{c}[x, y] = \mathsf{sort}([x, y])\\ \end{array} \]
\[x \cdot \frac{\frac{y}{z} \cdot t}{t} \]
\[\begin{array}{l} t_1 := x \cdot \frac{y}{z}\\ t_2 := x \cdot \frac{\frac{y}{z} \cdot t}{t}\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;t_2 \leq -1 \cdot 10^{-305}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_2 \leq 0:\\ \;\;\;\;\left(x \cdot y\right) \cdot \frac{1}{z}\\ \mathbf{elif}\;t_2 \leq 2 \cdot 10^{+233}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{z}{x \cdot y}}\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (* x (/ (* (/ y z) t) t)))
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* x (/ y z))) (t_2 (* x (/ (* (/ y z) t) t))))
   (if (<= t_2 (- INFINITY))
     (/ (* x y) z)
     (if (<= t_2 -1e-305)
       t_1
       (if (<= t_2 0.0)
         (* (* x y) (/ 1.0 z))
         (if (<= t_2 2e+233) t_1 (/ 1.0 (/ z (* x y)))))))))
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 t_1 = x * (y / z);
	double t_2 = x * (((y / z) * t) / t);
	double tmp;
	if (t_2 <= -((double) INFINITY)) {
		tmp = (x * y) / z;
	} else if (t_2 <= -1e-305) {
		tmp = t_1;
	} else if (t_2 <= 0.0) {
		tmp = (x * y) * (1.0 / z);
	} else if (t_2 <= 2e+233) {
		tmp = t_1;
	} else {
		tmp = 1.0 / (z / (x * y));
	}
	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 t_1 = x * (y / z);
	double t_2 = x * (((y / z) * t) / t);
	double tmp;
	if (t_2 <= -Double.POSITIVE_INFINITY) {
		tmp = (x * y) / z;
	} else if (t_2 <= -1e-305) {
		tmp = t_1;
	} else if (t_2 <= 0.0) {
		tmp = (x * y) * (1.0 / z);
	} else if (t_2 <= 2e+233) {
		tmp = t_1;
	} else {
		tmp = 1.0 / (z / (x * y));
	}
	return tmp;
}
def code(x, y, z, t):
	return x * (((y / z) * t) / t)
def code(x, y, z, t):
	t_1 = x * (y / z)
	t_2 = x * (((y / z) * t) / t)
	tmp = 0
	if t_2 <= -math.inf:
		tmp = (x * y) / z
	elif t_2 <= -1e-305:
		tmp = t_1
	elif t_2 <= 0.0:
		tmp = (x * y) * (1.0 / z)
	elif t_2 <= 2e+233:
		tmp = t_1
	else:
		tmp = 1.0 / (z / (x * y))
	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)
	t_1 = Float64(x * Float64(y / z))
	t_2 = Float64(x * Float64(Float64(Float64(y / z) * t) / t))
	tmp = 0.0
	if (t_2 <= Float64(-Inf))
		tmp = Float64(Float64(x * y) / z);
	elseif (t_2 <= -1e-305)
		tmp = t_1;
	elseif (t_2 <= 0.0)
		tmp = Float64(Float64(x * y) * Float64(1.0 / z));
	elseif (t_2 <= 2e+233)
		tmp = t_1;
	else
		tmp = Float64(1.0 / Float64(z / Float64(x * y)));
	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)
	t_1 = x * (y / z);
	t_2 = x * (((y / z) * t) / t);
	tmp = 0.0;
	if (t_2 <= -Inf)
		tmp = (x * y) / z;
	elseif (t_2 <= -1e-305)
		tmp = t_1;
	elseif (t_2 <= 0.0)
		tmp = (x * y) * (1.0 / z);
	elseif (t_2 <= 2e+233)
		tmp = t_1;
	else
		tmp = 1.0 / (z / (x * y));
	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_] := Block[{t$95$1 = N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x * N[(N[(N[(y / z), $MachinePrecision] * t), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[t$95$2, -1e-305], t$95$1, If[LessEqual[t$95$2, 0.0], N[(N[(x * y), $MachinePrecision] * N[(1.0 / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2e+233], t$95$1, N[(1.0 / N[(z / N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
x \cdot \frac{\frac{y}{z} \cdot t}{t}
\begin{array}{l}
t_1 := x \cdot \frac{y}{z}\\
t_2 := x \cdot \frac{\frac{y}{z} \cdot t}{t}\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;\frac{x \cdot y}{z}\\

\mathbf{elif}\;t_2 \leq -1 \cdot 10^{-305}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t_2 \leq 0:\\
\;\;\;\;\left(x \cdot y\right) \cdot \frac{1}{z}\\

\mathbf{elif}\;t_2 \leq 2 \cdot 10^{+233}:\\
\;\;\;\;t_1\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original76.9%
Target97.6%
Herbie97.6%
\[\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 4 regimes
  2. if (*.f64 x (/.f64 (*.f64 (/.f64 y z) t) t)) < -inf.0

    1. Initial program 0.0%

      \[x \cdot \frac{\frac{y}{z} \cdot t}{t} \]
    2. Simplified57.5%

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

      [Start]0.0

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

      associate-/l* [=>]57.5

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

      *-inverses [=>]57.5

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

      /-rgt-identity [=>]57.5

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

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

    if -inf.0 < (*.f64 x (/.f64 (*.f64 (/.f64 y z) t) t)) < -9.99999999999999996e-306 or 0.0 < (*.f64 x (/.f64 (*.f64 (/.f64 y z) t) t)) < 1.99999999999999995e233

    1. Initial program 98.7%

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

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

      [Start]98.7

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

      associate-/l* [=>]99.4

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

      *-inverses [=>]99.4

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

      /-rgt-identity [=>]99.4

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

    if -9.99999999999999996e-306 < (*.f64 x (/.f64 (*.f64 (/.f64 y z) t) t)) < 0.0

    1. Initial program 67.1%

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

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

      [Start]67.1

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

      associate-/l* [=>]85.7

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

      *-inverses [=>]85.7

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

      /-rgt-identity [=>]85.7

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

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

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

      [Start]97.9

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

      div-inv [=>]97.9

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

      *-commutative [=>]97.9

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

    if 1.99999999999999995e233 < (*.f64 x (/.f64 (*.f64 (/.f64 y z) t) t))

    1. Initial program 28.8%

      \[x \cdot \frac{\frac{y}{z} \cdot t}{t} \]
    2. Simplified86.5%

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

      [Start]28.8

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

      associate-/l* [=>]67.5

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

      *-inverses [=>]67.5

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

      /-rgt-identity [=>]67.5

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

      associate-*r/ [=>]88.6

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

      associate-*l/ [<=]86.5

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

      *-commutative [<=]86.5

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

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

      [Start]86.5

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

      associate-*r/ [=>]88.6

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

      clear-num [=>]88.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot \frac{\frac{y}{z} \cdot t}{t} \leq -\infty:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;x \cdot \frac{\frac{y}{z} \cdot t}{t} \leq -1 \cdot 10^{-305}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;x \cdot \frac{\frac{y}{z} \cdot t}{t} \leq 0:\\ \;\;\;\;\left(x \cdot y\right) \cdot \frac{1}{z}\\ \mathbf{elif}\;x \cdot \frac{\frac{y}{z} \cdot t}{t} \leq 2 \cdot 10^{+233}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{z}{x \cdot y}}\\ \end{array} \]

Alternatives

Alternative 1
Accuracy96.8%
Cost1101
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z} \leq -5 \cdot 10^{+183} \lor \neg \left(\frac{y}{z} \leq -5 \cdot 10^{-211}\right) \land \frac{y}{z} \leq 10^{-308}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \end{array} \]
Alternative 2
Accuracy96.9%
Cost1101
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z} \leq -5 \cdot 10^{+152} \lor \neg \left(\frac{y}{z} \leq -5 \cdot 10^{-211}\right) \land \frac{y}{z} \leq 2 \cdot 10^{-292}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \end{array} \]
Alternative 3
Accuracy96.7%
Cost1101
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z} \leq -9.6 \cdot 10^{+131} \lor \neg \left(\frac{y}{z} \leq -5 \cdot 10^{-211}\right) \land \frac{y}{z} \leq 2 \cdot 10^{-292}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \end{array} \]
Alternative 4
Accuracy89.8%
Cost320
\[x \cdot \frac{y}{z} \]

Error

Reproduce?

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