Average Error: 33.8 → 8.1
Time: 2.3m
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 -7.200109180968934 \cdot 10^{+122}:\\ \;\;\;\;\frac{c}{b} - \frac{b + b}{2 \cdot a}\\ \mathbf{if}\;b \le 3.5229942311186246 \cdot 10^{-276}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}{2 \cdot a}\\ \mathbf{if}\;b \le 5.023722770556518 \cdot 10^{-08}:\\ \;\;\;\;\frac{\frac{4 \cdot a}{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}} \cdot c}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{c}{2} \cdot 4}{2}}{a \cdot \frac{c}{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 < -7.200109180968934e+122

    1. Initial program 51.4

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

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

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

    if -7.200109180968934e+122 < b < 3.5229942311186246e-276

    1. Initial program 9.0

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

    if 3.5229942311186246e-276 < b < 5.023722770556518e-08

    1. Initial program 25.6

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

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

      \[\leadsto \frac{\frac{\color{blue}{c \cdot \left(a \cdot 4\right)}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity17.7

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

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

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

    if 5.023722770556518e-08 < b

    1. Initial program 55.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 flip-+55.0

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

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

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

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

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

      \[\leadsto \frac{c \cdot \frac{a \cdot 4}{\color{blue}{2 \cdot \frac{c \cdot a}{b} - 2 \cdot b}}}{2 \cdot a}\]
    10. Applied simplify5.6

      \[\leadsto \color{blue}{\frac{\frac{\frac{4}{1} \cdot \frac{c}{2}}{2}}{\frac{c}{b} \cdot a - b}}\]
  3. Recombined 4 regimes into one program.
  4. Applied simplify8.1

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \le -7.200109180968934 \cdot 10^{+122}:\\ \;\;\;\;\frac{c}{b} - \frac{b + b}{2 \cdot a}\\ \mathbf{if}\;b \le 3.5229942311186246 \cdot 10^{-276}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}{2 \cdot a}\\ \mathbf{if}\;b \le 5.023722770556518 \cdot 10^{-08}:\\ \;\;\;\;\frac{\frac{4 \cdot a}{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}} \cdot c}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{c}{2} \cdot 4}{2}}{a \cdot \frac{c}{b} - b}\\ \end{array}}\]

Runtime

Time bar (total: 2.3m)Debug logProfile

herbie shell --seed '#(1071215679 2002590028 935158157 1944352234 2656991306 2955288481)' 
(FPCore (a b c)
  :name "Quadratic roots, full range"
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))