Average Error: 34.5 → 7.0
Time: 4.4s
Precision: binary64
\[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
\[\begin{array}{l} \mathbf{if}\;b_2 \le -1.01384800159969898 \cdot 10^{70}:\\ \;\;\;\;\frac{\left(\frac{1}{2} \cdot \left(c \cdot \frac{a}{b_2}\right) - b_2\right) - b_2}{a}\\ \mathbf{elif}\;b_2 \le -1.5056723658874731 \cdot 10^{-296}:\\ \;\;\;\;\frac{1}{\frac{a}{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}}\\ \mathbf{elif}\;b_2 \le 3.9588277603203294 \cdot 10^{102}:\\ \;\;\;\;\frac{-c}{b_2 + \sqrt{b_2 \cdot b_2 - c \cdot a}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b_2

Bits error versus c

Derivation

  1. Split input into 4 regimes
  2. if b_2 < -1.01384800159969898e70

    1. Initial program 41.1

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified41.1

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Taylor expanded around -inf 11.5

      \[\leadsto \frac{\color{blue}{\left(\frac{1}{2} \cdot \frac{a \cdot c}{b_2} - b_2\right)} - b_2}{a}\]
    4. Simplified5.1

      \[\leadsto \frac{\color{blue}{\left(\frac{1}{2} \cdot \left(c \cdot \frac{a}{b_2}\right) - b_2\right)} - b_2}{a}\]

    if -1.01384800159969898e70 < b_2 < -1.5056723658874731e-296

    1. Initial program 9.7

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified9.7

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied clear-num9.8

      \[\leadsto \color{blue}{\frac{1}{\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}\]

    if -1.5056723658874731e-296 < b_2 < 3.9588277603203294e102

    1. Initial program 32.0

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified32.0

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied flip--32.0

      \[\leadsto \frac{\color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c} - b_2 \cdot b_2}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}}}{a}\]
    5. Simplified16.3

      \[\leadsto \frac{\frac{\color{blue}{0 - a \cdot c}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}}{a}\]
    6. Simplified16.3

      \[\leadsto \frac{\frac{0 - a \cdot c}{\color{blue}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}}}{a}\]
    7. Using strategy rm
    8. Applied sub0-neg16.3

      \[\leadsto \frac{\frac{\color{blue}{-a \cdot c}}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}\]
    9. Applied distribute-frac-neg16.3

      \[\leadsto \frac{\color{blue}{-\frac{a \cdot c}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}}}{a}\]
    10. Applied distribute-frac-neg16.3

      \[\leadsto \color{blue}{-\frac{\frac{a \cdot c}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}}\]
    11. Simplified8.9

      \[\leadsto -\color{blue}{1 \cdot \frac{c}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}}\]

    if 3.9588277603203294e102 < b_2

    1. Initial program 59.5

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified59.5

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Taylor expanded around inf 2.7

      \[\leadsto \color{blue}{\frac{-1}{2} \cdot \frac{c}{b_2}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification7.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -1.01384800159969898 \cdot 10^{70}:\\ \;\;\;\;\frac{\left(\frac{1}{2} \cdot \left(c \cdot \frac{a}{b_2}\right) - b_2\right) - b_2}{a}\\ \mathbf{elif}\;b_2 \le -1.5056723658874731 \cdot 10^{-296}:\\ \;\;\;\;\frac{1}{\frac{a}{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}}\\ \mathbf{elif}\;b_2 \le 3.9588277603203294 \cdot 10^{102}:\\ \;\;\;\;\frac{-c}{b_2 + \sqrt{b_2 \cdot b_2 - c \cdot a}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \end{array}\]

Reproduce

herbie shell --seed 2020182 
(FPCore (a b_2 c)
  :name "quad2p (problem 3.2.1, positive)"
  :precision binary64
  (/ (+ (neg b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))