Average Error: 24.5 → 7.3
Time: 23.7s
Precision: 64
\[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}\]
\[\begin{array}{l} \mathbf{if}\;z \le -6.273512883606796841386024110084118224546 \cdot 10^{95}:\\ \;\;\;\;\left(-x\right) \cdot y\\ \mathbf{elif}\;z \le 1.128541164460688343795276023661207274438 \cdot 10^{61}:\\ \;\;\;\;x \cdot \left(\frac{1}{\sqrt{z \cdot z - a \cdot t}} \cdot \left(y \cdot z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array}\]
\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}
\begin{array}{l}
\mathbf{if}\;z \le -6.273512883606796841386024110084118224546 \cdot 10^{95}:\\
\;\;\;\;\left(-x\right) \cdot y\\

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

\mathbf{else}:\\
\;\;\;\;x \cdot y\\

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r258360 = x;
        double r258361 = y;
        double r258362 = r258360 * r258361;
        double r258363 = z;
        double r258364 = r258362 * r258363;
        double r258365 = r258363 * r258363;
        double r258366 = t;
        double r258367 = a;
        double r258368 = r258366 * r258367;
        double r258369 = r258365 - r258368;
        double r258370 = sqrt(r258369);
        double r258371 = r258364 / r258370;
        return r258371;
}

double f(double x, double y, double z, double t, double a) {
        double r258372 = z;
        double r258373 = -6.273512883606797e+95;
        bool r258374 = r258372 <= r258373;
        double r258375 = x;
        double r258376 = -r258375;
        double r258377 = y;
        double r258378 = r258376 * r258377;
        double r258379 = 1.1285411644606883e+61;
        bool r258380 = r258372 <= r258379;
        double r258381 = 1.0;
        double r258382 = r258372 * r258372;
        double r258383 = a;
        double r258384 = t;
        double r258385 = r258383 * r258384;
        double r258386 = r258382 - r258385;
        double r258387 = sqrt(r258386);
        double r258388 = r258381 / r258387;
        double r258389 = r258377 * r258372;
        double r258390 = r258388 * r258389;
        double r258391 = r258375 * r258390;
        double r258392 = r258375 * r258377;
        double r258393 = r258380 ? r258391 : r258392;
        double r258394 = r258374 ? r258378 : r258393;
        return r258394;
}

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.5
Target7.6
Herbie7.3
\[\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 < -6.273512883606797e+95

    1. Initial program 42.4

      \[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}\]
    2. Simplified42.9

      \[\leadsto \color{blue}{\frac{z \cdot y}{\sqrt{\mathsf{fma}\left(z, z, -a \cdot t\right)}} \cdot x}\]
    3. Using strategy rm
    4. Applied div-inv42.9

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

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

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

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

    if -6.273512883606797e+95 < z < 1.1285411644606883e+61

    1. Initial program 10.8

      \[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}\]
    2. Simplified10.8

      \[\leadsto \color{blue}{\frac{z \cdot y}{\sqrt{\mathsf{fma}\left(z, z, -a \cdot t\right)}} \cdot x}\]
    3. Using strategy rm
    4. Applied div-inv10.9

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

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

    if 1.1285411644606883e+61 < z

    1. Initial program 39.0

      \[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}\]
    2. Simplified39.1

      \[\leadsto \color{blue}{\frac{z \cdot y}{\sqrt{\mathsf{fma}\left(z, z, -a \cdot t\right)}} \cdot x}\]
    3. Using strategy rm
    4. Applied div-inv39.1

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

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

      \[\leadsto \color{blue}{y} \cdot x\]
  3. Recombined 3 regimes into one program.
  4. Final simplification7.3

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

Reproduce

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