Average Error: 25.2 → 7.9
Time: 20.6s
Precision: binary64
Cost: 14028
\[ \begin{array}{c}[x, y] = \mathsf{sort}([x, y])\\ [t, a] = \mathsf{sort}([t, a])\\ \end{array} \]
\[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}} \]
\[\begin{array}{l} t_1 := \frac{x \cdot \left(z \cdot y\right)}{\sqrt{z \cdot z - t \cdot a}}\\ \mathbf{if}\;z \leq -5.2 \cdot 10^{-19}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{elif}\;z \leq -1 \cdot 10^{-300}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 10^{-185}:\\ \;\;\;\;x \cdot \left(y \cdot \left(z \cdot \left({\left(\frac{-1}{t}\right)}^{0.5} \cdot {a}^{-0.5}\right)\right)\right)\\ \mathbf{elif}\;z \leq 6.2 \cdot 10^{+33}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \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
 (let* ((t_1 (/ (* x (* z y)) (sqrt (- (* z z) (* t a))))))
   (if (<= z -5.2e-19)
     (* x (- y))
     (if (<= z -1e-300)
       t_1
       (if (<= z 1e-185)
         (* x (* y (* z (* (pow (/ -1.0 t) 0.5) (pow a -0.5)))))
         (if (<= z 6.2e+33) t_1 (* x y)))))))
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 t_1 = (x * (z * y)) / sqrt(((z * z) - (t * a)));
	double tmp;
	if (z <= -5.2e-19) {
		tmp = x * -y;
	} else if (z <= -1e-300) {
		tmp = t_1;
	} else if (z <= 1e-185) {
		tmp = x * (y * (z * (pow((-1.0 / t), 0.5) * pow(a, -0.5))));
	} else if (z <= 6.2e+33) {
		tmp = t_1;
	} else {
		tmp = x * y;
	}
	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) :: t_1
    real(8) :: tmp
    t_1 = (x * (z * y)) / sqrt(((z * z) - (t * a)))
    if (z <= (-5.2d-19)) then
        tmp = x * -y
    else if (z <= (-1d-300)) then
        tmp = t_1
    else if (z <= 1d-185) then
        tmp = x * (y * (z * ((((-1.0d0) / t) ** 0.5d0) * (a ** (-0.5d0)))))
    else if (z <= 6.2d+33) then
        tmp = t_1
    else
        tmp = x * y
    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 t_1 = (x * (z * y)) / Math.sqrt(((z * z) - (t * a)));
	double tmp;
	if (z <= -5.2e-19) {
		tmp = x * -y;
	} else if (z <= -1e-300) {
		tmp = t_1;
	} else if (z <= 1e-185) {
		tmp = x * (y * (z * (Math.pow((-1.0 / t), 0.5) * Math.pow(a, -0.5))));
	} else if (z <= 6.2e+33) {
		tmp = t_1;
	} else {
		tmp = x * y;
	}
	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):
	t_1 = (x * (z * y)) / math.sqrt(((z * z) - (t * a)))
	tmp = 0
	if z <= -5.2e-19:
		tmp = x * -y
	elif z <= -1e-300:
		tmp = t_1
	elif z <= 1e-185:
		tmp = x * (y * (z * (math.pow((-1.0 / t), 0.5) * math.pow(a, -0.5))))
	elif z <= 6.2e+33:
		tmp = t_1
	else:
		tmp = x * y
	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)
	t_1 = Float64(Float64(x * Float64(z * y)) / sqrt(Float64(Float64(z * z) - Float64(t * a))))
	tmp = 0.0
	if (z <= -5.2e-19)
		tmp = Float64(x * Float64(-y));
	elseif (z <= -1e-300)
		tmp = t_1;
	elseif (z <= 1e-185)
		tmp = Float64(x * Float64(y * Float64(z * Float64((Float64(-1.0 / t) ^ 0.5) * (a ^ -0.5)))));
	elseif (z <= 6.2e+33)
		tmp = t_1;
	else
		tmp = Float64(x * y);
	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)
	t_1 = (x * (z * y)) / sqrt(((z * z) - (t * a)));
	tmp = 0.0;
	if (z <= -5.2e-19)
		tmp = x * -y;
	elseif (z <= -1e-300)
		tmp = t_1;
	elseif (z <= 1e-185)
		tmp = x * (y * (z * (((-1.0 / t) ^ 0.5) * (a ^ -0.5))));
	elseif (z <= 6.2e+33)
		tmp = t_1;
	else
		tmp = x * y;
	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_] := Block[{t$95$1 = N[(N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[(z * z), $MachinePrecision] - N[(t * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -5.2e-19], N[(x * (-y)), $MachinePrecision], If[LessEqual[z, -1e-300], t$95$1, If[LessEqual[z, 1e-185], N[(x * N[(y * N[(z * N[(N[Power[N[(-1.0 / t), $MachinePrecision], 0.5], $MachinePrecision] * N[Power[a, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 6.2e+33], t$95$1, N[(x * y), $MachinePrecision]]]]]]
\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}
\begin{array}{l}
t_1 := \frac{x \cdot \left(z \cdot y\right)}{\sqrt{z \cdot z - t \cdot a}}\\
\mathbf{if}\;z \leq -5.2 \cdot 10^{-19}:\\
\;\;\;\;x \cdot \left(-y\right)\\

\mathbf{elif}\;z \leq -1 \cdot 10^{-300}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;z \leq 10^{-185}:\\
\;\;\;\;x \cdot \left(y \cdot \left(z \cdot \left({\left(\frac{-1}{t}\right)}^{0.5} \cdot {a}^{-0.5}\right)\right)\right)\\

\mathbf{elif}\;z \leq 6.2 \cdot 10^{+33}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;x \cdot y\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original25.2
Target7.4
Herbie7.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 4 regimes
  2. if z < -5.20000000000000026e-19

    1. Initial program 32.4

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

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

      \[\leadsto x \cdot \color{blue}{\left(y \cdot \left(z \cdot {\left(z \cdot z - t \cdot a\right)}^{-0.5}\right)\right)} \]
    4. Taylor expanded in z around -inf 5.8

      \[\leadsto x \cdot \color{blue}{\left(-1 \cdot y\right)} \]
    5. Simplified5.8

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

    if -5.20000000000000026e-19 < z < -1.00000000000000003e-300 or 9.9999999999999999e-186 < z < 6.2e33

    1. Initial program 11.0

      \[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}} \]
    2. Taylor expanded in x around 0 11.6

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

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

    if -1.00000000000000003e-300 < z < 9.9999999999999999e-186

    1. Initial program 19.5

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

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

      \[\leadsto x \cdot \color{blue}{\left(y \cdot \left(z \cdot {\left(z \cdot z - t \cdot a\right)}^{-0.5}\right)\right)} \]
    4. Taylor expanded in t around -inf 15.1

      \[\leadsto x \cdot \left(y \cdot \left(z \cdot \color{blue}{e^{-0.5 \cdot \left(\log \left(--1 \cdot a\right) + -1 \cdot \log \left(\frac{-1}{t}\right)\right)}}\right)\right) \]
    5. Simplified13.1

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

    if 6.2e33 < z

    1. Initial program 36.2

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

      \[\leadsto \color{blue}{x \cdot \frac{y \cdot z}{\sqrt{z \cdot z - t \cdot a}}} \]
    3. Taylor expanded in z around inf 4.5

      \[\leadsto x \cdot \color{blue}{y} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification7.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -5.2 \cdot 10^{-19}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{elif}\;z \leq -1 \cdot 10^{-300}:\\ \;\;\;\;\frac{x \cdot \left(z \cdot y\right)}{\sqrt{z \cdot z - t \cdot a}}\\ \mathbf{elif}\;z \leq 10^{-185}:\\ \;\;\;\;x \cdot \left(y \cdot \left(z \cdot \left({\left(\frac{-1}{t}\right)}^{0.5} \cdot {a}^{-0.5}\right)\right)\right)\\ \mathbf{elif}\;z \leq 6.2 \cdot 10^{+33}:\\ \;\;\;\;\frac{x \cdot \left(z \cdot y\right)}{\sqrt{z \cdot z - t \cdot a}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]

Alternatives

Alternative 1
Error7.9
Cost13964
\[\begin{array}{l} t_1 := \frac{x \cdot \left(z \cdot y\right)}{\sqrt{z \cdot z - t \cdot a}}\\ \mathbf{if}\;z \leq -5.2 \cdot 10^{-19}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{elif}\;z \leq -1 \cdot 10^{-300}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 10^{-178}:\\ \;\;\;\;x \cdot \left(y \cdot \left(z \cdot \left({a}^{-0.5} \cdot {\left(-t\right)}^{-0.5}\right)\right)\right)\\ \mathbf{elif}\;z \leq 6.2 \cdot 10^{+33}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 2
Error8.3
Cost7496
\[\begin{array}{l} \mathbf{if}\;z \leq -5.2 \cdot 10^{-19}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{elif}\;z \leq 6.2 \cdot 10^{+33}:\\ \;\;\;\;\frac{x \cdot \left(z \cdot y\right)}{\sqrt{z \cdot z - t \cdot a}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 3
Error12.8
Cost7368
\[\begin{array}{l} \mathbf{if}\;z \leq -5.4 \cdot 10^{-96}:\\ \;\;\;\;\frac{x \cdot y}{\frac{\frac{0.5}{\frac{\frac{z}{t}}{a}} - z}{z}}\\ \mathbf{elif}\;z \leq 1.02 \cdot 10^{-168}:\\ \;\;\;\;z \cdot \left(\left(x \cdot y\right) \cdot {\left(t \cdot \left(-a\right)\right)}^{-0.5}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{1 + \frac{-0.5}{z} \cdot \frac{t \cdot a}{z}}\\ \end{array} \]
Alternative 4
Error12.8
Cost7304
\[\begin{array}{l} \mathbf{if}\;z \leq -5.4 \cdot 10^{-96}:\\ \;\;\;\;\frac{x \cdot y}{\frac{\frac{0.5}{\frac{\frac{z}{t}}{a}} - z}{z}}\\ \mathbf{elif}\;z \leq 1.02 \cdot 10^{-168}:\\ \;\;\;\;\frac{z \cdot \left(x \cdot y\right)}{\sqrt{t \cdot \left(-a\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{1 + \frac{-0.5}{z} \cdot \frac{t \cdot a}{z}}\\ \end{array} \]
Alternative 5
Error15.8
Cost1092
\[\begin{array}{l} \mathbf{if}\;z \leq 5.8 \cdot 10^{-177}:\\ \;\;\;\;\frac{x \cdot y}{\frac{\frac{0.5}{\frac{\frac{z}{t}}{a}} - z}{z}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 6
Error15.4
Cost1092
\[\begin{array}{l} \mathbf{if}\;z \leq -1.4 \cdot 10^{-308}:\\ \;\;\;\;\frac{x \cdot y}{\frac{\frac{0.5}{\frac{\frac{z}{t}}{a}} - z}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{1 + \frac{-0.5}{z} \cdot \frac{t \cdot a}{z}}\\ \end{array} \]
Alternative 7
Error17.8
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -2.55 \cdot 10^{-232}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{elif}\;z \leq 6.5 \cdot 10^{-134}:\\ \;\;\;\;x \cdot \left(1 + \left(y + -1\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 8
Error17.5
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -2.55 \cdot 10^{-232}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{elif}\;z \leq 6.5 \cdot 10^{-134}:\\ \;\;\;\;\frac{x \cdot \left(z \cdot y\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 9
Error19.2
Cost388
\[\begin{array}{l} \mathbf{if}\;z \leq -1.4 \cdot 10^{-308}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 10
Error37.1
Cost192
\[x \cdot y \]

Error

Reproduce

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