Average Error: 24.9 → 7.3
Time: 5.7s
Precision: binary64
\[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}\]
\[\begin{array}{l} \mathbf{if}\;z \le -2.2997304670758846 \cdot 10^{98}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{elif}\;z \le 2.3611091436003512 \cdot 10^{30}:\\ \;\;\;\;x \cdot \left(\frac{y}{\sqrt{\sqrt{z \cdot z - t \cdot a}}} \cdot \frac{z}{\sqrt{\sqrt{z \cdot z - t \cdot a}}}\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{z + \left(t \cdot \frac{a}{z}\right) \cdot \frac{-1}{2}}\right)\\ \end{array}\]

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.9
Target7.9
Herbie7.3
\[\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.2997304670758846e98

    1. Initial program 43.5

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

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

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

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

    if -2.2997304670758846e98 < z < 2.3611091436003512e30

    1. Initial program 11.5

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

      \[\leadsto \color{blue}{x \cdot \left(y \cdot \frac{z}{\sqrt{z \cdot z - t \cdot a}}\right)}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt10.4

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

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

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

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

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

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

    if 2.3611091436003512e30 < z

    1. Initial program 35.1

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

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

      \[\leadsto x \cdot \left(y \cdot \frac{z}{\color{blue}{z - \frac{1}{2} \cdot \frac{a \cdot t}{z}}}\right)\]
    4. Simplified3.8

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -2.2997304670758846 \cdot 10^{98}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{elif}\;z \le 2.3611091436003512 \cdot 10^{30}:\\ \;\;\;\;x \cdot \left(\frac{y}{\sqrt{\sqrt{z \cdot z - t \cdot a}}} \cdot \frac{z}{\sqrt{\sqrt{z \cdot z - t \cdot a}}}\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot \frac{z}{z + \left(t \cdot \frac{a}{z}\right) \cdot \frac{-1}{2}}\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020182 
(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) (neg (* 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)))))