Average Error: 34.0 → 10.1
Time: 5.3s
Precision: binary64
\[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
\[\begin{array}{l} \mathbf{if}\;b_2 \leq -9.328589537535776 \cdot 10^{+153}:\\ \;\;\;\;\frac{\left(0.5 \cdot \left(c \cdot \frac{a}{b_2}\right) - b_2\right) - b_2}{a}\\ \mathbf{elif}\;b_2 \leq 1.5195718135839158 \cdot 10^{-43}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \end{array}\]
\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\begin{array}{l}
\mathbf{if}\;b_2 \leq -9.328589537535776 \cdot 10^{+153}:\\
\;\;\;\;\frac{\left(0.5 \cdot \left(c \cdot \frac{a}{b_2}\right) - b_2\right) - b_2}{a}\\

\mathbf{elif}\;b_2 \leq 1.5195718135839158 \cdot 10^{-43}:\\
\;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{a}\\

\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b_2}\\

\end{array}
(FPCore (a b_2 c)
 :precision binary64
 (/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))
(FPCore (a b_2 c)
 :precision binary64
 (if (<= b_2 -9.328589537535776e+153)
   (/ (- (- (* 0.5 (* c (/ a b_2))) b_2) b_2) a)
   (if (<= b_2 1.5195718135839158e-43)
     (/ (- (sqrt (- (* b_2 b_2) (* c a))) b_2) a)
     (* -0.5 (/ c b_2)))))
double code(double a, double b_2, double c) {
	return (((double) (((double) -(b_2)) + ((double) sqrt(((double) (((double) (b_2 * b_2)) - ((double) (a * c)))))))) / a);
}
double code(double a, double b_2, double c) {
	double tmp;
	if ((b_2 <= -9.328589537535776e+153)) {
		tmp = (((double) (((double) (((double) (0.5 * ((double) (c * (a / b_2))))) - b_2)) - b_2)) / a);
	} else {
		double tmp_1;
		if ((b_2 <= 1.5195718135839158e-43)) {
			tmp_1 = (((double) (((double) sqrt(((double) (((double) (b_2 * b_2)) - ((double) (c * a)))))) - b_2)) / a);
		} else {
			tmp_1 = ((double) (-0.5 * (c / b_2)));
		}
		tmp = tmp_1;
	}
	return tmp;
}

Error

Bits error versus a

Bits error versus b_2

Bits error versus c

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if b_2 < -9.32858953753577638e153

    1. Initial program Error: 64.0 bits

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. SimplifiedError: 64.0 bits

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Taylor expanded around -inf Error: 11.8 bits

      \[\leadsto \frac{\color{blue}{\left(0.5 \cdot \frac{a \cdot c}{b_2} - b_2\right)} - b_2}{a}\]
    4. SimplifiedError: 2.6 bits

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

    if -9.32858953753577638e153 < b_2 < 1.51957181358391582e-43

    1. Initial program Error: 13.1 bits

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. SimplifiedError: 13.1 bits

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]

    if 1.51957181358391582e-43 < b_2

    1. Initial program Error: 54.0 bits

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. SimplifiedError: 54.0 bits

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Taylor expanded around inf Error: 8.1 bits

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b_2}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplificationError: 10.1 bits

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -9.328589537535776 \cdot 10^{+153}:\\ \;\;\;\;\frac{\left(0.5 \cdot \left(c \cdot \frac{a}{b_2}\right) - b_2\right) - b_2}{a}\\ \mathbf{elif}\;b_2 \leq 1.5195718135839158 \cdot 10^{-43}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \end{array}\]

Reproduce

herbie shell --seed 2020203 
(FPCore (a b_2 c)
  :name "quad2p (problem 3.2.1, positive)"
  :precision binary64
  (/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))