Average Error: 32.8 → 7.9
Time: 39.7s
Precision: 64
Internal Precision: 3392
\[\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;-b \le -5.279113661116557 \cdot 10^{+90}:\\ \;\;\;\;\frac{c \cdot 4}{2 \cdot \left(\left(-b\right) - \left(b - 2 \cdot \frac{c \cdot a}{b}\right)\right)}\\ \mathbf{elif}\;-b \le -5.252396119558506 \cdot 10^{-267}:\\ \;\;\;\;\frac{4}{\left(-b\right) - \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4}} \cdot \frac{c}{2}\\ \mathbf{elif}\;-b \le 1.3105439542796333 \cdot 10^{+57}:\\ \;\;\;\;\frac{1}{\frac{2 \cdot a}{\left(-b\right) + \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4}}}\\ \mathbf{else}:\\ \;\;\;\;-\frac{b}{a}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original32.8
Target20.3
Herbie7.9
\[\begin{array}{l} \mathbf{if}\;b \lt 0:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{a \cdot \frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}}\\ \end{array}\]

Derivation

  1. Split input into 4 regimes
  2. if (- b) < -5.279113661116557e+90

    1. Initial program 58.1

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

      \[\leadsto \frac{\color{blue}{\frac{\left(-b\right) \cdot \left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} \cdot \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}}}{2 \cdot a}\]
    4. Applied associate-/l/58.5

      \[\leadsto \color{blue}{\frac{\left(-b\right) \cdot \left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} \cdot \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{\left(2 \cdot a\right) \cdot \left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)}}\]
    5. Simplified31.6

      \[\leadsto \frac{\color{blue}{\left(a \cdot c\right) \cdot 4}}{\left(2 \cdot a\right) \cdot \left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)}\]
    6. Using strategy rm
    7. Applied times-frac30.1

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

      \[\leadsto \color{blue}{\frac{c}{2}} \cdot \frac{4}{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}\]
    9. Using strategy rm
    10. Applied frac-times29.4

      \[\leadsto \color{blue}{\frac{c \cdot 4}{2 \cdot \left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)}}\]
    11. Taylor expanded around inf 6.8

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

    if -5.279113661116557e+90 < (- b) < -5.252396119558506e-267

    1. Initial program 31.5

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

      \[\leadsto \frac{\color{blue}{\frac{\left(-b\right) \cdot \left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} \cdot \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}}}{2 \cdot a}\]
    4. Applied associate-/l/36.3

      \[\leadsto \color{blue}{\frac{\left(-b\right) \cdot \left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} \cdot \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{\left(2 \cdot a\right) \cdot \left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)}}\]
    5. Simplified20.3

      \[\leadsto \frac{\color{blue}{\left(a \cdot c\right) \cdot 4}}{\left(2 \cdot a\right) \cdot \left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)}\]
    6. Using strategy rm
    7. Applied times-frac14.6

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

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

    if -5.252396119558506e-267 < (- b) < 1.3105439542796333e+57

    1. Initial program 10.2

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

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

    if 1.3105439542796333e+57 < (- b)

    1. Initial program 36.3

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

      \[\leadsto \color{blue}{-1 \cdot \frac{b}{a}}\]
    3. Simplified5.6

      \[\leadsto \color{blue}{\frac{-b}{a}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification7.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;-b \le -5.279113661116557 \cdot 10^{+90}:\\ \;\;\;\;\frac{c \cdot 4}{2 \cdot \left(\left(-b\right) - \left(b - 2 \cdot \frac{c \cdot a}{b}\right)\right)}\\ \mathbf{elif}\;-b \le -5.252396119558506 \cdot 10^{-267}:\\ \;\;\;\;\frac{4}{\left(-b\right) - \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4}} \cdot \frac{c}{2}\\ \mathbf{elif}\;-b \le 1.3105439542796333 \cdot 10^{+57}:\\ \;\;\;\;\frac{1}{\frac{2 \cdot a}{\left(-b\right) + \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4}}}\\ \mathbf{else}:\\ \;\;\;\;-\frac{b}{a}\\ \end{array}\]

Runtime

Time bar (total: 39.7s)Debug logProfile

herbie shell --seed 2018217 
(FPCore (a b c)
  :name "quadp (p42, positive)"

  :herbie-target
  (if (< b 0) (/ (+ (- b) (sqrt (- (* b b) (* 4 (* a c))))) (* 2 a)) (/ c (* a (/ (- (- b) (sqrt (- (* b b) (* 4 (* a c))))) (* 2 a)))))

  (/ (+ (- b) (sqrt (- (* b b) (* 4 (* a c))))) (* 2 a)))