Average Error: 33.8 → 7.0
Time: 3.0m
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 -4.480021572372691 \cdot 10^{+121}:\\ \;\;\;\;\frac{-b}{a} - \frac{\frac{c}{b}}{\frac{a}{a}}\\ \mathbf{if}\;b \le 3.3274636606180965 \cdot 10^{-305}:\\ \;\;\;\;\frac{1}{\frac{a \cdot 2}{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} - b}}\\ \mathbf{if}\;b \le 1.4399774592443239 \cdot 10^{+37}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c \cdot 4}{\left(-b\right) - \sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{c}{2 \cdot 2} \cdot 4}{\frac{a}{b} \cdot 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 < -4.480021572372691e+121

    1. Initial program 50.5

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

      \[\leadsto \frac{\color{blue}{-\left(2 \cdot \frac{a \cdot c}{b} + 2 \cdot b\right)}}{2 \cdot a}\]
    3. Applied simplify3.0

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

    if -4.480021572372691e+121 < b < 3.3274636606180965e-305

    1. Initial program 8.9

      \[\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-num9.1

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

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

    if 3.3274636606180965e-305 < b < 1.4399774592443239e+37

    1. Initial program 29.2

      \[\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-+29.3

      \[\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 simplify17.9

      \[\leadsto \frac{\frac{\color{blue}{\left(4 \cdot c\right) \cdot a}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity17.9

      \[\leadsto \frac{\color{blue}{1 \cdot \frac{\left(4 \cdot c\right) \cdot a}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}{2 \cdot a}\]
    7. Applied times-frac17.9

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

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

    if 1.4399774592443239e+37 < b

    1. Initial program 56.3

      \[\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-+56.4

      \[\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 simplify27.5

      \[\leadsto \frac{\frac{\color{blue}{\left(4 \cdot c\right) \cdot a}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity27.5

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

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

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

      \[\leadsto \frac{1}{2} \cdot \frac{c \cdot 4}{\color{blue}{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}}\]
    10. Applied simplify3.8

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

Runtime

Time bar (total: 3.0m)Debug logProfile

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