Average Error: 33.4 → 6.8
Time: 2.9m
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 -2.7057196726671236 \cdot 10^{+155}:\\ \;\;\;\;\frac{\frac{\frac{4}{2}}{\frac{2}{-c}}}{b + \frac{c}{\frac{b}{a}}}\\ \mathbf{if}\;-b \le -4.1706119510298147 \cdot 10^{-199}:\\ \;\;\;\;\frac{4}{2} \cdot \frac{-c}{\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} + b}\\ \mathbf{if}\;-b \le 2.5572764273511957 \cdot 10^{+110}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - a \cdot \left(c \cdot 4\right)} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\left(-\frac{c}{b}\right) - \frac{b + b}{a \cdot 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.4
Target21.1
Herbie6.8
\[\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) < -2.7057196726671236e+155

    1. Initial program 62.9

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    2. Applied simplify62.9

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

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

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

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

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

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

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

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

      \[\leadsto \left(-\frac{4}{2}\right) \cdot \frac{c}{\color{blue}{2 \cdot b + 2 \cdot \frac{c \cdot a}{b}}}\]
    13. Applied simplify2.3

      \[\leadsto \color{blue}{\frac{\frac{\frac{4}{2}}{\frac{2}{-c}}}{\frac{c}{\frac{b}{a}} + b}}\]

    if -2.7057196726671236e+155 < (- b) < -4.1706119510298147e-199

    1. Initial program 37.6

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    2. Applied simplify37.7

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

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

      \[\leadsto \frac{\frac{\color{blue}{\left(-4\right) \cdot \left(c \cdot a\right)}}{\sqrt{b \cdot b - \left(4 \cdot c\right) \cdot a} + b}}{2 \cdot a}\]
    6. Using strategy rm
    7. Applied *-un-lft-identity15.9

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

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

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

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

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

    if -4.1706119510298147e-199 < (- b) < 2.5572764273511957e+110

    1. Initial program 10.6

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    2. Applied simplify10.7

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

    if 2.5572764273511957e+110 < (- b)

    1. Initial program 48.0

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    2. Applied simplify48.0

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

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

      \[\leadsto \color{blue}{\frac{-\frac{c}{b}}{1} - \frac{b + b}{a \cdot 2}}\]
  3. Recombined 4 regimes into one program.
  4. Applied simplify6.8

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;-b \le -2.7057196726671236 \cdot 10^{+155}:\\ \;\;\;\;\frac{\frac{\frac{4}{2}}{\frac{2}{-c}}}{b + \frac{c}{\frac{b}{a}}}\\ \mathbf{if}\;-b \le -4.1706119510298147 \cdot 10^{-199}:\\ \;\;\;\;\frac{4}{2} \cdot \frac{-c}{\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} + b}\\ \mathbf{if}\;-b \le 2.5572764273511957 \cdot 10^{+110}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - a \cdot \left(c \cdot 4\right)} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\left(-\frac{c}{b}\right) - \frac{b + b}{a \cdot 2}\\ \end{array}}\]

Runtime

Time bar (total: 2.9m)Debug logProfile

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