Average Error: 24.6 → 6.2
Time: 32.4s
Precision: binary64
Cost: 20428
\[ \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 := \sqrt{z \cdot z - t \cdot a}\\ \mathbf{if}\;z \leq -4.125494499902614 \cdot 10^{+131}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq -1 \cdot 10^{-140}:\\ \;\;\;\;x \cdot \frac{z \cdot y}{t_1}\\ \mathbf{elif}\;z \leq 10^{-180}:\\ \;\;\;\;y \cdot \frac{1}{\frac{\mathsf{hypot}\left(z, \sqrt{-t} \cdot \sqrt{a}\right)}{z \cdot x}}\\ \mathbf{elif}\;z \leq 1.75 \cdot 10^{+96}:\\ \;\;\;\;\frac{y \cdot x}{\frac{t_1}{z}}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \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 (sqrt (- (* z z) (* t a)))))
   (if (<= z -4.125494499902614e+131)
     (* y (- x))
     (if (<= z -1e-140)
       (* x (/ (* z y) t_1))
       (if (<= z 1e-180)
         (* y (/ 1.0 (/ (hypot z (* (sqrt (- t)) (sqrt a))) (* z x))))
         (if (<= z 1.75e+96) (/ (* y x) (/ t_1 z)) (* y x)))))))
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 = sqrt(((z * z) - (t * a)));
	double tmp;
	if (z <= -4.125494499902614e+131) {
		tmp = y * -x;
	} else if (z <= -1e-140) {
		tmp = x * ((z * y) / t_1);
	} else if (z <= 1e-180) {
		tmp = y * (1.0 / (hypot(z, (sqrt(-t) * sqrt(a))) / (z * x)));
	} else if (z <= 1.75e+96) {
		tmp = (y * x) / (t_1 / z);
	} else {
		tmp = y * x;
	}
	return tmp;
}
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 = Math.sqrt(((z * z) - (t * a)));
	double tmp;
	if (z <= -4.125494499902614e+131) {
		tmp = y * -x;
	} else if (z <= -1e-140) {
		tmp = x * ((z * y) / t_1);
	} else if (z <= 1e-180) {
		tmp = y * (1.0 / (Math.hypot(z, (Math.sqrt(-t) * Math.sqrt(a))) / (z * x)));
	} else if (z <= 1.75e+96) {
		tmp = (y * x) / (t_1 / z);
	} else {
		tmp = y * x;
	}
	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 = math.sqrt(((z * z) - (t * a)))
	tmp = 0
	if z <= -4.125494499902614e+131:
		tmp = y * -x
	elif z <= -1e-140:
		tmp = x * ((z * y) / t_1)
	elif z <= 1e-180:
		tmp = y * (1.0 / (math.hypot(z, (math.sqrt(-t) * math.sqrt(a))) / (z * x)))
	elif z <= 1.75e+96:
		tmp = (y * x) / (t_1 / z)
	else:
		tmp = y * x
	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 = sqrt(Float64(Float64(z * z) - Float64(t * a)))
	tmp = 0.0
	if (z <= -4.125494499902614e+131)
		tmp = Float64(y * Float64(-x));
	elseif (z <= -1e-140)
		tmp = Float64(x * Float64(Float64(z * y) / t_1));
	elseif (z <= 1e-180)
		tmp = Float64(y * Float64(1.0 / Float64(hypot(z, Float64(sqrt(Float64(-t)) * sqrt(a))) / Float64(z * x))));
	elseif (z <= 1.75e+96)
		tmp = Float64(Float64(y * x) / Float64(t_1 / z));
	else
		tmp = Float64(y * x);
	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 = sqrt(((z * z) - (t * a)));
	tmp = 0.0;
	if (z <= -4.125494499902614e+131)
		tmp = y * -x;
	elseif (z <= -1e-140)
		tmp = x * ((z * y) / t_1);
	elseif (z <= 1e-180)
		tmp = y * (1.0 / (hypot(z, (sqrt(-t) * sqrt(a))) / (z * x)));
	elseif (z <= 1.75e+96)
		tmp = (y * x) / (t_1 / z);
	else
		tmp = y * x;
	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[Sqrt[N[(N[(z * z), $MachinePrecision] - N[(t * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[z, -4.125494499902614e+131], N[(y * (-x)), $MachinePrecision], If[LessEqual[z, -1e-140], N[(x * N[(N[(z * y), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1e-180], N[(y * N[(1.0 / N[(N[Sqrt[z ^ 2 + N[(N[Sqrt[(-t)], $MachinePrecision] * N[Sqrt[a], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] / N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.75e+96], N[(N[(y * x), $MachinePrecision] / N[(t$95$1 / z), $MachinePrecision]), $MachinePrecision], N[(y * x), $MachinePrecision]]]]]]
\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}
\begin{array}{l}
t_1 := \sqrt{z \cdot z - t \cdot a}\\
\mathbf{if}\;z \leq -4.125494499902614 \cdot 10^{+131}:\\
\;\;\;\;y \cdot \left(-x\right)\\

\mathbf{elif}\;z \leq -1 \cdot 10^{-140}:\\
\;\;\;\;x \cdot \frac{z \cdot y}{t_1}\\

\mathbf{elif}\;z \leq 10^{-180}:\\
\;\;\;\;y \cdot \frac{1}{\frac{\mathsf{hypot}\left(z, \sqrt{-t} \cdot \sqrt{a}\right)}{z \cdot x}}\\

\mathbf{elif}\;z \leq 1.75 \cdot 10^{+96}:\\
\;\;\;\;\frac{y \cdot x}{\frac{t_1}{z}}\\

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original24.6
Target7.9
Herbie6.2
\[\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 5 regimes
  2. if z < -4.12549449990261415e131

    1. Initial program 49.4

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

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

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

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

    if -4.12549449990261415e131 < z < -9.9999999999999998e-141

    1. Initial program 8.1

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

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

    if -9.9999999999999998e-141 < z < 1e-180

    1. Initial program 17.1

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

      \[\leadsto \frac{\color{blue}{y \cdot \left(z \cdot x\right)}}{\sqrt{z \cdot z - t \cdot a}} \]
    3. Applied egg-rr14.6

      \[\leadsto \color{blue}{y \cdot \frac{1}{\frac{\mathsf{hypot}\left(z, \sqrt{-t \cdot a}\right)}{z \cdot x}}} \]
    4. Applied egg-rr12.6

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

    if 1e-180 < z < 1.7499999999999999e96

    1. Initial program 8.5

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{{\left(z \cdot z - t \cdot a\right)}^{0.25}} \cdot \frac{z}{{\left(z \cdot z - t \cdot a\right)}^{0.25}}} \]
    3. Applied egg-rr6.0

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

    if 1.7499999999999999e96 < z

    1. Initial program 43.2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -4.125494499902614 \cdot 10^{+131}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq -1 \cdot 10^{-140}:\\ \;\;\;\;x \cdot \frac{z \cdot y}{\sqrt{z \cdot z - t \cdot a}}\\ \mathbf{elif}\;z \leq 10^{-180}:\\ \;\;\;\;y \cdot \frac{1}{\frac{\mathsf{hypot}\left(z, \sqrt{-t} \cdot \sqrt{a}\right)}{z \cdot x}}\\ \mathbf{elif}\;z \leq 1.75 \cdot 10^{+96}:\\ \;\;\;\;\frac{y \cdot x}{\frac{\sqrt{z \cdot z - t \cdot a}}{z}}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]

Alternatives

Alternative 1
Error6.5
Cost14028
\[\begin{array}{l} t_1 := \sqrt{z \cdot z - t \cdot a}\\ \mathbf{if}\;z \leq -4.125494499902614 \cdot 10^{+131}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq -1 \cdot 10^{-140}:\\ \;\;\;\;x \cdot \frac{z \cdot y}{t_1}\\ \mathbf{elif}\;z \leq 10^{-180}:\\ \;\;\;\;y \cdot \frac{1}{\frac{\mathsf{hypot}\left(z, \sqrt{t \cdot \left(-a\right)}\right)}{z \cdot x}}\\ \mathbf{elif}\;z \leq 1.75 \cdot 10^{+96}:\\ \;\;\;\;\frac{y \cdot x}{\frac{t_1}{z}}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 2
Error6.5
Cost7760
\[\begin{array}{l} t_1 := \frac{y \cdot x}{\frac{\sqrt{z \cdot z - t \cdot a}}{z}}\\ \mathbf{if}\;z \leq -3.641745439692241 \cdot 10^{+161}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq -1 \cdot 10^{-160}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 10^{-180}:\\ \;\;\;\;y \cdot \left(\left(z \cdot x\right) \cdot {\left(t \cdot \left(-a\right)\right)}^{-0.5}\right)\\ \mathbf{elif}\;z \leq 1.75 \cdot 10^{+96}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 3
Error7.5
Cost7560
\[\begin{array}{l} \mathbf{if}\;z \leq -2.7 \cdot 10^{+53}:\\ \;\;\;\;\frac{y \cdot x}{\mathsf{fma}\left(0.5, \frac{t}{z} \cdot \frac{a}{z}, -1\right)}\\ \mathbf{elif}\;z \leq 2.6 \cdot 10^{+23}:\\ \;\;\;\;y \cdot \left(\left(z \cdot x\right) \cdot {\left(z \cdot z - t \cdot a\right)}^{-0.5}\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 4
Error8.0
Cost7496
\[\begin{array}{l} \mathbf{if}\;z \leq -2.7 \cdot 10^{+53}:\\ \;\;\;\;\frac{y \cdot x}{\mathsf{fma}\left(0.5, \frac{t}{z} \cdot \frac{a}{z}, -1\right)}\\ \mathbf{elif}\;z \leq 2.6 \cdot 10^{+23}:\\ \;\;\;\;\frac{y \cdot \left(z \cdot x\right)}{\sqrt{z \cdot z - t \cdot a}}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 5
Error13.4
Cost7436
\[\begin{array}{l} \mathbf{if}\;z \leq -4.125494499902614 \cdot 10^{+131}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq -7 \cdot 10^{-167}:\\ \;\;\;\;x \cdot \frac{z \cdot y}{\left(t \cdot a\right) \cdot \frac{0.5}{z} - z}\\ \mathbf{elif}\;z \leq 2.4 \cdot 10^{-39}:\\ \;\;\;\;\frac{y \cdot x}{\frac{\sqrt{t \cdot \left(-a\right)}}{z}}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 6
Error12.8
Cost7368
\[\begin{array}{l} \mathbf{if}\;z \leq -1.2 \cdot 10^{-60}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 2.4 \cdot 10^{-39}:\\ \;\;\;\;y \cdot \left(\left(z \cdot x\right) \cdot {\left(t \cdot \left(-a\right)\right)}^{-0.5}\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 7
Error12.4
Cost7368
\[\begin{array}{l} \mathbf{if}\;z \leq -7 \cdot 10^{-167}:\\ \;\;\;\;\frac{y \cdot x}{\mathsf{fma}\left(0.5, \frac{t}{z} \cdot \frac{a}{z}, -1\right)}\\ \mathbf{elif}\;z \leq 2.4 \cdot 10^{-39}:\\ \;\;\;\;y \cdot \left(\left(z \cdot x\right) \cdot {\left(t \cdot \left(-a\right)\right)}^{-0.5}\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 8
Error12.8
Cost7304
\[\begin{array}{l} \mathbf{if}\;z \leq -1.2 \cdot 10^{-60}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 2.4 \cdot 10^{-39}:\\ \;\;\;\;\frac{y \cdot \left(z \cdot x\right)}{\sqrt{t \cdot \left(-a\right)}}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 9
Error16.9
Cost1224
\[\begin{array}{l} \mathbf{if}\;z \leq -5 \cdot 10^{-184}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 120000:\\ \;\;\;\;\frac{x}{\frac{z + -0.5 \cdot \frac{a}{\frac{z}{t}}}{z \cdot y}}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 10
Error16.5
Cost1224
\[\begin{array}{l} \mathbf{if}\;z \leq -1.3511806622917368 \cdot 10^{+205}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 7.6 \cdot 10^{-189}:\\ \;\;\;\;\frac{y \cdot x}{\frac{\left(t \cdot a\right) \cdot \frac{0.5}{z} - z}{z}}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 11
Error16.7
Cost1224
\[\begin{array}{l} \mathbf{if}\;z \leq -1.5 \cdot 10^{+25}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 7.6 \cdot 10^{-189}:\\ \;\;\;\;\frac{x}{\frac{\left(t \cdot a\right) \cdot \frac{0.5}{z} - z}{z \cdot y}}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 12
Error17.2
Cost1224
\[\begin{array}{l} \mathbf{if}\;z \leq -4.125494499902614 \cdot 10^{+131}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 7.6 \cdot 10^{-189}:\\ \;\;\;\;x \cdot \frac{z \cdot y}{\left(t \cdot a\right) \cdot \frac{0.5}{z} - z}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 13
Error18.1
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -5 \cdot 10^{-182}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 2.15 \cdot 10^{-32}:\\ \;\;\;\;\frac{y \cdot \left(z \cdot x\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 14
Error18.0
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -5.2 \cdot 10^{-107}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 2.25 \cdot 10^{-200}:\\ \;\;\;\;-1 + \left(1 - y \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 15
Error19.8
Cost388
\[\begin{array}{l} \mathbf{if}\;z \leq -2.9 \cdot 10^{-302}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 16
Error37.2
Cost192
\[y \cdot x \]

Error

Reproduce

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