Average Error: 33.8 → 10.9
Time: 32.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 -2.818264606683512 \cdot 10^{+17}:\\ \;\;\;\;-\frac{b}{a}\\ \mathbf{elif}\;b \le 1.2507329391222916 \cdot 10^{-46}:\\ \;\;\;\;\frac{\sqrt{\left(a \cdot -4\right) \cdot c + b \cdot b} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{-b}{c}}\\ \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.8
Target21.2
Herbie10.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 3 regimes
  2. if b < -2.818264606683512e+17

    1. Initial program 32.1

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

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

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

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

    if -2.818264606683512e+17 < b < 1.2507329391222916e-46

    1. Initial program 15.5

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

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

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

    if 1.2507329391222916e-46 < b

    1. Initial program 53.8

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

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

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

      \[\leadsto \color{blue}{\frac{1}{\frac{2 \cdot a}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}}}\]
    6. Taylor expanded around 0 8.2

      \[\leadsto \frac{1}{\color{blue}{-1 \cdot \frac{b}{c}}}\]
    7. Simplified8.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.818264606683512 \cdot 10^{+17}:\\ \;\;\;\;-\frac{b}{a}\\ \mathbf{elif}\;b \le 1.2507329391222916 \cdot 10^{-46}:\\ \;\;\;\;\frac{\sqrt{\left(a \cdot -4\right) \cdot c + b \cdot b} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{-b}{c}}\\ \end{array}\]

Runtime

Time bar (total: 32.3s)Debug logProfile

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