Average Error: 33.3 → 9.5
Time: 1.2m
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.575899002015852 \cdot 10^{+114}:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{elif}\;b \le -3.200589603484043 \cdot 10^{-62}:\\ \;\;\;\;\frac{\frac{4 \cdot \left(c \cdot a\right)}{a \cdot 2}}{\sqrt{a \cdot \left(-4 \cdot c\right) + b \cdot b} - b}\\ \mathbf{elif}\;b \le -8.207796680774689 \cdot 10^{-119}:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{elif}\;b \le 1.3071943870403567 \cdot 10^{+75}:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{{b}^{2} - 4 \cdot \left(c \cdot a\right)}}{a \cdot 2}\\ \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

Original33.3
Target20.9
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.575899002015852e+114 or -3.200589603484043e-62 < b < -8.207796680774689e-119

    1. Initial program 55.4

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

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

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

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

    if -1.575899002015852e+114 < b < -3.200589603484043e-62

    1. Initial program 44.2

      \[\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    2. Initial simplification44.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 flip--44.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}\]
    5. Applied associate-/l/46.7

      \[\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(2 \cdot a\right) \cdot \left(\left(-b\right) + \sqrt{b \cdot b + -4 \cdot \left(a \cdot c\right)}\right)}}\]
    6. Simplified16.2

      \[\leadsto \frac{\color{blue}{4 \cdot \left(a \cdot c\right)}}{\left(2 \cdot a\right) \cdot \left(\left(-b\right) + \sqrt{b \cdot b + -4 \cdot \left(a \cdot c\right)}\right)}\]
    7. Using strategy rm
    8. Applied associate-/r*12.1

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

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

    if -8.207796680774689e-119 < b < 1.3071943870403567e+75

    1. Initial program 12.0

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

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

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

    if 1.3071943870403567e+75 < b

    1. Initial program 39.9

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

      \[\leadsto \frac{\left(-b\right) - \sqrt{b \cdot b + -4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    3. Taylor expanded around inf 4.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.575899002015852 \cdot 10^{+114}:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{elif}\;b \le -3.200589603484043 \cdot 10^{-62}:\\ \;\;\;\;\frac{\frac{4 \cdot \left(c \cdot a\right)}{a \cdot 2}}{\sqrt{a \cdot \left(-4 \cdot c\right) + b \cdot b} - b}\\ \mathbf{elif}\;b \le -8.207796680774689 \cdot 10^{-119}:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{elif}\;b \le 1.3071943870403567 \cdot 10^{+75}:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{{b}^{2} - 4 \cdot \left(c \cdot a\right)}}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array}\]

Runtime

Time bar (total: 1.2m)Debug logProfile

BaselineHerbieOracleSpan%
Regimes31.79.55.726.085.4%
herbie shell --seed 2018263 
(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)))