Average Error: 34.5 → 6.8
Time: 1.1min
Precision: binary64
\[\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 -4.266218223523121 \cdot 10^{+118}:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{elif}\;b \leq -6.989967742266468 \cdot 10^{-286}:\\ \;\;\;\;\frac{1}{\frac{a}{\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{2}}}\\ \mathbf{elif}\;b \leq 2.1921691367601414 \cdot 10^{+102}:\\ \;\;\;\;\frac{1}{\frac{a}{-a \cdot 4}} \cdot \frac{\frac{c}{b + \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}}}{2}\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \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 -4.266218223523121 \cdot 10^{+118}:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\

\mathbf{elif}\;b \leq -6.989967742266468 \cdot 10^{-286}:\\
\;\;\;\;\frac{1}{\frac{a}{\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{2}}}\\

\mathbf{elif}\;b \leq 2.1921691367601414 \cdot 10^{+102}:\\
\;\;\;\;\frac{1}{\frac{a}{-a \cdot 4}} \cdot \frac{\frac{c}{b + \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}}}{2}\\

\mathbf{else}:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\

\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 -4.266218223523121e+118)
   (* 1.0 (- (/ c b) (/ b a)))
   (if (<= b -6.989967742266468e-286)
     (/ 1.0 (/ a (/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) 2.0)))
     (if (<= b 2.1921691367601414e+102)
       (*
        (/ 1.0 (/ a (- (* a 4.0))))
        (/ (/ c (+ b (sqrt (- (* b b) (* c (* a 4.0)))))) 2.0))
       (- (* 1.0 (/ c b)))))))
double code(double a, double b, double c) {
	return (((double) (((double) -(b)) + ((double) sqrt(((double) (((double) (b * b)) - ((double) (((double) (4.0 * a)) * c)))))))) / ((double) (2.0 * a)));
}
double code(double a, double b, double c) {
	double tmp;
	if ((b <= -4.266218223523121e+118)) {
		tmp = ((double) (1.0 * ((double) ((c / b) - (b / a)))));
	} else {
		double tmp_1;
		if ((b <= -6.989967742266468e-286)) {
			tmp_1 = (1.0 / (a / (((double) (((double) sqrt(((double) (((double) (b * b)) - ((double) (c * ((double) (a * 4.0)))))))) - b)) / 2.0)));
		} else {
			double tmp_2;
			if ((b <= 2.1921691367601414e+102)) {
				tmp_2 = ((double) ((1.0 / (a / ((double) -(((double) (a * 4.0)))))) * ((c / ((double) (b + ((double) sqrt(((double) (((double) (b * b)) - ((double) (c * ((double) (a * 4.0))))))))))) / 2.0)));
			} else {
				tmp_2 = ((double) -(((double) (1.0 * (c / b)))));
			}
			tmp_1 = tmp_2;
		}
		tmp = tmp_1;
	}
	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 4 regimes
  2. if b < -4.2662182235231212e118

    1. Initial program 52.2

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

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

      \[\leadsto \color{blue}{1 \cdot \frac{c}{b} - 1 \cdot \frac{b}{a}}\]
    4. Simplified3.3

      \[\leadsto \color{blue}{1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)}\]

    if -4.2662182235231212e118 < b < -6.98996774226646827e-286

    1. Initial program 8.9

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

      \[\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 clear-num_binary649.0

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

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

    if -6.98996774226646827e-286 < b < 2.19216913676014145e102

    1. Initial program 31.9

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

      \[\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 clear-num_binary6431.9

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

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

      \[\leadsto \frac{1}{\frac{a}{\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}}}{2}}}\]
    8. Simplified17.0

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

      \[\leadsto \frac{1}{\frac{a}{\frac{\frac{-\left(4 \cdot a\right) \cdot c}{\color{blue}{b + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}{2}}}\]
    10. Using strategy rm
    11. Applied *-un-lft-identity_binary6417.0

      \[\leadsto \frac{1}{\frac{a}{\frac{\frac{-\left(4 \cdot a\right) \cdot c}{b + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{\color{blue}{1 \cdot 2}}}}\]
    12. Applied *-un-lft-identity_binary6417.0

      \[\leadsto \frac{1}{\frac{a}{\frac{\frac{-\left(4 \cdot a\right) \cdot c}{\color{blue}{1 \cdot \left(b + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}}}{1 \cdot 2}}}\]
    13. Applied distribute-lft-neg-in_binary6417.0

      \[\leadsto \frac{1}{\frac{a}{\frac{\frac{\color{blue}{\left(-4 \cdot a\right) \cdot c}}{1 \cdot \left(b + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}}{1 \cdot 2}}}\]
    14. Applied times-frac_binary6414.5

      \[\leadsto \frac{1}{\frac{a}{\frac{\color{blue}{\frac{-4 \cdot a}{1} \cdot \frac{c}{b + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}{1 \cdot 2}}}\]
    15. Applied times-frac_binary6414.5

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

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

      \[\leadsto \frac{1}{\frac{\color{blue}{\frac{a}{-4 \cdot a}}}{\frac{\frac{c}{b + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2}}}\]
    18. Using strategy rm
    19. Applied associate-/r/_binary649.4

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

    if 2.19216913676014145e102 < b

    1. Initial program 60.0

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification6.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -4.266218223523121 \cdot 10^{+118}:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{elif}\;b \leq -6.989967742266468 \cdot 10^{-286}:\\ \;\;\;\;\frac{1}{\frac{a}{\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{2}}}\\ \mathbf{elif}\;b \leq 2.1921691367601414 \cdot 10^{+102}:\\ \;\;\;\;\frac{1}{\frac{a}{-a \cdot 4}} \cdot \frac{\frac{c}{b + \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}}}{2}\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

herbie shell --seed 2020204 
(FPCore (a b c)
  :name "Quadratic roots, full range"
  :precision binary64
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))