Average Error: 33.4 → 8.7
Time: 1.2m
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.7211479368677152 \cdot 10^{+157}:\\ \;\;\;\;\frac{-\frac{1}{2} \cdot \left(c \cdot 4\right)}{\frac{a \cdot c}{b} \cdot 2}\\ \mathbf{elif}\;b \le 5.738469888648177 \cdot 10^{-216}:\\ \;\;\;\;\frac{\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*}}{2 \cdot a} - \frac{b}{2 \cdot a}\\ \mathbf{elif}\;b \le 1.477600900922001 \cdot 10^{+116}:\\ \;\;\;\;\frac{-\frac{1}{2} \cdot \left(c \cdot 4\right)}{\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} + b}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\frac{1}{2} \cdot \left(c \cdot 4\right)}{b + b}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 4 regimes
  2. if b < -2.7211479368677152e+157

    1. Initial program 61.0

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

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

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

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

      \[\leadsto \frac{\color{blue}{\left(-c\right) \cdot \left(4 \cdot a\right)}}{\left(2 \cdot a\right) \cdot \left(\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} + b\right)}\]
    7. Using strategy rm
    8. Applied distribute-lft-neg-out62.5

      \[\leadsto \frac{\color{blue}{-c \cdot \left(4 \cdot a\right)}}{\left(2 \cdot a\right) \cdot \left(\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} + b\right)}\]
    9. Applied distribute-frac-neg62.5

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

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

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

    if -2.7211479368677152e+157 < b < 5.738469888648177e-216

    1. Initial program 10.4

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

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

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

    if 5.738469888648177e-216 < b < 1.477600900922001e+116

    1. Initial program 36.7

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

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

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

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

      \[\leadsto \frac{\color{blue}{\left(-c\right) \cdot \left(4 \cdot a\right)}}{\left(2 \cdot a\right) \cdot \left(\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} + b\right)}\]
    7. Using strategy rm
    8. Applied distribute-lft-neg-out19.1

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

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

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

    if 1.477600900922001e+116 < b

    1. Initial program 59.9

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

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

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

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

      \[\leadsto \frac{\color{blue}{\left(-c\right) \cdot \left(4 \cdot a\right)}}{\left(2 \cdot a\right) \cdot \left(\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} + b\right)}\]
    7. Using strategy rm
    8. Applied distribute-lft-neg-out32.6

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

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

      \[\leadsto -\color{blue}{\frac{\left(c \cdot 4\right) \cdot \frac{1}{2}}{b + \sqrt{(\left(a \cdot 4\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*}}}\]
    11. Taylor expanded around 0 2.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.7211479368677152 \cdot 10^{+157}:\\ \;\;\;\;\frac{-\frac{1}{2} \cdot \left(c \cdot 4\right)}{\frac{a \cdot c}{b} \cdot 2}\\ \mathbf{elif}\;b \le 5.738469888648177 \cdot 10^{-216}:\\ \;\;\;\;\frac{\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*}}{2 \cdot a} - \frac{b}{2 \cdot a}\\ \mathbf{elif}\;b \le 1.477600900922001 \cdot 10^{+116}:\\ \;\;\;\;\frac{-\frac{1}{2} \cdot \left(c \cdot 4\right)}{\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} + b}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\frac{1}{2} \cdot \left(c \cdot 4\right)}{b + b}\\ \end{array}\]

Runtime

Time bar (total: 1.2m)Debug logProfile

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