Average Error: 43.8 → 0.2
Time: 13.2s
Precision: binary64
\[\left(\left(1.1102230246251565 \cdot 10^{-16} < a \land a < 9007199254740992\right) \land \left(1.1102230246251565 \cdot 10^{-16} < b \land b < 9007199254740992\right)\right) \land \left(1.1102230246251565 \cdot 10^{-16} < c \land c < 9007199254740992\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)}} \]
\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 43.8

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

    \[\leadsto \color{blue}{\left(\sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)} - b\right) \cdot \frac{0.3333333333333333}{a}} \]
  3. Applied flip--_binary6443.8

    \[\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} \]
  4. Applied associate-*l/_binary6443.8

    \[\leadsto \color{blue}{\frac{\left(\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\right) \cdot \frac{0.3333333333333333}{a}}{\sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)} + b}} \]
  5. Simplified0.5

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

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

    \[\leadsto \frac{\frac{\color{blue}{\left(-c\right) \cdot a}}{a}}{\sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)} + b} \]
  8. Applied add-sqr-sqrt_binary640.4

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

    \[\leadsto \frac{\frac{\left(-c\right) \cdot a}{a}}{\color{blue}{\mathsf{fma}\left(\sqrt{\sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}}, \sqrt{\sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}}, b\right)}} \]
  10. Applied *-un-lft-identity_binary640.3

    \[\leadsto \frac{\frac{\left(-c\right) \cdot a}{a}}{\color{blue}{1 \cdot \mathsf{fma}\left(\sqrt{\sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}}, \sqrt{\sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}}, b\right)}} \]
  11. Applied *-un-lft-identity_binary640.3

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

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

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

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

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

Reproduce

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