Average Error: 19.3 → 13.0
Time: 16.8s
Precision: 64
Internal Precision: 128
\[\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.6036990415127427 \cdot 10^{+143}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\sqrt{(-4 \cdot \left(a \cdot c\right) + \left(b \cdot b\right))_*}} \cdot \sqrt{\sqrt{(-4 \cdot \left(a \cdot c\right) + \left(b \cdot b\right))_*}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{(-4 \cdot \left(a \cdot c\right) + \left(b \cdot b\right))_*} - b}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{{\left(c \cdot \left(-4 \cdot a\right)\right)}^{\frac{1}{2}} - b}{2 \cdot a}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if b < 2.6036990415127427e+143

    1. Initial program 15.6

      \[\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. Simplified15.6

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

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

    if 2.6036990415127427e+143 < b

    1. Initial program 35.2

      \[\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. Simplified35.1

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

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

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{{\left(e^{\frac{1}{4} \cdot \left(\log -4 - \left(\log \left(\frac{1}{a}\right) + \log \left(\frac{1}{c}\right)\right)\right)}\right)}^{2} - b}{2 \cdot a}\\ \end{array}\]
    9. Simplified1.3

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{{\left(c \cdot \left(-4 \cdot a\right)\right)}^{\frac{1}{2}} - b}{2 \cdot a}\\ \end{array}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification13.0

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

Reproduce

herbie shell --seed 2019053 +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))))