Average Error: 33.4 → 8.9
Time: 37.6s
Precision: 64
Internal Precision: 128
\[\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.9917452429919785 \cdot 10^{+149}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b} - \frac{b}{a} \cdot \frac{2}{3}\\ \mathbf{elif}\;b \le 9.853261051747485 \cdot 10^{-117}:\\ \;\;\;\;\frac{\sqrt{\left(-3 \cdot a\right) \cdot c + b \cdot b} - b}{a \cdot 3}\\ \mathbf{elif}\;b \le 2.4259893438094626 \cdot 10^{+83}:\\ \;\;\;\;\frac{\frac{3 \cdot \left(c \cdot a\right)}{\left(\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)}\right) \cdot 3}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} \cdot \frac{-1}{2}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Bits error versus d

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 4 regimes
  2. if b < -1.9917452429919785e+149

    1. Initial program 58.9

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

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{c}{b} - \frac{2}{3} \cdot \frac{b}{a}}\]

    if -1.9917452429919785e+149 < b < 9.853261051747485e-117

    1. Initial program 11.3

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

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

      \[\leadsto \frac{\left(-b\right) + \color{blue}{1 \cdot \sqrt{{b}^{2} - 3 \cdot \left(a \cdot c\right)}}}{3 \cdot a}\]
    5. Applied *-un-lft-identity11.3

      \[\leadsto \frac{\color{blue}{1 \cdot \left(-b\right)} + 1 \cdot \sqrt{{b}^{2} - 3 \cdot \left(a \cdot c\right)}}{3 \cdot a}\]
    6. Applied distribute-lft-out11.3

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

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

    if 9.853261051747485e-117 < b < 2.4259893438094626e+83

    1. Initial program 40.3

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Using strategy rm
    3. Applied associate-/r*40.3

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

      \[\leadsto \frac{\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}}{a}\]
    6. Applied associate-/l/40.4

      \[\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}}{3 \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}}{a}\]
    7. Simplified15.7

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

    if 2.4259893438094626e+83 < b

    1. Initial program 58.0

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

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

      \[\leadsto \color{blue}{\frac{-1}{2} \cdot \frac{c}{b}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification8.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.9917452429919785 \cdot 10^{+149}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b} - \frac{b}{a} \cdot \frac{2}{3}\\ \mathbf{elif}\;b \le 9.853261051747485 \cdot 10^{-117}:\\ \;\;\;\;\frac{\sqrt{\left(-3 \cdot a\right) \cdot c + b \cdot b} - b}{a \cdot 3}\\ \mathbf{elif}\;b \le 2.4259893438094626 \cdot 10^{+83}:\\ \;\;\;\;\frac{\frac{3 \cdot \left(c \cdot a\right)}{\left(\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)}\right) \cdot 3}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} \cdot \frac{-1}{2}\\ \end{array}\]

Runtime

Time bar (total: 37.6s)Debug logProfile

herbie shell --seed 2018296 
(FPCore (a b c d)
  :name "Cubic critical"
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))