Average Error: 33.4 → 6.7
Time: 3.6m
Precision: 64
Internal Precision: 128
\[\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 -4.0906093545612224 \cdot 10^{+106}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \le 1.654657044164791 \cdot 10^{-172}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b}{a}}{2}\\ \mathbf{elif}\;b \le 1.2708555626115063 \cdot 10^{+98}:\\ \;\;\;\;\frac{1}{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} + b} \cdot \left(\sqrt{\frac{1}{2}} \cdot \left(\frac{c}{\frac{-1}{4}} \cdot \sqrt{\frac{1}{2}}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-\frac{c}{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 < -4.0906093545612224e+106

    1. Initial program 46.0

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

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

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

    if -4.0906093545612224e+106 < b < 1.654657044164791e-172

    1. Initial program 10.6

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

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

      \[\leadsto \frac{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b}{\color{blue}{a \cdot 2}}\]
    5. Applied associate-/r*10.5

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

    if 1.654657044164791e-172 < b < 1.2708555626115063e+98

    1. Initial program 37.3

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

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

      \[\leadsto \frac{\color{blue}{1 \cdot \left(\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b\right)}}{2 \cdot a}\]
    5. Applied associate-/l*37.3

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{0 - \left(c \cdot a\right) \cdot 4}{\frac{a}{\frac{1}{2}}}} \cdot \frac{1}{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} + b}\]
    12. Using strategy rm
    13. Applied add-sqr-sqrt14.7

      \[\leadsto \frac{0 - \left(c \cdot a\right) \cdot 4}{\frac{a}{\color{blue}{\sqrt{\frac{1}{2}} \cdot \sqrt{\frac{1}{2}}}}} \cdot \frac{1}{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} + b}\]
    14. Applied *-un-lft-identity14.7

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

      \[\leadsto \frac{0 - \left(c \cdot a\right) \cdot 4}{\color{blue}{\frac{1}{\sqrt{\frac{1}{2}}} \cdot \frac{a}{\sqrt{\frac{1}{2}}}}} \cdot \frac{1}{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} + b}\]
    16. Applied *-un-lft-identity14.6

      \[\leadsto \frac{0 - \color{blue}{1 \cdot \left(\left(c \cdot a\right) \cdot 4\right)}}{\frac{1}{\sqrt{\frac{1}{2}}} \cdot \frac{a}{\sqrt{\frac{1}{2}}}} \cdot \frac{1}{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} + b}\]
    17. Applied *-un-lft-identity14.6

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

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

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

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

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

    if 1.2708555626115063e+98 < b

    1. Initial program 58.8

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}}\]
    4. Simplified2.4

      \[\leadsto \color{blue}{-\frac{c}{b}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification6.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -4.0906093545612224 \cdot 10^{+106}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \le 1.654657044164791 \cdot 10^{-172}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b}{a}}{2}\\ \mathbf{elif}\;b \le 1.2708555626115063 \cdot 10^{+98}:\\ \;\;\;\;\frac{1}{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} + b} \cdot \left(\sqrt{\frac{1}{2}} \cdot \left(\frac{c}{\frac{-1}{4}} \cdot \sqrt{\frac{1}{2}}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-\frac{c}{b}\\ \end{array}\]

Reproduce

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