Average Error: 24.5 → 5.9
Time: 8.3s
Precision: binary64
\[ \begin{array}{c}[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{a}{z \cdot \frac{z}{t}}\\ \mathbf{if}\;z \leq -1 \cdot 10^{+117}:\\ \;\;\;\;\left(x \cdot y\right) \cdot \frac{1}{\mathsf{fma}\left(0.5, t_1, -1\right)}\\ \mathbf{elif}\;z \leq -3.1 \cdot 10^{-263}:\\ \;\;\;\;\left(x \cdot y\right) \cdot \frac{1}{\frac{\sqrt{z \cdot z - a \cdot t}}{z}}\\ \mathbf{elif}\;z \leq 3.1 \cdot 10^{-201}:\\ \;\;\;\;\left(y \cdot \left(z \cdot x\right)\right) \cdot e^{-0.5 \cdot \left(\log a - \log \left(\frac{-1}{t}\right)\right)}\\ \mathbf{elif}\;z \leq 3.1 \cdot 10^{+37}:\\ \;\;\;\;\frac{x \cdot y}{\frac{\sqrt{\mathsf{fma}\left(z, z, a \cdot \left(-t\right)\right)}}{z}}\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot y\right) \cdot \frac{1}{\mathsf{fma}\left(t_1, -0.5, 1\right)}\\ \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 (/ z t)))))
   (if (<= z -1e+117)
     (* (* x y) (/ 1.0 (fma 0.5 t_1 -1.0)))
     (if (<= z -3.1e-263)
       (* (* x y) (/ 1.0 (/ (sqrt (- (* z z) (* a t))) z)))
       (if (<= z 3.1e-201)
         (* (* y (* z x)) (exp (* -0.5 (- (log a) (log (/ -1.0 t))))))
         (if (<= z 3.1e+37)
           (/ (* x y) (/ (sqrt (fma z z (* a (- t)))) z))
           (* (* x y) (/ 1.0 (fma t_1 -0.5 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 t_1 = a / (z * (z / t));
	double tmp;
	if (z <= -1e+117) {
		tmp = (x * y) * (1.0 / fma(0.5, t_1, -1.0));
	} else if (z <= -3.1e-263) {
		tmp = (x * y) * (1.0 / (sqrt(((z * z) - (a * t))) / z));
	} else if (z <= 3.1e-201) {
		tmp = (y * (z * x)) * exp((-0.5 * (log(a) - log((-1.0 / t)))));
	} else if (z <= 3.1e+37) {
		tmp = (x * y) / (sqrt(fma(z, z, (a * -t))) / z);
	} else {
		tmp = (x * y) * (1.0 / fma(t_1, -0.5, 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)
	t_1 = Float64(a / Float64(z * Float64(z / t)))
	tmp = 0.0
	if (z <= -1e+117)
		tmp = Float64(Float64(x * y) * Float64(1.0 / fma(0.5, t_1, -1.0)));
	elseif (z <= -3.1e-263)
		tmp = Float64(Float64(x * y) * Float64(1.0 / Float64(sqrt(Float64(Float64(z * z) - Float64(a * t))) / z)));
	elseif (z <= 3.1e-201)
		tmp = Float64(Float64(y * Float64(z * x)) * exp(Float64(-0.5 * Float64(log(a) - log(Float64(-1.0 / t))))));
	elseif (z <= 3.1e+37)
		tmp = Float64(Float64(x * y) / Float64(sqrt(fma(z, z, Float64(a * Float64(-t)))) / z));
	else
		tmp = Float64(Float64(x * y) * Float64(1.0 / fma(t_1, -0.5, 1.0)));
	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[(a / N[(z * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1e+117], N[(N[(x * y), $MachinePrecision] * N[(1.0 / N[(0.5 * t$95$1 + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -3.1e-263], N[(N[(x * y), $MachinePrecision] * N[(1.0 / N[(N[Sqrt[N[(N[(z * z), $MachinePrecision] - N[(a * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 3.1e-201], N[(N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision] * N[Exp[N[(-0.5 * N[(N[Log[a], $MachinePrecision] - N[Log[N[(-1.0 / t), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 3.1e+37], N[(N[(x * y), $MachinePrecision] / N[(N[Sqrt[N[(z * z + N[(a * (-t)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(N[(x * y), $MachinePrecision] * N[(1.0 / N[(t$95$1 * -0.5 + 1.0), $MachinePrecision]), $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 \frac{z}{t}}\\
\mathbf{if}\;z \leq -1 \cdot 10^{+117}:\\
\;\;\;\;\left(x \cdot y\right) \cdot \frac{1}{\mathsf{fma}\left(0.5, t_1, -1\right)}\\

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

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

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

\mathbf{else}:\\
\;\;\;\;\left(x \cdot y\right) \cdot \frac{1}{\mathsf{fma}\left(t_1, -0.5, 1\right)}\\


\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.5
Target8.0
Herbie5.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 5 regimes
  2. if z < -1.00000000000000005e117

    1. Initial program 45.3

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

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

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

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

    if -1.00000000000000005e117 < z < -3.10000000000000004e-263

    1. Initial program 10.2

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

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

    if -3.10000000000000004e-263 < z < 3.0999999999999999e-201

    1. Initial program 18.0

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

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

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

    if 3.0999999999999999e-201 < z < 3.1000000000000002e37

    1. Initial program 8.6

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

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

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

    if 3.1000000000000002e37 < z

    1. Initial program 36.1

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1 \cdot 10^{+117}:\\ \;\;\;\;\left(x \cdot y\right) \cdot \frac{1}{\mathsf{fma}\left(0.5, \frac{a}{z \cdot \frac{z}{t}}, -1\right)}\\ \mathbf{elif}\;z \leq -3.1 \cdot 10^{-263}:\\ \;\;\;\;\left(x \cdot y\right) \cdot \frac{1}{\frac{\sqrt{z \cdot z - a \cdot t}}{z}}\\ \mathbf{elif}\;z \leq 3.1 \cdot 10^{-201}:\\ \;\;\;\;\left(y \cdot \left(z \cdot x\right)\right) \cdot e^{-0.5 \cdot \left(\log a - \log \left(\frac{-1}{t}\right)\right)}\\ \mathbf{elif}\;z \leq 3.1 \cdot 10^{+37}:\\ \;\;\;\;\frac{x \cdot y}{\frac{\sqrt{\mathsf{fma}\left(z, z, a \cdot \left(-t\right)\right)}}{z}}\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot y\right) \cdot \frac{1}{\mathsf{fma}\left(\frac{a}{z \cdot \frac{z}{t}}, -0.5, 1\right)}\\ \end{array} \]

Reproduce

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