Average Error: 32.8 → 9.1
Time: 24.8s
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.1052071487533018 \cdot 10^{+151}:\\ \;\;\;\;\left(\frac{c}{b} - \frac{b}{a} \cdot \frac{1}{2}\right) - \frac{b}{2 \cdot a}\\ \mathbf{elif}\;b \le 3.9264312060713937 \cdot 10^{-109}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{2 \cdot a} - \frac{b}{2 \cdot a}\\ \mathbf{elif}\;b \le 6.187862221505769 \cdot 10^{+40}:\\ \;\;\;\;\frac{\left(c \cdot -4\right) \cdot a}{\left(b + \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}\right) \cdot \left(2 \cdot a\right)}\\ \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 < -2.1052071487533018e+151

    1. Initial program 60.1

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

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

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

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

    if -2.1052071487533018e+151 < b < 3.9264312060713937e-109

    1. Initial program 10.7

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

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

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

    if 3.9264312060713937e-109 < b < 6.187862221505769e+40

    1. Initial program 38.5

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

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

      \[\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/41.7

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

      \[\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.187862221505769e+40 < b

    1. Initial program 55.9

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

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

      \[\leadsto \color{blue}{\frac{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4}}{2 \cdot a} - \frac{b}{2 \cdot a}}\]
    5. Using strategy rm
    6. Applied add-sqr-sqrt56.8

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.1052071487533018 \cdot 10^{+151}:\\ \;\;\;\;\left(\frac{c}{b} - \frac{b}{a} \cdot \frac{1}{2}\right) - \frac{b}{2 \cdot a}\\ \mathbf{elif}\;b \le 3.9264312060713937 \cdot 10^{-109}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{2 \cdot a} - \frac{b}{2 \cdot a}\\ \mathbf{elif}\;b \le 6.187862221505769 \cdot 10^{+40}:\\ \;\;\;\;\frac{\left(c \cdot -4\right) \cdot a}{\left(b + \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}\right) \cdot \left(2 \cdot a\right)}\\ \mathbf{else}:\\ \;\;\;\;-\frac{c}{b}\\ \end{array}\]

Runtime

Time bar (total: 24.8s)Debug logProfile

BaselineHerbieOracleSpan%
Regimes33.19.15.627.587.4%
herbie shell --seed 2018296 
(FPCore (a b c)
  :name "Quadratic roots, full range"
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))