Average Error: 33.0 → 16.3
Time: 1.9m
Precision: 64
Internal Precision: 3456
\[\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 5.709051940510374 \cdot 10^{-27}:\\ \;\;\;\;(\left(\frac{1}{3 \cdot a}\right) \cdot \left(\sqrt{(\left(3 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*}\right) + \left(\frac{-b}{3 \cdot a}\right))_*\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{c}{-2}}{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 < 5.709051940510374e-27

    1. Initial program 21.4

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

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

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

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

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

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

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

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

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

    if 5.709051940510374e-27 < b

    1. Initial program 54.1

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

      \[\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 associate-/r*54.1

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

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

      \[\leadsto \frac{1}{\color{blue}{-2 \cdot \frac{b}{c}}}\]
    8. Applied simplify7.1

      \[\leadsto \color{blue}{\frac{\frac{c}{-2}}{b}}\]
  3. Recombined 2 regimes into one program.
  4. Applied simplify16.3

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \le 5.709051940510374 \cdot 10^{-27}:\\ \;\;\;\;(\left(\frac{1}{3 \cdot a}\right) \cdot \left(\sqrt{(\left(3 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*}\right) + \left(\frac{-b}{3 \cdot a}\right))_*\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{c}{-2}}{b}\\ \end{array}}\]

Runtime

Time bar (total: 1.9m)Debug logProfile

herbie shell --seed '#(1070960995 739739648 2531964651 3069671617 351857262 3877178482)' +o rules:numerics
(FPCore (a b c d)
  :name "Cubic critical"
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))