Average Error: 33.5 → 6.5
Time: 15.2s
Precision: binary64
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;b \leq -6.595237172330028 \cdot 10^{+80}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \leq -6.630631873525022 \cdot 10^{-297}:\\ \;\;\;\;\frac{1}{\frac{3}{\frac{\sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)} - b}{a}}}\\ \mathbf{elif}\;b \leq 3.1370236091553266 \cdot 10^{+85}:\\ \;\;\;\;\frac{c}{\frac{b + \sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)}}{\frac{-a}{a}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} \cdot -0.5\\ \end{array}\]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\begin{array}{l}
\mathbf{if}\;b \leq -6.595237172330028 \cdot 10^{+80}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666 \cdot \frac{b}{a}\\

\mathbf{elif}\;b \leq -6.630631873525022 \cdot 10^{-297}:\\
\;\;\;\;\frac{1}{\frac{3}{\frac{\sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)} - b}{a}}}\\

\mathbf{elif}\;b \leq 3.1370236091553266 \cdot 10^{+85}:\\
\;\;\;\;\frac{c}{\frac{b + \sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)}}{\frac{-a}{a}}}\\

\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\

\end{array}
(FPCore (a b c)
 :precision binary64
 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
(FPCore (a b c)
 :precision binary64
 (if (<= b -6.595237172330028e+80)
   (- (* 0.5 (/ c b)) (* 0.6666666666666666 (/ b a)))
   (if (<= b -6.630631873525022e-297)
     (/ 1.0 (/ 3.0 (/ (- (sqrt (- (* b b) (* 3.0 (* c a)))) b) a)))
     (if (<= b 3.1370236091553266e+85)
       (/ c (/ (+ b (sqrt (- (* b b) (* 3.0 (* c a))))) (/ (- a) a)))
       (* (/ c b) -0.5)))))
double code(double a, double b, double c) {
	return (-b + sqrt((b * b) - ((3.0 * a) * c))) / (3.0 * a);
}
double code(double a, double b, double c) {
	double tmp;
	if (b <= -6.595237172330028e+80) {
		tmp = (0.5 * (c / b)) - (0.6666666666666666 * (b / a));
	} else if (b <= -6.630631873525022e-297) {
		tmp = 1.0 / (3.0 / ((sqrt((b * b) - (3.0 * (c * a))) - b) / a));
	} else if (b <= 3.1370236091553266e+85) {
		tmp = c / ((b + sqrt((b * b) - (3.0 * (c * a)))) / (-a / a));
	} else {
		tmp = (c / b) * -0.5;
	}
	return tmp;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 4 regimes
  2. if b < -6.59523717233002765e80

    1. Initial program 43.5

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{c}{b} - 0.6666666666666666 \cdot \frac{b}{a}}\]

    if -6.59523717233002765e80 < b < -6.63063187352502212e-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. Simplified8.1

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

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

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

    if -6.63063187352502212e-297 < b < 3.13702360915532657e85

    1. Initial program 31.1

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

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

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

      \[\leadsto \left(\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b\right) \cdot \color{blue}{\frac{0.3333333333333333}{a}}\]
    6. Using strategy rm
    7. Applied flip--_binary64_141731.2

      \[\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}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + b}} \cdot \frac{0.3333333333333333}{a}\]
    8. Simplified16.0

      \[\leadsto \frac{\color{blue}{c \cdot \left(-3 \cdot a\right)}}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + b} \cdot \frac{0.3333333333333333}{a}\]
    9. Using strategy rm
    10. Applied pow1_binary64_150316.0

      \[\leadsto \frac{c \cdot \left(-3 \cdot a\right)}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + b} \cdot \color{blue}{{\left(\frac{0.3333333333333333}{a}\right)}^{1}}\]
    11. Applied pow1_binary64_150316.0

      \[\leadsto \color{blue}{{\left(\frac{c \cdot \left(-3 \cdot a\right)}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + b}\right)}^{1}} \cdot {\left(\frac{0.3333333333333333}{a}\right)}^{1}\]
    12. Applied pow-prod-down_binary64_151316.0

      \[\leadsto \color{blue}{{\left(\frac{c \cdot \left(-3 \cdot a\right)}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + b} \cdot \frac{0.3333333333333333}{a}\right)}^{1}}\]
    13. Simplified8.8

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

    if 3.13702360915532657e85 < b

    1. Initial program 58.6

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -6.595237172330028 \cdot 10^{+80}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \leq -6.630631873525022 \cdot 10^{-297}:\\ \;\;\;\;\frac{1}{\frac{3}{\frac{\sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)} - b}{a}}}\\ \mathbf{elif}\;b \leq 3.1370236091553266 \cdot 10^{+85}:\\ \;\;\;\;\frac{c}{\frac{b + \sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)}}{\frac{-a}{a}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} \cdot -0.5\\ \end{array}\]

Reproduce

herbie shell --seed 2021032 
(FPCore (a b c)
  :name "Cubic critical"
  :precision binary64
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))