Average Error: 33.6 → 9.8
Time: 1.4m
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}\;b_2 \le -5.878966939257894 \cdot 10^{+153}:\\ \;\;\;\;c \cdot \frac{\frac{1}{2}}{b_2} - \left(\frac{b_2}{a} + \frac{b_2}{a}\right)\\ \mathbf{if}\;b_2 \le 7.205556075081333 \cdot 10^{-82}:\\ \;\;\;\;\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b_2} \cdot \frac{-1}{2}\\ \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 b_2 < -5.878966939257894e+153

    1. Initial program 60.7

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

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

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

    if -5.878966939257894e+153 < b_2 < 7.205556075081333e-82

    1. Initial program 12.0

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

    if 7.205556075081333e-82 < b_2

    1. Initial program 52.5

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

      \[\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.4

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

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b_2 \le -5.878966939257894 \cdot 10^{+153}:\\ \;\;\;\;c \cdot \frac{\frac{1}{2}}{b_2} - \left(\frac{b_2}{a} + \frac{b_2}{a}\right)\\ \mathbf{if}\;b_2 \le 7.205556075081333 \cdot 10^{-82}:\\ \;\;\;\;\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b_2} \cdot \frac{-1}{2}\\ \end{array}}\]

Runtime

Time bar (total: 1.4m)Debug logProfile

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