Average Error: 34.0 → 15.1
Time: 1.4m
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.5226383508946404 \cdot 10^{+119}:\\ \;\;\;\;\frac{-b}{a}\\ \mathbf{elif}\;-b \le 1.8160081293285892 \cdot 10^{+30}:\\ \;\;\;\;\frac{1}{\frac{a}{\frac{\left(-b\right) - \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4}}{2}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-2 \cdot \frac{c \cdot a}{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

Original34.0
Target21.0
Herbie15.1
\[\begin{array}{l} \mathbf{if}\;b \lt 0:\\ \;\;\;\;\frac{c}{a \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}}\\ \mathbf{else}:\\ \;\;\;\;\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) < -1.5226383508946404e+119

    1. Initial program 50.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 associate-/r*50.1

      \[\leadsto \color{blue}{\frac{\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2}}{a}}\]
    4. Using strategy rm
    5. Applied div-inv50.1

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

      \[\leadsto \color{blue}{-1 \cdot \frac{b}{a}}\]
    7. Simplified3.7

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

    if -1.5226383508946404e+119 < (- b) < 1.8160081293285892e+30

    1. Initial program 17.9

      \[\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    2. Using strategy rm
    3. Applied associate-/r*17.9

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

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

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

    if 1.8160081293285892e+30 < (- b)

    1. Initial program 56.1

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

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

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

Runtime

Time bar (total: 1.4m)Debug logProfile

herbie shell --seed 2018225 
(FPCore (a b c)
  :name "quadm (p42, negative)"

  :herbie-target
  (if (< b 0) (/ c (* a (/ (+ (- b) (sqrt (- (* b b) (* 4 (* a c))))) (* 2 a)))) (/ (- (- b) (sqrt (- (* b b) (* 4 (* a c))))) (* 2 a)))

  (/ (- (- b) (sqrt (- (* b b) (* 4 (* a c))))) (* 2 a)))