Average Error: 33.6 → 9.6
Time: 5.5s
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 -1.3543978985140437 \cdot 10^{+138}:\\ \;\;\;\;\frac{\left(1.5 \cdot \frac{a \cdot c}{b} - b\right) - b}{a \cdot 3}\\ \mathbf{elif}\;b \leq -1.0583505148364568 \cdot 10^{-306}:\\ \;\;\;\;\frac{\sqrt{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b} \cdot \sqrt{\sqrt[3]{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)}} \cdot \left(\sqrt[3]{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)}} \cdot \sqrt[3]{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)}}\right) - b}}{a \cdot 3}\\ \mathbf{elif}\;b \leq 4.6929395429942243 \cdot 10^{+154}:\\ \;\;\;\;0.3333333333333333 \cdot \frac{c \cdot -3}{b + \sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{a \cdot \left(c \cdot -3\right)}{b + \left(b - 1.5 \cdot \frac{a \cdot c}{b}\right)}}{a \cdot 3}\\ \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 -1.3543978985140437 \cdot 10^{+138}:\\
\;\;\;\;\frac{\left(1.5 \cdot \frac{a \cdot c}{b} - b\right) - b}{a \cdot 3}\\

\mathbf{elif}\;b \leq -1.0583505148364568 \cdot 10^{-306}:\\
\;\;\;\;\frac{\sqrt{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b} \cdot \sqrt{\sqrt[3]{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)}} \cdot \left(\sqrt[3]{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)}} \cdot \sqrt[3]{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)}}\right) - b}}{a \cdot 3}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{a \cdot \left(c \cdot -3\right)}{b + \left(b - 1.5 \cdot \frac{a \cdot c}{b}\right)}}{a \cdot 3}\\

\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 -1.3543978985140437e+138)
   (/ (- (- (* 1.5 (/ (* a c) b)) b) b) (* a 3.0))
   (if (<= b -1.0583505148364568e-306)
     (/
      (*
       (sqrt (- (sqrt (- (* b b) (* c (* a 3.0)))) b))
       (sqrt
        (-
         (*
          (cbrt (sqrt (- (* b b) (* c (* a 3.0)))))
          (*
           (cbrt (sqrt (- (* b b) (* c (* a 3.0)))))
           (cbrt (sqrt (- (* b b) (* c (* a 3.0)))))))
         b)))
      (* a 3.0))
     (if (<= b 4.6929395429942243e+154)
       (*
        0.3333333333333333
        (/ (* c -3.0) (+ b (sqrt (- (* b b) (* c (* a 3.0)))))))
       (/ (/ (* a (* c -3.0)) (+ b (- b (* 1.5 (/ (* a c) b))))) (* a 3.0))))))
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 <= -1.3543978985140437e+138) {
		tmp = (((1.5 * ((a * c) / b)) - b) - b) / (a * 3.0);
	} else if (b <= -1.0583505148364568e-306) {
		tmp = (sqrt(sqrt((b * b) - (c * (a * 3.0))) - b) * sqrt((cbrt(sqrt((b * b) - (c * (a * 3.0)))) * (cbrt(sqrt((b * b) - (c * (a * 3.0)))) * cbrt(sqrt((b * b) - (c * (a * 3.0)))))) - b)) / (a * 3.0);
	} else if (b <= 4.6929395429942243e+154) {
		tmp = 0.3333333333333333 * ((c * -3.0) / (b + sqrt((b * b) - (c * (a * 3.0)))));
	} else {
		tmp = ((a * (c * -3.0)) / (b + (b - (1.5 * ((a * c) / b))))) / (a * 3.0);
	}
	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 < -1.35439789851404366e138

    1. Initial program 57.3

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

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

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

    if -1.35439789851404366e138 < b < -1.0583505148364568e-306

    1. Initial program 8.8

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

      \[\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 add-sqr-sqrt_binary649.0

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

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

    if -1.0583505148364568e-306 < b < 4.6929395429942243e154

    1. Initial program 34.1

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Simplified34.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 flip--_binary6434.1

      \[\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. Simplified15.0

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

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

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

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

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

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

    if 4.6929395429942243e154 < b

    1. Initial program 64.0

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

      \[\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 flip--_binary6464.0

      \[\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. Simplified37.1

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

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

      \[\leadsto \frac{\frac{a \cdot \left(c \cdot -3\right)}{b + \color{blue}{\left(b - 1.5 \cdot \frac{a \cdot c}{b}\right)}}}{3 \cdot a}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification9.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -1.3543978985140437 \cdot 10^{+138}:\\ \;\;\;\;\frac{\left(1.5 \cdot \frac{a \cdot c}{b} - b\right) - b}{a \cdot 3}\\ \mathbf{elif}\;b \leq -1.0583505148364568 \cdot 10^{-306}:\\ \;\;\;\;\frac{\sqrt{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b} \cdot \sqrt{\sqrt[3]{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)}} \cdot \left(\sqrt[3]{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)}} \cdot \sqrt[3]{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)}}\right) - b}}{a \cdot 3}\\ \mathbf{elif}\;b \leq 4.6929395429942243 \cdot 10^{+154}:\\ \;\;\;\;0.3333333333333333 \cdot \frac{c \cdot -3}{b + \sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{a \cdot \left(c \cdot -3\right)}{b + \left(b - 1.5 \cdot \frac{a \cdot c}{b}\right)}}{a \cdot 3}\\ \end{array}\]

Reproduce

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