Average Error: 33.6 → 10.4
Time: 2.4m
Precision: 64
Internal Precision: 3392
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;\frac{-\frac{3}{2}}{b} \le -7.0810516630579515 \cdot 10^{-90}:\\ \;\;\;\;\frac{\frac{c \cdot \left(3 \cdot a\right)}{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(3 \cdot a\right)}}}{3 \cdot a}\\ \mathbf{if}\;\frac{-\frac{3}{2}}{b} \le 6.507037389072192 \cdot 10^{-296}:\\ \;\;\;\;\frac{c}{b} \cdot \frac{\frac{-3}{2}}{3}\\ \mathbf{if}\;\frac{-\frac{3}{2}}{b} \le 14777437.12612732:\\ \;\;\;\;\frac{\frac{a \cdot \frac{3}{2}}{\frac{b}{c}} - \left(b + b\right)}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{3 \cdot a} \cdot \left(\sqrt{b \cdot b - c \cdot \left(3 \cdot a\right)} + \left(-b\right)\right)\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Bits error versus d

Derivation

  1. Split input into 4 regimes
  2. if (/ (- 3/2) b) < -7.0810516630579515e-90

    1. Initial program 32.4

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Using strategy rm
    3. Applied flip-+32.5

      \[\leadsto \frac{\color{blue}{\frac{\left(-b\right) \cdot \left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}{3 \cdot a}\]
    4. Applied simplify16.9

      \[\leadsto \frac{\frac{\color{blue}{c \cdot \left(a \cdot 3\right)}}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\]

    if -7.0810516630579515e-90 < (/ (- 3/2) b) < 6.507037389072192e-296

    1. Initial program 58.1

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Taylor expanded around inf 15.6

      \[\leadsto \frac{\color{blue}{\frac{-3}{2} \cdot \frac{c \cdot a}{b}}}{3 \cdot a}\]
    3. Applied simplify4.6

      \[\leadsto \color{blue}{1 \cdot \left(\frac{c}{b} \cdot \frac{\frac{-3}{2}}{3}\right)}\]

    if 6.507037389072192e-296 < (/ (- 3/2) b) < 14777437.12612732

    1. Initial program 30.3

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Taylor expanded around -inf 12.5

      \[\leadsto \frac{\left(-b\right) + \color{blue}{\left(\frac{3}{2} \cdot \frac{c \cdot a}{b} - b\right)}}{3 \cdot a}\]
    3. Applied simplify8.9

      \[\leadsto \color{blue}{\frac{\frac{\frac{3}{2} \cdot a}{\frac{b}{c}} - \left(b + b\right)}{3 \cdot a}}\]

    if 14777437.12612732 < (/ (- 3/2) b)

    1. Initial program 9.7

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Using strategy rm
    3. Applied div-inv9.7

      \[\leadsto \color{blue}{\left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right) \cdot \frac{1}{3 \cdot a}}\]
  3. Recombined 4 regimes into one program.
  4. Applied simplify10.4

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;\frac{-\frac{3}{2}}{b} \le -7.0810516630579515 \cdot 10^{-90}:\\ \;\;\;\;\frac{\frac{c \cdot \left(3 \cdot a\right)}{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(3 \cdot a\right)}}}{3 \cdot a}\\ \mathbf{if}\;\frac{-\frac{3}{2}}{b} \le 6.507037389072192 \cdot 10^{-296}:\\ \;\;\;\;\frac{c}{b} \cdot \frac{\frac{-3}{2}}{3}\\ \mathbf{if}\;\frac{-\frac{3}{2}}{b} \le 14777437.12612732:\\ \;\;\;\;\frac{\frac{a \cdot \frac{3}{2}}{\frac{b}{c}} - \left(b + b\right)}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{3 \cdot a} \cdot \left(\sqrt{b \cdot b - c \cdot \left(3 \cdot a\right)} + \left(-b\right)\right)\\ \end{array}}\]

Runtime

Time bar (total: 2.4m)Debug logProfile

herbie shell --seed '#(1071373924 2949776965 1885069702 3247780810 90874544 2263903749)' +o rules:numerics
(FPCore (a b c d)
  :name "Cubic critical"
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))