Average Error: 24.3 → 6.7
Time: 11.5s
Precision: binary64
\[[x, y] = \mathsf{sort}([x, y]) \[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.2154716544061854 \cdot 10^{-37}:\\ \;\;\;\;-y \cdot x\\ \mathbf{elif}\;z \leq 1.1954013876901866 \cdot 10^{-257}:\\ \;\;\;\;\frac{x}{\frac{1}{\sqrt[3]{z} \cdot \sqrt[3]{z}}} \cdot \frac{y}{\frac{\mathsf{hypot}\left(\sqrt{-a \cdot t}, z\right)}{\sqrt[3]{z}}}\\ \mathbf{elif}\;z \leq 1.2271992071220414 \cdot 10^{-173}:\\ \;\;\;\;\frac{1}{\frac{\frac{1}{\sqrt{z}}}{\sqrt[3]{y} \cdot \sqrt[3]{y}}} \cdot \frac{x}{\frac{\frac{\mathsf{hypot}\left(\sqrt{a} \cdot \sqrt{-t}, z\right)}{\sqrt{z}}}{\sqrt[3]{y}}}\\ \mathbf{elif}\;z \leq 1.2689282843189357 \cdot 10^{+142}:\\ \;\;\;\;\left(y \cdot x\right) \cdot \frac{z}{\sqrt{z \cdot z - a \cdot t}}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \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.2154716544061854 \cdot 10^{-37}:\\
\;\;\;\;-y \cdot x\\

\mathbf{elif}\;z \leq 1.1954013876901866 \cdot 10^{-257}:\\
\;\;\;\;\frac{x}{\frac{1}{\sqrt[3]{z} \cdot \sqrt[3]{z}}} \cdot \frac{y}{\frac{\mathsf{hypot}\left(\sqrt{-a \cdot t}, z\right)}{\sqrt[3]{z}}}\\

\mathbf{elif}\;z \leq 1.2271992071220414 \cdot 10^{-173}:\\
\;\;\;\;\frac{1}{\frac{\frac{1}{\sqrt{z}}}{\sqrt[3]{y} \cdot \sqrt[3]{y}}} \cdot \frac{x}{\frac{\frac{\mathsf{hypot}\left(\sqrt{a} \cdot \sqrt{-t}, z\right)}{\sqrt{z}}}{\sqrt[3]{y}}}\\

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

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


\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.2154716544061854e-37)
   (- (* y x))
   (if (<= z 1.1954013876901866e-257)
     (*
      (/ x (/ 1.0 (* (cbrt z) (cbrt z))))
      (/ y (/ (hypot (sqrt (- (* a t))) z) (cbrt z))))
     (if (<= z 1.2271992071220414e-173)
       (*
        (/ 1.0 (/ (/ 1.0 (sqrt z)) (* (cbrt y) (cbrt y))))
        (/ x (/ (/ (hypot (* (sqrt a) (sqrt (- t))) z) (sqrt z)) (cbrt y))))
       (if (<= z 1.2689282843189357e+142)
         (* (* y x) (/ z (sqrt (- (* z z) (* a t)))))
         (* 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.2154716544061854e-37) {
		tmp = -(y * x);
	} else if (z <= 1.1954013876901866e-257) {
		tmp = (x / (1.0 / (cbrt(z) * cbrt(z)))) * (y / (hypot(sqrt(-(a * t)), z) / cbrt(z)));
	} else if (z <= 1.2271992071220414e-173) {
		tmp = (1.0 / ((1.0 / sqrt(z)) / (cbrt(y) * cbrt(y)))) * (x / ((hypot((sqrt(a) * sqrt(-t)), z) / sqrt(z)) / cbrt(y)));
	} else if (z <= 1.2689282843189357e+142) {
		tmp = (y * x) * (z / sqrt((z * z) - (a * t)));
	} else {
		tmp = y * x;
	}
	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.3
Target7.7
Herbie6.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 5 regimes
  2. if z < -1.2154716544061854e-37

    1. Initial program 31.0

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

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

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

    if -1.2154716544061854e-37 < z < 1.1954013876901866e-257

    1. Initial program 13.5

      \[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}} \]
    2. Applied associate-/l*_binary6414.0

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

      \[\leadsto \frac{x \cdot y}{\color{blue}{\frac{\mathsf{hypot}\left(\sqrt{-a \cdot t}, z\right)}{z}}} \]
    4. Applied add-cube-cbrt_binary6415.0

      \[\leadsto \frac{x \cdot y}{\frac{\mathsf{hypot}\left(\sqrt{-a \cdot t}, z\right)}{\color{blue}{\left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \sqrt[3]{z}}}} \]
    5. Applied *-un-lft-identity_binary6415.0

      \[\leadsto \frac{x \cdot y}{\frac{\color{blue}{1 \cdot \mathsf{hypot}\left(\sqrt{-a \cdot t}, z\right)}}{\left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \sqrt[3]{z}}} \]
    6. Applied times-frac_binary6415.0

      \[\leadsto \frac{x \cdot y}{\color{blue}{\frac{1}{\sqrt[3]{z} \cdot \sqrt[3]{z}} \cdot \frac{\mathsf{hypot}\left(\sqrt{-a \cdot t}, z\right)}{\sqrt[3]{z}}}} \]
    7. Applied times-frac_binary6412.9

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

    if 1.1954013876901866e-257 < z < 1.2271992071220414e-173

    1. Initial program 18.4

      \[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}} \]
    2. Applied associate-/l*_binary6419.7

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

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

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

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

      \[\leadsto \frac{x}{\frac{\frac{\mathsf{hypot}\left(\color{blue}{\sqrt{a} \cdot \sqrt{-t}}, z\right)}{z}}{y}} \]
    7. Applied add-cube-cbrt_binary6413.5

      \[\leadsto \frac{x}{\frac{\frac{\mathsf{hypot}\left(\sqrt{a} \cdot \sqrt{-t}, z\right)}{z}}{\color{blue}{\left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right) \cdot \sqrt[3]{y}}}} \]
    8. Applied add-sqr-sqrt_binary6413.5

      \[\leadsto \frac{x}{\frac{\frac{\mathsf{hypot}\left(\sqrt{a} \cdot \sqrt{-t}, z\right)}{\color{blue}{\sqrt{z} \cdot \sqrt{z}}}}{\left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right) \cdot \sqrt[3]{y}}} \]
    9. Applied *-un-lft-identity_binary6413.5

      \[\leadsto \frac{x}{\frac{\frac{\color{blue}{1 \cdot \mathsf{hypot}\left(\sqrt{a} \cdot \sqrt{-t}, z\right)}}{\sqrt{z} \cdot \sqrt{z}}}{\left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right) \cdot \sqrt[3]{y}}} \]
    10. Applied times-frac_binary6413.4

      \[\leadsto \frac{x}{\frac{\color{blue}{\frac{1}{\sqrt{z}} \cdot \frac{\mathsf{hypot}\left(\sqrt{a} \cdot \sqrt{-t}, z\right)}{\sqrt{z}}}}{\left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right) \cdot \sqrt[3]{y}}} \]
    11. Applied times-frac_binary649.7

      \[\leadsto \frac{x}{\color{blue}{\frac{\frac{1}{\sqrt{z}}}{\sqrt[3]{y} \cdot \sqrt[3]{y}} \cdot \frac{\frac{\mathsf{hypot}\left(\sqrt{a} \cdot \sqrt{-t}, z\right)}{\sqrt{z}}}{\sqrt[3]{y}}}} \]
    12. Applied *-un-lft-identity_binary649.7

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

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

    if 1.2271992071220414e-173 < z < 1.26892828431893575e142

    1. Initial program 8.3

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

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

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

    if 1.26892828431893575e142 < z

    1. Initial program 51.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.2154716544061854 \cdot 10^{-37}:\\ \;\;\;\;-y \cdot x\\ \mathbf{elif}\;z \leq 1.1954013876901866 \cdot 10^{-257}:\\ \;\;\;\;\frac{x}{\frac{1}{\sqrt[3]{z} \cdot \sqrt[3]{z}}} \cdot \frac{y}{\frac{\mathsf{hypot}\left(\sqrt{-a \cdot t}, z\right)}{\sqrt[3]{z}}}\\ \mathbf{elif}\;z \leq 1.2271992071220414 \cdot 10^{-173}:\\ \;\;\;\;\frac{1}{\frac{\frac{1}{\sqrt{z}}}{\sqrt[3]{y} \cdot \sqrt[3]{y}}} \cdot \frac{x}{\frac{\frac{\mathsf{hypot}\left(\sqrt{a} \cdot \sqrt{-t}, z\right)}{\sqrt{z}}}{\sqrt[3]{y}}}\\ \mathbf{elif}\;z \leq 1.2689282843189357 \cdot 10^{+142}:\\ \;\;\;\;\left(y \cdot x\right) \cdot \frac{z}{\sqrt{z \cdot z - a \cdot t}}\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]

Reproduce

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