Average Error: 33.4 → 12.0
Time: 34.2s
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 -1.4257270821599501 \cdot 10^{+146}:\\ \;\;\;\;-\frac{b}{a}\\ \mathbf{elif}\;b \le 3.56781503140682 \cdot 10^{-128}:\\ \;\;\;\;\frac{\sqrt{\sqrt{b \cdot b - \left(a \cdot c\right) \cdot 4} - b}}{\frac{a \cdot 2}{\sqrt{\sqrt{b \cdot b - \left(a \cdot c\right) \cdot 4} - b}}}\\ \mathbf{elif}\;b \le 6.3215630568799626 \cdot 10^{+119}:\\ \;\;\;\;\frac{a \cdot \left(-4 \cdot c\right)}{\left(\sqrt{b \cdot b - \left(a \cdot c\right) \cdot 4} + b\right) \cdot \left(a \cdot 2\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{-2 \cdot \frac{a \cdot c}{b}}{a \cdot 2}\\ \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 < -1.4257270821599501e+146

    1. Initial program 57.7

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

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

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

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

    if -1.4257270821599501e+146 < b < 3.56781503140682e-128

    1. Initial program 11.0

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

      \[\leadsto \frac{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b}{2 \cdot a}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt11.4

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

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

    if 3.56781503140682e-128 < b < 6.3215630568799626e+119

    1. Initial program 41.3

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

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

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

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

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

    if 6.3215630568799626e+119 < b

    1. Initial program 60.2

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

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

      \[\leadsto \frac{\color{blue}{-2 \cdot \frac{a \cdot c}{b}}}{2 \cdot a}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification12.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.4257270821599501 \cdot 10^{+146}:\\ \;\;\;\;-\frac{b}{a}\\ \mathbf{elif}\;b \le 3.56781503140682 \cdot 10^{-128}:\\ \;\;\;\;\frac{\sqrt{\sqrt{b \cdot b - \left(a \cdot c\right) \cdot 4} - b}}{\frac{a \cdot 2}{\sqrt{\sqrt{b \cdot b - \left(a \cdot c\right) \cdot 4} - b}}}\\ \mathbf{elif}\;b \le 6.3215630568799626 \cdot 10^{+119}:\\ \;\;\;\;\frac{a \cdot \left(-4 \cdot c\right)}{\left(\sqrt{b \cdot b - \left(a \cdot c\right) \cdot 4} + b\right) \cdot \left(a \cdot 2\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{-2 \cdot \frac{a \cdot c}{b}}{a \cdot 2}\\ \end{array}\]

Runtime

Time bar (total: 34.2s)Debug logProfile

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