Average Error: 44.0 → 6.0
Time: 6.7s
Precision: binary64
\[1.1102230246251565 \cdot 10^{-16} < a \land a < 9007199254740992 \land 1.1102230246251565 \cdot 10^{-16} < b \land b < 9007199254740992 \land 1.1102230246251565 \cdot 10^{-16} < c \land c < 9007199254740992\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
\[\frac{c}{b} \cdot -0.5 + \frac{a \cdot \left(c \cdot c\right)}{{b}^{3}} \cdot -0.375\]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\frac{c}{b} \cdot -0.5 + \frac{a \cdot \left(c \cdot c\right)}{{b}^{3}} \cdot -0.375
(FPCore (a b c)
 :precision binary64
 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
(FPCore (a b c)
 :precision binary64
 (+ (* (/ c b) -0.5) (* (/ (* a (* c c)) (pow b 3.0)) -0.375)))
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) {
	return ((c / b) * -0.5) + (((a * (c * c)) / pow(b, 3.0)) * -0.375);
}

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. Initial program 44.0

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

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

    \[\leadsto \color{blue}{-\left(0.5 \cdot \frac{c}{b} + 0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}}\right)}\]
  4. Simplified6.0

    \[\leadsto \color{blue}{\frac{c}{b} \cdot -0.5 + \frac{a \cdot \left(c \cdot c\right)}{{b}^{3}} \cdot -0.375}\]
  5. Final simplification6.0

    \[\leadsto \frac{c}{b} \cdot -0.5 + \frac{a \cdot \left(c \cdot c\right)}{{b}^{3}} \cdot -0.375\]

Reproduce

herbie shell --seed 2020339 
(FPCore (a b c)
  :name "Cubic critical, medium range"
  :precision binary64
  :pre (and (< 1.1102230246251565e-16 a 9007199254740992.0) (< 1.1102230246251565e-16 b 9007199254740992.0) (< 1.1102230246251565e-16 c 9007199254740992.0))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))