Average Error: 19.3 → 6.5
Time: 1.2m
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 -1.7541950816692702 \cdot 10^{+101}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{c \cdot 2}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot c\right) \cdot a}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b + b}{a \cdot 2}\\ \end{array}\\ \mathbf{if}\;b \le -3.9131956284591527 \cdot 10^{-271}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;e^{-\log \left(\frac{a}{b} - \frac{b}{c}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b + \left(c \cdot a\right) \cdot -4} - b}{a \cdot 2}\\ \end{array}\\ \mathbf{if}\;b \le 6.244806792019259 \cdot 10^{+112}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{c \cdot 2}{\left(-b\right) - \sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\left(a \cdot 4\right) \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c}}}{a \cdot 2}\\ \end{array}\\ \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{c}{c \cdot \frac{a}{b} - b}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 4 regimes
  2. if b < -1.7541950816692702e+101

    1. Initial program 45.0

      \[\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 9.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(2 \cdot \frac{c \cdot a}{b} - b\right)}{2 \cdot a}\\ \end{array}\]
    3. Applied simplify3.6

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

    if -1.7541950816692702e+101 < b < -3.9131956284591527e-271

    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. Taylor expanded around inf 8.5

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

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

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

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

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

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

    if -3.9131956284591527e-271 < b < 6.244806792019259e+112

    1. Initial program 8.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 flip-+8.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{\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}}}{2 \cdot a}\\ \end{array}\]
    4. Applied simplify8.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{\frac{c \cdot \left(a \cdot 4\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\\ \end{array}\]

    if 6.244806792019259e+112 < b

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{c}{a \cdot \frac{c}{b} - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - b}{2 \cdot a}\\ \end{array}\]
    5. Applied simplify2.4

      \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{c}{\frac{a}{b} \cdot c - b}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}}\]
  3. Recombined 4 regimes into one program.
  4. Applied simplify6.5

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \le -1.7541950816692702 \cdot 10^{+101}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{c \cdot 2}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot c\right) \cdot a}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b + b}{a \cdot 2}\\ \end{array}\\ \mathbf{if}\;b \le -3.9131956284591527 \cdot 10^{-271}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;e^{-\log \left(\frac{a}{b} - \frac{b}{c}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b + \left(c \cdot a\right) \cdot -4} - b}{a \cdot 2}\\ \end{array}\\ \mathbf{if}\;b \le 6.244806792019259 \cdot 10^{+112}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{c \cdot 2}{\left(-b\right) - \sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\left(a \cdot 4\right) \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c}}}{a \cdot 2}\\ \end{array}\\ \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{c}{c \cdot \frac{a}{b} - b}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}}\]

Runtime

Time bar (total: 1.2m)Debug logProfile

herbie shell --seed '#(1071373924 2949776965 1885069702 3247780810 90874544 2263903749)' 
(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))))