Average Error: 34.4 → 21.4
Time: 26.4s
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 -1.3646970996418853 \cdot 10^{+154}:\\ \;\;\;\;\left(\sqrt{0} - b_2\right) \cdot \frac{1}{a}\\ \mathbf{elif}\;b_2 \leq -1.3415086610309752 \cdot 10^{-272}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\\ \mathbf{elif}\;b_2 \leq 1.3503059635204164 \cdot 10^{+154}:\\ \;\;\;\;\frac{\frac{0 \cdot \left(b_2 \cdot b_2\right) - a \cdot c}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}\\ \mathbf{else}:\\ \;\;\;\;0\\ \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 -1.3646970996418853 \cdot 10^{+154}:\\
\;\;\;\;\left(\sqrt{0} - b_2\right) \cdot \frac{1}{a}\\

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

\mathbf{elif}\;b_2 \leq 1.3503059635204164 \cdot 10^{+154}:\\
\;\;\;\;\frac{\frac{0 \cdot \left(b_2 \cdot b_2\right) - a \cdot c}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}\\

\mathbf{else}:\\
\;\;\;\;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
 (if (<= b_2 -1.3646970996418853e+154)
   (* (- (sqrt 0.0) b_2) (/ 1.0 a))
   (if (<= b_2 -1.3415086610309752e-272)
     (/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)
     (if (<= b_2 1.3503059635204164e+154)
       (/
        (/
         (- (* 0.0 (* b_2 b_2)) (* a c))
         (+ b_2 (sqrt (- (* b_2 b_2) (* a c)))))
        a)
       0.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 tmp;
	if (b_2 <= -1.3646970996418853e+154) {
		tmp = (sqrt(0.0) - b_2) * (1.0 / a);
	} else if (b_2 <= -1.3415086610309752e-272) {
		tmp = (sqrt((b_2 * b_2) - (a * c)) - b_2) / a;
	} else if (b_2 <= 1.3503059635204164e+154) {
		tmp = (((0.0 * (b_2 * b_2)) - (a * c)) / (b_2 + sqrt((b_2 * b_2) - (a * c)))) / a;
	} else {
		tmp = 0.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 4 regimes
  2. if b_2 < -1.3646970996418853e154

    1. Initial program 64.0

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified64.0

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied div-inv_binary6464.0

      \[\leadsto \color{blue}{\left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right) \cdot \frac{1}{a}}\]
    5. Taylor expanded around 0 52.2

      \[\leadsto \left(\sqrt{\color{blue}{0}} - b_2\right) \cdot \frac{1}{a}\]

    if -1.3646970996418853e154 < b_2 < -1.34150866103097518e-272

    1. Initial program 8.6

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified8.6

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

    if -1.34150866103097518e-272 < b_2 < 1.35030596352041636e154

    1. Initial program 33.8

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified33.8

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied flip--_binary6433.9

      \[\leadsto \frac{\color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c} - b_2 \cdot b_2}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}}}{a}\]
    5. Simplified16.2

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

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

    if 1.35030596352041636e154 < b_2

    1. Initial program 64.0

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified64.0

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Taylor expanded around 0 36.6

      \[\leadsto \color{blue}{0}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification21.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -1.3646970996418853 \cdot 10^{+154}:\\ \;\;\;\;\left(\sqrt{0} - b_2\right) \cdot \frac{1}{a}\\ \mathbf{elif}\;b_2 \leq -1.3415086610309752 \cdot 10^{-272}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\\ \mathbf{elif}\;b_2 \leq 1.3503059635204164 \cdot 10^{+154}:\\ \;\;\;\;\frac{\frac{0 \cdot \left(b_2 \cdot b_2\right) - a \cdot c}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}\]

Reproduce

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