Average Error: 33.6 → 9.3
Time: 1.1m
Precision: 64
Internal Precision: 3456
\[\frac{\left(-b/2\right) + \sqrt{b/2 \cdot b/2 - a \cdot c}}{a}\]
\[\begin{array}{l} \mathbf{if}\;b/2 \le -2.457418119489787 \cdot 10^{+19}:\\ \;\;\;\;c \cdot \frac{\frac{1}{2}}{b/2} - \left(\frac{b/2}{a} + \frac{b/2}{a}\right)\\ \mathbf{if}\;b/2 \le 1.5894297950996805 \cdot 10^{-161}:\\ \;\;\;\;\frac{1}{\frac{a}{\sqrt{b/2 \cdot b/2 - a \cdot c} - b/2}}\\ \mathbf{if}\;b/2 \le 2.649139789995478 \cdot 10^{+27}:\\ \;\;\;\;\frac{\frac{c \cdot a}{\left(-b/2\right) - \sqrt{b/2 \cdot b/2 - a \cdot c}}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{\frac{b/2}{\frac{-1}{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 < -2.457418119489787e+19

    1. Initial program 32.4

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

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

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

    if -2.457418119489787e+19 < b/2 < 1.5894297950996805e-161

    1. Initial program 11.8

      \[\frac{\left(-b/2\right) + \sqrt{b/2 \cdot b/2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied clear-num11.9

      \[\leadsto \color{blue}{\frac{1}{\frac{a}{\left(-b/2\right) + \sqrt{b/2 \cdot b/2 - a \cdot c}}}}\]
    4. Applied simplify11.9

      \[\leadsto \frac{1}{\color{blue}{\frac{a}{\sqrt{b/2 \cdot b/2 - a \cdot c} - b/2}}}\]

    if 1.5894297950996805e-161 < b/2 < 2.649139789995478e+27

    1. Initial program 34.9

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

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

      \[\leadsto \frac{\frac{\color{blue}{c \cdot a}}{\left(-b/2\right) - \sqrt{b/2 \cdot b/2 - a \cdot c}}}{a}\]

    if 2.649139789995478e+27 < b/2

    1. Initial program 55.6

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

      \[\leadsto \frac{\color{blue}{\frac{-1}{2} \cdot \frac{c \cdot a}{b/2}}}{a}\]
    3. Applied simplify4.5

      \[\leadsto \color{blue}{\frac{c}{\frac{b/2}{\frac{-1}{2}}}}\]
  3. Recombined 4 regimes into one program.

Runtime

Time bar (total: 1.1m)Debug logProfile

herbie shell --seed '#(1070864556 424010669 783715395 1203517814 4070606583 4107618214)' +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))