Average Error: 33.2 → 22.4
Time: 1.5m
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}\;b \le 1.5305926060395946 \cdot 10^{-53}:\\ \;\;\;\;\frac{1}{3} \cdot \frac{\sqrt{{b}^{2} - 3 \cdot \left(c \cdot a\right)} - b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\left(a \cdot 3\right) \cdot \left(-c\right)}{a \cdot 3}}{\sqrt{(\left(3 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} + b}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Bits error versus d

Derivation

  1. Split input into 2 regimes
  2. if b < 1.5305926060395946e-53

    1. Initial program 21.5

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Applied simplify21.5

      \[\leadsto \color{blue}{\frac{\sqrt{(\left(3 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b}{3 \cdot a}}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity21.5

      \[\leadsto \frac{\color{blue}{1 \cdot \left(\sqrt{(\left(3 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b\right)}}{3 \cdot a}\]
    5. Applied times-frac21.6

      \[\leadsto \color{blue}{\frac{1}{3} \cdot \frac{\sqrt{(\left(3 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b}{a}}\]
    6. Taylor expanded around 0 21.5

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

    if 1.5305926060395946e-53 < b

    1. Initial program 52.8

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Applied simplify52.8

      \[\leadsto \color{blue}{\frac{\sqrt{(\left(3 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b}{3 \cdot a}}\]
    3. Using strategy rm
    4. Applied div-inv52.8

      \[\leadsto \color{blue}{\left(\sqrt{(\left(3 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b\right) \cdot \frac{1}{3 \cdot a}}\]
    5. Using strategy rm
    6. Applied flip--52.9

      \[\leadsto \color{blue}{\frac{\sqrt{(\left(3 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} \cdot \sqrt{(\left(3 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b \cdot b}{\sqrt{(\left(3 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} + b}} \cdot \frac{1}{3 \cdot a}\]
    7. Applied associate-*l/52.9

      \[\leadsto \color{blue}{\frac{\left(\sqrt{(\left(3 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} \cdot \sqrt{(\left(3 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b \cdot b\right) \cdot \frac{1}{3 \cdot a}}{\sqrt{(\left(3 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} + b}}\]
    8. Applied simplify23.9

      \[\leadsto \frac{\color{blue}{\frac{\left(a \cdot 3\right) \cdot \left(-c\right)}{a \cdot 3}}}{\sqrt{(\left(3 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} + b}\]
  3. Recombined 2 regimes into one program.

Runtime

Time bar (total: 1.5m)Debug logProfile

herbie shell --seed '#(1071246582 2318319007 2683472949 3810440501 3233274817 2724848749)' +o rules:numerics
(FPCore (a b c d)
  :name "Cubic critical"
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))