Average Error: 33.5 → 6.7
Time: 53.3s
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 -4.384136757871355 \cdot 10^{+120}:\\ \;\;\;\;\frac{\frac{\left(\frac{c}{b} \cdot a - b\right) \cdot 2}{a}}{2}\\ \mathbf{elif}\;b \le -6.765448404116972 \cdot 10^{-288}:\\ \;\;\;\;\frac{\frac{\sqrt{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} - b}}{\frac{a}{\sqrt{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} - b}}}}{2}\\ \mathbf{elif}\;b \le 1.3463736235234204 \cdot 10^{+126}:\\ \;\;\;\;\frac{\frac{\frac{c \cdot -4}{\sqrt{b + \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}}}{\sqrt{b + \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}}}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{c \cdot -4}{\left(b - \frac{c}{b} \cdot a\right) \cdot 2}}{2}\\ \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.5
Target20.6
Herbie6.7
\[\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 < -4.384136757871355e+120

    1. Initial program 50.1

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

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

      \[\leadsto \frac{\frac{\color{blue}{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}}{a}}{2}\]
    4. Simplified2.7

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

    if -4.384136757871355e+120 < b < -6.765448404116972e-288

    1. Initial program 8.6

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

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

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

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

    if -6.765448404116972e-288 < b < 1.3463736235234204e+126

    1. Initial program 32.8

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

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

      \[\leadsto \frac{\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}}}{a}}{2}\]
    5. Applied associate-/l/37.3

      \[\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}{a \cdot \left(\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + b\right)}}}{2}\]
    6. Simplified19.5

      \[\leadsto \frac{\frac{\color{blue}{\left(-4 \cdot c\right) \cdot a}}{a \cdot \left(\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + b\right)}}{2}\]
    7. Using strategy rm
    8. Applied associate-/r*14.1

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

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

      \[\leadsto \frac{\frac{-4 \cdot c}{\color{blue}{\sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + b} \cdot \sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + b}}}}{2}\]
    12. Applied associate-/r*8.9

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

    if 1.3463736235234204e+126 < b

    1. Initial program 60.3

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

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

      \[\leadsto \frac{\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}}}{a}}{2}\]
    5. Applied associate-/l/60.3

      \[\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}{a \cdot \left(\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + b\right)}}}{2}\]
    6. Simplified34.5

      \[\leadsto \frac{\frac{\color{blue}{\left(-4 \cdot c\right) \cdot a}}{a \cdot \left(\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + b\right)}}{2}\]
    7. Using strategy rm
    8. Applied associate-/r*33.8

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

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

      \[\leadsto \frac{\frac{-4 \cdot c}{\color{blue}{2 \cdot b - 2 \cdot \frac{a \cdot c}{b}}}}{2}\]
    11. Simplified2.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -4.384136757871355 \cdot 10^{+120}:\\ \;\;\;\;\frac{\frac{\left(\frac{c}{b} \cdot a - b\right) \cdot 2}{a}}{2}\\ \mathbf{elif}\;b \le -6.765448404116972 \cdot 10^{-288}:\\ \;\;\;\;\frac{\frac{\sqrt{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} - b}}{\frac{a}{\sqrt{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} - b}}}}{2}\\ \mathbf{elif}\;b \le 1.3463736235234204 \cdot 10^{+126}:\\ \;\;\;\;\frac{\frac{\frac{c \cdot -4}{\sqrt{b + \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}}}{\sqrt{b + \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}}}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{c \cdot -4}{\left(b - \frac{c}{b} \cdot a\right) \cdot 2}}{2}\\ \end{array}\]

Runtime

Time bar (total: 53.3s)Debug logProfile

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