?

Average Error: 23.2% → 0.56%
Time: 5.8s
Precision: binary64
Cost: 1360

?

\[ \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{y}{\frac{z}{x}}\\ \mathbf{elif}\;\frac{y}{z} \leq -1 \cdot 10^{-234}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{elif}\;\frac{y}{z} \leq 10^{-169}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \mathbf{elif}\;\frac{y}{z} \leq 2 \cdot 10^{+254}:\\ \;\;\;\;\frac{y}{z} \cdot x\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{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))
   (/ y (/ z x))
   (if (<= (/ y z) -1e-234)
     (/ x (/ z y))
     (if (<= (/ y z) 1e-169)
       (/ (* y x) z)
       (if (<= (/ y z) 2e+254) (* (/ y z) x) (* 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 = y / (z / x);
	} else if ((y / z) <= -1e-234) {
		tmp = x / (z / y);
	} else if ((y / z) <= 1e-169) {
		tmp = (y * x) / z;
	} else if ((y / z) <= 2e+254) {
		tmp = (y / z) * x;
	} 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 = y / (z / x);
	} else if ((y / z) <= -1e-234) {
		tmp = x / (z / y);
	} else if ((y / z) <= 1e-169) {
		tmp = (y * x) / z;
	} else if ((y / z) <= 2e+254) {
		tmp = (y / z) * x;
	} 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 = y / (z / x)
	elif (y / z) <= -1e-234:
		tmp = x / (z / y)
	elif (y / z) <= 1e-169:
		tmp = (y * x) / z
	elif (y / z) <= 2e+254:
		tmp = (y / z) * x
	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(y / Float64(z / x));
	elseif (Float64(y / z) <= -1e-234)
		tmp = Float64(x / Float64(z / y));
	elseif (Float64(y / z) <= 1e-169)
		tmp = Float64(Float64(y * x) / z);
	elseif (Float64(y / z) <= 2e+254)
		tmp = Float64(Float64(y / z) * x);
	else
		tmp = Float64(y * Float64(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 = y / (z / x);
	elseif ((y / z) <= -1e-234)
		tmp = x / (z / y);
	elseif ((y / z) <= 1e-169)
		tmp = (y * x) / z;
	elseif ((y / z) <= 2e+254)
		tmp = (y / z) * x;
	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[(y / N[(z / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(y / z), $MachinePrecision], -1e-234], N[(x / N[(z / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(y / z), $MachinePrecision], 1e-169], N[(N[(y * x), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[N[(y / z), $MachinePrecision], 2e+254], N[(N[(y / z), $MachinePrecision] * x), $MachinePrecision], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]]]]]
x \cdot \frac{\frac{y}{z} \cdot t}{t}
\begin{array}{l}
\mathbf{if}\;\frac{y}{z} \leq -\infty:\\
\;\;\;\;\frac{y}{\frac{z}{x}}\\

\mathbf{elif}\;\frac{y}{z} \leq -1 \cdot 10^{-234}:\\
\;\;\;\;\frac{x}{\frac{z}{y}}\\

\mathbf{elif}\;\frac{y}{z} \leq 10^{-169}:\\
\;\;\;\;\frac{y \cdot x}{z}\\

\mathbf{elif}\;\frac{y}{z} \leq 2 \cdot 10^{+254}:\\
\;\;\;\;\frac{y}{z} \cdot x\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original23.2%
Target2.32%
Herbie0.56%
\[\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 5 regimes
  2. if (/.f64 y z) < -inf.0

    1. Initial program 100

      \[x \cdot \frac{\frac{y}{z} \cdot t}{t} \]
    2. Simplified0.43

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

      [Start]100

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

      associate-/l* [=>]100

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

      *-inverses [=>]100

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

      /-rgt-identity [=>]100

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

      associate-*r/ [=>]0.43

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

      associate-*l/ [<=]0.43

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

      *-commutative [<=]0.43

      \[ \color{blue}{y \cdot \frac{x}{z}} \]
    3. Applied egg-rr0.41

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

    if -inf.0 < (/.f64 y z) < -9.9999999999999996e-235

    1. Initial program 17.2

      \[x \cdot \frac{\frac{y}{z} \cdot t}{t} \]
    2. Simplified0.36

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

      [Start]17.2

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

      associate-/l* [=>]0.36

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

      *-inverses [=>]0.36

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

      /-rgt-identity [=>]0.36

      \[ x \cdot \color{blue}{\frac{y}{z}} \]
    3. Applied egg-rr0.37

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

    if -9.9999999999999996e-235 < (/.f64 y z) < 1.00000000000000002e-169

    1. Initial program 25.26

      \[x \cdot \frac{\frac{y}{z} \cdot t}{t} \]
    2. Simplified15.45

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

      [Start]25.26

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

      associate-/l* [=>]15.45

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

      *-inverses [=>]15.45

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

      /-rgt-identity [=>]15.45

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

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

    if 1.00000000000000002e-169 < (/.f64 y z) < 1.9999999999999999e254

    1. Initial program 14.18

      \[x \cdot \frac{\frac{y}{z} \cdot t}{t} \]
    2. Simplified0.37

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

      [Start]14.18

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

      associate-/l* [=>]0.37

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

      *-inverses [=>]0.37

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

      /-rgt-identity [=>]0.37

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

    if 1.9999999999999999e254 < (/.f64 y z)

    1. Initial program 83.51

      \[x \cdot \frac{\frac{y}{z} \cdot t}{t} \]
    2. Simplified0.39

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

      [Start]83.51

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

      associate-/l* [=>]59.7

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

      *-inverses [=>]59.7

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

      /-rgt-identity [=>]59.7

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

      associate-*r/ [=>]0.77

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

      associate-*l/ [<=]0.39

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

      *-commutative [<=]0.39

      \[ \color{blue}{y \cdot \frac{x}{z}} \]
  3. Recombined 5 regimes into one program.
  4. Final simplification0.56

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} \leq -\infty:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;\frac{y}{z} \leq -1 \cdot 10^{-234}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{elif}\;\frac{y}{z} \leq 10^{-169}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \mathbf{elif}\;\frac{y}{z} \leq 2 \cdot 10^{+254}:\\ \;\;\;\;\frac{y}{z} \cdot x\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \end{array} \]

Alternatives

Alternative 1
Error0.81%
Cost1362
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z} \leq -\infty \lor \neg \left(\frac{y}{z} \leq -2 \cdot 10^{-146}\right) \land \left(\frac{y}{z} \leq 4 \cdot 10^{-215} \lor \neg \left(\frac{y}{z} \leq 2 \cdot 10^{+254}\right)\right):\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot x\\ \end{array} \]
Alternative 2
Error0.39%
Cost1361
\[\begin{array}{l} t_1 := y \cdot \frac{x}{z}\\ \mathbf{if}\;\frac{y}{z} \leq -\infty:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{y}{z} \leq -5 \cdot 10^{-250}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{elif}\;\frac{y}{z} \leq 4 \cdot 10^{-215} \lor \neg \left(\frac{y}{z} \leq 2 \cdot 10^{+254}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot x\\ \end{array} \]
Alternative 3
Error0.39%
Cost1361
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z} \leq -\infty:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;\frac{y}{z} \leq -5 \cdot 10^{-250}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{elif}\;\frac{y}{z} \leq 4 \cdot 10^{-215} \lor \neg \left(\frac{y}{z} \leq 2 \cdot 10^{+254}\right):\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot x\\ \end{array} \]
Alternative 4
Error9.35%
Cost320
\[\frac{y}{z} \cdot x \]

Error

Reproduce?

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