Average Error: 33.8 → 42.4
Time: 10.0s
Precision: binary64
\[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a} \]
\[\begin{array}{l} t_0 := \frac{\left(-b_2\right) + b_2}{a}\\ t_1 := \frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\ \mathbf{if}\;t_1 \leq -7.037395604649231 \cdot 10^{+132}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;t_1 \leq 3.0062298434955216 \cdot 10^{-32}:\\ \;\;\;\;\frac{\left(-b_2\right) + {\left(b_2 \cdot b_2 - c \cdot a\right)}^{0.5}}{a}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\begin{array}{l}
t_0 := \frac{\left(-b_2\right) + b_2}{a}\\
t_1 := \frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\
\mathbf{if}\;t_1 \leq -7.037395604649231 \cdot 10^{+132}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;t_1 \leq 3.0062298434955216 \cdot 10^{-32}:\\
\;\;\;\;\frac{\left(-b_2\right) + {\left(b_2 \cdot b_2 - c \cdot a\right)}^{0.5}}{a}\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\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
 (let* ((t_0 (/ (+ (- b_2) b_2) a))
        (t_1 (/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a)))
   (if (<= t_1 -7.037395604649231e+132)
     t_0
     (if (<= t_1 3.0062298434955216e-32)
       (/ (+ (- b_2) (pow (- (* b_2 b_2) (* c a)) 0.5)) a)
       t_0))))
double code(double a, double b_2, double c) {
	return (-b_2 + sqrt(((b_2 * b_2) - (a * c)))) / a;
}
double code(double a, double b_2, double c) {
	double t_0 = (-b_2 + b_2) / a;
	double t_1 = (-b_2 + sqrt(((b_2 * b_2) - (a * c)))) / a;
	double tmp;
	if (t_1 <= -7.037395604649231e+132) {
		tmp = t_0;
	} else if (t_1 <= 3.0062298434955216e-32) {
		tmp = (-b_2 + pow(((b_2 * b_2) - (c * a)), 0.5)) / a;
	} else {
		tmp = t_0;
	}
	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 2 regimes
  2. if (/.f64 (+.f64 (neg.f64 b_2) (sqrt.f64 (-.f64 (*.f64 b_2 b_2) (*.f64 a c)))) a) < -7.0373956046492312e132 or 3.00622984349552157e-32 < (/.f64 (+.f64 (neg.f64 b_2) (sqrt.f64 (-.f64 (*.f64 b_2 b_2) (*.f64 a c)))) a)

    1. Initial program 40.1

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a} \]
    2. Taylor expanded in b_2 around inf 54.8

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

    if -7.0373956046492312e132 < (/.f64 (+.f64 (neg.f64 b_2) (sqrt.f64 (-.f64 (*.f64 b_2 b_2) (*.f64 a c)))) a) < 3.00622984349552157e-32

    1. Initial program 24.9

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a} \]
    2. Applied egg-rr43.4

      \[\leadsto \frac{\left(-b_2\right) + \color{blue}{\sqrt{c} \cdot \sqrt{\frac{b_2 \cdot b_2}{c} - a}}}{a} \]
    3. Applied egg-rr43.4

      \[\leadsto \frac{\left(-b_2\right) + \sqrt{c} \cdot \color{blue}{{\left({\left(\frac{b_2 \cdot b_2}{c} - a\right)}^{0.25}\right)}^{2}}}{a} \]
    4. Applied egg-rr24.9

      \[\leadsto \frac{\color{blue}{{\left(\left(-b_2\right) + {\left(b_2 \cdot b_2 - c \cdot a\right)}^{0.5}\right)}^{1}}}{a} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification42.4

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

Reproduce

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