Average Error: 24.8 → 6.5
Time: 4.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 -2.6550496665863674 \cdot 10^{104}:\\ \;\;\;\;-1 \cdot \left(x \cdot y\right)\\ \mathbf{elif}\;z \le 1.8937249127317549 \cdot 10^{137}:\\ \;\;\;\;\left(x \cdot y\right) \cdot \left(\frac{1}{\sqrt{z \cdot z - t \cdot a}} \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot y\right) \cdot 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 -2.6550496665863674 \cdot 10^{104}:\\
\;\;\;\;-1 \cdot \left(x \cdot y\right)\\

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

\mathbf{else}:\\
\;\;\;\;\left(x \cdot y\right) \cdot 1\\

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r262646 = x;
        double r262647 = y;
        double r262648 = r262646 * r262647;
        double r262649 = z;
        double r262650 = r262648 * r262649;
        double r262651 = r262649 * r262649;
        double r262652 = t;
        double r262653 = a;
        double r262654 = r262652 * r262653;
        double r262655 = r262651 - r262654;
        double r262656 = sqrt(r262655);
        double r262657 = r262650 / r262656;
        return r262657;
}

double f(double x, double y, double z, double t, double a) {
        double r262658 = z;
        double r262659 = -2.6550496665863674e+104;
        bool r262660 = r262658 <= r262659;
        double r262661 = -1.0;
        double r262662 = x;
        double r262663 = y;
        double r262664 = r262662 * r262663;
        double r262665 = r262661 * r262664;
        double r262666 = 1.893724912731755e+137;
        bool r262667 = r262658 <= r262666;
        double r262668 = 1.0;
        double r262669 = r262658 * r262658;
        double r262670 = t;
        double r262671 = a;
        double r262672 = r262670 * r262671;
        double r262673 = r262669 - r262672;
        double r262674 = sqrt(r262673);
        double r262675 = r262668 / r262674;
        double r262676 = r262675 * r262658;
        double r262677 = r262664 * r262676;
        double r262678 = r262664 * r262668;
        double r262679 = r262667 ? r262677 : r262678;
        double r262680 = r262660 ? r262665 : r262679;
        return r262680;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original24.8
Target7.6
Herbie6.5
\[\begin{array}{l} \mathbf{if}\;z \lt -3.1921305903852764 \cdot 10^{46}:\\ \;\;\;\;-y \cdot x\\ \mathbf{elif}\;z \lt 5.9762681209208942 \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.6550496665863674e+104

    1. Initial program 44.5

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

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

    if -2.6550496665863674e+104 < z < 1.893724912731755e+137

    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.6

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

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

      \[\leadsto \frac{x \cdot y}{\frac{\color{blue}{\sqrt{\sqrt{z \cdot z - t \cdot a}} \cdot \sqrt{\sqrt{z \cdot z - t \cdot a}}}}{z}}\]
    7. Using strategy rm
    8. Applied div-inv9.8

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

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

    if 1.893724912731755e+137 < z

    1. Initial program 50.0

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

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

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

      \[\leadsto \frac{x \cdot y}{\frac{\color{blue}{\sqrt{\sqrt{z \cdot z - t \cdot a}} \cdot \sqrt{\sqrt{z \cdot z - t \cdot a}}}}{z}}\]
    7. Using strategy rm
    8. Applied div-inv48.9

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

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

      \[\leadsto \left(x \cdot y\right) \cdot \color{blue}{1}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification6.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -2.6550496665863674 \cdot 10^{104}:\\ \;\;\;\;-1 \cdot \left(x \cdot y\right)\\ \mathbf{elif}\;z \le 1.8937249127317549 \cdot 10^{137}:\\ \;\;\;\;\left(x \cdot y\right) \cdot \left(\frac{1}{\sqrt{z \cdot z - t \cdot a}} \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot y\right) \cdot 1\\ \end{array}\]

Reproduce

herbie shell --seed 2020024 +o rules:numerics
(FPCore (x y z t a)
  :name "Statistics.Math.RootFinding:ridders from math-functions-0.1.5.2"
  :precision binary64

  :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)))))