Average Error: 33.4 → 6.7
Time: 42.0s
Precision: 64
Internal Precision: 128
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;b \le -6.0480812527784834 \cdot 10^{+150}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \le -3.719799124860053 \cdot 10^{-308}:\\ \;\;\;\;\frac{\sqrt{{b}^{2} - \left(c \cdot a\right) \cdot 4} - b}{a \cdot 2}\\ \mathbf{elif}\;b \le 1.0692676985676485 \cdot 10^{+82}:\\ \;\;\;\;\frac{c \cdot -2}{\sqrt{{b}^{2} - \left(c \cdot a\right) \cdot 4} + b}\\ \mathbf{else}:\\ \;\;\;\;-\frac{c}{b}\\ \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

Derivation

  1. Split input into 4 regimes
  2. if b < -6.0480812527784834e+150

    1. Initial program 59.1

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

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

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

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

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

    if -6.0480812527784834e+150 < b < -3.719799124860053e-308

    1. Initial program 8.9

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

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

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

    if -3.719799124860053e-308 < b < 1.0692676985676485e+82

    1. Initial program 31.0

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

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

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

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

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

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

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

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

    if 1.0692676985676485e+82 < b

    1. Initial program 58.3

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -6.0480812527784834 \cdot 10^{+150}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \le -3.719799124860053 \cdot 10^{-308}:\\ \;\;\;\;\frac{\sqrt{{b}^{2} - \left(c \cdot a\right) \cdot 4} - b}{a \cdot 2}\\ \mathbf{elif}\;b \le 1.0692676985676485 \cdot 10^{+82}:\\ \;\;\;\;\frac{c \cdot -2}{\sqrt{{b}^{2} - \left(c \cdot a\right) \cdot 4} + b}\\ \mathbf{else}:\\ \;\;\;\;-\frac{c}{b}\\ \end{array}\]

Runtime

Time bar (total: 42.0s)Debug logProfile

herbie shell --seed 2018258 
(FPCore (a b c)
  :name "Quadratic roots, full range"
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))