Average Error: 25.1 → 7.7
Time: 9.0s
Precision: binary64
\[\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 -4.2219193410772696 \cdot 10^{+73}:\\ \;\;\;\;\frac{y \cdot x}{\mathsf{fma}\left(0.5, t_1, -1\right)}\\ \mathbf{elif}\;z \leq 4.861570841540991 \cdot 10^{-16}:\\ \;\;\;\;\frac{z \cdot \left(y \cdot x\right)}{\sqrt{\mathsf{fma}\left(z, z, a \cdot \left(-t\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x}{\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 -4.2219193410772696e+73)
     (/ (* y x) (fma 0.5 t_1 -1.0))
     (if (<= z 4.861570841540991e-16)
       (/ (* z (* y x)) (sqrt (fma z z (* a (- t)))))
       (/ (* y x) (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 <= -4.2219193410772696e+73) {
		tmp = (y * x) / fma(0.5, t_1, -1.0);
	} else if (z <= 4.861570841540991e-16) {
		tmp = (z * (y * x)) / sqrt(fma(z, z, (a * -t)));
	} else {
		tmp = (y * x) / 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 <= -4.2219193410772696e+73)
		tmp = Float64(Float64(y * x) / fma(0.5, t_1, -1.0));
	elseif (z <= 4.861570841540991e-16)
		tmp = Float64(Float64(z * Float64(y * x)) / sqrt(fma(z, z, Float64(a * Float64(-t)))));
	else
		tmp = Float64(Float64(y * x) / 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, -4.2219193410772696e+73], N[(N[(y * x), $MachinePrecision] / N[(0.5 * t$95$1 + -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 4.861570841540991e-16], N[(N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(z * z + N[(a * (-t)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(y * x), $MachinePrecision] / N[(t$95$1 * -0.5 + 1.0), $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 -4.2219193410772696 \cdot 10^{+73}:\\
\;\;\;\;\frac{y \cdot x}{\mathsf{fma}\left(0.5, t_1, -1\right)}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{y \cdot x}{\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

Original25.1
Target7.7
Herbie7.7
\[\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 3 regimes
  2. if z < -4.22191934107726956e73

    1. Initial program 39.7

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

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

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

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

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

    if -4.22191934107726956e73 < z < 4.8615708415409906e-16

    1. Initial program 12.0

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

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

    if 4.8615708415409906e-16 < z

    1. Initial program 32.6

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -4.2219193410772696 \cdot 10^{+73}:\\ \;\;\;\;\frac{y \cdot x}{\mathsf{fma}\left(0.5, \frac{a}{z \cdot \frac{z}{t}}, -1\right)}\\ \mathbf{elif}\;z \leq 4.861570841540991 \cdot 10^{-16}:\\ \;\;\;\;\frac{z \cdot \left(y \cdot x\right)}{\sqrt{\mathsf{fma}\left(z, z, a \cdot \left(-t\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x}{\mathsf{fma}\left(\frac{a}{z \cdot \frac{z}{t}}, -0.5, 1\right)}\\ \end{array} \]

Reproduce

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