Average Error: 24.8 → 6.9
Time: 33.4s
Precision: binary64
Cost: 13960
\[ \begin{array}{c}[x, y] = \mathsf{sort}([x, y])\\ \end{array} \]
\[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}} \]
\[\begin{array}{l} \mathbf{if}\;z \leq -4.9 \cdot 10^{+154}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 1.65 \cdot 10^{-254}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{\sqrt{z \cdot z - t \cdot a}}\right)\\ \mathbf{else}:\\ \;\;\;\;{\left(\frac{\sqrt{1 - \frac{a}{z} \cdot \frac{t}{z}}}{y \cdot x}\right)}^{-1}\\ \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (/ (* (* x y) z) (sqrt (- (* z z) (* t a)))))
(FPCore (x y z t a)
 :precision binary64
 (if (<= z -4.9e+154)
   (* y (- x))
   (if (<= z 1.65e-254)
     (* x (* y (/ z (sqrt (- (* z z) (* t a))))))
     (pow (/ (sqrt (- 1.0 (* (/ a z) (/ t z)))) (* y x)) -1.0))))
double code(double x, double y, double z, double t, double a) {
	return ((x * y) * z) / sqrt(((z * z) - (t * a)));
}
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if (z <= -4.9e+154) {
		tmp = y * -x;
	} else if (z <= 1.65e-254) {
		tmp = x * (y * (z / sqrt(((z * z) - (t * a)))));
	} else {
		tmp = pow((sqrt((1.0 - ((a / z) * (t / z)))) / (y * x)), -1.0);
	}
	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) / sqrt(((z * 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) :: tmp
    if (z <= (-4.9d+154)) then
        tmp = y * -x
    else if (z <= 1.65d-254) then
        tmp = x * (y * (z / sqrt(((z * z) - (t * a)))))
    else
        tmp = (sqrt((1.0d0 - ((a / z) * (t / z)))) / (y * x)) ** (-1.0d0)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
	return ((x * y) * z) / Math.sqrt(((z * z) - (t * a)));
}
public static double code(double x, double y, double z, double t, double a) {
	double tmp;
	if (z <= -4.9e+154) {
		tmp = y * -x;
	} else if (z <= 1.65e-254) {
		tmp = x * (y * (z / Math.sqrt(((z * z) - (t * a)))));
	} else {
		tmp = Math.pow((Math.sqrt((1.0 - ((a / z) * (t / z)))) / (y * x)), -1.0);
	}
	return tmp;
}
def code(x, y, z, t, a):
	return ((x * y) * z) / math.sqrt(((z * z) - (t * a)))
def code(x, y, z, t, a):
	tmp = 0
	if z <= -4.9e+154:
		tmp = y * -x
	elif z <= 1.65e-254:
		tmp = x * (y * (z / math.sqrt(((z * z) - (t * a)))))
	else:
		tmp = math.pow((math.sqrt((1.0 - ((a / z) * (t / z)))) / (y * x)), -1.0)
	return tmp
function code(x, y, z, t, a)
	return Float64(Float64(Float64(x * y) * z) / sqrt(Float64(Float64(z * z) - Float64(t * a))))
end
function code(x, y, z, t, a)
	tmp = 0.0
	if (z <= -4.9e+154)
		tmp = Float64(y * Float64(-x));
	elseif (z <= 1.65e-254)
		tmp = Float64(x * Float64(y * Float64(z / sqrt(Float64(Float64(z * z) - Float64(t * a))))));
	else
		tmp = Float64(sqrt(Float64(1.0 - Float64(Float64(a / z) * Float64(t / z)))) / Float64(y * x)) ^ -1.0;
	end
	return tmp
end
function tmp = code(x, y, z, t, a)
	tmp = ((x * y) * z) / sqrt(((z * z) - (t * a)));
end
function tmp_2 = code(x, y, z, t, a)
	tmp = 0.0;
	if (z <= -4.9e+154)
		tmp = y * -x;
	elseif (z <= 1.65e-254)
		tmp = x * (y * (z / sqrt(((z * z) - (t * a)))));
	else
		tmp = (sqrt((1.0 - ((a / z) * (t / z)))) / (y * x)) ^ -1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_] := N[(N[(N[(x * y), $MachinePrecision] * z), $MachinePrecision] / N[Sqrt[N[(N[(z * z), $MachinePrecision] - N[(t * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -4.9e+154], N[(y * (-x)), $MachinePrecision], If[LessEqual[z, 1.65e-254], N[(x * N[(y * N[(z / N[Sqrt[N[(N[(z * z), $MachinePrecision] - N[(t * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[N[(N[Sqrt[N[(1.0 - N[(N[(a / z), $MachinePrecision] * N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(y * x), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]]]
\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}
\begin{array}{l}
\mathbf{if}\;z \leq -4.9 \cdot 10^{+154}:\\
\;\;\;\;y \cdot \left(-x\right)\\

\mathbf{elif}\;z \leq 1.65 \cdot 10^{-254}:\\
\;\;\;\;x \cdot \left(y \cdot \frac{z}{\sqrt{z \cdot z - t \cdot a}}\right)\\

\mathbf{else}:\\
\;\;\;\;{\left(\frac{\sqrt{1 - \frac{a}{z} \cdot \frac{t}{z}}}{y \cdot x}\right)}^{-1}\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original24.8
Target7.6
Herbie6.9
\[\begin{array}{l} \mathbf{if}\;z < -3.1921305903852764 \cdot 10^{+46}:\\ \;\;\;\;-y \cdot x\\ \mathbf{elif}\;z < 5.976268120920894 \cdot 10^{+90}:\\ \;\;\;\;\frac{x \cdot z}{\frac{\sqrt{z \cdot z - a \cdot t}}{y}}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]

Derivation

  1. Split input into 3 regimes
  2. if z < -4.9000000000000002e154

    1. Initial program 53.7

      \[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}} \]
    2. Simplified53.3

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

      [Start]53.7

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

      associate-*r/ [<=]53.3

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

      associate-*l* [=>]53.3

      \[ \color{blue}{x \cdot \left(y \cdot \frac{z}{\sqrt{z \cdot z - t \cdot a}}\right)} \]
    3. Taylor expanded in z around -inf 1.4

      \[\leadsto \color{blue}{-1 \cdot \left(y \cdot x\right)} \]
    4. Simplified1.4

      \[\leadsto \color{blue}{\left(-y\right) \cdot x} \]
      Proof

      [Start]1.4

      \[ -1 \cdot \left(y \cdot x\right) \]

      associate-*r* [=>]1.4

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

      mul-1-neg [=>]1.4

      \[ \color{blue}{\left(-y\right)} \cdot x \]

    if -4.9000000000000002e154 < z < 1.65000000000000008e-254

    1. Initial program 11.9

      \[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}} \]
    2. Simplified9.4

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

      [Start]11.9

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

      associate-*r/ [<=]9.5

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

      associate-*l* [=>]9.4

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

    if 1.65000000000000008e-254 < z

    1. Initial program 25.5

      \[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}} \]
    2. Simplified23.4

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

      [Start]25.5

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

      associate-/l* [=>]23.4

      \[ \color{blue}{\frac{x \cdot y}{\frac{\sqrt{z \cdot z - t \cdot a}}{z}}} \]
    3. Applied egg-rr30.3

      \[\leadsto \frac{x \cdot y}{\color{blue}{\sqrt{\frac{z \cdot z - t \cdot a}{z \cdot z}}}} \]
    4. Simplified9.0

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

      [Start]30.3

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

      *-commutative [=>]30.3

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

      div-sub [=>]33.2

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

      unpow2 [<=]33.2

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

      unpow2 [<=]33.2

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

      *-inverses [=>]11.2

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

      unpow2 [<=]11.2

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

      associate-/l* [=>]8.9

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

      associate-/r/ [=>]9.0

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

      unpow2 [=>]9.0

      \[ \frac{x \cdot y}{\sqrt{1 - \frac{a}{\color{blue}{z \cdot z}} \cdot t}} \]
    5. Applied egg-rr6.7

      \[\leadsto \frac{x \cdot y}{\sqrt{1 - \color{blue}{\frac{\frac{a}{z} \cdot t}{z}}}} \]
    6. Applied egg-rr6.9

      \[\leadsto \color{blue}{{\left(\frac{\sqrt{1 - \frac{a}{z} \cdot \frac{t}{z}}}{x \cdot y}\right)}^{-1}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification6.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -4.9 \cdot 10^{+154}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 1.65 \cdot 10^{-254}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{\sqrt{z \cdot z - t \cdot a}}\right)\\ \mathbf{else}:\\ \;\;\;\;{\left(\frac{\sqrt{1 - \frac{a}{z} \cdot \frac{t}{z}}}{y \cdot x}\right)}^{-1}\\ \end{array} \]

Alternatives

Alternative 1
Error6.2
Cost7496
\[\begin{array}{l} \mathbf{if}\;z \leq -4.9 \cdot 10^{+154}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 10^{+134}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{\sqrt{z \cdot z - t \cdot a}}\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{\frac{z + -0.5 \cdot \frac{a}{\frac{z}{t}}}{z}}\\ \end{array} \]
Alternative 2
Error6.8
Cost7496
\[\begin{array}{l} \mathbf{if}\;z \leq -4.9 \cdot 10^{+154}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 3 \cdot 10^{-272}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{\sqrt{z \cdot z - t \cdot a}}\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{\sqrt{1 - \frac{a}{z} \cdot \frac{t}{z}}}\\ \end{array} \]
Alternative 3
Error14.4
Cost7304
\[\begin{array}{l} \mathbf{if}\;z \leq -1 \cdot 10^{+38}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 2.3 \cdot 10^{-201}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{\sqrt{t \cdot \left(-a\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{\frac{z + -0.5 \cdot \frac{a}{\frac{z}{t}}}{z}}\\ \end{array} \]
Alternative 4
Error14.2
Cost7304
\[\begin{array}{l} \mathbf{if}\;z \leq -3.5 \cdot 10^{+38}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 2.5 \cdot 10^{-200}:\\ \;\;\;\;z \cdot \frac{x}{\frac{\sqrt{t \cdot \left(-a\right)}}{y}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{\frac{z + -0.5 \cdot \frac{a}{\frac{z}{t}}}{z}}\\ \end{array} \]
Alternative 5
Error15.1
Cost1224
\[\begin{array}{l} \mathbf{if}\;z \leq -5.2 \cdot 10^{+22}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq -7 \cdot 10^{-282}:\\ \;\;\;\;\frac{y \cdot \left(z \cdot x\right)}{\left(t \cdot a\right) \cdot \frac{0.5}{z} - z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{\frac{z + -0.5 \cdot \frac{a}{\frac{z}{t}}}{z}}\\ \end{array} \]
Alternative 6
Error14.6
Cost1224
\[\begin{array}{l} \mathbf{if}\;z \leq -1 \cdot 10^{+211}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq -2 \cdot 10^{-280}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{0.5 \cdot \frac{t \cdot a}{z} - z}\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{\frac{z + -0.5 \cdot \frac{a}{\frac{z}{t}}}{z}}\\ \end{array} \]
Alternative 7
Error17.5
Cost1096
\[\begin{array}{l} \mathbf{if}\;z \leq -7.5 \cdot 10^{-119}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 4 \cdot 10^{-98}:\\ \;\;\;\;-2 \cdot \left(\frac{y}{a} \cdot \frac{x \cdot \left(z \cdot z\right)}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 8
Error17.6
Cost1096
\[\begin{array}{l} \mathbf{if}\;z \leq -5.8 \cdot 10^{-116}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 2.2 \cdot 10^{-99}:\\ \;\;\;\;z \cdot \left(\frac{z \cdot x}{\frac{a}{2}} \cdot \frac{y}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 9
Error17.4
Cost1096
\[\begin{array}{l} \mathbf{if}\;z \leq -7.5 \cdot 10^{-116}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 1.04 \cdot 10^{-100}:\\ \;\;\;\;\frac{z \cdot \left(y \cdot x\right)}{0.5 \cdot \frac{t}{\frac{z}{a}}}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 10
Error17.5
Cost1096
\[\begin{array}{l} \mathbf{if}\;z \leq -2.45 \cdot 10^{-117}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 1.2 \cdot 10^{-97}:\\ \;\;\;\;\frac{z \cdot \left(y \cdot x\right)}{\frac{t}{z} \cdot \left(a \cdot -0.5\right)}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 11
Error15.9
Cost1092
\[\begin{array}{l} \mathbf{if}\;z \leq -1.1 \cdot 10^{-118}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{z + -0.5 \cdot \frac{a}{\frac{z}{t}}}\right)\\ \end{array} \]
Alternative 12
Error15.9
Cost1092
\[\begin{array}{l} \mathbf{if}\;z \leq -4.2 \cdot 10^{-118}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{\frac{z + -0.5 \cdot \frac{a}{\frac{z}{t}}}{z}}\\ \end{array} \]
Alternative 13
Error17.6
Cost840
\[\begin{array}{l} \mathbf{if}\;z \leq -9.5 \cdot 10^{-118}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 3.8 \cdot 10^{-100}:\\ \;\;\;\;\frac{1}{z} \cdot \left(x \cdot \left(z \cdot y\right)\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 14
Error19.5
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -8.6 \cdot 10^{-119}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 1.95 \cdot 10^{-125}:\\ \;\;\;\;\left(z \cdot y\right) \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 15
Error18.6
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -7.5 \cdot 10^{-119}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 2 \cdot 10^{-125}:\\ \;\;\;\;x \cdot \frac{z \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 16
Error19.3
Cost388
\[\begin{array}{l} \mathbf{if}\;z \leq -7 \cdot 10^{-282}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 17
Error37.0
Cost192
\[y \cdot x \]

Error

Reproduce

herbie shell --seed 2023016 
(FPCore (x y z t a)
  :name "Statistics.Math.RootFinding:ridders from math-functions-0.1.5.2"
  :precision binary64

  :herbie-target
  (if (< z -3.1921305903852764e+46) (- (* y x)) (if (< z 5.976268120920894e+90) (/ (* x z) (/ (sqrt (- (* z z) (* a t))) y)) (* y x)))

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