Average Error: 34.7 → 10.3
Time: 13.8s
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 -4.439880162502227 \cdot 10^{+90}:\\ \;\;\;\;\frac{\frac{b \cdot -2}{3}}{a}\\ \mathbf{elif}\;b \leq 1.3752342204584442 \cdot 10^{-108}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}\\ \mathbf{elif}\;b \leq 7.728774522489216 \cdot 10^{+106}:\\ \;\;\;\;a \cdot \frac{-\frac{c}{b + \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}{a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \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 -4.439880162502227 \cdot 10^{+90}:\\
\;\;\;\;\frac{\frac{b \cdot -2}{3}}{a}\\

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

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

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

\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 -4.439880162502227e+90)
   (/ (/ (* b -2.0) 3.0) a)
   (if (<= b 1.3752342204584442e-108)
     (/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) (* 3.0 a))
     (if (<= b 7.728774522489216e+106)
       (* a (/ (- (/ c (+ b (sqrt (- (* b b) (* 3.0 (* a c))))))) a))
       (* -0.5 (/ c b))))))
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 <= -4.439880162502227e+90) {
		tmp = ((b * -2.0) / 3.0) / a;
	} else if (b <= 1.3752342204584442e-108) {
		tmp = (sqrt((b * b) - ((3.0 * a) * c)) - b) / (3.0 * a);
	} else if (b <= 7.728774522489216e+106) {
		tmp = a * (-(c / (b + sqrt((b * b) - (3.0 * (a * c))))) / a);
	} else {
		tmp = -0.5 * (c / b);
	}
	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 < -4.4398801625022268e90

    1. Initial program 45.7

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

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

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

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

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

    if -4.4398801625022268e90 < b < 1.37523422045844416e-108

    1. Initial program 12.7

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

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

    if 1.37523422045844416e-108 < b < 7.72877452248921616e106

    1. Initial program 41.7

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

      \[\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 associate-/r*_binary64_206841.8

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

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

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

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

      \[\leadsto \frac{\frac{\frac{a \cdot \left(c \cdot -3\right)}{\color{blue}{b + \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}}{3}}{a}\]
    10. Using strategy rm
    11. Applied *-un-lft-identity_binary64_212414.7

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

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

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

      \[\leadsto \frac{\frac{\color{blue}{\frac{a}{1} \cdot \frac{c \cdot -3}{b + \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}}{1 \cdot 3}}{1 \cdot a}\]
    15. Applied times-frac_binary64_213013.2

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

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

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

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

    if 7.72877452248921616e106 < b

    1. Initial program 59.7

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -4.439880162502227 \cdot 10^{+90}:\\ \;\;\;\;\frac{\frac{b \cdot -2}{3}}{a}\\ \mathbf{elif}\;b \leq 1.3752342204584442 \cdot 10^{-108}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}\\ \mathbf{elif}\;b \leq 7.728774522489216 \cdot 10^{+106}:\\ \;\;\;\;a \cdot \frac{-\frac{c}{b + \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}{a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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