Average Error: 25.2 → 8.1
Time: 49.0s
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.696983515699775782779959954264589471041 \cdot 10^{105}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{elif}\;z \le 7.016332579849616821378684143943451656749 \cdot 10^{58}:\\ \;\;\;\;\frac{x}{\sqrt{z \cdot z - t \cdot a}} \cdot \frac{1}{\frac{\frac{1}{z}}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{\mathsf{fma}\left(t \cdot \frac{a}{z \cdot 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 -1.696983515699775782779959954264589471041 \cdot 10^{105}:\\
\;\;\;\;x \cdot \left(-y\right)\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r10692440 = x;
        double r10692441 = y;
        double r10692442 = r10692440 * r10692441;
        double r10692443 = z;
        double r10692444 = r10692442 * r10692443;
        double r10692445 = r10692443 * r10692443;
        double r10692446 = t;
        double r10692447 = a;
        double r10692448 = r10692446 * r10692447;
        double r10692449 = r10692445 - r10692448;
        double r10692450 = sqrt(r10692449);
        double r10692451 = r10692444 / r10692450;
        return r10692451;
}

double f(double x, double y, double z, double t, double a) {
        double r10692452 = z;
        double r10692453 = -1.6969835156997758e+105;
        bool r10692454 = r10692452 <= r10692453;
        double r10692455 = x;
        double r10692456 = y;
        double r10692457 = -r10692456;
        double r10692458 = r10692455 * r10692457;
        double r10692459 = 7.016332579849617e+58;
        bool r10692460 = r10692452 <= r10692459;
        double r10692461 = r10692452 * r10692452;
        double r10692462 = t;
        double r10692463 = a;
        double r10692464 = r10692462 * r10692463;
        double r10692465 = r10692461 - r10692464;
        double r10692466 = sqrt(r10692465);
        double r10692467 = r10692455 / r10692466;
        double r10692468 = 1.0;
        double r10692469 = r10692468 / r10692452;
        double r10692470 = r10692469 / r10692456;
        double r10692471 = r10692468 / r10692470;
        double r10692472 = r10692467 * r10692471;
        double r10692473 = r10692455 * r10692456;
        double r10692474 = r10692463 / r10692461;
        double r10692475 = r10692462 * r10692474;
        double r10692476 = -0.5;
        double r10692477 = fma(r10692475, r10692476, r10692468);
        double r10692478 = r10692473 / r10692477;
        double r10692479 = r10692460 ? r10692472 : r10692478;
        double r10692480 = r10692454 ? r10692458 : r10692479;
        return r10692480;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original25.2
Target8.0
Herbie8.1
\[\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 < -1.6969835156997758e+105

    1. Initial program 44.1

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

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

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

      \[\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-prod42.0

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

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

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

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

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

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

    if -1.6969835156997758e+105 < z < 7.016332579849617e+58

    1. Initial program 12.2

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

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

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

      \[\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-prod10.9

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

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

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

      \[\leadsto \color{blue}{x} \cdot \frac{y}{\frac{\sqrt{z \cdot z - t \cdot a}}{z}}\]
    11. Using strategy rm
    12. Applied clear-num10.7

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

      \[\leadsto x \cdot \frac{1}{\frac{\frac{\sqrt{z \cdot z - t \cdot a}}{z}}{\color{blue}{1 \cdot y}}}\]
    15. Applied div-inv10.7

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

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

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

      \[\leadsto x \cdot \color{blue}{\left(\frac{1}{\frac{\sqrt{z \cdot z - t \cdot a}}{1}} \cdot \frac{1}{\frac{\frac{1}{z}}{y}}\right)}\]
    19. Applied associate-*r*12.8

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

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

    if 7.016332579849617e+58 < z

    1. Initial program 39.0

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

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

      \[\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}{\mathsf{fma}\left(\frac{a}{z \cdot z} \cdot t, \frac{-1}{2}, 1\right)}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification8.1

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

Reproduce

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