Average Error: 33.7 → 9.7
Time: 2.1m
Precision: 64
Internal Precision: 3200
\[\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.75299105006453 \cdot 10^{+128}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{if}\;b \le 1.843888019713357 \cdot 10^{-142}:\\ \;\;\;\;\left(\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right) \cdot \frac{1}{2 \cdot a}\\ \mathbf{if}\;b \le 2.8473372903889037 \cdot 10^{-109}:\\ \;\;\;\;\frac{\frac{4}{\frac{2}{c}}}{\frac{a}{b} \cdot \left(c + c\right) + \left(\left(-b\right) - b\right)}\\ \mathbf{if}\;b \le 7.658082708264784 \cdot 10^{-92}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\\ \mathbf{if}\;b \le 2.1442339633593368 \cdot 10^{-64}:\\ \;\;\;\;\frac{c}{b} \cdot \frac{-2}{2}\\ \mathbf{if}\;b \le 2.580407554019278 \cdot 10^{+102}:\\ \;\;\;\;\frac{\frac{4 \cdot \left(a \cdot c\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{4}{\frac{2}{c}}}{\frac{a}{b} \cdot \left(c + c\right) + \left(\left(-b\right) - b\right)}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 6 regimes
  2. if b < -2.75299105006453e+128

    1. Initial program 52.3

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

      \[\leadsto \frac{\color{blue}{2 \cdot \frac{c \cdot a}{b} - 2 \cdot b}}{2 \cdot a}\]
    3. Applied simplify3.2

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

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

    if -2.75299105006453e+128 < b < 1.843888019713357e-142

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

      \[\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}}\]

    if 1.843888019713357e-142 < b < 2.8473372903889037e-109 or 2.580407554019278e+102 < b

    1. Initial program 56.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-+56.7

      \[\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 simplify31.5

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

      \[\leadsto \frac{\frac{4 \cdot \left(a \cdot c\right)}{\left(-b\right) - \color{blue}{\left(b - 2 \cdot \frac{c \cdot a}{b}\right)}}}{2 \cdot a}\]
    6. Applied simplify5.9

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

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

    if 2.8473372903889037e-109 < b < 7.658082708264784e-92

    1. Initial program 23.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-sqr-sqrt23.0

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

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

    if 7.658082708264784e-92 < b < 2.1442339633593368e-64

    1. Initial program 34.9

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

      \[\leadsto \frac{\color{blue}{-2 \cdot \frac{c \cdot a}{b}}}{2 \cdot a}\]
    3. Applied simplify33.8

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

    if 2.1442339633593368e-64 < b < 2.580407554019278e+102

    1. Initial program 43.2

      \[\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-+43.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 simplify14.6

      \[\leadsto \frac{\frac{\color{blue}{4 \cdot \left(a \cdot c\right)}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\]
  3. Recombined 6 regimes into one program.
  4. Removed slow pow expressions.

Runtime

Time bar (total: 2.1m)Debug log

herbie shell --seed '#(2961832646 520228599 1275628947 1047906571 1774476463 2890033825)' 
(FPCore (a b c)
  :name "Quadratic roots"
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))