Average Error: 33.3 → 6.6
Time: 1.3m
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 -3.2253779719569066 \cdot 10^{+106}:\\ \;\;\;\;\frac{-2}{3} \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le -5.571754887817011 \cdot 10^{-297}:\\ \;\;\;\;\frac{1}{\frac{a \cdot 3}{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b}}\\ \mathbf{elif}\;b \le 3.0315580821352444 \cdot 10^{+148}:\\ \;\;\;\;\frac{-c}{b + \sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{-2 \cdot \frac{b}{c}}\\ \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 < -3.2253779719569066e+106

    1. Initial program 48.0

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Initial simplification48.0

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

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

    if -3.2253779719569066e+106 < b < -5.571754887817011e-297

    1. Initial program 8.1

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

      \[\leadsto \frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}\]
    3. Using strategy rm
    4. Applied clear-num8.2

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

    if -5.571754887817011e-297 < b < 3.0315580821352444e+148

    1. Initial program 33.3

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

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

      \[\leadsto \frac{\color{blue}{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b \cdot b}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + b}}}{3 \cdot a}\]
    5. Applied associate-/l/37.7

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

      \[\leadsto \frac{\color{blue}{\left(-c\right) \cdot \left(3 \cdot a\right)}}{\left(3 \cdot a\right) \cdot \left(\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + b\right)}\]
    7. Using strategy rm
    8. Applied distribute-lft-neg-out19.8

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

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

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

    if 3.0315580821352444e+148 < b

    1. Initial program 62.1

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

      \[\leadsto \frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}\]
    3. Using strategy rm
    4. Applied clear-num62.1

      \[\leadsto \color{blue}{\frac{1}{\frac{3 \cdot a}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}}}\]
    5. Taylor expanded around 0 2.6

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -3.2253779719569066 \cdot 10^{+106}:\\ \;\;\;\;\frac{-2}{3} \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le -5.571754887817011 \cdot 10^{-297}:\\ \;\;\;\;\frac{1}{\frac{a \cdot 3}{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b}}\\ \mathbf{elif}\;b \le 3.0315580821352444 \cdot 10^{+148}:\\ \;\;\;\;\frac{-c}{b + \sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{-2 \cdot \frac{b}{c}}\\ \end{array}\]

Runtime

Time bar (total: 1.3m)Debug logProfile

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