Average Error: 33.3 → 10.1
Time: 45.1s
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 -501671907657.34106:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{elif}\;b \le -5.460929706117908 \cdot 10^{-18}:\\ \;\;\;\;\frac{\left(4 \cdot c\right) \cdot a}{\left(2 \cdot a\right) \cdot \left(\sqrt{b \cdot b + a \cdot \left(-4 \cdot c\right)} - b\right)}\\ \mathbf{elif}\;b \le -3.71101226524406 \cdot 10^{-66}:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{elif}\;b \le 5.213921241762901 \cdot 10^{+84}:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{{b}^{2} - 4 \cdot \left(a \cdot c\right)}}{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

Original33.3
Target20.8
Herbie10.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 4 regimes
  2. if b < -501671907657.34106 or -5.460929706117908e-18 < b < -3.71101226524406e-66

    1. Initial program 52.8

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

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

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

    if -501671907657.34106 < b < -5.460929706117908e-18

    1. Initial program 43.1

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

      \[\leadsto \frac{\left(-b\right) - \sqrt{\color{blue}{{b}^{2} - 4 \cdot \left(a \cdot c\right)}}}{2 \cdot a}\]
    3. Using strategy rm
    4. Applied clear-num43.1

      \[\leadsto \color{blue}{\frac{1}{\frac{2 \cdot a}{\left(-b\right) - \sqrt{{b}^{2} - 4 \cdot \left(a \cdot c\right)}}}}\]
    5. Using strategy rm
    6. Applied associate-/r/43.1

      \[\leadsto \color{blue}{\frac{1}{2 \cdot a} \cdot \left(\left(-b\right) - \sqrt{{b}^{2} - 4 \cdot \left(a \cdot c\right)}\right)}\]
    7. Using strategy rm
    8. Applied flip--43.1

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

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

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

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

    if -3.71101226524406e-66 < b < 5.213921241762901e+84

    1. Initial program 13.4

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

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

    if 5.213921241762901e+84 < b

    1. Initial program 43.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -501671907657.34106:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{elif}\;b \le -5.460929706117908 \cdot 10^{-18}:\\ \;\;\;\;\frac{\left(4 \cdot c\right) \cdot a}{\left(2 \cdot a\right) \cdot \left(\sqrt{b \cdot b + a \cdot \left(-4 \cdot c\right)} - b\right)}\\ \mathbf{elif}\;b \le -3.71101226524406 \cdot 10^{-66}:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{elif}\;b \le 5.213921241762901 \cdot 10^{+84}:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{{b}^{2} - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array}\]

Runtime

Time bar (total: 45.1s)Debug logProfile

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