Average Error: 19.1 → 6.9
Time: 1.6m
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}\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\frac{c \cdot \left(a \cdot 4\right)}{\sqrt{b \cdot b - \left(4 \cdot c\right) \cdot a} - 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} \le -3.537802341368214 \cdot 10^{-246}:\\ \;\;\;\;\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{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}\\ \end{array}\\ \mathbf{if}\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\frac{c \cdot \left(a \cdot 4\right)}{\sqrt{b \cdot b - \left(4 \cdot c\right) \cdot a} - 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} \le 3.624347587788428 \cdot 10^{-216}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{1}{\frac{b}{c}} - \frac{b + b}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\frac{c \cdot 2}{\frac{b}{a}} - \left(b + b\right)}\\ \end{array}\\ \mathbf{if}\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\frac{c \cdot \left(a \cdot 4\right)}{\sqrt{b \cdot b - \left(4 \cdot c\right) \cdot a} - 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} \le 1.957585607018184 \cdot 10^{+284}:\\ \;\;\;\;\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{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}\\ \end{array}\\ \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{1}{\frac{b}{c}} - \frac{b + b}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\frac{c \cdot 2}{\frac{b}{a}} - \left(b + b\right)}\\ \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 (if (>= b 0) (/ (/ (* c (* a 4)) (- (sqrt (- (* b b) (* (* 4 c) a))) b)) (* 2 a)) (/ (* 2 c) (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))))) < -3.537802341368214e-246 or 3.624347587788428e-216 < (if (>= b 0) (/ (/ (* c (* a 4)) (- (sqrt (- (* b b) (* (* 4 c) a))) b)) (* 2 a)) (/ (* 2 c) (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))))) < 1.957585607018184e+284

    1. Initial program 1.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 add-sqr-sqrt1.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{2 \cdot c}{\color{blue}{\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}}}\\ \end{array}\]
    4. Applied sqrt-prod2.0

      \[\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) + \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}}}}\\ \end{array}\]

    if -3.537802341368214e-246 < (if (>= b 0) (/ (/ (* c (* a 4)) (- (sqrt (- (* b b) (* (* 4 c) a))) b)) (* 2 a)) (/ (* 2 c) (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))))) < 3.624347587788428e-216 or 1.957585607018184e+284 < (if (>= b 0) (/ (/ (* c (* a 4)) (- (sqrt (- (* b b) (* (* 4 c) a))) b)) (* 2 a)) (/ (* 2 c) (+ (- b) (sqrt (- (* b b) (* (* 4 a) c))))))

    1. Initial program 35.3

      \[\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 25.6

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

      \[\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}}\]
    4. Taylor expanded around inf 13.4

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

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

Runtime

Time bar (total: 1.6m)Debug logProfile

herbie shell --seed 2018198 
(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)))))))