Average Error: 24.8 → 5.7
Time: 21.5s
Precision: 64
\[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}\]
\[\begin{array}{l} \mathbf{if}\;z \le -5.979373433067621707384015273322967579969 \cdot 10^{153}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{elif}\;z \le 3.280936158314262078662177353861886074421 \cdot 10^{107}:\\ \;\;\;\;\frac{x}{\sqrt[3]{\frac{\sqrt{z \cdot z - t \cdot a}}{z}} \cdot \sqrt[3]{\frac{\sqrt{z \cdot z - t \cdot a}}{z}}} \cdot \frac{y}{\sqrt[3]{\frac{\sqrt{z \cdot z - t \cdot a}}{z}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{\mathsf{fma}\left(\frac{t}{z} \cdot \frac{a}{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 -5.979373433067621707384015273322967579969 \cdot 10^{153}:\\
\;\;\;\;x \cdot \left(-y\right)\\

\mathbf{elif}\;z \le 3.280936158314262078662177353861886074421 \cdot 10^{107}:\\
\;\;\;\;\frac{x}{\sqrt[3]{\frac{\sqrt{z \cdot z - t \cdot a}}{z}} \cdot \sqrt[3]{\frac{\sqrt{z \cdot z - t \cdot a}}{z}}} \cdot \frac{y}{\sqrt[3]{\frac{\sqrt{z \cdot z - t \cdot a}}{z}}}\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r13197656 = x;
        double r13197657 = y;
        double r13197658 = r13197656 * r13197657;
        double r13197659 = z;
        double r13197660 = r13197658 * r13197659;
        double r13197661 = r13197659 * r13197659;
        double r13197662 = t;
        double r13197663 = a;
        double r13197664 = r13197662 * r13197663;
        double r13197665 = r13197661 - r13197664;
        double r13197666 = sqrt(r13197665);
        double r13197667 = r13197660 / r13197666;
        return r13197667;
}

double f(double x, double y, double z, double t, double a) {
        double r13197668 = z;
        double r13197669 = -5.979373433067622e+153;
        bool r13197670 = r13197668 <= r13197669;
        double r13197671 = x;
        double r13197672 = y;
        double r13197673 = -r13197672;
        double r13197674 = r13197671 * r13197673;
        double r13197675 = 3.280936158314262e+107;
        bool r13197676 = r13197668 <= r13197675;
        double r13197677 = r13197668 * r13197668;
        double r13197678 = t;
        double r13197679 = a;
        double r13197680 = r13197678 * r13197679;
        double r13197681 = r13197677 - r13197680;
        double r13197682 = sqrt(r13197681);
        double r13197683 = r13197682 / r13197668;
        double r13197684 = cbrt(r13197683);
        double r13197685 = r13197684 * r13197684;
        double r13197686 = r13197671 / r13197685;
        double r13197687 = r13197672 / r13197684;
        double r13197688 = r13197686 * r13197687;
        double r13197689 = r13197671 * r13197672;
        double r13197690 = r13197678 / r13197668;
        double r13197691 = r13197679 / r13197668;
        double r13197692 = r13197690 * r13197691;
        double r13197693 = -0.5;
        double r13197694 = 1.0;
        double r13197695 = fma(r13197692, r13197693, r13197694);
        double r13197696 = r13197689 / r13197695;
        double r13197697 = r13197676 ? r13197688 : r13197696;
        double r13197698 = r13197670 ? r13197674 : r13197697;
        return r13197698;
}

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
Herbie5.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 < -5.979373433067622e+153

    1. Initial program 54.0

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

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

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

    if -5.979373433067622e+153 < z < 3.280936158314262e+107

    1. Initial program 10.6

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

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

      \[\leadsto \frac{x \cdot y}{\color{blue}{\left(\sqrt[3]{\frac{\sqrt{z \cdot z - t \cdot a}}{z}} \cdot \sqrt[3]{\frac{\sqrt{z \cdot z - t \cdot a}}{z}}\right) \cdot \sqrt[3]{\frac{\sqrt{z \cdot z - t \cdot a}}{z}}}}\]
    6. Applied times-frac7.9

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

    if 3.280936158314262e+107 < z

    1. Initial program 45.3

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

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

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

      \[\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 simplification5.7

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

Reproduce

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