Average Error: 28.4 → 0.3
Time: 4.6s
Precision: 64
\[1.05367121277235087 \cdot 10^{-8} \lt a \lt 94906265.6242515594 \land 1.05367121277235087 \cdot 10^{-8} \lt b \lt 94906265.6242515594 \land 1.05367121277235087 \cdot 10^{-8} \lt c \lt 94906265.6242515594\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
\[\frac{\frac{\mathsf{fma}\left(4 \cdot c, a, 0\right)}{a}}{\left(b + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right) \cdot \left(-2\right)}\]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\frac{\frac{\mathsf{fma}\left(4 \cdot c, a, 0\right)}{a}}{\left(b + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right) \cdot \left(-2\right)}
double code(double a, double b, double c) {
	return ((-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a));
}
double code(double a, double b, double c) {
	return ((fma((4.0 * c), a, 0.0) / a) / ((b + sqrt(((b * b) - ((4.0 * a) * c)))) * -2.0));
}

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 28.4

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
  2. Using strategy rm
  3. Applied flip-+28.4

    \[\leadsto \frac{\color{blue}{\frac{\left(-b\right) \cdot \left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}{2 \cdot a}\]
  4. Simplified0.4

    \[\leadsto \frac{\frac{\color{blue}{\mathsf{fma}\left(4 \cdot c, a, 0\right)}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\]
  5. Using strategy rm
  6. Applied frac-2neg0.4

    \[\leadsto \frac{\color{blue}{\frac{-\mathsf{fma}\left(4 \cdot c, a, 0\right)}{-\left(\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}}}{2 \cdot a}\]
  7. Applied associate-/l/0.4

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

    \[\leadsto \frac{-\mathsf{fma}\left(4 \cdot c, a, 0\right)}{\color{blue}{\left(b + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right) \cdot \left(2 \cdot a\right)}}\]
  9. Using strategy rm
  10. Applied *-commutative0.4

    \[\leadsto \frac{-\mathsf{fma}\left(4 \cdot c, a, 0\right)}{\left(b + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right) \cdot \color{blue}{\left(a \cdot 2\right)}}\]
  11. Applied associate-*r*0.4

    \[\leadsto \frac{-\mathsf{fma}\left(4 \cdot c, a, 0\right)}{\color{blue}{\left(\left(b + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right) \cdot a\right) \cdot 2}}\]
  12. Applied neg-mul-10.4

    \[\leadsto \frac{\color{blue}{-1 \cdot \mathsf{fma}\left(4 \cdot c, a, 0\right)}}{\left(\left(b + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right) \cdot a\right) \cdot 2}\]
  13. Applied times-frac0.5

    \[\leadsto \color{blue}{\frac{-1}{\left(b + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right) \cdot a} \cdot \frac{\mathsf{fma}\left(4 \cdot c, a, 0\right)}{2}}\]
  14. Using strategy rm
  15. Applied frac-2neg0.5

    \[\leadsto \frac{-1}{\left(b + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right) \cdot a} \cdot \color{blue}{\frac{-\mathsf{fma}\left(4 \cdot c, a, 0\right)}{-2}}\]
  16. Applied *-commutative0.5

    \[\leadsto \frac{-1}{\color{blue}{a \cdot \left(b + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}} \cdot \frac{-\mathsf{fma}\left(4 \cdot c, a, 0\right)}{-2}\]
  17. Applied associate-/r*0.5

    \[\leadsto \color{blue}{\frac{\frac{-1}{a}}{b + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}} \cdot \frac{-\mathsf{fma}\left(4 \cdot c, a, 0\right)}{-2}\]
  18. Applied frac-times0.5

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

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

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

Reproduce

herbie shell --seed 2020078 +o rules:numerics
(FPCore (a b c)
  :name "Quadratic roots, narrow range"
  :precision binary64
  :pre (and (< 1.0536712127723509e-08 a 94906265.62425156) (< 1.0536712127723509e-08 b 94906265.62425156) (< 1.0536712127723509e-08 c 94906265.62425156))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))