Average Error: 24.8 → 6.6
Time: 8.5s
Precision: binary64
\[ \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 -1.75 \cdot 10^{+99}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{elif}\;z \leq -3 \cdot 10^{-167}:\\ \;\;\;\;\sqrt{\frac{1}{\mathsf{fma}\left(t, -a, z \cdot z\right)}} \cdot \left(x \cdot \left(z \cdot y\right)\right)\\ \mathbf{elif}\;z \leq 1.28 \cdot 10^{-68}:\\ \;\;\;\;\frac{x}{\frac{\mathsf{hypot}\left(\sqrt{t \cdot \left(-a\right)}, z\right)}{z \cdot y}}\\ \mathbf{elif}\;z \leq 1.05 \cdot 10^{+98}:\\ \;\;\;\;\frac{z \cdot \left(x \cdot y\right)}{\sqrt{z \cdot z - t \cdot a}}\\ \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
 (if (<= z -1.75e+99)
   (* x (- y))
   (if (<= z -3e-167)
     (* (sqrt (/ 1.0 (fma t (- a) (* z z)))) (* x (* z y)))
     (if (<= z 1.28e-68)
       (/ x (/ (hypot (sqrt (* t (- a))) z) (* z y)))
       (if (<= z 1.05e+98)
         (/ (* z (* x y)) (sqrt (- (* z z) (* t a))))
         (* 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 tmp;
	if (z <= -1.75e+99) {
		tmp = x * -y;
	} else if (z <= -3e-167) {
		tmp = sqrt((1.0 / fma(t, -a, (z * z)))) * (x * (z * y));
	} else if (z <= 1.28e-68) {
		tmp = x / (hypot(sqrt((t * -a)), z) / (z * y));
	} else if (z <= 1.05e+98) {
		tmp = (z * (x * y)) / sqrt(((z * z) - (t * a)));
	} 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)
	tmp = 0.0
	if (z <= -1.75e+99)
		tmp = Float64(x * Float64(-y));
	elseif (z <= -3e-167)
		tmp = Float64(sqrt(Float64(1.0 / fma(t, Float64(-a), Float64(z * z)))) * Float64(x * Float64(z * y)));
	elseif (z <= 1.28e-68)
		tmp = Float64(x / Float64(hypot(sqrt(Float64(t * Float64(-a))), z) / Float64(z * y)));
	elseif (z <= 1.05e+98)
		tmp = Float64(Float64(z * Float64(x * y)) / sqrt(Float64(Float64(z * z) - Float64(t * a))));
	else
		tmp = Float64(x * y);
	end
	return 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, -1.75e+99], N[(x * (-y)), $MachinePrecision], If[LessEqual[z, -3e-167], N[(N[Sqrt[N[(1.0 / N[(t * (-a) + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.28e-68], N[(x / N[(N[Sqrt[N[Sqrt[N[(t * (-a)), $MachinePrecision]], $MachinePrecision] ^ 2 + z ^ 2], $MachinePrecision] / N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.05e+98], N[(N[(z * N[(x * y), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[(z * z), $MachinePrecision] - N[(t * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(x * y), $MachinePrecision]]]]]
\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}
\begin{array}{l}
\mathbf{if}\;z \leq -1.75 \cdot 10^{+99}:\\
\;\;\;\;x \cdot \left(-y\right)\\

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

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

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

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


\end{array}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.8
Target7.3
Herbie6.6
\[\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 < -1.7499999999999999e99

    1. Initial program 44.2

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

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

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

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

    if -1.7499999999999999e99 < z < -2.9999999999999998e-167

    1. Initial program 7.5

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

      \[\leadsto \color{blue}{\sqrt{\frac{1}{{z}^{2} - a \cdot t}} \cdot \left(y \cdot \left(z \cdot x\right)\right)} \]
    3. Simplified9.6

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

    if -2.9999999999999998e-167 < z < 1.27999999999999999e-68

    1. Initial program 15.5

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

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

      \[\leadsto \color{blue}{\frac{x}{\frac{\sqrt{z \cdot z - t \cdot a}}{z \cdot y}}} \]
    4. Taylor expanded in y around 0 15.0

      \[\leadsto \frac{x}{\color{blue}{\sqrt{{z}^{2} - a \cdot t} \cdot \frac{1}{y \cdot z}}} \]
    5. Simplified12.9

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

    if 1.27999999999999999e-68 < z < 1.05000000000000002e98

    1. Initial program 6.4

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

    if 1.05000000000000002e98 < z

    1. Initial program 43.3

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.75 \cdot 10^{+99}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{elif}\;z \leq -3 \cdot 10^{-167}:\\ \;\;\;\;\sqrt{\frac{1}{\mathsf{fma}\left(t, -a, z \cdot z\right)}} \cdot \left(x \cdot \left(z \cdot y\right)\right)\\ \mathbf{elif}\;z \leq 1.28 \cdot 10^{-68}:\\ \;\;\;\;\frac{x}{\frac{\mathsf{hypot}\left(\sqrt{t \cdot \left(-a\right)}, z\right)}{z \cdot y}}\\ \mathbf{elif}\;z \leq 1.05 \cdot 10^{+98}:\\ \;\;\;\;\frac{z \cdot \left(x \cdot y\right)}{\sqrt{z \cdot z - t \cdot a}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]

Reproduce

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