Average Error: 33.3 → 6.5
Time: 49.6s
Precision: 64
Internal Precision: 3136
\[\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.263114766361561 \cdot 10^{+105}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \le 2.5149337534701423 \cdot 10^{-225}:\\ \;\;\;\;(\left(\frac{\frac{1}{2}}{a}\right) \cdot \left(\sqrt{(\left(-4 \cdot a\right) \cdot c + \left(b \cdot b\right))_*}\right) + \left(\frac{b \cdot \frac{-1}{2}}{a}\right))_*\\ \mathbf{elif}\;b \le 4.276320085217255 \cdot 10^{+140}:\\ \;\;\;\;2 \cdot \frac{c}{\left(-b\right) - \sqrt{(-4 \cdot \left(c \cdot a\right) + \left(b \cdot b\right))_*}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\left(-b\right) - (\left(\frac{c}{b} \cdot a\right) \cdot -2 + 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 < -1.263114766361561e+105

    1. Initial program 45.7

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

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

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

    if -1.263114766361561e+105 < b < 2.5149337534701423e-225

    1. Initial program 10.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 div-inv10.1

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

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

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

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

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

    if 2.5149337534701423e-225 < b < 4.276320085217255e+140

    1. Initial program 36.8

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

      \[\leadsto \color{blue}{\left(\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right) \cdot \frac{1}{2 \cdot a}}\]
    4. Using strategy rm
    5. Applied flip-+36.9

      \[\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(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}} \cdot \frac{1}{2 \cdot a}\]
    6. Applied associate-*l/36.9

      \[\leadsto \color{blue}{\frac{\left(\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}\right) \cdot \frac{1}{2 \cdot a}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}\]
    7. Simplified15.0

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

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

      \[\leadsto \frac{2 \cdot c}{\left(-b\right) - \color{blue}{1 \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}\]
    11. Applied *-un-lft-identity7.3

      \[\leadsto \frac{2 \cdot c}{\color{blue}{1 \cdot \left(-b\right)} - 1 \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\]
    12. Applied distribute-lft-out--7.3

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

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

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

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

    if 4.276320085217255e+140 < b

    1. Initial program 61.4

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

      \[\leadsto \color{blue}{\left(\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right) \cdot \frac{1}{2 \cdot a}}\]
    4. Using strategy rm
    5. Applied flip-+61.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(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}} \cdot \frac{1}{2 \cdot a}\]
    6. Applied associate-*l/61.5

      \[\leadsto \color{blue}{\frac{\left(\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}\right) \cdot \frac{1}{2 \cdot a}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}\]
    7. Simplified35.4

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

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

      \[\leadsto \frac{2 \cdot c}{\left(-b\right) - \color{blue}{\left(b - 2 \cdot \frac{a \cdot c}{b}\right)}}\]
    10. Simplified1.3

      \[\leadsto \frac{2 \cdot c}{\left(-b\right) - \color{blue}{(\left(\frac{c}{b} \cdot a\right) \cdot -2 + b)_*}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification6.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.263114766361561 \cdot 10^{+105}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \le 2.5149337534701423 \cdot 10^{-225}:\\ \;\;\;\;(\left(\frac{\frac{1}{2}}{a}\right) \cdot \left(\sqrt{(\left(-4 \cdot a\right) \cdot c + \left(b \cdot b\right))_*}\right) + \left(\frac{b \cdot \frac{-1}{2}}{a}\right))_*\\ \mathbf{elif}\;b \le 4.276320085217255 \cdot 10^{+140}:\\ \;\;\;\;2 \cdot \frac{c}{\left(-b\right) - \sqrt{(-4 \cdot \left(c \cdot a\right) + \left(b \cdot b\right))_*}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\left(-b\right) - (\left(\frac{c}{b} \cdot a\right) \cdot -2 + b)_*}\\ \end{array}\]

Runtime

Time bar (total: 49.6s)Debug logProfile

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