Average Error: 28.9 → 4.9
Time: 8.3s
Precision: binary64
\[1.0536712127723509 \cdot 10^{-08} < a \land a < 94906265.62425156 \land 1.0536712127723509 \cdot 10^{-08} < b \land b < 94906265.62425156 \land 1.0536712127723509 \cdot 10^{-08} < c \land c < 94906265.62425156\]
\[\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 0.06125406275388499:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - 3 \cdot \left(a \cdot c\right)\right) - b \cdot b}{b + \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{{a}^{3} \cdot {c}^{4}}{{b}^{7}} \cdot -1.0546875 - \left(0.5 \cdot \frac{c}{b} + \left(0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + 0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}}\right)\right)\\ \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 0.06125406275388499:\\
\;\;\;\;\frac{\frac{\left(b \cdot b - 3 \cdot \left(a \cdot c\right)\right) - b \cdot b}{b + \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}{3 \cdot a}\\

\mathbf{else}:\\
\;\;\;\;\frac{{a}^{3} \cdot {c}^{4}}{{b}^{7}} \cdot -1.0546875 - \left(0.5 \cdot \frac{c}{b} + \left(0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + 0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}}\right)\right)\\

\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 0.06125406275388499)
   (/
    (/
     (- (- (* b b) (* 3.0 (* a c))) (* b b))
     (+ b (sqrt (- (* b b) (* 3.0 (* a c))))))
    (* 3.0 a))
   (-
    (* (/ (* (pow a 3.0) (pow c 4.0)) (pow b 7.0)) -1.0546875)
    (+
     (* 0.5 (/ c b))
     (+
      (* 0.375 (/ (* a (pow c 2.0)) (pow b 3.0)))
      (* 0.5625 (/ (* (pow a 2.0) (pow c 3.0)) (pow b 5.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 <= 0.06125406275388499) {
		tmp = ((((b * b) - (3.0 * (a * c))) - (b * b)) / (b + sqrt((b * b) - (3.0 * (a * c))))) / (3.0 * a);
	} else {
		tmp = (((pow(a, 3.0) * pow(c, 4.0)) / pow(b, 7.0)) * -1.0546875) - ((0.5 * (c / b)) + ((0.375 * ((a * pow(c, 2.0)) / pow(b, 3.0))) + (0.5625 * ((pow(a, 2.0) * pow(c, 3.0)) / pow(b, 5.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 2 regimes
  2. if b < 0.0612540627538849872

    1. Initial program 9.7

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

      \[\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. Simplified8.8

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

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

    if 0.0612540627538849872 < b

    1. Initial program 30.8

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

      \[\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.5

      \[\leadsto \color{blue}{-\left(1.0546875 \cdot \frac{{a}^{3} \cdot {c}^{4}}{{b}^{7}} + \left(0.5 \cdot \frac{c}{b} + \left(0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + 0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}}\right)\right)\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification4.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 0.06125406275388499:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - 3 \cdot \left(a \cdot c\right)\right) - b \cdot b}{b + \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{{a}^{3} \cdot {c}^{4}}{{b}^{7}} \cdot -1.0546875 - \left(0.5 \cdot \frac{c}{b} + \left(0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + 0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}}\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2021139 
(FPCore (a b c)
  :name "Cubic critical, narrow range"
  :precision binary64
  :pre (and (< 1.0536712127723509e-08 a 94906265.62425156) (< 1.0536712127723509e-08 b 94906265.62425156) (< 1.0536712127723509e-08 c 94906265.62425156))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))