?

Average Error: 7.5 → 1.2
Time: 27.2s
Precision: binary64
Cost: 1928

?

\[ \begin{array}{c}[z, t] = \mathsf{sort}([z, t])\\ \end{array} \]
\[\frac{x \cdot y - z \cdot t}{a} \]
\[\begin{array}{l} t_1 := -\frac{t}{\frac{a}{z}}\\ t_2 := x \cdot y - z \cdot t\\ \mathbf{if}\;t_2 \leq -5 \cdot 10^{+150}:\\ \;\;\;\;t_1 + y \cdot \frac{x}{a}\\ \mathbf{elif}\;t_2 \leq 2 \cdot 10^{+229}:\\ \;\;\;\;\frac{t_2}{a}\\ \mathbf{else}:\\ \;\;\;\;t_1 + \frac{\frac{y}{a}}{\frac{1}{x}}\\ \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 (- (/ t (/ a z)))) (t_2 (- (* x y) (* z t))))
   (if (<= t_2 -5e+150)
     (+ t_1 (* y (/ x a)))
     (if (<= t_2 2e+229) (/ t_2 a) (+ t_1 (/ (/ y a) (/ 1.0 x)))))))
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 = -(t / (a / z));
	double t_2 = (x * y) - (z * t);
	double tmp;
	if (t_2 <= -5e+150) {
		tmp = t_1 + (y * (x / a));
	} else if (t_2 <= 2e+229) {
		tmp = t_2 / a;
	} else {
		tmp = t_1 + ((y / a) / (1.0 / x));
	}
	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) :: t_2
    real(8) :: tmp
    t_1 = -(t / (a / z))
    t_2 = (x * y) - (z * t)
    if (t_2 <= (-5d+150)) then
        tmp = t_1 + (y * (x / a))
    else if (t_2 <= 2d+229) then
        tmp = t_2 / a
    else
        tmp = t_1 + ((y / a) / (1.0d0 / x))
    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 = -(t / (a / z));
	double t_2 = (x * y) - (z * t);
	double tmp;
	if (t_2 <= -5e+150) {
		tmp = t_1 + (y * (x / a));
	} else if (t_2 <= 2e+229) {
		tmp = t_2 / a;
	} else {
		tmp = t_1 + ((y / a) / (1.0 / x));
	}
	return tmp;
}
def code(x, y, z, t, a):
	return ((x * y) - (z * t)) / a
def code(x, y, z, t, a):
	t_1 = -(t / (a / z))
	t_2 = (x * y) - (z * t)
	tmp = 0
	if t_2 <= -5e+150:
		tmp = t_1 + (y * (x / a))
	elif t_2 <= 2e+229:
		tmp = t_2 / a
	else:
		tmp = t_1 + ((y / a) / (1.0 / x))
	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(t / Float64(a / z)))
	t_2 = Float64(Float64(x * y) - Float64(z * t))
	tmp = 0.0
	if (t_2 <= -5e+150)
		tmp = Float64(t_1 + Float64(y * Float64(x / a)));
	elseif (t_2 <= 2e+229)
		tmp = Float64(t_2 / a);
	else
		tmp = Float64(t_1 + Float64(Float64(y / a) / Float64(1.0 / x)));
	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 = -(t / (a / z));
	t_2 = (x * y) - (z * t);
	tmp = 0.0;
	if (t_2 <= -5e+150)
		tmp = t_1 + (y * (x / a));
	elseif (t_2 <= 2e+229)
		tmp = t_2 / a;
	else
		tmp = t_1 + ((y / a) / (1.0 / x));
	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[(t / N[(a / z), $MachinePrecision]), $MachinePrecision])}, Block[{t$95$2 = N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -5e+150], N[(t$95$1 + N[(y * N[(x / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2e+229], N[(t$95$2 / a), $MachinePrecision], N[(t$95$1 + N[(N[(y / a), $MachinePrecision] / N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\frac{x \cdot y - z \cdot t}{a}
\begin{array}{l}
t_1 := -\frac{t}{\frac{a}{z}}\\
t_2 := x \cdot y - z \cdot t\\
\mathbf{if}\;t_2 \leq -5 \cdot 10^{+150}:\\
\;\;\;\;t_1 + y \cdot \frac{x}{a}\\

\mathbf{elif}\;t_2 \leq 2 \cdot 10^{+229}:\\
\;\;\;\;\frac{t_2}{a}\\

\mathbf{else}:\\
\;\;\;\;t_1 + \frac{\frac{y}{a}}{\frac{1}{x}}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original7.5
Target5.5
Herbie1.2
\[\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 3 regimes
  2. if (-.f64 (*.f64 x y) (*.f64 z t)) < -5.00000000000000009e150

    1. Initial program 19.3

      \[\frac{x \cdot y - z \cdot t}{a} \]
    2. Taylor expanded in x around 0 19.3

      \[\leadsto \color{blue}{-1 \cdot \frac{t \cdot z}{a} + \frac{y \cdot x}{a}} \]
    3. Simplified2.7

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

      [Start]19.3

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

      rational.json-simplify-2 [=>]19.3

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

      rational.json-simplify-9 [=>]19.3

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

      rational.json-simplify-2 [<=]19.3

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

      rational.json-simplify-49 [=>]10.5

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

      rational.json-simplify-2 [=>]10.5

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

      rational.json-simplify-49 [=>]2.7

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

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

    if -5.00000000000000009e150 < (-.f64 (*.f64 x y) (*.f64 z t)) < 2e229

    1. Initial program 0.9

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

    if 2e229 < (-.f64 (*.f64 x y) (*.f64 z t))

    1. Initial program 34.6

      \[\frac{x \cdot y - z \cdot t}{a} \]
    2. Taylor expanded in x around 0 34.6

      \[\leadsto \color{blue}{-1 \cdot \frac{t \cdot z}{a} + \frac{y \cdot x}{a}} \]
    3. Simplified0.9

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

      [Start]34.6

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

      rational.json-simplify-2 [=>]34.6

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

      rational.json-simplify-9 [=>]34.6

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

      rational.json-simplify-2 [<=]34.6

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

      rational.json-simplify-49 [=>]20.2

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

      rational.json-simplify-2 [=>]20.2

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

      rational.json-simplify-49 [=>]0.9

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

      \[\leadsto \left(-\color{blue}{\frac{t}{\frac{a}{z}}}\right) + y \cdot \frac{x}{a} \]
    5. Applied egg-rr0.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \leq -5 \cdot 10^{+150}:\\ \;\;\;\;\left(-\frac{t}{\frac{a}{z}}\right) + y \cdot \frac{x}{a}\\ \mathbf{elif}\;x \cdot y - z \cdot t \leq 2 \cdot 10^{+229}:\\ \;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\ \mathbf{else}:\\ \;\;\;\;\left(-\frac{t}{\frac{a}{z}}\right) + \frac{\frac{y}{a}}{\frac{1}{x}}\\ \end{array} \]

Alternatives

Alternative 1
Error1.1
Cost1800
\[\begin{array}{l} t_1 := x \cdot y - z \cdot t\\ t_2 := \left(-t \cdot \frac{z}{a}\right) + y \cdot \frac{x}{a}\\ \mathbf{if}\;t_1 \leq -5 \cdot 10^{+150}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 2 \cdot 10^{+245}:\\ \;\;\;\;\frac{t_1}{a}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error1.2
Cost1800
\[\begin{array}{l} t_1 := x \cdot y - z \cdot t\\ t_2 := \left(-\frac{t}{\frac{a}{z}}\right) + y \cdot \frac{x}{a}\\ \mathbf{if}\;t_1 \leq -5 \cdot 10^{+150}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 5 \cdot 10^{+225}:\\ \;\;\;\;\frac{t_1}{a}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error4.4
Cost1616
\[\begin{array}{l} t_1 := \frac{x \cdot y - z \cdot t}{a}\\ \mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+270}:\\ \;\;\;\;\frac{y}{\frac{a}{x}}\\ \mathbf{elif}\;x \cdot y \leq -1 \cdot 10^{-273}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \cdot y \leq 0:\\ \;\;\;\;\frac{-z}{\frac{a}{t}}\\ \mathbf{elif}\;x \cdot y \leq 10^{+227}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{a}\\ \end{array} \]
Alternative 4
Error20.0
Cost904
\[\begin{array}{l} \mathbf{if}\;x \cdot y \leq -5 \cdot 10^{-9}:\\ \;\;\;\;\frac{x}{\frac{a}{y}}\\ \mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{-29}:\\ \;\;\;\;\frac{-t}{\frac{a}{z}}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{a}\\ \end{array} \]
Alternative 5
Error25.0
Cost648
\[\begin{array}{l} \mathbf{if}\;y \leq -1.3 \cdot 10^{-126}:\\ \;\;\;\;y \cdot \frac{x}{a}\\ \mathbf{elif}\;y \leq 9.5 \cdot 10^{-22}:\\ \;\;\;\;-t \cdot \frac{z}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{a}{x}}\\ \end{array} \]
Alternative 6
Error31.7
Cost584
\[\begin{array}{l} \mathbf{if}\;a \leq -3.8 \cdot 10^{+43}:\\ \;\;\;\;y \cdot \frac{x}{a}\\ \mathbf{elif}\;a \leq 1.65 \cdot 10^{+71}:\\ \;\;\;\;\frac{y \cdot x}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{a}{x}}\\ \end{array} \]
Alternative 7
Error33.2
Cost452
\[\begin{array}{l} \mathbf{if}\;z \leq -3.1 \cdot 10^{-141}:\\ \;\;\;\;y \cdot \frac{x}{a}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{a}\\ \end{array} \]
Alternative 8
Error33.2
Cost452
\[\begin{array}{l} \mathbf{if}\;x \leq 3.4 \cdot 10^{-274}:\\ \;\;\;\;\frac{x}{\frac{a}{y}}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{a}\\ \end{array} \]
Alternative 9
Error33.2
Cost320
\[x \cdot \frac{y}{a} \]

Error

Reproduce?

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