Average Error: 19.1 → 6.4
Time: 46.0s
Precision: 64
Internal Precision: 384
\[\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{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{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} = -\infty:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{1}{\sqrt[3]{a + a} \cdot \sqrt[3]{a + a}} \cdot \frac{(\left(\frac{a}{b}\right) \cdot \left(c + c\right) + \left(-b\right))_* - b}{\sqrt[3]{a + a}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{(a \cdot \left(\frac{c}{b}\right) + \left(-b\right))_*}\\ \end{array}\\ \mathbf{if}\;\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}{\frac{c \cdot \left(a \cdot 4\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}\\ \end{array} \le -5.04823493111339 \cdot 10^{-146}:\\ \;\;\;\;\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}{\frac{c \cdot \left(a \cdot 4\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}\\ \end{array}\\ \mathbf{if}\;\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}{\frac{c \cdot \left(a \cdot 4\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}\\ \end{array} \le 4.402883190451402 \cdot 10^{-272}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\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}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \end{array}\\ \mathbf{if}\;\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}{\frac{c \cdot \left(a \cdot 4\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}\\ \end{array} \le 2.461703732367004 \cdot 10^{+280}:\\ \;\;\;\;\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}{\frac{c \cdot \left(a \cdot 4\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}\\ \end{array}\\ \mathbf{if}\;b \ge 0:\\ \;\;\;\;(e^{\log_* (1 + \frac{(\left(\frac{a}{b}\right) \cdot \left(c + c\right) + \left(-b\right))_* - b}{a + a})} - 1)^*\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{(a \cdot \left(\frac{c}{b}\right) + \left(-b\right))_*}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 4 regimes
  2. if (if (>= b 0) (/ (- (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)) (/ (* 2 c) (/ (* c (* a 4)) (- (- b) (sqrt (- (* b b) (* (* 4 a) c))))))) < -inf.0

    1. Initial program 47.5

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

      \[\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 simplify28.4

      \[\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)}}{a + a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{c + c}{2}}{(a \cdot \left(\frac{c}{b}\right) + \left(-b\right))_*}\\ \end{array}}\]
    4. Taylor expanded around inf 9.7

      \[\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)}}{a + a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{c + c}{2}}{(a \cdot \left(\frac{c}{b}\right) + \left(-b\right))_*}\\ \end{array}\]
    5. Applied simplify7.9

      \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{(\left(\frac{a}{b}\right) \cdot \left(c + c\right) + \left(-b\right))_* - b}{a + a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{(a \cdot \left(\frac{c}{b}\right) + \left(-b\right))_*}\\ \end{array}}\]
    6. Using strategy rm
    7. Applied add-cube-cbrt8.3

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

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

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

    if -inf.0 < (if (>= b 0) (/ (- (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)) (/ (* 2 c) (/ (* c (* a 4)) (- (- b) (sqrt (- (* b b) (* (* 4 a) c))))))) < -5.04823493111339e-146 or 4.402883190451402e-272 < (if (>= b 0) (/ (- (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)) (/ (* 2 c) (/ (* c (* a 4)) (- (- b) (sqrt (- (* b b) (* (* 4 a) c))))))) < 2.461703732367004e+280

    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 flip-+2.2

      \[\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 simplify2.2

      \[\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 -5.04823493111339e-146 < (if (>= b 0) (/ (- (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)) (/ (* 2 c) (/ (* c (* a 4)) (- (- b) (sqrt (- (* b b) (* (* 4 a) c))))))) < 4.402883190451402e-272

    1. Initial program 0.1

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

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

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

    if 2.461703732367004e+280 < (if (>= b 0) (/ (- (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)) (/ (* 2 c) (/ (* c (* a 4)) (- (- b) (sqrt (- (* b b) (* (* 4 a) c)))))))

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

      \[\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)}}{a + a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{c + c}{2}}{(a \cdot \left(\frac{c}{b}\right) + \left(-b\right))_*}\\ \end{array}}\]
    4. Taylor expanded around inf 16.3

      \[\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)}}{a + a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{c + c}{2}}{(a \cdot \left(\frac{c}{b}\right) + \left(-b\right))_*}\\ \end{array}\]
    5. Applied simplify13.5

      \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{(\left(\frac{a}{b}\right) \cdot \left(c + c\right) + \left(-b\right))_* - b}{a + a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{(a \cdot \left(\frac{c}{b}\right) + \left(-b\right))_*}\\ \end{array}}\]
    6. Using strategy rm
    7. Applied expm1-log1p-u15.4

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

Runtime

Time bar (total: 46.0s)Debug logProfile

herbie shell --seed '#(1070355188 2193211668 3977393919 3454156579 3755371326 1656365382)' +o rules:numerics
(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)))))))