Average Error: 20.1 → 6.0
Time: 41.6s
Precision: 64
Internal precision: 128
\[\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}\\ \end{array}\]
\[\begin{array}{l} \mathbf{if}\;b \le -6.68779020034681 \cdot 10^{+139}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{a + a}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{a}{b} - \frac{b}{c}}\\ \end{array}\\ \mathbf{if}\;b \le 1.0905893076356243 \cdot 10^{+100}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + {\left(\sqrt{\sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}\right)}^2}\\ \end{array}\\ \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c + c}{\sqrt{{b}^2 - \left(a \cdot 4\right) \cdot c} + \left(-b\right)}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 3 regimes.
  2. if b < -6.68779020034681e+139

    1. Initial program 36.3

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

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{a + a}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{a \cdot \frac{c}{b} - b}{c}}\\ \end{array}\]
    7. Applied simplify 0.7

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

    if -6.68779020034681e+139 < b < 1.0905893076356243e+100

    1. Initial program 8.9

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

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

    if 1.0905893076356243e+100 < b

    1. Initial program 44.9

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

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

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

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

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

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

Runtime

Time bar (total: 41.6s) Debug log

Please include this information when filing a bug report:

herbie --seed '#(123808518 2218013225 1756950217 1769879623 1932823857 3195783140)'
(FPCore (a b c)
  :name "jeff quadratic root 1"
  (if (>= b 0) (/ (- (- b) (sqrt (- (sqr b) (* (* 4 a) c)))) (* 2 a)) (/ (* 2 c) (+ (- b) (sqrt (- (sqr b) (* (* 4 a) c)))))))