Average Error: 24.6 → 6.3
Time: 17.9s
Precision: 64
\[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}\]
\[\begin{array}{l} \mathbf{if}\;z \le -2.558831417467723153025129249761319438693 \cdot 10^{125}:\\ \;\;\;\;x \cdot \frac{y}{\frac{\mathsf{fma}\left(\frac{1}{2}, t \cdot \frac{a}{z}, -z\right)}{z}}\\ \mathbf{elif}\;z \le 2.235109143959163856726491853381009293961 \cdot 10^{72}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{\sqrt{\mathsf{fma}\left(-a, t, z \cdot z\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{\mathsf{fma}\left(t \cdot \frac{a}{z}, \frac{-1}{2}, z\right)}{z}} \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 \le -2.558831417467723153025129249761319438693 \cdot 10^{125}:\\
\;\;\;\;x \cdot \frac{y}{\frac{\mathsf{fma}\left(\frac{1}{2}, t \cdot \frac{a}{z}, -z\right)}{z}}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{\mathsf{fma}\left(t \cdot \frac{a}{z}, \frac{-1}{2}, z\right)}{z}} \cdot x\\

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r216729 = x;
        double r216730 = y;
        double r216731 = r216729 * r216730;
        double r216732 = z;
        double r216733 = r216731 * r216732;
        double r216734 = r216732 * r216732;
        double r216735 = t;
        double r216736 = a;
        double r216737 = r216735 * r216736;
        double r216738 = r216734 - r216737;
        double r216739 = sqrt(r216738);
        double r216740 = r216733 / r216739;
        return r216740;
}

double f(double x, double y, double z, double t, double a) {
        double r216741 = z;
        double r216742 = -2.558831417467723e+125;
        bool r216743 = r216741 <= r216742;
        double r216744 = x;
        double r216745 = y;
        double r216746 = 0.5;
        double r216747 = t;
        double r216748 = a;
        double r216749 = r216748 / r216741;
        double r216750 = r216747 * r216749;
        double r216751 = -r216741;
        double r216752 = fma(r216746, r216750, r216751);
        double r216753 = r216752 / r216741;
        double r216754 = r216745 / r216753;
        double r216755 = r216744 * r216754;
        double r216756 = 2.235109143959164e+72;
        bool r216757 = r216741 <= r216756;
        double r216758 = -r216748;
        double r216759 = r216741 * r216741;
        double r216760 = fma(r216758, r216747, r216759);
        double r216761 = sqrt(r216760);
        double r216762 = r216741 / r216761;
        double r216763 = r216745 * r216762;
        double r216764 = r216744 * r216763;
        double r216765 = -0.5;
        double r216766 = fma(r216750, r216765, r216741);
        double r216767 = r216766 / r216741;
        double r216768 = r216745 / r216767;
        double r216769 = r216768 * r216744;
        double r216770 = r216757 ? r216764 : r216769;
        double r216771 = r216743 ? r216755 : r216770;
        return r216771;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.6
Target7.8
Herbie6.3
\[\begin{array}{l} \mathbf{if}\;z \lt -3.192130590385276419686361646843883646209 \cdot 10^{46}:\\ \;\;\;\;-y \cdot x\\ \mathbf{elif}\;z \lt 5.976268120920894210257945708950453212935 \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 < -2.558831417467723e+125

    1. Initial program 48.3

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

      \[\leadsto \color{blue}{\frac{z \cdot y}{\sqrt{\mathsf{fma}\left(z, z, -a \cdot t\right)}} \cdot x}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity48.2

      \[\leadsto \frac{z \cdot y}{\sqrt{\mathsf{fma}\left(z, z, -a \cdot t\right)}} \cdot \color{blue}{\left(1 \cdot x\right)}\]
    5. Applied associate-*r*48.2

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

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

      \[\leadsto \frac{y}{\frac{\color{blue}{\frac{1}{2} \cdot \frac{a \cdot t}{z} - z}}{z}} \cdot x\]
    8. Simplified2.0

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

    if -2.558831417467723e+125 < z < 2.235109143959164e+72

    1. Initial program 10.7

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

      \[\leadsto \color{blue}{\frac{z \cdot y}{\sqrt{\mathsf{fma}\left(z, z, -a \cdot t\right)}} \cdot x}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity10.5

      \[\leadsto \frac{z \cdot y}{\sqrt{\mathsf{fma}\left(z, z, -a \cdot t\right)}} \cdot \color{blue}{\left(1 \cdot x\right)}\]
    5. Applied associate-*r*10.5

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

      \[\leadsto \color{blue}{\frac{y}{\frac{\sqrt{z \cdot z - t \cdot a}}{z}}} \cdot x\]
    7. Using strategy rm
    8. Applied div-inv9.2

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

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

    if 2.235109143959164e+72 < z

    1. Initial program 40.3

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

      \[\leadsto \color{blue}{\frac{z \cdot y}{\sqrt{\mathsf{fma}\left(z, z, -a \cdot t\right)}} \cdot x}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity41.2

      \[\leadsto \frac{z \cdot y}{\sqrt{\mathsf{fma}\left(z, z, -a \cdot t\right)}} \cdot \color{blue}{\left(1 \cdot x\right)}\]
    5. Applied associate-*r*41.2

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

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

      \[\leadsto \frac{y}{\frac{\color{blue}{z - \frac{1}{2} \cdot \frac{a \cdot t}{z}}}{z}} \cdot x\]
    8. Simplified2.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -2.558831417467723153025129249761319438693 \cdot 10^{125}:\\ \;\;\;\;x \cdot \frac{y}{\frac{\mathsf{fma}\left(\frac{1}{2}, t \cdot \frac{a}{z}, -z\right)}{z}}\\ \mathbf{elif}\;z \le 2.235109143959163856726491853381009293961 \cdot 10^{72}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{\sqrt{\mathsf{fma}\left(-a, t, z \cdot z\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{\mathsf{fma}\left(t \cdot \frac{a}{z}, \frac{-1}{2}, z\right)}{z}} \cdot x\\ \end{array}\]

Reproduce

herbie shell --seed 2019194 +o rules:numerics
(FPCore (x y z t a)
  :name "Statistics.Math.RootFinding:ridders from math-functions-0.1.5.2"

  :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)))))