Average Error: 28.5 → 0.3
Time: 8.7s
Precision: binary64
\[1.0536712127723509 \cdot 10^{-8} < a \land a < 94906265.62425156 \land 1.0536712127723509 \cdot 10^{-8} < b \land b < 94906265.62425156 \land 1.0536712127723509 \cdot 10^{-8} < c \land c < 94906265.62425156\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
\[\frac{-c}{b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}} \]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\frac{-c}{b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}}
(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 (sqrt (fma a (* c -3.0) (* b 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) {
	return -c / (b + sqrt(fma(a, (c * -3.0), (b * b))));
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Initial program 28.5

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

    \[\leadsto \color{blue}{\left(\sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)} - b\right) \cdot \frac{0.3333333333333333}{a}} \]
  3. Using strategy rm
  4. Applied flip--_binary6428.5

    \[\leadsto \color{blue}{\frac{\sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)} \cdot \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)} - b \cdot b}{\sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)} + b}} \cdot \frac{0.3333333333333333}{a} \]
  5. Simplified0.6

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

    \[\leadsto \frac{c \cdot \left(a \cdot -3\right) + 0}{\color{blue}{b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}}} \cdot \frac{0.3333333333333333}{a} \]
  7. Using strategy rm
  8. Applied associate-*l/_binary640.6

    \[\leadsto \color{blue}{\frac{\left(c \cdot \left(a \cdot -3\right) + 0\right) \cdot \frac{0.3333333333333333}{a}}{b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}}} \]
  9. Simplified0.3

    \[\leadsto \frac{\color{blue}{\frac{c \cdot \left(-a\right)}{a}}}{b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}} \]
  10. Using strategy rm
  11. Applied distribute-rgt-neg-out_binary640.3

    \[\leadsto \frac{\frac{\color{blue}{-c \cdot a}}{a}}{b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}} \]
  12. Applied distribute-frac-neg_binary640.3

    \[\leadsto \frac{\color{blue}{-\frac{c \cdot a}{a}}}{b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}} \]
  13. Applied distribute-frac-neg_binary640.3

    \[\leadsto \color{blue}{-\frac{\frac{c \cdot a}{a}}{b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}}} \]
  14. Applied distribute-neg-frac_binary640.3

    \[\leadsto \color{blue}{\frac{-\frac{c \cdot a}{a}}{b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}}} \]
  15. Simplified0.3

    \[\leadsto \frac{\color{blue}{-c}}{b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}} \]
  16. Final simplification0.3

    \[\leadsto \frac{-c}{b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}} \]

Reproduce

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