Average Error: 32.8 → 9.5
Time: 46.4s
Precision: 64
Internal Precision: 128
\[\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.628235187191868 \cdot 10^{+78}:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{elif}\;b \le -1.2620768881986187 \cdot 10^{-106}:\\ \;\;\;\;\frac{\left(a \cdot 4\right) \cdot \left(\frac{\frac{1}{2}}{a} \cdot c\right)}{\sqrt{b \cdot b + \left(c \cdot a\right) \cdot -4} + \left(-b\right)}\\ \mathbf{elif}\;b \le 3.119551424702198 \cdot 10^{+110}:\\ \;\;\;\;\left(\left(-b\right) - \sqrt{b \cdot b + \left(c \cdot a\right) \cdot -4}\right) \cdot \frac{1}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \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

Original32.8
Target19.8
Herbie9.5
\[\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 4 regimes
  2. if b < -1.628235187191868e+78

    1. Initial program 57.2

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

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

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

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

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

    if -1.628235187191868e+78 < b < -1.2620768881986187e-106

    1. Initial program 40.0

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

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

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

      \[\leadsto \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)}}} \cdot \frac{1}{2 \cdot a}\]
    7. Applied associate-*l/40.2

      \[\leadsto \color{blue}{\frac{\left(\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)}\right) \cdot \frac{1}{2 \cdot a}}{\left(-b\right) + \sqrt{b \cdot b + -4 \cdot \left(a \cdot c\right)}}}\]
    8. Simplified18.5

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

    if -1.2620768881986187e-106 < b < 3.119551424702198e+110

    1. Initial program 11.8

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

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

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

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

    if 3.119551424702198e+110 < b

    1. Initial program 45.7

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

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

      \[\leadsto \color{blue}{\frac{c}{b} - \frac{b}{a}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification9.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.628235187191868 \cdot 10^{+78}:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{elif}\;b \le -1.2620768881986187 \cdot 10^{-106}:\\ \;\;\;\;\frac{\left(a \cdot 4\right) \cdot \left(\frac{\frac{1}{2}}{a} \cdot c\right)}{\sqrt{b \cdot b + \left(c \cdot a\right) \cdot -4} + \left(-b\right)}\\ \mathbf{elif}\;b \le 3.119551424702198 \cdot 10^{+110}:\\ \;\;\;\;\left(\left(-b\right) - \sqrt{b \cdot b + \left(c \cdot a\right) \cdot -4}\right) \cdot \frac{1}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array}\]

Runtime

Time bar (total: 46.4s)Debug logProfile

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