Average Error: 33.4 → 8.0
Time: 50.1s
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 -1.5869302652106472 \cdot 10^{+66}:\\ \;\;\;\;-\frac{b}{a}\\ \mathbf{elif}\;b \le 9.424191924514193 \cdot 10^{-216}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c}}{a \cdot 2} - \frac{b}{a \cdot 2}\\ \mathbf{elif}\;b \le 2.289615514984053 \cdot 10^{+152}:\\ \;\;\;\;\frac{\left(-c\right) \cdot 4}{2 \cdot \left(\sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c} + b\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{4}{\left(b - 2 \cdot \frac{c \cdot a}{b}\right) + b} \cdot \left(-\frac{c}{2}\right)\\ \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

Original33.4
Target20.2
Herbie8.0
\[\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 < -1.5869302652106472e+66

    1. Initial program 37.1

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    2. Initial simplification37.1

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

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

      \[\leadsto \color{blue}{\frac{-b}{a}}\]

    if -1.5869302652106472e+66 < b < 9.424191924514193e-216

    1. Initial program 10.8

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    2. Initial simplification10.8

      \[\leadsto \frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{2 \cdot a}\]
    3. Using strategy rm
    4. Applied div-sub10.8

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

    if 9.424191924514193e-216 < b < 2.289615514984053e+152

    1. Initial program 37.8

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    2. Initial simplification37.8

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

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

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

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

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

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

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

    if 2.289615514984053e+152 < b

    1. Initial program 62.8

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    2. Initial simplification62.8

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

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

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

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

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

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

      \[\leadsto \frac{c}{2} \cdot \frac{-4}{\color{blue}{\left(b - 2 \cdot \frac{a \cdot c}{b}\right)} + b}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification8.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.5869302652106472 \cdot 10^{+66}:\\ \;\;\;\;-\frac{b}{a}\\ \mathbf{elif}\;b \le 9.424191924514193 \cdot 10^{-216}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c}}{a \cdot 2} - \frac{b}{a \cdot 2}\\ \mathbf{elif}\;b \le 2.289615514984053 \cdot 10^{+152}:\\ \;\;\;\;\frac{\left(-c\right) \cdot 4}{2 \cdot \left(\sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c} + b\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{4}{\left(b - 2 \cdot \frac{c \cdot a}{b}\right) + b} \cdot \left(-\frac{c}{2}\right)\\ \end{array}\]

Runtime

Time bar (total: 50.1s)Debug logProfile

herbie shell --seed 2018220 
(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)))