Average Error: 33.5 → 9.8
Time: 2.9m
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 \cdot \frac{-2}{3} \le -2.1683233250760578 \cdot 10^{-48}:\\ \;\;\;\;\frac{\frac{-3}{2}}{3} \cdot \frac{c}{b}\\ \mathbf{if}\;b \cdot \frac{-2}{3} \le -1.6818441142097269 \cdot 10^{-102}:\\ \;\;\;\;\frac{1}{a \cdot 3} \cdot \left(\left(-b\right) + \sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)}\right)\\ \mathbf{if}\;b \cdot \frac{-2}{3} \le -5.091735158589211 \cdot 10^{-138}:\\ \;\;\;\;\frac{\frac{-3}{2}}{3} \cdot \frac{c}{b}\\ \mathbf{if}\;b \cdot \frac{-2}{3} \le 1.8102385683527764 \cdot 10^{+111}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}{3}}{a} - \frac{\frac{b}{3}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot \frac{-2}{3}}{a}\\ \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 (* -2/3 b) < -2.1683233250760578e-48 or -1.6818441142097269e-102 < (* -2/3 b) < -5.091735158589211e-138

    1. Initial program 52.1

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

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

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

    if -2.1683233250760578e-48 < (* -2/3 b) < -1.6818441142097269e-102

    1. Initial program 31.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-inv31.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}}\]

    if -5.091735158589211e-138 < (* -2/3 b) < 1.8102385683527764e+111

    1. Initial program 10.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*10.3

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

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

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

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

    if 1.8102385683527764e+111 < (* -2/3 b)

    1. Initial program 48.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*48.3

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

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

      \[\leadsto \frac{\color{blue}{\frac{-2}{3} \cdot b}}{a}\]
  3. Recombined 4 regimes into one program.
  4. Applied simplify9.8

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \cdot \frac{-2}{3} \le -2.1683233250760578 \cdot 10^{-48}:\\ \;\;\;\;\frac{\frac{-3}{2}}{3} \cdot \frac{c}{b}\\ \mathbf{if}\;b \cdot \frac{-2}{3} \le -1.6818441142097269 \cdot 10^{-102}:\\ \;\;\;\;\frac{1}{a \cdot 3} \cdot \left(\left(-b\right) + \sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)}\right)\\ \mathbf{if}\;b \cdot \frac{-2}{3} \le -5.091735158589211 \cdot 10^{-138}:\\ \;\;\;\;\frac{\frac{-3}{2}}{3} \cdot \frac{c}{b}\\ \mathbf{if}\;b \cdot \frac{-2}{3} \le 1.8102385683527764 \cdot 10^{+111}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}{3}}{a} - \frac{\frac{b}{3}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot \frac{-2}{3}}{a}\\ \end{array}}\]

Runtime

Time bar (total: 2.9m)Debug logProfile

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