Average Error: 33.7 → 9.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 -3.6187761808561937 \cdot 10^{+133}:\\ \;\;\;\;\frac{\left(-c\right) \cdot \frac{4}{2}}{\frac{a \cdot c}{b} \cdot 2}\\ \mathbf{elif}\;b \le -1.3942267552537598 \cdot 10^{-276}:\\ \;\;\;\;\frac{\sqrt{{b}^{2} - \left(a \cdot c\right) \cdot 4} - b}{2 \cdot a}\\ \mathbf{elif}\;b \le 2.504823922999971 \cdot 10^{+88}:\\ \;\;\;\;\frac{\left(-c\right) \cdot \frac{4}{2}}{\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} + b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-c\right) \cdot \frac{4}{2}}{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 < -3.6187761808561937e+133

    1. Initial program 53.8

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

      \[\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.2

      \[\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.2

      \[\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.4

      \[\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.4

      \[\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.4

      \[\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.3

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

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

    if -3.6187761808561937e+133 < b < -1.3942267552537598e-276

    1. Initial program 8.7

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

      \[\leadsto \frac{\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b}{2 \cdot a}\]
    3. Taylor expanded around 0 8.6

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

    if -1.3942267552537598e-276 < b < 2.504823922999971e+88

    1. Initial program 31.3

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

      \[\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--31.5

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

      \[\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. Simplified22.0

      \[\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-out22.0

      \[\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-neg22.0

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

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

    if 2.504823922999971e+88 < b

    1. Initial program 58.1

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

      \[\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--58.1

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

      \[\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. Simplified31.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-out31.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-neg31.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. Simplified28.2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -3.6187761808561937 \cdot 10^{+133}:\\ \;\;\;\;\frac{\left(-c\right) \cdot \frac{4}{2}}{\frac{a \cdot c}{b} \cdot 2}\\ \mathbf{elif}\;b \le -1.3942267552537598 \cdot 10^{-276}:\\ \;\;\;\;\frac{\sqrt{{b}^{2} - \left(a \cdot c\right) \cdot 4} - b}{2 \cdot a}\\ \mathbf{elif}\;b \le 2.504823922999971 \cdot 10^{+88}:\\ \;\;\;\;\frac{\left(-c\right) \cdot \frac{4}{2}}{\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} + b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-c\right) \cdot \frac{4}{2}}{b + b}\\ \end{array}\]

Runtime

Time bar (total: 1.2m)Debug logProfile

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