Average Error: 19.2 → 12.4
Time: 1.1m
Precision: 64
Internal Precision: 320
\[\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{\left(4 \cdot c\right) \cdot a}{\sqrt{(\left(-c\right) \cdot \left(4 \cdot a\right) + \left(b \cdot b\right))_*} - b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b}{a \cdot 2}\\ \end{array} \le -6.002826656229516 \cdot 10^{+278}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{c}{(\left(\frac{c}{b}\right) \cdot a + \left(-b\right))_*}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{(\left(-c\right) \cdot \left(4 \cdot a\right) + \left(b \cdot b\right))_*} - b}{2 \cdot a}\\ \end{array}\\ \mathbf{if}\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\frac{\left(4 \cdot c\right) \cdot a}{\sqrt{(\left(-c\right) \cdot \left(4 \cdot a\right) + \left(b \cdot b\right))_*} - b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b}{a \cdot 2}\\ \end{array} \le 3.84801378214129 \cdot 10^{+276}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b} \cdot \sqrt{\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b}}{a \cdot 2}\\ \end{array}\\ \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{c}{(\left(\frac{c}{b}\right) \cdot a + \left(-b\right))_*}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{(\left(-c\right) \cdot \left(4 \cdot a\right) + \left(b \cdot b\right))_*} - b}{2 \cdot a}\\ \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) (/ (* (* 4 c) a) (- (sqrt (fma (- c) (* 4 a) (* b b))) b))) (/ (- (sqrt (fma (* 4 a) (- c) (* b b))) b) (* a 2))) < -6.002826656229516e+278 or 3.84801378214129e+276 < (if (>= b 0) (/ (* 2 c) (/ (* (* 4 c) a) (- (sqrt (fma (- c) (* 4 a) (* b b))) b))) (/ (- (sqrt (fma (* 4 a) (- c) (* b b))) b) (* a 2)))

    1. Initial program 44.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. Applied simplify44.0

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

      \[\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{\sqrt{(\left(4 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b}{a \cdot 2}\\ \end{array}\]
    4. Applied simplify27.5

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

    if -6.002826656229516e+278 < (if (>= b 0) (/ (* 2 c) (/ (* (* 4 c) a) (- (sqrt (fma (- c) (* 4 a) (* b b))) b))) (/ (- (sqrt (fma (* 4 a) (- c) (* b b))) b) (* a 2))) < 3.84801378214129e+276

    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. Applied simplify1.4

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

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

Runtime

Time bar (total: 1.1m)Debug logProfile

herbie shell --seed '#(1071852389 864846987 1238109217 3425890003 4124793586 650694553)' +o rules:numerics
(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))))