Average Error: 52.8 → 0.1
Time: 11.9s
Precision: binary64
\[\left(\left(4.930380657631324 \cdot 10^{-32} < a \land a < 2.028240960365167 \cdot 10^{+31}\right) \land \left(4.930380657631324 \cdot 10^{-32} < b \land b < 2.028240960365167 \cdot 10^{+31}\right)\right) \land \left(4.930380657631324 \cdot 10^{-32} < c \land c < 2.028240960365167 \cdot 10^{+31}\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 52.8

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
  2. Simplified52.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--_binary6452.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/_binary6452.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 div-inv_binary640.5

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

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

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

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

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

    \[\leadsto \frac{\left(\color{blue}{{\left(-c\right)}^{1}} \cdot {a}^{1}\right) \cdot {\left(\frac{1}{a}\right)}^{1}}{\sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)} + b} \]
  12. Applied pow-prod-down_binary640.3

    \[\leadsto \frac{\color{blue}{{\left(\left(-c\right) \cdot a\right)}^{1}} \cdot {\left(\frac{1}{a}\right)}^{1}}{\sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)} + b} \]
  13. Applied pow-prod-down_binary640.3

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

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

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

Reproduce

herbie shell --seed 2022063 
(FPCore (a b c)
  :name "Cubic critical, wide range"
  :precision binary64
  :pre (and (and (and (< 4.930380657631324e-32 a) (< a 2.028240960365167e+31)) (and (< 4.930380657631324e-32 b) (< b 2.028240960365167e+31))) (and (< 4.930380657631324e-32 c) (< c 2.028240960365167e+31)))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))