Average Error: 19.7 → 6.8
Time: 1.2m
Precision: 64
Internal Precision: 384
\[\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
\[\begin{array}{l} \mathbf{if}\;b \le -2.7887640869868202 \cdot 10^{+101}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\left(\left(-b\right) + \sqrt{b \cdot b - a \cdot \left(c \cdot 4\right)}\right) \cdot \frac{\frac{2}{1}}{a \cdot 4}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b + b}{a + a}\\ \end{array}\\ \mathbf{if}\;b \le 1.984850483081724 \cdot 10^{+105}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{c + c}{\left(-b\right) - \sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{(\left(\sqrt{-b}\right) \cdot \left(\sqrt{-b}\right) + \left(\sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c}\right))_*}{a + a}\\ \end{array}\\ \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\frac{c + c}{1}}{(\left(\frac{c}{b} + \frac{c}{b}\right) \cdot a + \left(\left(-b\right) - b\right))_*}\\ \mathbf{else}:\\ \;\;\;\;\frac{(\left(\frac{c}{b}\right) \cdot a + \left(-b\right))_* + (\left(\frac{c}{b}\right) \cdot a + \left(-b\right))_*}{a + a}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 3 regimes
  2. if b < -2.7887640869868202e+101

    1. Initial program 45.0

      \[\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    2. Taylor expanded around -inf 9.4

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \left(2 \cdot \frac{c \cdot a}{b} - b\right)}{2 \cdot a}\\ \end{array}\]
    3. Applied simplify3.3

      \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{c + c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot c\right) \cdot a}}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \frac{c}{b} - \frac{b + b}{a + a}\\ \end{array}}\]
    4. Using strategy rm
    5. Applied flip--3.3

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{c + c}{\color{blue}{\frac{\left(-b\right) \cdot \left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot c\right) \cdot a} \cdot \sqrt{b \cdot b - \left(4 \cdot c\right) \cdot a}}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot c\right) \cdot a}}}}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \frac{c}{b} - \frac{b + b}{a + a}\\ \end{array}\]
    6. Applied associate-/r/3.3

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\color{blue}{\frac{c + c}{\left(-b\right) \cdot \left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot c\right) \cdot a} \cdot \sqrt{b \cdot b - \left(4 \cdot c\right) \cdot a}} \cdot \left(\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot c\right) \cdot a}\right)}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \frac{c}{b} - \frac{b + b}{a + a}\\ \end{array}\]
    7. Applied simplify3.3

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\color{blue}{\frac{\frac{2}{1}}{a \cdot 4}} \cdot \left(\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot c\right) \cdot a}\right)\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \frac{c}{b} - \frac{b + b}{a + a}\\ \end{array}\]

    if -2.7887640869868202e+101 < b < 1.984850483081724e+105

    1. Initial program 9.3

      \[\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt9.4

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{-b} \cdot \sqrt{-b} + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    4. Applied fma-def9.4

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{(\left(\sqrt{-b}\right) \cdot \left(\sqrt{-b}\right) + \left(\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right))_*}{2 \cdot a}\\ \end{array}\]

    if 1.984850483081724e+105 < b

    1. Initial program 31.1

      \[\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    2. Taylor expanded around inf 6.0

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \color{blue}{\left(b - 2 \cdot \frac{c \cdot a}{b}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    3. Applied simplify2.2

      \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{c + c}{(\left(\frac{c + c}{b}\right) \cdot a + \left(\left(-b\right) - b\right))_*}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot c\right) \cdot 4} + \left(-b\right)}{a + a}\\ \end{array}}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity2.2

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{c + c}{\color{blue}{1 \cdot (\left(\frac{c + c}{b}\right) \cdot a + \left(\left(-b\right) - b\right))_*}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot c\right) \cdot 4} + \left(-b\right)}{a + a}\\ \end{array}\]
    6. Applied add-cube-cbrt3.0

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\color{blue}{\left(\sqrt[3]{c + c} \cdot \sqrt[3]{c + c}\right) \cdot \sqrt[3]{c + c}}}{1 \cdot (\left(\frac{c + c}{b}\right) \cdot a + \left(\left(-b\right) - b\right))_*}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot c\right) \cdot 4} + \left(-b\right)}{a + a}\\ \end{array}\]
    7. Applied times-frac3.0

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\color{blue}{\frac{\sqrt[3]{c + c} \cdot \sqrt[3]{c + c}}{1} \cdot \frac{\sqrt[3]{c + c}}{(\left(\frac{c + c}{b}\right) \cdot a + \left(\left(-b\right) - b\right))_*}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot c\right) \cdot 4} + \left(-b\right)}{a + a}\\ \end{array}\]
    8. Taylor expanded around -inf 3.0

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\sqrt[3]{c + c} \cdot \sqrt[3]{c + c}}{1} \cdot \frac{\sqrt[3]{c + c}}{(\left(\frac{c + c}{b}\right) \cdot a + \left(\left(-b\right) - b\right))_*}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(2 \cdot \frac{c \cdot a}{b} - b\right) + \left(-b\right)}{a + a}\\ \end{array}\]
    9. Applied simplify2.2

      \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\frac{c + c}{1}}{(\left(\frac{c}{b} + \frac{c}{b}\right) \cdot a + \left(\left(-b\right) - b\right))_*}\\ \mathbf{else}:\\ \;\;\;\;\frac{(\left(\frac{c}{b}\right) \cdot a + \left(-b\right))_* + (\left(\frac{c}{b}\right) \cdot a + \left(-b\right))_*}{a + a}\\ \end{array}}\]
  3. Recombined 3 regimes into one program.
  4. Applied simplify6.8

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \le -2.7887640869868202 \cdot 10^{+101}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\left(\left(-b\right) + \sqrt{b \cdot b - a \cdot \left(c \cdot 4\right)}\right) \cdot \frac{\frac{2}{1}}{a \cdot 4}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b + b}{a + a}\\ \end{array}\\ \mathbf{if}\;b \le 1.984850483081724 \cdot 10^{+105}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{c + c}{\left(-b\right) - \sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{(\left(\sqrt{-b}\right) \cdot \left(\sqrt{-b}\right) + \left(\sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c}\right))_*}{a + a}\\ \end{array}\\ \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\frac{c + c}{1}}{(\left(\frac{c}{b} + \frac{c}{b}\right) \cdot a + \left(\left(-b\right) - b\right))_*}\\ \mathbf{else}:\\ \;\;\;\;\frac{(\left(\frac{c}{b}\right) \cdot a + \left(-b\right))_* + (\left(\frac{c}{b}\right) \cdot a + \left(-b\right))_*}{a + a}\\ \end{array}}\]

Runtime

Time bar (total: 1.2m)Debug logProfile

herbie shell --seed '#(1064173506 2580572819 2847706409 4129882574 1125180799 1845288547)' +o rules:numerics
(FPCore (a b c)
  :name "jeff quadratic root 2"
  (if (>= b 0) (/ (* 2 c) (- (- b) (sqrt (- (* b b) (* (* 4 a) c))))) (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a))))