?

Average Accuracy: 81.3% → 98.5%
Time: 3.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} t_1 := \frac{x}{\frac{z}{y}}\\ t_2 := \frac{y \cdot x}{z}\\ \mathbf{if}\;\frac{y}{z} \leq -1 \cdot 10^{+203}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;\frac{y}{z} \leq -1 \cdot 10^{-102}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{y}{z} \leq 4 \cdot 10^{-313}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;\frac{y}{z} \leq 2 \cdot 10^{+126}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \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 (/ z y))) (t_2 (/ (* y x) z)))
   (if (<= (/ y z) -1e+203)
     t_2
     (if (<= (/ y z) -1e-102)
       t_1
       (if (<= (/ y z) 4e-313)
         t_2
         (if (<= (/ y z) 2e+126) t_1 (/ y (/ z x))))))))
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 / (z / y);
	double t_2 = (y * x) / z;
	double tmp;
	if ((y / z) <= -1e+203) {
		tmp = t_2;
	} else if ((y / z) <= -1e-102) {
		tmp = t_1;
	} else if ((y / z) <= 4e-313) {
		tmp = t_2;
	} else if ((y / z) <= 2e+126) {
		tmp = t_1;
	} else {
		tmp = y / (z / x);
	}
	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) :: t_2
    real(8) :: tmp
    t_1 = x / (z / y)
    t_2 = (y * x) / z
    if ((y / z) <= (-1d+203)) then
        tmp = t_2
    else if ((y / z) <= (-1d-102)) then
        tmp = t_1
    else if ((y / z) <= 4d-313) then
        tmp = t_2
    else if ((y / z) <= 2d+126) then
        tmp = t_1
    else
        tmp = y / (z / x)
    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 = x / (z / y);
	double t_2 = (y * x) / z;
	double tmp;
	if ((y / z) <= -1e+203) {
		tmp = t_2;
	} else if ((y / z) <= -1e-102) {
		tmp = t_1;
	} else if ((y / z) <= 4e-313) {
		tmp = t_2;
	} else if ((y / z) <= 2e+126) {
		tmp = t_1;
	} else {
		tmp = y / (z / x);
	}
	return tmp;
}
def code(x, y, z, t):
	return x * (((y / z) * t) / t)
def code(x, y, z, t):
	t_1 = x / (z / y)
	t_2 = (y * x) / z
	tmp = 0
	if (y / z) <= -1e+203:
		tmp = t_2
	elif (y / z) <= -1e-102:
		tmp = t_1
	elif (y / z) <= 4e-313:
		tmp = t_2
	elif (y / z) <= 2e+126:
		tmp = t_1
	else:
		tmp = y / (z / x)
	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(z / y))
	t_2 = Float64(Float64(y * x) / z)
	tmp = 0.0
	if (Float64(y / z) <= -1e+203)
		tmp = t_2;
	elseif (Float64(y / z) <= -1e-102)
		tmp = t_1;
	elseif (Float64(y / z) <= 4e-313)
		tmp = t_2;
	elseif (Float64(y / z) <= 2e+126)
		tmp = t_1;
	else
		tmp = Float64(y / Float64(z / x));
	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 / (z / y);
	t_2 = (y * x) / z;
	tmp = 0.0;
	if ((y / z) <= -1e+203)
		tmp = t_2;
	elseif ((y / z) <= -1e-102)
		tmp = t_1;
	elseif ((y / z) <= 4e-313)
		tmp = t_2;
	elseif ((y / z) <= 2e+126)
		tmp = t_1;
	else
		tmp = y / (z / x);
	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[(z / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(y * x), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[N[(y / z), $MachinePrecision], -1e+203], t$95$2, If[LessEqual[N[(y / z), $MachinePrecision], -1e-102], t$95$1, If[LessEqual[N[(y / z), $MachinePrecision], 4e-313], t$95$2, If[LessEqual[N[(y / z), $MachinePrecision], 2e+126], t$95$1, N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision]]]]]]]
x \cdot \frac{\frac{y}{z} \cdot t}{t}
\begin{array}{l}
t_1 := \frac{x}{\frac{z}{y}}\\
t_2 := \frac{y \cdot x}{z}\\
\mathbf{if}\;\frac{y}{z} \leq -1 \cdot 10^{+203}:\\
\;\;\;\;t_2\\

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

\mathbf{elif}\;\frac{y}{z} \leq 4 \cdot 10^{-313}:\\
\;\;\;\;t_2\\

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

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


\end{array}

Error?

Bogosity?

Bogosity

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original81.3%
Target98.2%
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 3 regimes
  2. if (/.f64 y z) < -9.9999999999999999e202 or -9.99999999999999933e-103 < (/.f64 y z) < 4.0000000000037e-313

    1. Initial program 81.4%

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

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

      [Start]81.4

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

      associate-/l* [=>]93.7

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

      *-inverses [=>]93.7

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

      /-rgt-identity [=>]93.7

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

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

    if -9.9999999999999999e202 < (/.f64 y z) < -9.99999999999999933e-103 or 4.0000000000037e-313 < (/.f64 y z) < 1.99999999999999985e126

    1. Initial program 88.3%

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

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

      [Start]88.3

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

      associate-/l* [=>]99.5

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

      *-inverses [=>]99.5

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

      /-rgt-identity [=>]99.5

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

      \[\leadsto \color{blue}{\frac{y \cdot x}{z}} \]
    4. Simplified99.0%

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

      [Start]85.5

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

      *-commutative [=>]85.5

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

      associate-/l* [=>]99.0

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

    if 1.99999999999999985e126 < (/.f64 y z)

    1. Initial program 57.9%

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

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

      [Start]57.9

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

      *-commutative [=>]57.9

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

      associate-/l* [=>]77.7

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

      *-inverses [=>]77.7

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

      /-rgt-identity [=>]77.7

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

      associate-*l/ [=>]98.0

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

      associate-*r/ [<=]97.4

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

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

      [Start]97.4

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

      clear-num [=>]97.4

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

      un-div-inv [=>]97.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} \leq -1 \cdot 10^{+203}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \mathbf{elif}\;\frac{y}{z} \leq -1 \cdot 10^{-102}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{elif}\;\frac{y}{z} \leq 4 \cdot 10^{-313}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \mathbf{elif}\;\frac{y}{z} \leq 2 \cdot 10^{+126}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \end{array} \]

Alternatives

Alternative 1
Accuracy99.4%
Cost1362
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z} \leq -1 \cdot 10^{+286} \lor \neg \left(\frac{y}{z} \leq -1 \cdot 10^{-197}\right) \land \left(\frac{y}{z} \leq 4 \cdot 10^{-272} \lor \neg \left(\frac{y}{z} \leq 5 \cdot 10^{+165}\right)\right):\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot x\\ \end{array} \]
Alternative 2
Accuracy99.2%
Cost1362
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z} \leq -\infty \lor \neg \left(\frac{y}{z} \leq -1 \cdot 10^{-181} \lor \neg \left(\frac{y}{z} \leq 4 \cdot 10^{-313}\right) \land \frac{y}{z} \leq 5 \cdot 10^{+165}\right):\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \end{array} \]
Alternative 3
Accuracy99.1%
Cost1361
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z} \leq -\infty:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;\frac{y}{z} \leq -2 \cdot 10^{-213} \lor \neg \left(\frac{y}{z} \leq 4 \cdot 10^{-313}\right) \land \frac{y}{z} \leq 2 \cdot 10^{+126}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \end{array} \]
Alternative 4
Accuracy92.3%
Cost320
\[\frac{y}{z} \cdot x \]

Error

Reproduce?

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