Average Error: 24.8 → 6.3
Time: 17.2s
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.3222627138699112 \cdot 10^{+154}:\\ \;\;\;\;\frac{x \cdot y}{\mathsf{fma}\left(\frac{\frac{1}{2}}{z}, \frac{a}{z} \cdot t, -1\right)}\\ \mathbf{elif}\;z \le 4.1336262698551934 \cdot 10^{+63}:\\ \;\;\;\;\frac{y}{\frac{1}{\frac{z}{\sqrt{z \cdot z - a \cdot t}}}} \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{\left(\frac{t}{z} \cdot \frac{a}{z}\right) \cdot \frac{-1}{2} + 1}\\ \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.3222627138699112 \cdot 10^{+154}:\\
\;\;\;\;\frac{x \cdot y}{\mathsf{fma}\left(\frac{\frac{1}{2}}{z}, \frac{a}{z} \cdot t, -1\right)}\\

\mathbf{elif}\;z \le 4.1336262698551934 \cdot 10^{+63}:\\
\;\;\;\;\frac{y}{\frac{1}{\frac{z}{\sqrt{z \cdot z - a \cdot t}}}} \cdot x\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r4678479 = x;
        double r4678480 = y;
        double r4678481 = r4678479 * r4678480;
        double r4678482 = z;
        double r4678483 = r4678481 * r4678482;
        double r4678484 = r4678482 * r4678482;
        double r4678485 = t;
        double r4678486 = a;
        double r4678487 = r4678485 * r4678486;
        double r4678488 = r4678484 - r4678487;
        double r4678489 = sqrt(r4678488);
        double r4678490 = r4678483 / r4678489;
        return r4678490;
}

double f(double x, double y, double z, double t, double a) {
        double r4678491 = z;
        double r4678492 = -1.3222627138699112e+154;
        bool r4678493 = r4678491 <= r4678492;
        double r4678494 = x;
        double r4678495 = y;
        double r4678496 = r4678494 * r4678495;
        double r4678497 = 0.5;
        double r4678498 = r4678497 / r4678491;
        double r4678499 = a;
        double r4678500 = r4678499 / r4678491;
        double r4678501 = t;
        double r4678502 = r4678500 * r4678501;
        double r4678503 = -1.0;
        double r4678504 = fma(r4678498, r4678502, r4678503);
        double r4678505 = r4678496 / r4678504;
        double r4678506 = 4.1336262698551934e+63;
        bool r4678507 = r4678491 <= r4678506;
        double r4678508 = 1.0;
        double r4678509 = r4678491 * r4678491;
        double r4678510 = r4678499 * r4678501;
        double r4678511 = r4678509 - r4678510;
        double r4678512 = sqrt(r4678511);
        double r4678513 = r4678491 / r4678512;
        double r4678514 = r4678508 / r4678513;
        double r4678515 = r4678495 / r4678514;
        double r4678516 = r4678515 * r4678494;
        double r4678517 = r4678501 / r4678491;
        double r4678518 = r4678517 * r4678500;
        double r4678519 = -0.5;
        double r4678520 = r4678518 * r4678519;
        double r4678521 = r4678520 + r4678508;
        double r4678522 = r4678496 / r4678521;
        double r4678523 = r4678507 ? r4678516 : r4678522;
        double r4678524 = r4678493 ? r4678505 : r4678523;
        return r4678524;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.8
Target7.7
Herbie6.3
\[\begin{array}{l} \mathbf{if}\;z \lt -3.1921305903852764 \cdot 10^{+46}:\\ \;\;\;\;-y \cdot x\\ \mathbf{elif}\;z \lt 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 3 regimes
  2. if z < -1.3222627138699112e+154

    1. Initial program 54.3

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

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

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

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

    if -1.3222627138699112e+154 < z < 4.1336262698551934e+63

    1. Initial program 11.2

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{\frac{\sqrt{z \cdot z - t \cdot a}}{z}}}\]
    4. Using strategy rm
    5. Applied clear-num9.4

      \[\leadsto \frac{x \cdot y}{\color{blue}{\frac{1}{\frac{z}{\sqrt{z \cdot z - t \cdot a}}}}}\]
    6. Using strategy rm
    7. Applied *-un-lft-identity9.4

      \[\leadsto \frac{x \cdot y}{\frac{1}{\frac{z}{\color{blue}{1 \cdot \sqrt{z \cdot z - t \cdot a}}}}}\]
    8. Applied *-un-lft-identity9.4

      \[\leadsto \frac{x \cdot y}{\frac{1}{\frac{\color{blue}{1 \cdot z}}{1 \cdot \sqrt{z \cdot z - t \cdot a}}}}\]
    9. Applied times-frac9.4

      \[\leadsto \frac{x \cdot y}{\frac{1}{\color{blue}{\frac{1}{1} \cdot \frac{z}{\sqrt{z \cdot z - t \cdot a}}}}}\]
    10. Applied *-un-lft-identity9.4

      \[\leadsto \frac{x \cdot y}{\frac{\color{blue}{1 \cdot 1}}{\frac{1}{1} \cdot \frac{z}{\sqrt{z \cdot z - t \cdot a}}}}\]
    11. Applied times-frac9.4

      \[\leadsto \frac{x \cdot y}{\color{blue}{\frac{1}{\frac{1}{1}} \cdot \frac{1}{\frac{z}{\sqrt{z \cdot z - t \cdot a}}}}}\]
    12. Applied times-frac9.2

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

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

    if 4.1336262698551934e+63 < z

    1. Initial program 38.0

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

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

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

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

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

Reproduce

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