?

Average Accuracy: 76.9% → 98.5%
Time: 4.0s
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} t_1 := \frac{y}{\frac{z}{x}}\\ \mathbf{if}\;\frac{y}{z} \leq -5 \cdot 10^{+198}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{y}{z} \leq -1 \cdot 10^{-259}:\\ \;\;\;\;\frac{y}{z} \cdot x\\ \mathbf{elif}\;\frac{y}{z} \leq 10^{-271}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{y}{z} \leq 10^{+78}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \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
 (let* ((t_1 (/ y (/ z x))))
   (if (<= (/ y z) -5e+198)
     t_1
     (if (<= (/ y z) -1e-259)
       (* (/ y z) x)
       (if (<= (/ y z) 1e-271)
         t_1
         (if (<= (/ y z) 1e+78) (/ 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 t_1 = y / (z / x);
	double tmp;
	if ((y / z) <= -5e+198) {
		tmp = t_1;
	} else if ((y / z) <= -1e-259) {
		tmp = (y / z) * x;
	} else if ((y / z) <= 1e-271) {
		tmp = t_1;
	} else if ((y / z) <= 1e+78) {
		tmp = x / (z / y);
	} else {
		tmp = y * (x / z);
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = x * (((y / z) * t) / t)
end function
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: t_1
    real(8) :: tmp
    t_1 = y / (z / x)
    if ((y / z) <= (-5d+198)) then
        tmp = t_1
    else if ((y / z) <= (-1d-259)) then
        tmp = (y / z) * x
    else if ((y / z) <= 1d-271) then
        tmp = t_1
    else if ((y / z) <= 1d+78) then
        tmp = x / (z / y)
    else
        tmp = y * (x / z)
    end if
    code = tmp
end function
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 = y / (z / x);
	double tmp;
	if ((y / z) <= -5e+198) {
		tmp = t_1;
	} else if ((y / z) <= -1e-259) {
		tmp = (y / z) * x;
	} else if ((y / z) <= 1e-271) {
		tmp = t_1;
	} else if ((y / z) <= 1e+78) {
		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):
	t_1 = y / (z / x)
	tmp = 0
	if (y / z) <= -5e+198:
		tmp = t_1
	elif (y / z) <= -1e-259:
		tmp = (y / z) * x
	elif (y / z) <= 1e-271:
		tmp = t_1
	elif (y / z) <= 1e+78:
		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)
	t_1 = Float64(y / Float64(z / x))
	tmp = 0.0
	if (Float64(y / z) <= -5e+198)
		tmp = t_1;
	elseif (Float64(y / z) <= -1e-259)
		tmp = Float64(Float64(y / z) * x);
	elseif (Float64(y / z) <= 1e-271)
		tmp = t_1;
	elseif (Float64(y / z) <= 1e+78)
		tmp = Float64(x / Float64(z / y));
	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)
	t_1 = y / (z / x);
	tmp = 0.0;
	if ((y / z) <= -5e+198)
		tmp = t_1;
	elseif ((y / z) <= -1e-259)
		tmp = (y / z) * x;
	elseif ((y / z) <= 1e-271)
		tmp = t_1;
	elseif ((y / z) <= 1e+78)
		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_] := Block[{t$95$1 = N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(y / z), $MachinePrecision], -5e+198], t$95$1, If[LessEqual[N[(y / z), $MachinePrecision], -1e-259], N[(N[(y / z), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[N[(y / z), $MachinePrecision], 1e-271], t$95$1, If[LessEqual[N[(y / z), $MachinePrecision], 1e+78], N[(x / N[(z / y), $MachinePrecision]), $MachinePrecision], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]]]]]]
x \cdot \frac{\frac{y}{z} \cdot t}{t}
\begin{array}{l}
t_1 := \frac{y}{\frac{z}{x}}\\
\mathbf{if}\;\frac{y}{z} \leq -5 \cdot 10^{+198}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;\frac{y}{z} \leq 10^{-271}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;\frac{y}{z} \leq 10^{+78}:\\
\;\;\;\;\frac{x}{\frac{z}{y}}\\

\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

Original76.9%
Target97.6%
Herbie98.5%
\[\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 y z) < -5.00000000000000049e198 or -1.0000000000000001e-259 < (/.f64 y z) < 9.99999999999999963e-272

    1. Initial program 61.0%

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

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

      [Start]61.0

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

      associate-/l* [=>]71.7

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

      *-inverses [=>]71.7

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

      /-rgt-identity [=>]71.7

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

      associate-*r/ [=>]99.5

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

      associate-*l/ [<=]99.2

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

      *-commutative [<=]99.2

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

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

    if -5.00000000000000049e198 < (/.f64 y z) < -1.0000000000000001e-259

    1. Initial program 87.5%

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

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

      [Start]87.5

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

      associate-/l* [=>]99.6

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

      *-inverses [=>]99.6

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

      /-rgt-identity [=>]99.6

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

    if 9.99999999999999963e-272 < (/.f64 y z) < 1.00000000000000001e78

    1. Initial program 88.7%

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

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

      [Start]88.7

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

      associate-/l* [=>]99.6

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

      *-inverses [=>]99.6

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

      /-rgt-identity [=>]99.6

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

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

    if 1.00000000000000001e78 < (/.f64 y z)

    1. Initial program 58.0%

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

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

      [Start]58.0

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

      associate-/l* [=>]79.6

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

      *-inverses [=>]79.6

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

      /-rgt-identity [=>]79.6

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

      associate-*r/ [=>]93.3

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

      associate-*l/ [<=]92.0

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

      *-commutative [<=]92.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} \leq -5 \cdot 10^{+198}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;\frac{y}{z} \leq -1 \cdot 10^{-259}:\\ \;\;\;\;\frac{y}{z} \cdot x\\ \mathbf{elif}\;\frac{y}{z} \leq 10^{-271}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;\frac{y}{z} \leq 10^{+78}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \end{array} \]

Alternatives

Alternative 1
Accuracy98.4%
Cost1362
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z} \leq -\infty \lor \neg \left(\frac{y}{z} \leq -1 \cdot 10^{-202}\right) \land \left(\frac{y}{z} \leq 0 \lor \neg \left(\frac{y}{z} \leq 10^{+78}\right)\right):\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot x\\ \end{array} \]
Alternative 2
Accuracy98.2%
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 -1 \cdot 10^{-202}:\\ \;\;\;\;\frac{y}{z} \cdot x\\ \mathbf{elif}\;\frac{y}{z} \leq 0 \lor \neg \left(\frac{y}{z} \leq 10^{+78}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \end{array} \]
Alternative 3
Accuracy89.6%
Cost320
\[\frac{y}{z} \cdot x \]

Error

Reproduce?

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