Average Error: 33.6 → 6.7
Time: 3.0m
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 -6.215459245046153 \cdot 10^{+88}:\\ \;\;\;\;-\frac{b}{a}\\ \mathbf{if}\;b \le 2.2207920706136116 \cdot 10^{-291}:\\ \;\;\;\;\frac{\sqrt{\sqrt{b \cdot b - \left(a \cdot c\right) \cdot 4} + \left(-b\right)}}{\frac{a \cdot 2}{\sqrt{\sqrt{b \cdot b - \left(a \cdot c\right) \cdot 4} - b}}}\\ \mathbf{if}\;b \le 2.88215723413983 \cdot 10^{+143}:\\ \;\;\;\;\sqrt[3]{\frac{\frac{1}{2} \cdot \left(4 \cdot c\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(a \cdot c\right) \cdot 4}}} \cdot \left(\sqrt[3]{\frac{\frac{4 \cdot c}{2}}{\left(-b\right) - \sqrt{b \cdot b - a \cdot \left(4 \cdot c\right)}}} \cdot \sqrt[3]{\frac{\frac{4 \cdot c}{2}}{\left(-b\right) - \sqrt{b \cdot b - a \cdot \left(4 \cdot c\right)}}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{4}{2} \cdot c}{\frac{c \cdot 2}{\frac{b}{a}} + \left(\left(-b\right) + \left(-b\right)\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.6
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 < -6.215459245046153e+88

    1. Initial program 42.9

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

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

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

    if -6.215459245046153e+88 < b < 2.2207920706136116e-291

    1. Initial program 9.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 add-sqr-sqrt9.4

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

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

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

    if 2.2207920706136116e-291 < b < 2.88215723413983e+143

    1. Initial program 35.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-+35.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 simplify15.7

      \[\leadsto \frac{\frac{\color{blue}{\left(a \cdot c\right) \cdot 4}}{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}}{2 \cdot a}\]
    5. Using strategy rm
    6. Applied add-cube-cbrt16.4

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

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

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

    if 2.88215723413983e+143 < b

    1. Initial program 61.7

      \[\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-+61.7

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

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

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

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

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \le -6.215459245046153 \cdot 10^{+88}:\\ \;\;\;\;-\frac{b}{a}\\ \mathbf{if}\;b \le 2.2207920706136116 \cdot 10^{-291}:\\ \;\;\;\;\frac{\sqrt{\sqrt{b \cdot b - \left(a \cdot c\right) \cdot 4} + \left(-b\right)}}{\frac{a \cdot 2}{\sqrt{\sqrt{b \cdot b - \left(a \cdot c\right) \cdot 4} - b}}}\\ \mathbf{if}\;b \le 2.88215723413983 \cdot 10^{+143}:\\ \;\;\;\;\sqrt[3]{\frac{\frac{1}{2} \cdot \left(4 \cdot c\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(a \cdot c\right) \cdot 4}}} \cdot \left(\sqrt[3]{\frac{\frac{4 \cdot c}{2}}{\left(-b\right) - \sqrt{b \cdot b - a \cdot \left(4 \cdot c\right)}}} \cdot \sqrt[3]{\frac{\frac{4 \cdot c}{2}}{\left(-b\right) - \sqrt{b \cdot b - a \cdot \left(4 \cdot c\right)}}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{4}{2} \cdot c}{\frac{c \cdot 2}{\frac{b}{a}} + \left(\left(-b\right) + \left(-b\right)\right)}\\ \end{array}}\]

Runtime

Time bar (total: 3.0m)Debug logProfile

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