Average Error: 33.4 → 8.1
Time: 1.4m
Precision: 64
Internal Precision: 3392
\[\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 -2.5434455921029368 \cdot 10^{+64}:\\ \;\;\;\;-\frac{b}{a}\\ \mathbf{elif}\;b \le 3.386674077924689 \cdot 10^{-200}:\\ \;\;\;\;\frac{1}{\frac{a \cdot 2}{\left(-b\right) + \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}}}\\ \mathbf{elif}\;b \le 7.943654785924554 \cdot 10^{+151}:\\ \;\;\;\;\frac{c \cdot \frac{4}{2}}{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot \frac{4}{2}}{\left(-b\right) - \left(b - \frac{c \cdot a}{b} \cdot 2\right)}\\ \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 < -2.5434455921029368e+64

    1. Initial program 36.9

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

      \[\leadsto \color{blue}{-1 \cdot \frac{b}{a}}\]
    3. Simplified5.7

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

    if -2.5434455921029368e+64 < b < 3.386674077924689e-200

    1. Initial program 11.0

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

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

    if 3.386674077924689e-200 < b < 7.943654785924554e+151

    1. Initial program 38.6

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{4 \cdot \left(c \cdot a\right)}{2 \cdot a}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}\]
    8. Using strategy rm
    9. Applied times-frac13.8

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

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

    if 7.943654785924554e+151 < b

    1. Initial program 62.8

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{4}{2} \cdot c}{\left(-b\right) - \color{blue}{\left(b - 2 \cdot \frac{a \cdot c}{b}\right)}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification8.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.5434455921029368 \cdot 10^{+64}:\\ \;\;\;\;-\frac{b}{a}\\ \mathbf{elif}\;b \le 3.386674077924689 \cdot 10^{-200}:\\ \;\;\;\;\frac{1}{\frac{a \cdot 2}{\left(-b\right) + \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}}}\\ \mathbf{elif}\;b \le 7.943654785924554 \cdot 10^{+151}:\\ \;\;\;\;\frac{c \cdot \frac{4}{2}}{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot \frac{4}{2}}{\left(-b\right) - \left(b - \frac{c \cdot a}{b} \cdot 2\right)}\\ \end{array}\]

Runtime

Time bar (total: 1.4m)Debug logProfile

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