Average Error: 7.9 → 0.7
Time: 8.0s
Precision: binary64
Cost: 1737
\[ \begin{array}{c}[x, y] = \mathsf{sort}([x, y])\\ \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 -5 \cdot 10^{+266} \lor \neg \left(t_1 \leq 5.2 \cdot 10^{+246}\right):\\ \;\;\;\;y \cdot \frac{x}{a} - \frac{z}{\frac{a}{t}}\\ \mathbf{else}:\\ \;\;\;\;\frac{t_1}{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 -5e+266) (not (<= t_1 5.2e+246)))
     (- (* y (/ x a)) (/ z (/ a t)))
     (/ t_1 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 <= -5e+266) || !(t_1 <= 5.2e+246)) {
		tmp = (y * (x / a)) - (z / (a / t));
	} else {
		tmp = t_1 / 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 <= (-5d+266)) .or. (.not. (t_1 <= 5.2d+246))) then
        tmp = (y * (x / a)) - (z / (a / t))
    else
        tmp = t_1 / 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 <= -5e+266) || !(t_1 <= 5.2e+246)) {
		tmp = (y * (x / a)) - (z / (a / t));
	} else {
		tmp = t_1 / 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 <= -5e+266) or not (t_1 <= 5.2e+246):
		tmp = (y * (x / a)) - (z / (a / t))
	else:
		tmp = t_1 / 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 <= -5e+266) || !(t_1 <= 5.2e+246))
		tmp = Float64(Float64(y * Float64(x / a)) - Float64(z / Float64(a / t)));
	else
		tmp = Float64(t_1 / 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 <= -5e+266) || ~((t_1 <= 5.2e+246)))
		tmp = (y * (x / a)) - (z / (a / t));
	else
		tmp = t_1 / 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, -5e+266], N[Not[LessEqual[t$95$1, 5.2e+246]], $MachinePrecision]], N[(N[(y * N[(x / a), $MachinePrecision]), $MachinePrecision] - N[(z / N[(a / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 / 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 -5 \cdot 10^{+266} \lor \neg \left(t_1 \leq 5.2 \cdot 10^{+246}\right):\\
\;\;\;\;y \cdot \frac{x}{a} - \frac{z}{\frac{a}{t}}\\

\mathbf{else}:\\
\;\;\;\;\frac{t_1}{a}\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original7.9
Target5.9
Herbie0.7
\[\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)) < -4.9999999999999999e266 or 5.20000000000000028e246 < (-.f64 (*.f64 x y) (*.f64 z t))

    1. Initial program 41.6

      \[\frac{x \cdot y - z \cdot t}{a} \]
    2. Applied egg-rr0.4

      \[\leadsto \color{blue}{\frac{x}{\frac{a}{y}} - \frac{z}{\frac{a}{t}}} \]
    3. Applied egg-rr0.4

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

    if -4.9999999999999999e266 < (-.f64 (*.f64 x y) (*.f64 z t)) < 5.20000000000000028e246

    1. Initial program 0.8

      \[\frac{x \cdot y - z \cdot t}{a} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.7

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

Alternatives

Alternative 1
Error4.4
Cost1864
\[\begin{array}{l} t_1 := \frac{x \cdot y - z \cdot t}{a}\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;\frac{y}{\frac{a}{x}}\\ \mathbf{elif}\;t_1 \leq 2 \cdot 10^{+300}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{-\frac{a}{t}}\\ \end{array} \]
Alternative 2
Error23.8
Cost1176
\[\begin{array}{l} t_1 := z \cdot \left(-\frac{t}{a}\right)\\ t_2 := \frac{y}{\frac{a}{x}}\\ \mathbf{if}\;x \leq -1.9 \cdot 10^{+65}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -5.4 \cdot 10^{+22}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -110:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -3.2 \cdot 10^{-37}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.7 \cdot 10^{-47}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 3.5 \cdot 10^{-89}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{a}{y}}\\ \end{array} \]
Alternative 3
Error19.2
Cost1165
\[\begin{array}{l} \mathbf{if}\;z \cdot t \leq -2 \cdot 10^{+259}:\\ \;\;\;\;\frac{z}{-\frac{a}{t}}\\ \mathbf{elif}\;z \cdot t \leq -1 \cdot 10^{-52} \lor \neg \left(z \cdot t \leq 10^{-67}\right):\\ \;\;\;\;\frac{t \cdot \left(-z\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{a}{x}}\\ \end{array} \]
Alternative 4
Error26.8
Cost912
\[\begin{array}{l} t_1 := z \cdot \left(-\frac{t}{a}\right)\\ \mathbf{if}\;t \leq -1.7 \cdot 10^{-228}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 3.6 \cdot 10^{-25}:\\ \;\;\;\;\frac{y}{\frac{a}{x}}\\ \mathbf{elif}\;t \leq 1.5 \cdot 10^{+25}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 3 \cdot 10^{+68}:\\ \;\;\;\;x \cdot \frac{y}{a}\\ \mathbf{else}:\\ \;\;\;\;t \cdot \frac{-z}{a}\\ \end{array} \]
Alternative 5
Error31.7
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -8 \cdot 10^{+162}:\\ \;\;\;\;\frac{y}{\frac{a}{x}}\\ \mathbf{elif}\;x \leq 1.02 \cdot 10^{+33}:\\ \;\;\;\;\frac{x \cdot y}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{a}{y}}\\ \end{array} \]
Alternative 6
Error32.7
Cost320
\[x \cdot \frac{y}{a} \]
Alternative 7
Error33.0
Cost320
\[\frac{y}{\frac{a}{x}} \]

Error

Reproduce

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