Average Error: 18.7 → 6.6
Time: 1.4m
Precision: 64
Internal Precision: 576
\[\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \end{array}\]
\[\begin{array}{l} \mathbf{if}\;b \le -3.6808702261921996 \cdot 10^{+52}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c}}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\left(a \cdot 2\right) \cdot \frac{c}{b} - \left(b + b\right)}\\ \end{array}\\ \mathbf{if}\;b \le -4.583442782241351 \cdot 10^{-282} \lor \neg \left(b \le 6.83408329523738 \cdot 10^{+97}\right):\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{\sqrt{\sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c} - b}} \cdot \frac{2}{\sqrt{\sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c} - b}}\\ \end{array}\\ \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c}}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\frac{\left(a \cdot 4\right) \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c}}}\\ \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 4 regimes
  2. if b < -3.6808702261921996e+52

    1. Initial program 25.2

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

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

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

    if -3.6808702261921996e+52 < b < -4.583442782241351e-282

    1. Initial program 8.2

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

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

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

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

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

    if -4.583442782241351e-282 < b < 6.83408329523738e+97

    1. Initial program 8.8

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

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

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

    if 6.83408329523738e+97 < b

    1. Initial program 43.2

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

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

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

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

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

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \le -3.6808702261921996 \cdot 10^{+52}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c}}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\left(a \cdot 2\right) \cdot \frac{c}{b} - \left(b + b\right)}\\ \end{array}\\ \mathbf{if}\;b \le -4.583442782241351 \cdot 10^{-282} \lor \neg \left(b \le 6.83408329523738 \cdot 10^{+97}\right):\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{\sqrt{\sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c} - b}} \cdot \frac{2}{\sqrt{\sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c} - b}}\\ \end{array}\\ \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c}}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\frac{\left(a \cdot 4\right) \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c}}}\\ \end{array}}\]

Runtime

Time bar (total: 1.4m)Debug logProfile

herbie shell --seed '#(1072743783 989954326 4239155542 3782239461 3602631542 1719177920)' 
(FPCore (a b c)
  :name "jeff quadratic root 1"
  (if (>= b 0) (/ (- (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)) (/ (* 2 c) (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))))))