Average Error: 18.9 → 6.7
Time: 1.1m
Precision: 64
Internal Precision: 384
\[\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}\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\frac{c \cdot \left(a \cdot 4\right)}{\sqrt{b \cdot b - \left(4 \cdot c\right) \cdot a} - b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} = -\infty:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{c}{c \cdot \frac{a}{b} - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(2 \cdot c\right) \cdot \frac{a}{b} - \left(b + b\right)}{a \cdot 2}\\ \end{array}\\ \mathbf{if}\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\frac{c \cdot \left(a \cdot 4\right)}{\sqrt{b \cdot b - \left(4 \cdot c\right) \cdot a} - b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \le 5.039531899994073 \cdot 10^{+192}:\\ \;\;\;\;\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{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\\ \end{array}\\ \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{c}{c \cdot \frac{a}{b} - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(2 \cdot c\right) \cdot \frac{a}{b} - \left(b + b\right)}{a \cdot 2}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

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

    1. Initial program 41.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 28.1

      \[\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 simplify26.1

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

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

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

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

    if -inf.0 < (if (>= b 0) (/ (* 2 c) (/ (* c (* a 4)) (- (sqrt (- (* b b) (* (* 4 c) a))) b))) (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a))) < 5.039531899994073e+192

    1. Initial program 1.4

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

      \[\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) + \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}\]
    4. Applied sqrt-prod1.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) + \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}}}{2 \cdot a}\\ \end{array}\]
  3. Recombined 2 regimes into one program.

Runtime

Time bar (total: 1.1m)Debug logProfile

herbie shell --seed '#(1070960995 739739648 2531964651 3069671617 351857262 3877178482)' 
(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))))