Average Error: 24.9 → 7.7
Time: 19.4s
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.885407554804660517455724314669671165557 \cdot 10^{71}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{elif}\;z \le 5.930939844067445722258493130712277239397 \cdot 10^{90}:\\ \;\;\;\;\frac{x \cdot \left(y \cdot z\right)}{\sqrt{z \cdot z - a \cdot t}}\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{\mathsf{fma}\left(\frac{-1}{2}, \frac{a}{\frac{z}{t}}, z\right)} \cdot \left(y \cdot x\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 -2.885407554804660517455724314669671165557 \cdot 10^{71}:\\
\;\;\;\;x \cdot \left(-y\right)\\

\mathbf{elif}\;z \le 5.930939844067445722258493130712277239397 \cdot 10^{90}:\\
\;\;\;\;\frac{x \cdot \left(y \cdot z\right)}{\sqrt{z \cdot z - a \cdot t}}\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r10760585 = x;
        double r10760586 = y;
        double r10760587 = r10760585 * r10760586;
        double r10760588 = z;
        double r10760589 = r10760587 * r10760588;
        double r10760590 = r10760588 * r10760588;
        double r10760591 = t;
        double r10760592 = a;
        double r10760593 = r10760591 * r10760592;
        double r10760594 = r10760590 - r10760593;
        double r10760595 = sqrt(r10760594);
        double r10760596 = r10760589 / r10760595;
        return r10760596;
}

double f(double x, double y, double z, double t, double a) {
        double r10760597 = z;
        double r10760598 = -2.8854075548046605e+71;
        bool r10760599 = r10760597 <= r10760598;
        double r10760600 = x;
        double r10760601 = y;
        double r10760602 = -r10760601;
        double r10760603 = r10760600 * r10760602;
        double r10760604 = 5.930939844067446e+90;
        bool r10760605 = r10760597 <= r10760604;
        double r10760606 = r10760601 * r10760597;
        double r10760607 = r10760600 * r10760606;
        double r10760608 = r10760597 * r10760597;
        double r10760609 = a;
        double r10760610 = t;
        double r10760611 = r10760609 * r10760610;
        double r10760612 = r10760608 - r10760611;
        double r10760613 = sqrt(r10760612);
        double r10760614 = r10760607 / r10760613;
        double r10760615 = -0.5;
        double r10760616 = r10760597 / r10760610;
        double r10760617 = r10760609 / r10760616;
        double r10760618 = fma(r10760615, r10760617, r10760597);
        double r10760619 = r10760597 / r10760618;
        double r10760620 = r10760601 * r10760600;
        double r10760621 = r10760619 * r10760620;
        double r10760622 = r10760605 ? r10760614 : r10760621;
        double r10760623 = r10760599 ? r10760603 : r10760622;
        return r10760623;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.9
Target7.9
Herbie7.7
\[\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.8854075548046605e+71

    1. Initial program 39.6

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

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

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

    if -2.8854075548046605e+71 < z < 5.930939844067446e+90

    1. Initial program 11.0

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

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

    if 5.930939844067446e+90 < z

    1. Initial program 43.0

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

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

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

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

      \[\leadsto \color{blue}{\left(y \cdot x\right)} \cdot \frac{z}{\sqrt{z \cdot z - t \cdot a}}\]
    7. Taylor expanded around inf 5.2

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

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

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

Reproduce

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