Average Error: 24.4 → 6.4
Time: 24.8s
Precision: 64
\[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}\]
\[\begin{array}{l} \mathbf{if}\;z \le -1.43040902062389516402298439265226618597 \cdot 10^{130}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{elif}\;z \le 1.824825512052022623262391905051015124356 \cdot 10^{78}:\\ \;\;\;\;\frac{x}{\frac{\frac{\sqrt{z \cdot z - t \cdot a}}{z}}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{\mathsf{fma}\left(\frac{a}{z} \cdot \frac{t}{z}, \frac{-1}{2}, 1\right)}\\ \end{array}\]
\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}
\begin{array}{l}
\mathbf{if}\;z \le -1.43040902062389516402298439265226618597 \cdot 10^{130}:\\
\;\;\;\;x \cdot \left(-y\right)\\

\mathbf{elif}\;z \le 1.824825512052022623262391905051015124356 \cdot 10^{78}:\\
\;\;\;\;\frac{x}{\frac{\frac{\sqrt{z \cdot z - t \cdot a}}{z}}{y}}\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r15448727 = x;
        double r15448728 = y;
        double r15448729 = r15448727 * r15448728;
        double r15448730 = z;
        double r15448731 = r15448729 * r15448730;
        double r15448732 = r15448730 * r15448730;
        double r15448733 = t;
        double r15448734 = a;
        double r15448735 = r15448733 * r15448734;
        double r15448736 = r15448732 - r15448735;
        double r15448737 = sqrt(r15448736);
        double r15448738 = r15448731 / r15448737;
        return r15448738;
}

double f(double x, double y, double z, double t, double a) {
        double r15448739 = z;
        double r15448740 = -1.4304090206238952e+130;
        bool r15448741 = r15448739 <= r15448740;
        double r15448742 = x;
        double r15448743 = y;
        double r15448744 = -r15448743;
        double r15448745 = r15448742 * r15448744;
        double r15448746 = 1.8248255120520226e+78;
        bool r15448747 = r15448739 <= r15448746;
        double r15448748 = r15448739 * r15448739;
        double r15448749 = t;
        double r15448750 = a;
        double r15448751 = r15448749 * r15448750;
        double r15448752 = r15448748 - r15448751;
        double r15448753 = sqrt(r15448752);
        double r15448754 = r15448753 / r15448739;
        double r15448755 = r15448754 / r15448743;
        double r15448756 = r15448742 / r15448755;
        double r15448757 = r15448742 * r15448743;
        double r15448758 = r15448750 / r15448739;
        double r15448759 = r15448749 / r15448739;
        double r15448760 = r15448758 * r15448759;
        double r15448761 = -0.5;
        double r15448762 = 1.0;
        double r15448763 = fma(r15448760, r15448761, r15448762);
        double r15448764 = r15448757 / r15448763;
        double r15448765 = r15448747 ? r15448756 : r15448764;
        double r15448766 = r15448741 ? r15448745 : r15448765;
        return r15448766;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.4
Target7.5
Herbie6.4
\[\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 < -1.4304090206238952e+130

    1. Initial program 48.3

      \[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}\]
    2. Using strategy rm
    3. Applied associate-/l*46.8

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

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

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

    if -1.4304090206238952e+130 < z < 1.8248255120520226e+78

    1. Initial program 11.1

      \[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}\]
    2. Using strategy rm
    3. Applied associate-/l*9.5

      \[\leadsto \color{blue}{\frac{x \cdot y}{\frac{\sqrt{z \cdot z - t \cdot a}}{z}}}\]
    4. Using strategy rm
    5. Applied associate-/l*9.3

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

    if 1.8248255120520226e+78 < z

    1. Initial program 40.6

      \[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}\]
    2. Using strategy rm
    3. Applied associate-/l*37.9

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

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

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

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

Reproduce

herbie shell --seed 2019170 +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)))))