Average Error: 19.3 → 6.6
Time: 47.7s
Precision: 64
Internal Precision: 576
\[\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.5692996466264766 \cdot 10^{+148} \lor \neg \left(b \le 4.4193134745531346 \cdot 10^{+135}\right):\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\frac{2 \cdot c}{\frac{b}{a}} - \left(b + b\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \left|b\right|}{a \cdot 2}\\ \end{array}\\ \mathbf{elif}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}} \cdot \sqrt{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} + \left(-b\right)}{a \cdot 2}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if b < -3.5692996466264766e+148 or 4.4193134745531346e+135 < b

    1. Initial program 43.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. Taylor expanded around inf 25.4

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \color{blue}{\left(b - 2 \cdot \frac{a \cdot c}{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. Simplified22.8

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - (\left(\frac{c}{b} \cdot a\right) \cdot -2 + b)_*}\\ \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}\]
    6. Applied rem-sqrt-square22.8

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - (\left(\frac{c}{b} \cdot a\right) \cdot -2 + b)_*}\\ \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}\]
    8. Taylor expanded around 0 2.1

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - (\left(\frac{c}{b} \cdot a\right) \cdot -2 + b)_*}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \left|b\right|}{2 \cdot a}\\ \end{array}\]
    9. Using strategy rm
    10. Applied add-cube-cbrt2.4

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

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

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

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

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

    if -3.5692996466264766e+148 < b < 4.4193134745531346e+135

    1. Initial program 8.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-sqrt8.7

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\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}}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification6.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -3.5692996466264766 \cdot 10^{+148} \lor \neg \left(b \le 4.4193134745531346 \cdot 10^{+135}\right):\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\frac{2 \cdot c}{\frac{b}{a}} - \left(b + b\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \left|b\right|}{a \cdot 2}\\ \end{array}\\ \mathbf{elif}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}} \cdot \sqrt{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} + \left(-b\right)}{a \cdot 2}\\ \end{array}\]

Runtime

Time bar (total: 47.7s)Debug logProfile

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