?

Average Accuracy: 76.3% → 97.7%
Time: 5.3s
Precision: binary64
Cost: 1361

?

\[ \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 -2 \cdot 10^{+151}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;\frac{y}{z} \leq -5 \cdot 10^{-253} \lor \neg \left(\frac{y}{z} \leq 10^{-101}\right) \land \frac{y}{z} \leq 5 \cdot 10^{+86}:\\ \;\;\;\;\frac{y}{z} \cdot x\\ \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) -2e+151)
   (/ y (/ z x))
   (if (or (<= (/ y z) -5e-253)
           (and (not (<= (/ y z) 1e-101)) (<= (/ y z) 5e+86)))
     (* (/ 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) <= -2e+151) {
		tmp = y / (z / x);
	} else if (((y / z) <= -5e-253) || (!((y / z) <= 1e-101) && ((y / z) <= 5e+86))) {
		tmp = (y / z) * x;
	} 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) :: tmp
    if ((y / z) <= (-2d+151)) then
        tmp = y / (z / x)
    else if (((y / z) <= (-5d-253)) .or. (.not. ((y / z) <= 1d-101)) .and. ((y / z) <= 5d+86)) then
        tmp = (y / z) * x
    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 tmp;
	if ((y / z) <= -2e+151) {
		tmp = y / (z / x);
	} else if (((y / z) <= -5e-253) || (!((y / z) <= 1e-101) && ((y / z) <= 5e+86))) {
		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) <= -2e+151:
		tmp = y / (z / x)
	elif ((y / z) <= -5e-253) or (not ((y / z) <= 1e-101) and ((y / z) <= 5e+86)):
		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) <= -2e+151)
		tmp = Float64(y / Float64(z / x));
	elseif ((Float64(y / z) <= -5e-253) || (!(Float64(y / z) <= 1e-101) && (Float64(y / z) <= 5e+86)))
		tmp = Float64(Float64(y / z) * x);
	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) <= -2e+151)
		tmp = y / (z / x);
	elseif (((y / z) <= -5e-253) || (~(((y / z) <= 1e-101)) && ((y / z) <= 5e+86)))
		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], -2e+151], N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[N[(y / z), $MachinePrecision], -5e-253], And[N[Not[LessEqual[N[(y / z), $MachinePrecision], 1e-101]], $MachinePrecision], LessEqual[N[(y / z), $MachinePrecision], 5e+86]]], N[(N[(y / z), $MachinePrecision] * x), $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 -2 \cdot 10^{+151}:\\
\;\;\;\;\frac{y}{\frac{z}{x}}\\

\mathbf{elif}\;\frac{y}{z} \leq -5 \cdot 10^{-253} \lor \neg \left(\frac{y}{z} \leq 10^{-101}\right) \land \frac{y}{z} \leq 5 \cdot 10^{+86}:\\
\;\;\;\;\frac{y}{z} \cdot x\\

\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.3%
Target97.7%
Herbie97.7%
\[\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) < -2.00000000000000003e151

    1. Initial program 42.9%

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

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

      [Start]42.9

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

      associate-/l* [=>]69.4

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

      *-inverses [=>]69.4

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

      /-rgt-identity [=>]69.4

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

      associate-*r/ [=>]96.4

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

      associate-*l/ [<=]96.2

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

      *-commutative [<=]96.2

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

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

      [Start]96.2

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

      associate-*r/ [=>]96.4

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

      associate-/l* [=>]96.3

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

    if -2.00000000000000003e151 < (/.f64 y z) < -4.99999999999999971e-253 or 1.00000000000000005e-101 < (/.f64 y z) < 4.9999999999999998e86

    1. Initial program 89.6%

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

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

      [Start]89.6

      \[ 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 -4.99999999999999971e-253 < (/.f64 y z) < 1.00000000000000005e-101 or 4.9999999999999998e86 < (/.f64 y z)

    1. Initial program 68.5%

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

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

      [Start]68.5

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

      associate-/l* [=>]83.0

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

      *-inverses [=>]83.0

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

      /-rgt-identity [=>]83.0

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} \leq -2 \cdot 10^{+151}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;\frac{y}{z} \leq -5 \cdot 10^{-253} \lor \neg \left(\frac{y}{z} \leq 10^{-101}\right) \land \frac{y}{z} \leq 5 \cdot 10^{+86}:\\ \;\;\;\;\frac{y}{z} \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \end{array} \]

Alternatives

Alternative 1
Accuracy99.4%
Cost1362
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z} \leq -2 \cdot 10^{+171} \lor \neg \left(\frac{y}{z} \leq -5 \cdot 10^{-253} \lor \neg \left(\frac{y}{z} \leq 2 \cdot 10^{-311}\right) \land \frac{y}{z} \leq 10^{+188}\right):\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot x\\ \end{array} \]
Alternative 2
Accuracy98.8%
Cost1362
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z} \leq -2 \cdot 10^{+151} \lor \neg \left(\frac{y}{z} \leq -5 \cdot 10^{-219} \lor \neg \left(\frac{y}{z} \leq 2 \cdot 10^{-144}\right) \land \frac{y}{z} \leq 10^{+188}\right):\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot x\\ \end{array} \]
Alternative 3
Accuracy89.8%
Cost320
\[\frac{y}{z} \cdot x \]

Error

Reproduce?

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