Average Error: 24.8 → 6.5
Time: 43.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 -7.751960138449552 \cdot 10^{+153}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \le 1.0718201324596577 \cdot 10^{+102}:\\ \;\;\;\;\frac{y}{\frac{\sqrt{z \cdot z - t \cdot a}}{z}} \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{\mathsf{fma}\left(\frac{a}{z} \cdot t, \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 -7.751960138449552 \cdot 10^{+153}:\\
\;\;\;\;y \cdot \left(-x\right)\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r12707691 = x;
        double r12707692 = y;
        double r12707693 = r12707691 * r12707692;
        double r12707694 = z;
        double r12707695 = r12707693 * r12707694;
        double r12707696 = r12707694 * r12707694;
        double r12707697 = t;
        double r12707698 = a;
        double r12707699 = r12707697 * r12707698;
        double r12707700 = r12707696 - r12707699;
        double r12707701 = sqrt(r12707700);
        double r12707702 = r12707695 / r12707701;
        return r12707702;
}

double f(double x, double y, double z, double t, double a) {
        double r12707703 = z;
        double r12707704 = -7.751960138449552e+153;
        bool r12707705 = r12707703 <= r12707704;
        double r12707706 = y;
        double r12707707 = x;
        double r12707708 = -r12707707;
        double r12707709 = r12707706 * r12707708;
        double r12707710 = 1.0718201324596577e+102;
        bool r12707711 = r12707703 <= r12707710;
        double r12707712 = r12707703 * r12707703;
        double r12707713 = t;
        double r12707714 = a;
        double r12707715 = r12707713 * r12707714;
        double r12707716 = r12707712 - r12707715;
        double r12707717 = sqrt(r12707716);
        double r12707718 = r12707717 / r12707703;
        double r12707719 = r12707706 / r12707718;
        double r12707720 = r12707719 * r12707707;
        double r12707721 = r12707714 / r12707703;
        double r12707722 = r12707721 * r12707713;
        double r12707723 = -0.5;
        double r12707724 = fma(r12707722, r12707723, r12707703);
        double r12707725 = r12707724 / r12707703;
        double r12707726 = r12707706 / r12707725;
        double r12707727 = r12707726 * r12707707;
        double r12707728 = r12707711 ? r12707720 : r12707727;
        double r12707729 = r12707705 ? r12707709 : r12707728;
        return r12707729;
}

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.9
Herbie6.5
\[\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 < -7.751960138449552e+153

    1. Initial program 53.7

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{\frac{\sqrt{z \cdot z - t \cdot a}}{z}}}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity53.2

      \[\leadsto \frac{x \cdot y}{\frac{\sqrt{z \cdot z - t \cdot a}}{\color{blue}{1 \cdot z}}}\]
    6. Applied *-un-lft-identity53.2

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

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

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

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

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

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

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

    if -7.751960138449552e+153 < z < 1.0718201324596577e+102

    1. Initial program 11.4

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

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

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

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

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

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

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

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

    if 1.0718201324596577e+102 < z

    1. Initial program 44.2

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

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

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

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

      \[\leadsto \frac{x \cdot y}{\frac{\color{blue}{\sqrt{1} \cdot \sqrt{z \cdot z - t \cdot a}}}{1 \cdot z}}\]
    8. Applied times-frac41.6

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

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

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

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

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

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

Reproduce

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