Average Error: 33.5 → 10.3
Time: 2.1m
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 -7.132459056487529 \cdot 10^{+59}:\\ \;\;\;\;c \cdot \frac{\frac{1}{2}}{b_2} - \left(\frac{b_2}{a} + \frac{b_2}{a}\right)\\ \mathbf{if}\;b_2 \le 2.9525934633708343 \cdot 10^{-101}:\\ \;\;\;\;\frac{(\left(\sqrt[3]{-b_2} \cdot \sqrt[3]{-b_2}\right) \cdot \left(\sqrt[3]{-b_2}\right) + \left(\sqrt{b_2 \cdot b_2 - a \cdot c}\right))_*}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{\left(-b_2\right) + (\left(\frac{c}{b_2}\right) \cdot \left(\frac{1}{2} \cdot a\right) + \left(-b_2\right))_*}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b_2

Bits error versus c

Try it out

  1. Inputs

  2. Original Output:

    Herbie Output:

Derivation

  1. Split input into 3 regimes
  2. if b_2 < -7.132459056487529e+59

    1. Initial program 36.3

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

      \[\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 simplify5.6

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

    if -7.132459056487529e+59 < b_2 < 2.9525934633708343e-101

    1. Initial program 12.6

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied add-cube-cbrt12.8

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{-b_2} \cdot \sqrt[3]{-b_2}\right) \cdot \sqrt[3]{-b_2}} + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    4. Applied fma-def12.8

      \[\leadsto \frac{\color{blue}{(\left(\sqrt[3]{-b_2} \cdot \sqrt[3]{-b_2}\right) \cdot \left(\sqrt[3]{-b_2}\right) + \left(\sqrt{b_2 \cdot b_2 - a \cdot c}\right))_*}}{a}\]

    if 2.9525934633708343e-101 < b_2

    1. Initial program 51.2

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied flip-+51.3

      \[\leadsto \frac{\color{blue}{\frac{\left(-b_2\right) \cdot \left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}}{a}\]
    4. Applied simplify23.8

      \[\leadsto \frac{\frac{\color{blue}{c \cdot a}}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}\]
    5. Taylor expanded around inf 20.7

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

      \[\leadsto \color{blue}{\frac{c}{\left(-b_2\right) + (\left(\frac{c}{b_2}\right) \cdot \left(\frac{1}{2} \cdot a\right) + \left(-b_2\right))_*}}\]
  3. Recombined 3 regimes into one program.

Runtime

Time bar (total: 2.1m)Debug logProfile

herbie shell --seed '#(1072361757 3390613284 2339397988 1175251238 145061547 3101881848)' +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))