Average Error: 33.4 → 12.0
Time: 30.9s
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 1.9729334767141602 \cdot 10^{-129}:\\ \;\;\;\;\frac{(\left(\sqrt[3]{-b} \cdot \sqrt[3]{-b}\right) \cdot \left(\sqrt[3]{-b}\right) + \left(\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}\right))_*}{a \cdot 2}\\ \mathbf{elif}\;b \le 7.159459861338518 \cdot 10^{+120}:\\ \;\;\;\;\frac{\left(a \cdot c\right) \cdot 4}{\left(a \cdot 2\right) \cdot \left(\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}\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

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. Taylor expanded around -inf 2.3

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

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

    if -1.4257270821599501e+146 < b < 1.9729334767141602e-129

    1. Initial program 11.0

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

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

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

    if 1.9729334767141602e-129 < b < 7.159459861338518e+120

    1. Initial program 41.1

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

      \[\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 associate-/l/43.5

      \[\leadsto \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(2 \cdot a\right) \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}}\]
    5. Simplified16.9

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

    if 7.159459861338518e+120 < b

    1. Initial program 60.3

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. 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 1.9729334767141602 \cdot 10^{-129}:\\ \;\;\;\;\frac{(\left(\sqrt[3]{-b} \cdot \sqrt[3]{-b}\right) \cdot \left(\sqrt[3]{-b}\right) + \left(\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}\right))_*}{a \cdot 2}\\ \mathbf{elif}\;b \le 7.159459861338518 \cdot 10^{+120}:\\ \;\;\;\;\frac{\left(a \cdot c\right) \cdot 4}{\left(a \cdot 2\right) \cdot \left(\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{-2 \cdot \frac{a \cdot c}{b}}{a \cdot 2}\\ \end{array}\]

Runtime

Time bar (total: 30.9s)Debug logProfile

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