Average Error: 33.6 → 9.9
Time: 1.2m
Precision: 64
Internal Precision: 3392
\[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\frac{-1}{2}}{b_2} \le -5.198788477184911 \cdot 10^{+87}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} + \left(-b_2\right)}{a}\\ \mathbf{if}\;\frac{\frac{-1}{2}}{b_2} \le 1.3930544562317008 \cdot 10^{-307}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{if}\;\frac{\frac{-1}{2}}{b_2} \le 1.874782776624899 \cdot 10^{-155}:\\ \;\;\;\;\frac{\frac{c}{b_2}}{2} - \left(\frac{b_2}{a} + \frac{b_2}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} + \left(-b_2\right)}{a}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b_2

Bits error versus c

Derivation

  1. Split input into 3 regimes
  2. if (/ -1/2 b_2) < -5.198788477184911e+87 or 1.874782776624899e-155 < (/ -1/2 b_2)

    1. Initial program 11.8

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

    if -5.198788477184911e+87 < (/ -1/2 b_2) < 1.3930544562317008e-307

    1. Initial program 52.2

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Taylor expanded around inf 47.9

      \[\leadsto \frac{\left(-b_2\right) + \color{blue}{\left(b_2 - \frac{1}{2} \cdot \frac{c \cdot a}{b_2}\right)}}{a}\]
    3. Applied simplify9.9

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

    if 1.3930544562317008e-307 < (/ -1/2 b_2) < 1.874782776624899e-155

    1. Initial program 60.9

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Taylor expanded around -inf 10.5

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

      \[\leadsto \color{blue}{\frac{\frac{c}{b_2}}{2} - \left(\frac{b_2}{a} + \frac{b_2}{a}\right)}\]
  3. Recombined 3 regimes into one program.
  4. Applied simplify9.9

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;\frac{\frac{-1}{2}}{b_2} \le -5.198788477184911 \cdot 10^{+87}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} + \left(-b_2\right)}{a}\\ \mathbf{if}\;\frac{\frac{-1}{2}}{b_2} \le 1.3930544562317008 \cdot 10^{-307}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{if}\;\frac{\frac{-1}{2}}{b_2} \le 1.874782776624899 \cdot 10^{-155}:\\ \;\;\;\;\frac{\frac{c}{b_2}}{2} - \left(\frac{b_2}{a} + \frac{b_2}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} + \left(-b_2\right)}{a}\\ \end{array}}\]

Runtime

Time bar (total: 1.2m)Debug logProfile

herbie shell --seed '#(1071373924 2949776965 1885069702 3247780810 90874544 2263903749)' 
(FPCore (a b_2 c)
  :name "quad2p (problem 3.2.1, positive)"
  (/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))