Average Error: 52.4 → 0.1
Time: 6.1s
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.4

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

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

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

    \[\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 *-un-lft-identity_binary640.5

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

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

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

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

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

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

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

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

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

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

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

Reproduce

herbie shell --seed 2021280 
(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)))