Average Error: 20.1 → 7.1
Time: 48.7s
Precision: 64
Internal Precision: 320
\[\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 -3.819497819135284 \cdot 10^{+153} \lor \neg \left(b \le 3.41583987548531 \cdot 10^{+47}\right):\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \left|b\right|}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \ge 0:\\ \;\;\;\;\frac{c \cdot 2}{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \left|\sqrt{\sqrt{(\left(-4 \cdot a\right) \cdot c + \left(b \cdot b\right))_*}} \cdot \sqrt{\sqrt{(\left(-4 \cdot a\right) \cdot c + \left(b \cdot b\right))_*}}\right|}{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 < -3.819497819135284e+153 or 3.41583987548531e+47 < b

    1. Initial program 34.8

      \[\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-sqrt34.8

      \[\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) + \sqrt{\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}\\ \end{array}\]
    4. Applied rem-sqrt-square34.8

      \[\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|\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right|}{2 \cdot a}\\ \end{array}\]
    5. Simplified34.8

      \[\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|\sqrt{(\left(a \cdot -4\right) \cdot c + \left(b \cdot b\right))_*}\right|}{2 \cdot a}\\ \end{array}\]
    6. Taylor expanded around 0 19.1

      \[\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|b\right|}{2 \cdot a}\\ \end{array}\]
    7. Using strategy rm
    8. Applied associate-/l*19.4

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

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

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

    if -3.819497819135284e+153 < b < 3.41583987548531e+47

    1. Initial program 9.5

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

      \[\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) + \sqrt{\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}\\ \end{array}\]
    4. Applied rem-sqrt-square9.5

      \[\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|\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right|}{2 \cdot a}\\ \end{array}\]
    5. Simplified9.5

      \[\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|\sqrt{(\left(a \cdot -4\right) \cdot c + \left(b \cdot b\right))_*}\right|}{2 \cdot a}\\ \end{array}\]
    6. Using strategy rm
    7. Applied add-sqr-sqrt9.6

      \[\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|\sqrt{\sqrt{(\left(a \cdot -4\right) \cdot c + \left(b \cdot b\right))_*}} \cdot \sqrt{\sqrt{(\left(a \cdot -4\right) \cdot c + \left(b \cdot b\right))_*}}\right|}{2 \cdot a}\\ \end{array}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification7.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -3.819497819135284 \cdot 10^{+153} \lor \neg \left(b \le 3.41583987548531 \cdot 10^{+47}\right):\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \left|b\right|}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \ge 0:\\ \;\;\;\;\frac{c \cdot 2}{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \left|\sqrt{\sqrt{(\left(-4 \cdot a\right) \cdot c + \left(b \cdot b\right))_*}} \cdot \sqrt{\sqrt{(\left(-4 \cdot a\right) \cdot c + \left(b \cdot b\right))_*}}\right|}{2 \cdot a}\\ \end{array}\]

Runtime

Time bar (total: 48.7s)Debug logProfile

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