?

Average Accuracy: 88.5% → 98.8%
Time: 10.7s
Precision: binary64
Cost: 1993

?

\[ \begin{array}{c}[x, y] = \mathsf{sort}([x, y])\\ [z, t] = \mathsf{sort}([z, t])\\ \end{array} \]
\[\frac{x \cdot y - z \cdot t}{a} \]
\[\begin{array}{l} t_1 := x \cdot y - z \cdot t\\ \mathbf{if}\;t_1 \leq -2 \cdot 10^{+288} \lor \neg \left(t_1 \leq 10^{+253}\right):\\ \;\;\;\;\frac{x}{\frac{a}{y}} - \frac{z}{\frac{a}{t}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x \cdot y + z \cdot t\right) + \left(z \cdot t\right) \cdot -2}{a}\\ \end{array} \]
(FPCore (x y z t a) :precision binary64 (/ (- (* x y) (* z t)) a))
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (- (* x y) (* z t))))
   (if (or (<= t_1 -2e+288) (not (<= t_1 1e+253)))
     (- (/ x (/ a y)) (/ z (/ a t)))
     (/ (+ (+ (* x y) (* z t)) (* (* z t) -2.0)) a))))
double code(double x, double y, double z, double t, double a) {
	return ((x * y) - (z * t)) / a;
}
double code(double x, double y, double z, double t, double a) {
	double t_1 = (x * y) - (z * t);
	double tmp;
	if ((t_1 <= -2e+288) || !(t_1 <= 1e+253)) {
		tmp = (x / (a / y)) - (z / (a / t));
	} else {
		tmp = (((x * y) + (z * t)) + ((z * t) * -2.0)) / a;
	}
	return tmp;
}
real(8) function code(x, y, z, t, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    code = ((x * y) - (z * t)) / a
end function
real(8) function code(x, y, z, t, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8) :: t_1
    real(8) :: tmp
    t_1 = (x * y) - (z * t)
    if ((t_1 <= (-2d+288)) .or. (.not. (t_1 <= 1d+253))) then
        tmp = (x / (a / y)) - (z / (a / t))
    else
        tmp = (((x * y) + (z * t)) + ((z * t) * (-2.0d0))) / a
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
	return ((x * y) - (z * t)) / a;
}
public static double code(double x, double y, double z, double t, double a) {
	double t_1 = (x * y) - (z * t);
	double tmp;
	if ((t_1 <= -2e+288) || !(t_1 <= 1e+253)) {
		tmp = (x / (a / y)) - (z / (a / t));
	} else {
		tmp = (((x * y) + (z * t)) + ((z * t) * -2.0)) / a;
	}
	return tmp;
}
def code(x, y, z, t, a):
	return ((x * y) - (z * t)) / a
def code(x, y, z, t, a):
	t_1 = (x * y) - (z * t)
	tmp = 0
	if (t_1 <= -2e+288) or not (t_1 <= 1e+253):
		tmp = (x / (a / y)) - (z / (a / t))
	else:
		tmp = (((x * y) + (z * t)) + ((z * t) * -2.0)) / a
	return tmp
function code(x, y, z, t, a)
	return Float64(Float64(Float64(x * y) - Float64(z * t)) / a)
end
function code(x, y, z, t, a)
	t_1 = Float64(Float64(x * y) - Float64(z * t))
	tmp = 0.0
	if ((t_1 <= -2e+288) || !(t_1 <= 1e+253))
		tmp = Float64(Float64(x / Float64(a / y)) - Float64(z / Float64(a / t)));
	else
		tmp = Float64(Float64(Float64(Float64(x * y) + Float64(z * t)) + Float64(Float64(z * t) * -2.0)) / a);
	end
	return tmp
end
function tmp = code(x, y, z, t, a)
	tmp = ((x * y) - (z * t)) / a;
end
function tmp_2 = code(x, y, z, t, a)
	t_1 = (x * y) - (z * t);
	tmp = 0.0;
	if ((t_1 <= -2e+288) || ~((t_1 <= 1e+253)))
		tmp = (x / (a / y)) - (z / (a / t));
	else
		tmp = (((x * y) + (z * t)) + ((z * t) * -2.0)) / a;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_] := N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -2e+288], N[Not[LessEqual[t$95$1, 1e+253]], $MachinePrecision]], N[(N[(x / N[(a / y), $MachinePrecision]), $MachinePrecision] - N[(z / N[(a / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] + N[(N[(z * t), $MachinePrecision] * -2.0), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]]]
\frac{x \cdot y - z \cdot t}{a}
\begin{array}{l}
t_1 := x \cdot y - z \cdot t\\
\mathbf{if}\;t_1 \leq -2 \cdot 10^{+288} \lor \neg \left(t_1 \leq 10^{+253}\right):\\
\;\;\;\;\frac{x}{\frac{a}{y}} - \frac{z}{\frac{a}{t}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\left(x \cdot y + z \cdot t\right) + \left(z \cdot t\right) \cdot -2}{a}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original88.5%
Target91.4%
Herbie98.8%
\[\begin{array}{l} \mathbf{if}\;z < -2.468684968699548 \cdot 10^{+170}:\\ \;\;\;\;\frac{y}{a} \cdot x - \frac{t}{a} \cdot z\\ \mathbf{elif}\;z < 6.309831121978371 \cdot 10^{-71}:\\ \;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{a} \cdot x - \frac{t}{a} \cdot z\\ \end{array} \]

Derivation?

  1. Split input into 2 regimes
  2. if (-.f64 (*.f64 x y) (*.f64 z t)) < -2e288 or 9.9999999999999994e252 < (-.f64 (*.f64 x y) (*.f64 z t))

    1. Initial program 27.1%

      \[\frac{x \cdot y - z \cdot t}{a} \]
    2. Applied egg-rr99.5%

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

      [Start]27.1

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

      div-sub [=>]27.1

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

      associate-/l* [=>]61.0

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

      associate-/l* [=>]99.5

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

    if -2e288 < (-.f64 (*.f64 x y) (*.f64 z t)) < 9.9999999999999994e252

    1. Initial program 98.6%

      \[\frac{x \cdot y - z \cdot t}{a} \]
    2. Applied egg-rr98.5%

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

      [Start]98.6

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

      div-inv [=>]98.5

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

      *-commutative [=>]98.5

      \[ \color{blue}{\frac{1}{a} \cdot \left(x \cdot y - z \cdot t\right)} \]
    3. Applied egg-rr98.5%

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

      [Start]98.5

      \[ \frac{1}{a} \cdot \left(x \cdot y - z \cdot t\right) \]

      prod-diff [=>]98.5

      \[ \frac{1}{a} \cdot \color{blue}{\left(\mathsf{fma}\left(x, y, -t \cdot z\right) + \mathsf{fma}\left(-t, z, t \cdot z\right)\right)} \]

      *-commutative [<=]98.5

      \[ \frac{1}{a} \cdot \left(\mathsf{fma}\left(x, y, -\color{blue}{z \cdot t}\right) + \mathsf{fma}\left(-t, z, t \cdot z\right)\right) \]

      fma-neg [<=]98.5

      \[ \frac{1}{a} \cdot \left(\color{blue}{\left(x \cdot y - z \cdot t\right)} + \mathsf{fma}\left(-t, z, t \cdot z\right)\right) \]

      *-commutative [<=]98.5

      \[ \frac{1}{a} \cdot \left(\left(x \cdot y - z \cdot t\right) + \mathsf{fma}\left(-t, z, \color{blue}{z \cdot t}\right)\right) \]

      fma-udef [=>]98.5

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

      distribute-lft-neg-in [<=]98.5

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

      *-commutative [<=]98.5

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

      associate-+r+ [=>]98.5

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

      distribute-rgt-neg-in [=>]98.5

      \[ \frac{1}{a} \cdot \left(\left(\left(x \cdot y - z \cdot t\right) + \color{blue}{z \cdot \left(-t\right)}\right) + z \cdot t\right) \]
    4. Applied egg-rr98.4%

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

      [Start]98.5

      \[ \frac{1}{a} \cdot \left(\left(\left(x \cdot y - z \cdot t\right) + z \cdot \left(-t\right)\right) + z \cdot t\right) \]

      associate-+l+ [=>]98.5

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

      +-commutative [=>]98.5

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

      +-commutative [=>]98.5

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

      distribute-rgt-neg-out [=>]98.5

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

      distribute-lft-neg-in [=>]98.5

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

      add-sqr-sqrt [=>]73.2

      \[ \frac{1}{a} \cdot \left(\left(z \cdot t + \left(-z\right) \cdot \color{blue}{\left(\sqrt{t} \cdot \sqrt{t}\right)}\right) + \left(x \cdot y - z \cdot t\right)\right) \]

      sqrt-unprod [=>]67.5

      \[ \frac{1}{a} \cdot \left(\left(z \cdot t + \left(-z\right) \cdot \color{blue}{\sqrt{t \cdot t}}\right) + \left(x \cdot y - z \cdot t\right)\right) \]

      sqr-neg [<=]67.5

      \[ \frac{1}{a} \cdot \left(\left(z \cdot t + \left(-z\right) \cdot \sqrt{\color{blue}{\left(-t\right) \cdot \left(-t\right)}}\right) + \left(x \cdot y - z \cdot t\right)\right) \]

      sqrt-unprod [<=]13.1

      \[ \frac{1}{a} \cdot \left(\left(z \cdot t + \left(-z\right) \cdot \color{blue}{\left(\sqrt{-t} \cdot \sqrt{-t}\right)}\right) + \left(x \cdot y - z \cdot t\right)\right) \]

      add-sqr-sqrt [<=]52.3

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

      cancel-sign-sub-inv [<=]52.3

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

      add-sqr-sqrt [=>]32.9

      \[ \frac{1}{a} \cdot \left(\left(\color{blue}{\sqrt{z \cdot t} \cdot \sqrt{z \cdot t}} - z \cdot \left(-t\right)\right) + \left(x \cdot y - z \cdot t\right)\right) \]

      sqrt-unprod [=>]67.7

      \[ \frac{1}{a} \cdot \left(\left(\color{blue}{\sqrt{\left(z \cdot t\right) \cdot \left(z \cdot t\right)}} - z \cdot \left(-t\right)\right) + \left(x \cdot y - z \cdot t\right)\right) \]

      sqr-neg [<=]67.7

      \[ \frac{1}{a} \cdot \left(\left(\sqrt{\color{blue}{\left(-z \cdot t\right) \cdot \left(-z \cdot t\right)}} - z \cdot \left(-t\right)\right) + \left(x \cdot y - z \cdot t\right)\right) \]

      distribute-rgt-neg-out [<=]67.7

      \[ \frac{1}{a} \cdot \left(\left(\sqrt{\color{blue}{\left(z \cdot \left(-t\right)\right)} \cdot \left(-z \cdot t\right)} - z \cdot \left(-t\right)\right) + \left(x \cdot y - z \cdot t\right)\right) \]

      distribute-rgt-neg-out [<=]67.7

      \[ \frac{1}{a} \cdot \left(\left(\sqrt{\left(z \cdot \left(-t\right)\right) \cdot \color{blue}{\left(z \cdot \left(-t\right)\right)}} - z \cdot \left(-t\right)\right) + \left(x \cdot y - z \cdot t\right)\right) \]

      sqrt-unprod [<=]55.0

      \[ \frac{1}{a} \cdot \left(\left(\color{blue}{\sqrt{z \cdot \left(-t\right)} \cdot \sqrt{z \cdot \left(-t\right)}} - z \cdot \left(-t\right)\right) + \left(x \cdot y - z \cdot t\right)\right) \]

      add-sqr-sqrt [<=]98.5

      \[ \frac{1}{a} \cdot \left(\left(\color{blue}{z \cdot \left(-t\right)} - z \cdot \left(-t\right)\right) + \left(x \cdot y - z \cdot t\right)\right) \]
    5. Taylor expanded in a around 0 98.6%

      \[\leadsto \color{blue}{\frac{\left(y \cdot x + t \cdot z\right) - 2 \cdot \left(t \cdot z\right)}{a}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \leq -2 \cdot 10^{+288} \lor \neg \left(x \cdot y - z \cdot t \leq 10^{+253}\right):\\ \;\;\;\;\frac{x}{\frac{a}{y}} - \frac{z}{\frac{a}{t}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x \cdot y + z \cdot t\right) + \left(z \cdot t\right) \cdot -2}{a}\\ \end{array} \]

Alternatives

Alternative 1
Accuracy98.8%
Cost1737
\[\begin{array}{l} t_1 := x \cdot y - z \cdot t\\ \mathbf{if}\;t_1 \leq -2 \cdot 10^{+288} \lor \neg \left(t_1 \leq 10^{+253}\right):\\ \;\;\;\;\frac{x}{\frac{a}{y}} - \frac{z}{\frac{a}{t}}\\ \mathbf{else}:\\ \;\;\;\;\frac{t_1}{a}\\ \end{array} \]
Alternative 2
Accuracy93.4%
Cost1608
\[\begin{array}{l} t_1 := x \cdot y - z \cdot t\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;x \cdot \frac{y}{a}\\ \mathbf{elif}\;t_1 \leq 5 \cdot 10^{+296}:\\ \;\;\;\;\frac{t_1}{a}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{a}\\ \end{array} \]
Alternative 3
Accuracy62.1%
Cost648
\[\begin{array}{l} \mathbf{if}\;y \leq -3.3 \cdot 10^{-41}:\\ \;\;\;\;y \cdot \frac{x}{a}\\ \mathbf{elif}\;y \leq 5.4 \cdot 10^{-48}:\\ \;\;\;\;\frac{-t}{\frac{a}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{a}{y}}\\ \end{array} \]
Alternative 4
Accuracy63.8%
Cost648
\[\begin{array}{l} \mathbf{if}\;y \leq -4.8 \cdot 10^{-123}:\\ \;\;\;\;y \cdot \frac{x}{a}\\ \mathbf{elif}\;y \leq 3.5 \cdot 10^{-48}:\\ \;\;\;\;\frac{z \cdot \left(-t\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{a}{y}}\\ \end{array} \]
Alternative 5
Accuracy50.2%
Cost585
\[\begin{array}{l} \mathbf{if}\;a \leq -4 \cdot 10^{-91} \lor \neg \left(a \leq 2.75 \cdot 10^{+97}\right):\\ \;\;\;\;y \cdot \frac{x}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{a}\\ \end{array} \]
Alternative 6
Accuracy48.4%
Cost320
\[y \cdot \frac{x}{a} \]

Error

Reproduce?

herbie shell --seed 2023133 
(FPCore (x y z t a)
  :name "Data.Colour.Matrix:inverse from colour-2.3.3, B"
  :precision binary64

  :herbie-target
  (if (< z -2.468684968699548e+170) (- (* (/ y a) x) (* (/ t a) z)) (if (< z 6.309831121978371e-71) (/ (- (* x y) (* z t)) a) (- (* (/ y a) x) (* (/ t a) z))))

  (/ (- (* x y) (* z t)) a))