Average Error: 25.1 → 5.8
Time: 6.4s
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} t_1 := \frac{a}{z} \cdot t\\ t_2 := \sqrt{a \cdot \left(-t\right)}\\ t_3 := \frac{z}{\sqrt{z \cdot z - a \cdot t}}\\ \mathbf{if}\;z \leq -1 \cdot 10^{+154}:\\ \;\;\;\;\frac{y \cdot x}{\frac{0.5 \cdot t_1 - z}{z}}\\ \mathbf{elif}\;z \leq -1.9 \cdot 10^{-160}:\\ \;\;\;\;y \cdot \left(x \cdot t_3\right)\\ \mathbf{elif}\;z \leq 9 \cdot 10^{-143}:\\ \;\;\;\;x \cdot \frac{z \cdot y}{\mathsf{fma}\left(0.5, \frac{z}{\frac{t_2}{z}}, t_2\right)}\\ \mathbf{elif}\;z \leq 1.5 \cdot 10^{+116}:\\ \;\;\;\;\left(y \cdot x\right) \cdot t_3\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x}{\frac{z + t_1 \cdot -0.5}{z}}\\ \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 (* (/ a z) t))
        (t_2 (sqrt (* a (- t))))
        (t_3 (/ z (sqrt (- (* z z) (* a t))))))
   (if (<= z -1e+154)
     (/ (* y x) (/ (- (* 0.5 t_1) z) z))
     (if (<= z -1.9e-160)
       (* y (* x t_3))
       (if (<= z 9e-143)
         (* x (/ (* z y) (fma 0.5 (/ z (/ t_2 z)) t_2)))
         (if (<= z 1.5e+116)
           (* (* y x) t_3)
           (/ (* y x) (/ (+ z (* t_1 -0.5)) z))))))))
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 = (a / z) * t;
	double t_2 = sqrt((a * -t));
	double t_3 = z / sqrt(((z * z) - (a * t)));
	double tmp;
	if (z <= -1e+154) {
		tmp = (y * x) / (((0.5 * t_1) - z) / z);
	} else if (z <= -1.9e-160) {
		tmp = y * (x * t_3);
	} else if (z <= 9e-143) {
		tmp = x * ((z * y) / fma(0.5, (z / (t_2 / z)), t_2));
	} else if (z <= 1.5e+116) {
		tmp = (y * x) * t_3;
	} else {
		tmp = (y * x) / ((z + (t_1 * -0.5)) / z);
	}
	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(a / z) * t)
	t_2 = sqrt(Float64(a * Float64(-t)))
	t_3 = Float64(z / sqrt(Float64(Float64(z * z) - Float64(a * t))))
	tmp = 0.0
	if (z <= -1e+154)
		tmp = Float64(Float64(y * x) / Float64(Float64(Float64(0.5 * t_1) - z) / z));
	elseif (z <= -1.9e-160)
		tmp = Float64(y * Float64(x * t_3));
	elseif (z <= 9e-143)
		tmp = Float64(x * Float64(Float64(z * y) / fma(0.5, Float64(z / Float64(t_2 / z)), t_2)));
	elseif (z <= 1.5e+116)
		tmp = Float64(Float64(y * x) * t_3);
	else
		tmp = Float64(Float64(y * x) / Float64(Float64(z + Float64(t_1 * -0.5)) / z));
	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_] := Block[{t$95$1 = N[(N[(a / z), $MachinePrecision] * t), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(a * (-t)), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(z / N[Sqrt[N[(N[(z * z), $MachinePrecision] - N[(a * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1e+154], N[(N[(y * x), $MachinePrecision] / N[(N[(N[(0.5 * t$95$1), $MachinePrecision] - z), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -1.9e-160], N[(y * N[(x * t$95$3), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 9e-143], N[(x * N[(N[(z * y), $MachinePrecision] / N[(0.5 * N[(z / N[(t$95$2 / z), $MachinePrecision]), $MachinePrecision] + t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.5e+116], N[(N[(y * x), $MachinePrecision] * t$95$3), $MachinePrecision], N[(N[(y * x), $MachinePrecision] / N[(N[(z + N[(t$95$1 * -0.5), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]]]]]]]
\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}
\begin{array}{l}
t_1 := \frac{a}{z} \cdot t\\
t_2 := \sqrt{a \cdot \left(-t\right)}\\
t_3 := \frac{z}{\sqrt{z \cdot z - a \cdot t}}\\
\mathbf{if}\;z \leq -1 \cdot 10^{+154}:\\
\;\;\;\;\frac{y \cdot x}{\frac{0.5 \cdot t_1 - z}{z}}\\

\mathbf{elif}\;z \leq -1.9 \cdot 10^{-160}:\\
\;\;\;\;y \cdot \left(x \cdot t_3\right)\\

\mathbf{elif}\;z \leq 9 \cdot 10^{-143}:\\
\;\;\;\;x \cdot \frac{z \cdot y}{\mathsf{fma}\left(0.5, \frac{z}{\frac{t_2}{z}}, t_2\right)}\\

\mathbf{elif}\;z \leq 1.5 \cdot 10^{+116}:\\
\;\;\;\;\left(y \cdot x\right) \cdot t_3\\

\mathbf{else}:\\
\;\;\;\;\frac{y \cdot x}{\frac{z + t_1 \cdot -0.5}{z}}\\


\end{array}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original25.1
Target8.0
Herbie5.8
\[\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.00000000000000004e154

    1. Initial program 54.1

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

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

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

      \[\leadsto \frac{y \cdot x}{\frac{\color{blue}{0.5 \cdot \frac{a \cdot t}{z} - z}}{z}} \]
    5. Simplified1.2

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

    if -1.00000000000000004e154 < z < -1.8999999999999999e-160

    1. Initial program 9.6

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

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

      \[\leadsto \color{blue}{\frac{y \cdot x}{\frac{\sqrt{z \cdot z - t \cdot a}}{z}}} \]
    4. Applied egg-rr5.2

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

    if -1.8999999999999999e-160 < z < 9.00000000000000001e-143

    1. Initial program 18.7

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

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

      \[\leadsto x \cdot \frac{y \cdot z}{\color{blue}{0.5 \cdot \frac{{z}^{2}}{\sqrt{-a \cdot t}} + \sqrt{-a \cdot t}}} \]
    4. Simplified15.7

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

    if 9.00000000000000001e-143 < z < 1.4999999999999999e116

    1. Initial program 7.9

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

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

      \[\leadsto \color{blue}{\frac{y \cdot x}{\frac{\sqrt{z \cdot z - t \cdot a}}{z}}} \]
    4. Applied egg-rr4.5

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

    if 1.4999999999999999e116 < z

    1. Initial program 46.4

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

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

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

      \[\leadsto \frac{y \cdot x}{\frac{\color{blue}{z - 0.5 \cdot \frac{a \cdot t}{z}}}{z}} \]
    5. Simplified1.7

      \[\leadsto \frac{y \cdot x}{\frac{\color{blue}{z + \left(\frac{a}{z} \cdot t\right) \cdot -0.5}}{z}} \]
  3. Recombined 5 regimes into one program.
  4. Final simplification5.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1 \cdot 10^{+154}:\\ \;\;\;\;\frac{y \cdot x}{\frac{0.5 \cdot \left(\frac{a}{z} \cdot t\right) - z}{z}}\\ \mathbf{elif}\;z \leq -1.9 \cdot 10^{-160}:\\ \;\;\;\;y \cdot \left(x \cdot \frac{z}{\sqrt{z \cdot z - a \cdot t}}\right)\\ \mathbf{elif}\;z \leq 9 \cdot 10^{-143}:\\ \;\;\;\;x \cdot \frac{z \cdot y}{\mathsf{fma}\left(0.5, \frac{z}{\frac{\sqrt{a \cdot \left(-t\right)}}{z}}, \sqrt{a \cdot \left(-t\right)}\right)}\\ \mathbf{elif}\;z \leq 1.5 \cdot 10^{+116}:\\ \;\;\;\;\left(y \cdot x\right) \cdot \frac{z}{\sqrt{z \cdot z - a \cdot t}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x}{\frac{z + \left(\frac{a}{z} \cdot t\right) \cdot -0.5}{z}}\\ \end{array} \]

Reproduce

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