Average Error: 24.7 → 5.5
Time: 8.8s
Precision: binary64
\[[t, a] = \mathsf{sort}([t, a]) \\]
\[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}} \]
\[\begin{array}{l} \mathbf{if}\;z \leq -1.8547055447344963 \cdot 10^{+153}:\\ \;\;\;\;-y \cdot x\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_1 := \sqrt{z \cdot z - t \cdot a}\\ \mathbf{if}\;z \leq -1.717551219244167 \cdot 10^{-157}:\\ \;\;\;\;\left(y \cdot x\right) \cdot \frac{z}{t_1}\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_2 := y \cdot \left(x \cdot \frac{z}{\mathsf{hypot}\left(\sqrt{a} \cdot \sqrt{-t}, z\right)}\right)\\ \mathbf{if}\;z \leq 2.008610550034131 \cdot 10^{-205}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 8.420471240038822 \cdot 10^{+27}:\\ \;\;\;\;\begin{array}{l} t_3 := \sqrt{t_1}\\ \frac{y \cdot x}{t_3} \cdot \frac{z}{t_3} \end{array}\\ \mathbf{elif}\;z \leq 7.766070028302245 \cdot 10^{+29}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array}\\ \end{array}\\ \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.8547055447344963 \cdot 10^{+153}:\\
\;\;\;\;-y \cdot x\\

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_1 := \sqrt{z \cdot z - t \cdot a}\\
\mathbf{if}\;z \leq -1.717551219244167 \cdot 10^{-157}:\\
\;\;\;\;\left(y \cdot x\right) \cdot \frac{z}{t_1}\\

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_2 := y \cdot \left(x \cdot \frac{z}{\mathsf{hypot}\left(\sqrt{a} \cdot \sqrt{-t}, z\right)}\right)\\
\mathbf{if}\;z \leq 2.008610550034131 \cdot 10^{-205}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;z \leq 8.420471240038822 \cdot 10^{+27}:\\
\;\;\;\;\begin{array}{l}
t_3 := \sqrt{t_1}\\
\frac{y \cdot x}{t_3} \cdot \frac{z}{t_3}
\end{array}\\

\mathbf{elif}\;z \leq 7.766070028302245 \cdot 10^{+29}:\\
\;\;\;\;t_2\\

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


\end{array}\\


\end{array}\\


\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.8547055447344963e+153)
   (- (* y x))
   (let* ((t_1 (sqrt (- (* z z) (* t a)))))
     (if (<= z -1.717551219244167e-157)
       (* (* y x) (/ z t_1))
       (let* ((t_2 (* y (* x (/ z (hypot (* (sqrt a) (sqrt (- t))) z))))))
         (if (<= z 2.008610550034131e-205)
           t_2
           (if (<= z 8.420471240038822e+27)
             (let* ((t_3 (sqrt t_1))) (* (/ (* y x) t_3) (/ z t_3)))
             (if (<= z 7.766070028302245e+29) t_2 (* 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 tmp;
	if (z <= -1.8547055447344963e+153) {
		tmp = -(y * x);
	} else {
		double t_1 = sqrt((z * z) - (t * a));
		double tmp_1;
		if (z <= -1.717551219244167e-157) {
			tmp_1 = (y * x) * (z / t_1);
		} else {
			double t_2 = y * (x * (z / hypot((sqrt(a) * sqrt(-t)), z)));
			double tmp_2;
			if (z <= 2.008610550034131e-205) {
				tmp_2 = t_2;
			} else if (z <= 8.420471240038822e+27) {
				double t_3 = sqrt(t_1);
				tmp_2 = ((y * x) / t_3) * (z / t_3);
			} else if (z <= 7.766070028302245e+29) {
				tmp_2 = t_2;
			} else {
				tmp_2 = y * x;
			}
			tmp_1 = tmp_2;
		}
		tmp = tmp_1;
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original24.7
Target7.2
Herbie5.5
\[\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.8547055447344963e153

    1. Initial program 55.1

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

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

      \[\leadsto \color{blue}{-y \cdot x} \]

    if -1.8547055447344963e153 < z < -1.717551219244167e-157

    1. Initial program 8.0

      \[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}} \]
    2. Applied *-un-lft-identity_binary648.0

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

      \[\leadsto \frac{\left(x \cdot y\right) \cdot z}{\color{blue}{\sqrt{1} \cdot \sqrt{z \cdot z - t \cdot a}}} \]
    4. Applied times-frac_binary645.0

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

    if -1.717551219244167e-157 < z < 2.00861055003413093e-205 or 8.4204712400388224e27 < z < 7.7660700283022452e29

    1. Initial program 17.1

      \[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}} \]
    2. Applied *-un-lft-identity_binary6417.1

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

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

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

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

      \[\leadsto \left(y \cdot x\right) \cdot \color{blue}{\frac{z}{\mathsf{hypot}\left(\sqrt{-a \cdot t}, z\right)}} \]
    7. Applied associate-*l*_binary6413.3

      \[\leadsto \color{blue}{y \cdot \left(x \cdot \frac{z}{\mathsf{hypot}\left(\sqrt{-a \cdot t}, z\right)}\right)} \]
    8. Applied distribute-rgt-neg-in_binary6413.3

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

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

    if 2.00861055003413093e-205 < z < 8.4204712400388224e27

    1. Initial program 8.9

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

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

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

    if 7.7660700283022452e29 < z

    1. Initial program 35.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.8547055447344963 \cdot 10^{+153}:\\ \;\;\;\;-y \cdot x\\ \mathbf{elif}\;z \leq -1.717551219244167 \cdot 10^{-157}:\\ \;\;\;\;\left(y \cdot x\right) \cdot \frac{z}{\sqrt{z \cdot z - t \cdot a}}\\ \mathbf{elif}\;z \leq 2.008610550034131 \cdot 10^{-205}:\\ \;\;\;\;y \cdot \left(x \cdot \frac{z}{\mathsf{hypot}\left(\sqrt{a} \cdot \sqrt{-t}, z\right)}\right)\\ \mathbf{elif}\;z \leq 8.420471240038822 \cdot 10^{+27}:\\ \;\;\;\;\frac{y \cdot x}{\sqrt{\sqrt{z \cdot z - t \cdot a}}} \cdot \frac{z}{\sqrt{\sqrt{z \cdot z - t \cdot a}}}\\ \mathbf{elif}\;z \leq 7.766070028302245 \cdot 10^{+29}:\\ \;\;\;\;y \cdot \left(x \cdot \frac{z}{\mathsf{hypot}\left(\sqrt{a} \cdot \sqrt{-t}, z\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]

Reproduce

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