Average Error: 33.3 → 8.5
Time: 25.4s
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.349861988811081 \cdot 10^{+116}:\\ \;\;\;\;-\frac{c}{b}\\ \mathbf{elif}\;b \le 5.783509935196275 \cdot 10^{-273}:\\ \;\;\;\;\frac{\left(\left(c \cdot 4\right) \cdot a\right) \cdot \frac{\frac{1}{2}}{a}}{\left(-b\right) + \sqrt{{b}^{2} - \left(c \cdot a\right) \cdot 4}}\\ \mathbf{elif}\;b \le 1.4036353374114051 \cdot 10^{+100}:\\ \;\;\;\;\frac{1}{\frac{a \cdot 2}{\left(-b\right) - \sqrt{-4 \cdot \left(c \cdot a\right) + b \cdot b}}}\\ \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.7
Herbie8.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 < -2.349861988811081e+116

    1. Initial program 59.3

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

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

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

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

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

    if -2.349861988811081e+116 < b < 5.783509935196275e-273

    1. Initial program 31.0

      \[\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    2. Initial simplification31.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 31.0

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

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

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

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

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

    if 5.783509935196275e-273 < b < 1.4036353374114051e+100

    1. Initial program 8.7

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

      \[\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 *-un-lft-identity8.7

      \[\leadsto \frac{\left(-b\right) - \color{blue}{1 \cdot \sqrt{b \cdot b + -4 \cdot \left(a \cdot c\right)}}}{2 \cdot a}\]
    5. Applied *-un-lft-identity8.7

      \[\leadsto \frac{\color{blue}{1 \cdot \left(-b\right)} - 1 \cdot \sqrt{b \cdot b + -4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    6. Applied distribute-lft-out--8.7

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

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

    if 1.4036353374114051e+100 < 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 3.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.349861988811081 \cdot 10^{+116}:\\ \;\;\;\;-\frac{c}{b}\\ \mathbf{elif}\;b \le 5.783509935196275 \cdot 10^{-273}:\\ \;\;\;\;\frac{\left(\left(c \cdot 4\right) \cdot a\right) \cdot \frac{\frac{1}{2}}{a}}{\left(-b\right) + \sqrt{{b}^{2} - \left(c \cdot a\right) \cdot 4}}\\ \mathbf{elif}\;b \le 1.4036353374114051 \cdot 10^{+100}:\\ \;\;\;\;\frac{1}{\frac{a \cdot 2}{\left(-b\right) - \sqrt{-4 \cdot \left(c \cdot a\right) + b \cdot b}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array}\]

Runtime

Time bar (total: 25.4s)Debug logProfile

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