Average Error: 28.3 → 5.1
Time: 6.5s
Precision: binary64
\[1.0536712127723509 \cdot 10^{-08} < a \land a < 94906265.62425156 \land 1.0536712127723509 \cdot 10^{-08} < b \land b < 94906265.62425156 \land 1.0536712127723509 \cdot 10^{-08} < c \land c < 94906265.62425156\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;b \leq 0.24703772097975585:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - 4 \cdot \left(a \cdot c\right)\right) - b \cdot b}{b + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(-2 \cdot \frac{\left(a \cdot a\right) \cdot {c}^{3}}{{b}^{5}} - \frac{\frac{a}{\sqrt{{b}^{3}}} \cdot \left(c \cdot c\right)}{\sqrt{{b}^{3}}}\right) - \frac{c}{b}\right) + \frac{{a}^{3} \cdot {c}^{4}}{{b}^{7}} \cdot -5\\ \end{array}\]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\begin{array}{l}
\mathbf{if}\;b \leq 0.24703772097975585:\\
\;\;\;\;\frac{\frac{\left(b \cdot b - 4 \cdot \left(a \cdot c\right)\right) - b \cdot b}{b + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}}{a \cdot 2}\\

\mathbf{else}:\\
\;\;\;\;\left(\left(-2 \cdot \frac{\left(a \cdot a\right) \cdot {c}^{3}}{{b}^{5}} - \frac{\frac{a}{\sqrt{{b}^{3}}} \cdot \left(c \cdot c\right)}{\sqrt{{b}^{3}}}\right) - \frac{c}{b}\right) + \frac{{a}^{3} \cdot {c}^{4}}{{b}^{7}} \cdot -5\\

\end{array}
(FPCore (a b c)
 :precision binary64
 (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
(FPCore (a b c)
 :precision binary64
 (if (<= b 0.24703772097975585)
   (/
    (/
     (- (- (* b b) (* 4.0 (* a c))) (* b b))
     (+ b (sqrt (- (* b b) (* 4.0 (* a c))))))
    (* a 2.0))
   (+
    (-
     (-
      (* -2.0 (/ (* (* a a) (pow c 3.0)) (pow b 5.0)))
      (/ (* (/ a (sqrt (pow b 3.0))) (* c c)) (sqrt (pow b 3.0))))
     (/ c b))
    (* (/ (* (pow a 3.0) (pow c 4.0)) (pow b 7.0)) -5.0))))
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) {
	double tmp;
	if (b <= 0.24703772097975585) {
		tmp = ((((b * b) - (4.0 * (a * c))) - (b * b)) / (b + sqrt((b * b) - (4.0 * (a * c))))) / (a * 2.0);
	} else {
		tmp = (((-2.0 * (((a * a) * pow(c, 3.0)) / pow(b, 5.0))) - (((a / sqrt(pow(b, 3.0))) * (c * c)) / sqrt(pow(b, 3.0)))) - (c / b)) + (((pow(a, 3.0) * pow(c, 4.0)) / pow(b, 7.0)) * -5.0);
	}
	return tmp;
}

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. Split input into 2 regimes
  2. if b < 0.24703772097975585

    1. Initial program 11.0

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

      \[\leadsto \color{blue}{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{a \cdot 2}}\]
    3. Using strategy rm
    4. Applied flip--_binary6411.1

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

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

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

    if 0.24703772097975585 < b

    1. Initial program 30.8

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

      \[\leadsto \color{blue}{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{a \cdot 2}}\]
    3. Taylor expanded around inf 4.4

      \[\leadsto \color{blue}{-\left(5 \cdot \frac{{a}^{3} \cdot {c}^{4}}{{b}^{7}} + \left(\frac{c}{b} + \left(\frac{a \cdot {c}^{2}}{{b}^{3}} + 2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}}\right)\right)\right)}\]
    4. Simplified4.4

      \[\leadsto \color{blue}{\left(\left(-2 \cdot \frac{\left(a \cdot a\right) \cdot {c}^{3}}{{b}^{5}} - \frac{a \cdot \left(c \cdot c\right)}{{b}^{3}}\right) - \frac{c}{b}\right) + \frac{{a}^{3} \cdot {c}^{4}}{{b}^{7}} \cdot -5}\]
    5. Using strategy rm
    6. Applied add-sqr-sqrt_binary644.4

      \[\leadsto \left(\left(-2 \cdot \frac{\left(a \cdot a\right) \cdot {c}^{3}}{{b}^{5}} - \frac{a \cdot \left(c \cdot c\right)}{\color{blue}{\sqrt{{b}^{3}} \cdot \sqrt{{b}^{3}}}}\right) - \frac{c}{b}\right) + \frac{{a}^{3} \cdot {c}^{4}}{{b}^{7}} \cdot -5\]
    7. Applied associate-/r*_binary644.4

      \[\leadsto \left(\left(-2 \cdot \frac{\left(a \cdot a\right) \cdot {c}^{3}}{{b}^{5}} - \color{blue}{\frac{\frac{a \cdot \left(c \cdot c\right)}{\sqrt{{b}^{3}}}}{\sqrt{{b}^{3}}}}\right) - \frac{c}{b}\right) + \frac{{a}^{3} \cdot {c}^{4}}{{b}^{7}} \cdot -5\]
    8. Simplified4.4

      \[\leadsto \left(\left(-2 \cdot \frac{\left(a \cdot a\right) \cdot {c}^{3}}{{b}^{5}} - \frac{\color{blue}{\frac{a}{\sqrt{{b}^{3}}} \cdot \left(c \cdot c\right)}}{\sqrt{{b}^{3}}}\right) - \frac{c}{b}\right) + \frac{{a}^{3} \cdot {c}^{4}}{{b}^{7}} \cdot -5\]
  3. Recombined 2 regimes into one program.
  4. Final simplification5.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 0.24703772097975585:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - 4 \cdot \left(a \cdot c\right)\right) - b \cdot b}{b + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(-2 \cdot \frac{\left(a \cdot a\right) \cdot {c}^{3}}{{b}^{5}} - \frac{\frac{a}{\sqrt{{b}^{3}}} \cdot \left(c \cdot c\right)}{\sqrt{{b}^{3}}}\right) - \frac{c}{b}\right) + \frac{{a}^{3} \cdot {c}^{4}}{{b}^{7}} \cdot -5\\ \end{array}\]

Alternatives

Reproduce

herbie shell --seed 2021110 
(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.0 a) c)))) (* 2.0 a)))