quad2m (problem 3.2.1, negative)

Percentage Accurate: 53.0% → 85.3%
Time: 15.2s
Alternatives: 8
Speedup: 15.9×

Specification

?
\[\begin{array}{l} \\ \frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a} \end{array} \]
(FPCore (a b_2 c)
 :precision binary64
 (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))
double code(double a, double b_2, double c) {
	return (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / a;
}
real(8) function code(a, b_2, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b_2
    real(8), intent (in) :: c
    code = (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / a
end function
public static double code(double a, double b_2, double c) {
	return (-b_2 - Math.sqrt(((b_2 * b_2) - (a * c)))) / a;
}
def code(a, b_2, c):
	return (-b_2 - math.sqrt(((b_2 * b_2) - (a * c)))) / a
function code(a, b_2, c)
	return Float64(Float64(Float64(-b_2) - sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c)))) / a)
end
function tmp = code(a, b_2, c)
	tmp = (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / a;
end
code[a_, b$95$2_, c_] := N[(N[((-b$95$2) - N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]
\begin{array}{l}

\\
\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 8 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 53.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a} \end{array} \]
(FPCore (a b_2 c)
 :precision binary64
 (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))
double code(double a, double b_2, double c) {
	return (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / a;
}
real(8) function code(a, b_2, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b_2
    real(8), intent (in) :: c
    code = (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / a
end function
public static double code(double a, double b_2, double c) {
	return (-b_2 - Math.sqrt(((b_2 * b_2) - (a * c)))) / a;
}
def code(a, b_2, c):
	return (-b_2 - math.sqrt(((b_2 * b_2) - (a * c)))) / a
function code(a, b_2, c)
	return Float64(Float64(Float64(-b_2) - sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c)))) / a)
end
function tmp = code(a, b_2, c)
	tmp = (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / a;
end
code[a_, b$95$2_, c_] := N[(N[((-b$95$2) - N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]
\begin{array}{l}

\\
\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\end{array}

Alternative 1: 85.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b_2 \leq -6 \cdot 10^{-70}:\\ \;\;\;\;\frac{-0.5 \cdot c}{b_2}\\ \mathbf{elif}\;b_2 \leq 2 \cdot 10^{+98}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{b_2 \cdot -2}{a}\\ \end{array} \end{array} \]
(FPCore (a b_2 c)
 :precision binary64
 (if (<= b_2 -6e-70)
   (/ (* -0.5 c) b_2)
   (if (<= b_2 2e+98)
     (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* c a)))) a)
     (/ (* b_2 -2.0) a))))
double code(double a, double b_2, double c) {
	double tmp;
	if (b_2 <= -6e-70) {
		tmp = (-0.5 * c) / b_2;
	} else if (b_2 <= 2e+98) {
		tmp = (-b_2 - sqrt(((b_2 * b_2) - (c * a)))) / a;
	} else {
		tmp = (b_2 * -2.0) / a;
	}
	return tmp;
}
real(8) function code(a, b_2, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b_2
    real(8), intent (in) :: c
    real(8) :: tmp
    if (b_2 <= (-6d-70)) then
        tmp = ((-0.5d0) * c) / b_2
    else if (b_2 <= 2d+98) then
        tmp = (-b_2 - sqrt(((b_2 * b_2) - (c * a)))) / a
    else
        tmp = (b_2 * (-2.0d0)) / a
    end if
    code = tmp
end function
public static double code(double a, double b_2, double c) {
	double tmp;
	if (b_2 <= -6e-70) {
		tmp = (-0.5 * c) / b_2;
	} else if (b_2 <= 2e+98) {
		tmp = (-b_2 - Math.sqrt(((b_2 * b_2) - (c * a)))) / a;
	} else {
		tmp = (b_2 * -2.0) / a;
	}
	return tmp;
}
def code(a, b_2, c):
	tmp = 0
	if b_2 <= -6e-70:
		tmp = (-0.5 * c) / b_2
	elif b_2 <= 2e+98:
		tmp = (-b_2 - math.sqrt(((b_2 * b_2) - (c * a)))) / a
	else:
		tmp = (b_2 * -2.0) / a
	return tmp
function code(a, b_2, c)
	tmp = 0.0
	if (b_2 <= -6e-70)
		tmp = Float64(Float64(-0.5 * c) / b_2);
	elseif (b_2 <= 2e+98)
		tmp = Float64(Float64(Float64(-b_2) - sqrt(Float64(Float64(b_2 * b_2) - Float64(c * a)))) / a);
	else
		tmp = Float64(Float64(b_2 * -2.0) / a);
	end
	return tmp
end
function tmp_2 = code(a, b_2, c)
	tmp = 0.0;
	if (b_2 <= -6e-70)
		tmp = (-0.5 * c) / b_2;
	elseif (b_2 <= 2e+98)
		tmp = (-b_2 - sqrt(((b_2 * b_2) - (c * a)))) / a;
	else
		tmp = (b_2 * -2.0) / a;
	end
	tmp_2 = tmp;
end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -6e-70], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision], If[LessEqual[b$95$2, 2e+98], N[(N[((-b$95$2) - N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(b$95$2 * -2.0), $MachinePrecision] / a), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -6 \cdot 10^{-70}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b_2}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{b_2 \cdot -2}{a}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b_2 < -6.0000000000000003e-70

    1. Initial program 15.0%

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

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b_2}} \]
    3. Step-by-step derivation
      1. associate-*r/88.8%

        \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b_2}} \]
    4. Applied egg-rr88.8%

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

    if -6.0000000000000003e-70 < b_2 < 2e98

    1. Initial program 75.6%

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a} \]

    if 2e98 < b_2

    1. Initial program 61.6%

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

      \[\leadsto \frac{\color{blue}{-2 \cdot b_2}}{a} \]
    3. Step-by-step derivation
      1. *-commutative100.0%

        \[\leadsto \frac{\color{blue}{b_2 \cdot -2}}{a} \]
    4. Simplified100.0%

      \[\leadsto \frac{\color{blue}{b_2 \cdot -2}}{a} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification85.1%

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

Alternative 2: 80.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b_2 \leq -3.2 \cdot 10^{-65}:\\ \;\;\;\;\frac{-0.5 \cdot c}{b_2}\\ \mathbf{elif}\;b_2 \leq 10^{-11}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{a \cdot \left(-c\right)}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{b_2 \cdot -2}{a}\\ \end{array} \end{array} \]
(FPCore (a b_2 c)
 :precision binary64
 (if (<= b_2 -3.2e-65)
   (/ (* -0.5 c) b_2)
   (if (<= b_2 1e-11)
     (/ (- (- b_2) (sqrt (* a (- c)))) a)
     (/ (* b_2 -2.0) a))))
double code(double a, double b_2, double c) {
	double tmp;
	if (b_2 <= -3.2e-65) {
		tmp = (-0.5 * c) / b_2;
	} else if (b_2 <= 1e-11) {
		tmp = (-b_2 - sqrt((a * -c))) / a;
	} else {
		tmp = (b_2 * -2.0) / a;
	}
	return tmp;
}
real(8) function code(a, b_2, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b_2
    real(8), intent (in) :: c
    real(8) :: tmp
    if (b_2 <= (-3.2d-65)) then
        tmp = ((-0.5d0) * c) / b_2
    else if (b_2 <= 1d-11) then
        tmp = (-b_2 - sqrt((a * -c))) / a
    else
        tmp = (b_2 * (-2.0d0)) / a
    end if
    code = tmp
end function
public static double code(double a, double b_2, double c) {
	double tmp;
	if (b_2 <= -3.2e-65) {
		tmp = (-0.5 * c) / b_2;
	} else if (b_2 <= 1e-11) {
		tmp = (-b_2 - Math.sqrt((a * -c))) / a;
	} else {
		tmp = (b_2 * -2.0) / a;
	}
	return tmp;
}
def code(a, b_2, c):
	tmp = 0
	if b_2 <= -3.2e-65:
		tmp = (-0.5 * c) / b_2
	elif b_2 <= 1e-11:
		tmp = (-b_2 - math.sqrt((a * -c))) / a
	else:
		tmp = (b_2 * -2.0) / a
	return tmp
function code(a, b_2, c)
	tmp = 0.0
	if (b_2 <= -3.2e-65)
		tmp = Float64(Float64(-0.5 * c) / b_2);
	elseif (b_2 <= 1e-11)
		tmp = Float64(Float64(Float64(-b_2) - sqrt(Float64(a * Float64(-c)))) / a);
	else
		tmp = Float64(Float64(b_2 * -2.0) / a);
	end
	return tmp
end
function tmp_2 = code(a, b_2, c)
	tmp = 0.0;
	if (b_2 <= -3.2e-65)
		tmp = (-0.5 * c) / b_2;
	elseif (b_2 <= 1e-11)
		tmp = (-b_2 - sqrt((a * -c))) / a;
	else
		tmp = (b_2 * -2.0) / a;
	end
	tmp_2 = tmp;
end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -3.2e-65], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision], If[LessEqual[b$95$2, 1e-11], N[(N[((-b$95$2) - N[Sqrt[N[(a * (-c)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(b$95$2 * -2.0), $MachinePrecision] / a), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -3.2 \cdot 10^{-65}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b_2}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{b_2 \cdot -2}{a}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b_2 < -3.1999999999999999e-65

    1. Initial program 15.0%

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

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b_2}} \]
    3. Step-by-step derivation
      1. associate-*r/88.8%

        \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b_2}} \]
    4. Applied egg-rr88.8%

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

    if -3.1999999999999999e-65 < b_2 < 9.99999999999999939e-12

    1. Initial program 72.8%

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a} \]
    2. Taylor expanded in b_2 around 0 62.8%

      \[\leadsto \frac{\left(-b_2\right) - \sqrt{\color{blue}{-1 \cdot \left(a \cdot c\right)}}}{a} \]
    3. Step-by-step derivation
      1. associate-*r*62.8%

        \[\leadsto \frac{\left(-b_2\right) - \sqrt{\color{blue}{\left(-1 \cdot a\right) \cdot c}}}{a} \]
      2. neg-mul-162.8%

        \[\leadsto \frac{\left(-b_2\right) - \sqrt{\color{blue}{\left(-a\right)} \cdot c}}{a} \]
      3. *-commutative62.8%

        \[\leadsto \frac{\left(-b_2\right) - \sqrt{\color{blue}{c \cdot \left(-a\right)}}}{a} \]
    4. Simplified62.8%

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

    if 9.99999999999999939e-12 < b_2

    1. Initial program 69.7%

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

      \[\leadsto \frac{\color{blue}{-2 \cdot b_2}}{a} \]
    3. Step-by-step derivation
      1. *-commutative89.6%

        \[\leadsto \frac{\color{blue}{b_2 \cdot -2}}{a} \]
    4. Simplified89.6%

      \[\leadsto \frac{\color{blue}{b_2 \cdot -2}}{a} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification80.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -3.2 \cdot 10^{-65}:\\ \;\;\;\;\frac{-0.5 \cdot c}{b_2}\\ \mathbf{elif}\;b_2 \leq 10^{-11}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{a \cdot \left(-c\right)}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{b_2 \cdot -2}{a}\\ \end{array} \]

Alternative 3: 79.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b_2 \leq -1.15 \cdot 10^{-67}:\\ \;\;\;\;\frac{-0.5 \cdot c}{b_2}\\ \mathbf{elif}\;b_2 \leq 10^{-11}:\\ \;\;\;\;\frac{-\sqrt{a \cdot \left(-c\right)}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{b_2 \cdot -2}{a}\\ \end{array} \end{array} \]
(FPCore (a b_2 c)
 :precision binary64
 (if (<= b_2 -1.15e-67)
   (/ (* -0.5 c) b_2)
   (if (<= b_2 1e-11) (/ (- (sqrt (* a (- c)))) a) (/ (* b_2 -2.0) a))))
double code(double a, double b_2, double c) {
	double tmp;
	if (b_2 <= -1.15e-67) {
		tmp = (-0.5 * c) / b_2;
	} else if (b_2 <= 1e-11) {
		tmp = -sqrt((a * -c)) / a;
	} else {
		tmp = (b_2 * -2.0) / a;
	}
	return tmp;
}
real(8) function code(a, b_2, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b_2
    real(8), intent (in) :: c
    real(8) :: tmp
    if (b_2 <= (-1.15d-67)) then
        tmp = ((-0.5d0) * c) / b_2
    else if (b_2 <= 1d-11) then
        tmp = -sqrt((a * -c)) / a
    else
        tmp = (b_2 * (-2.0d0)) / a
    end if
    code = tmp
end function
public static double code(double a, double b_2, double c) {
	double tmp;
	if (b_2 <= -1.15e-67) {
		tmp = (-0.5 * c) / b_2;
	} else if (b_2 <= 1e-11) {
		tmp = -Math.sqrt((a * -c)) / a;
	} else {
		tmp = (b_2 * -2.0) / a;
	}
	return tmp;
}
def code(a, b_2, c):
	tmp = 0
	if b_2 <= -1.15e-67:
		tmp = (-0.5 * c) / b_2
	elif b_2 <= 1e-11:
		tmp = -math.sqrt((a * -c)) / a
	else:
		tmp = (b_2 * -2.0) / a
	return tmp
function code(a, b_2, c)
	tmp = 0.0
	if (b_2 <= -1.15e-67)
		tmp = Float64(Float64(-0.5 * c) / b_2);
	elseif (b_2 <= 1e-11)
		tmp = Float64(Float64(-sqrt(Float64(a * Float64(-c)))) / a);
	else
		tmp = Float64(Float64(b_2 * -2.0) / a);
	end
	return tmp
end
function tmp_2 = code(a, b_2, c)
	tmp = 0.0;
	if (b_2 <= -1.15e-67)
		tmp = (-0.5 * c) / b_2;
	elseif (b_2 <= 1e-11)
		tmp = -sqrt((a * -c)) / a;
	else
		tmp = (b_2 * -2.0) / a;
	end
	tmp_2 = tmp;
end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -1.15e-67], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision], If[LessEqual[b$95$2, 1e-11], N[((-N[Sqrt[N[(a * (-c)), $MachinePrecision]], $MachinePrecision]) / a), $MachinePrecision], N[(N[(b$95$2 * -2.0), $MachinePrecision] / a), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -1.15 \cdot 10^{-67}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b_2}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{b_2 \cdot -2}{a}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b_2 < -1.15e-67

    1. Initial program 15.0%

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

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b_2}} \]
    3. Step-by-step derivation
      1. associate-*r/88.8%

        \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b_2}} \]
    4. Applied egg-rr88.8%

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

    if -1.15e-67 < b_2 < 9.99999999999999939e-12

    1. Initial program 72.8%

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a} \]
    2. Step-by-step derivation
      1. prod-diff72.3%

        \[\leadsto \frac{\left(-b_2\right) - \sqrt{\color{blue}{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right) + \mathsf{fma}\left(-c, a, c \cdot a\right)}}}{a} \]
      2. *-commutative72.3%

        \[\leadsto \frac{\left(-b_2\right) - \sqrt{\mathsf{fma}\left(b_2, b_2, -\color{blue}{a \cdot c}\right) + \mathsf{fma}\left(-c, a, c \cdot a\right)}}{a} \]
      3. fma-neg72.3%

        \[\leadsto \frac{\left(-b_2\right) - \sqrt{\color{blue}{\left(b_2 \cdot b_2 - a \cdot c\right)} + \mathsf{fma}\left(-c, a, c \cdot a\right)}}{a} \]
      4. prod-diff72.3%

        \[\leadsto \frac{\left(-b_2\right) - \sqrt{\color{blue}{\left(\mathsf{fma}\left(b_2, b_2, -c \cdot a\right) + \mathsf{fma}\left(-c, a, c \cdot a\right)\right)} + \mathsf{fma}\left(-c, a, c \cdot a\right)}}{a} \]
      5. *-commutative72.3%

        \[\leadsto \frac{\left(-b_2\right) - \sqrt{\left(\mathsf{fma}\left(b_2, b_2, -\color{blue}{a \cdot c}\right) + \mathsf{fma}\left(-c, a, c \cdot a\right)\right) + \mathsf{fma}\left(-c, a, c \cdot a\right)}}{a} \]
      6. fma-neg72.3%

        \[\leadsto \frac{\left(-b_2\right) - \sqrt{\left(\color{blue}{\left(b_2 \cdot b_2 - a \cdot c\right)} + \mathsf{fma}\left(-c, a, c \cdot a\right)\right) + \mathsf{fma}\left(-c, a, c \cdot a\right)}}{a} \]
      7. associate-+l+72.3%

        \[\leadsto \frac{\left(-b_2\right) - \sqrt{\color{blue}{\left(b_2 \cdot b_2 - a \cdot c\right) + \left(\mathsf{fma}\left(-c, a, c \cdot a\right) + \mathsf{fma}\left(-c, a, c \cdot a\right)\right)}}}{a} \]
      8. *-commutative72.3%

        \[\leadsto \frac{\left(-b_2\right) - \sqrt{\left(b_2 \cdot b_2 - a \cdot c\right) + \left(\mathsf{fma}\left(-c, a, \color{blue}{a \cdot c}\right) + \mathsf{fma}\left(-c, a, c \cdot a\right)\right)}}{a} \]
      9. fma-udef72.3%

        \[\leadsto \frac{\left(-b_2\right) - \sqrt{\left(b_2 \cdot b_2 - a \cdot c\right) + \left(\color{blue}{\left(\left(-c\right) \cdot a + a \cdot c\right)} + \mathsf{fma}\left(-c, a, c \cdot a\right)\right)}}{a} \]
      10. distribute-lft-neg-in72.3%

        \[\leadsto \frac{\left(-b_2\right) - \sqrt{\left(b_2 \cdot b_2 - a \cdot c\right) + \left(\left(\color{blue}{\left(-c \cdot a\right)} + a \cdot c\right) + \mathsf{fma}\left(-c, a, c \cdot a\right)\right)}}{a} \]
      11. *-commutative72.3%

        \[\leadsto \frac{\left(-b_2\right) - \sqrt{\left(b_2 \cdot b_2 - a \cdot c\right) + \left(\left(\left(-\color{blue}{a \cdot c}\right) + a \cdot c\right) + \mathsf{fma}\left(-c, a, c \cdot a\right)\right)}}{a} \]
      12. distribute-rgt-neg-in72.3%

        \[\leadsto \frac{\left(-b_2\right) - \sqrt{\left(b_2 \cdot b_2 - a \cdot c\right) + \left(\left(\color{blue}{a \cdot \left(-c\right)} + a \cdot c\right) + \mathsf{fma}\left(-c, a, c \cdot a\right)\right)}}{a} \]
      13. fma-def72.3%

        \[\leadsto \frac{\left(-b_2\right) - \sqrt{\left(b_2 \cdot b_2 - a \cdot c\right) + \left(\color{blue}{\mathsf{fma}\left(a, -c, a \cdot c\right)} + \mathsf{fma}\left(-c, a, c \cdot a\right)\right)}}{a} \]
      14. *-commutative72.3%

        \[\leadsto \frac{\left(-b_2\right) - \sqrt{\left(b_2 \cdot b_2 - a \cdot c\right) + \left(\mathsf{fma}\left(a, -c, a \cdot c\right) + \mathsf{fma}\left(-c, a, \color{blue}{a \cdot c}\right)\right)}}{a} \]
      15. fma-udef72.3%

        \[\leadsto \frac{\left(-b_2\right) - \sqrt{\left(b_2 \cdot b_2 - a \cdot c\right) + \left(\mathsf{fma}\left(a, -c, a \cdot c\right) + \color{blue}{\left(\left(-c\right) \cdot a + a \cdot c\right)}\right)}}{a} \]
      16. distribute-lft-neg-in72.3%

        \[\leadsto \frac{\left(-b_2\right) - \sqrt{\left(b_2 \cdot b_2 - a \cdot c\right) + \left(\mathsf{fma}\left(a, -c, a \cdot c\right) + \left(\color{blue}{\left(-c \cdot a\right)} + a \cdot c\right)\right)}}{a} \]
      17. *-commutative72.3%

        \[\leadsto \frac{\left(-b_2\right) - \sqrt{\left(b_2 \cdot b_2 - a \cdot c\right) + \left(\mathsf{fma}\left(a, -c, a \cdot c\right) + \left(\left(-\color{blue}{a \cdot c}\right) + a \cdot c\right)\right)}}{a} \]
      18. distribute-rgt-neg-in72.3%

        \[\leadsto \frac{\left(-b_2\right) - \sqrt{\left(b_2 \cdot b_2 - a \cdot c\right) + \left(\mathsf{fma}\left(a, -c, a \cdot c\right) + \left(\color{blue}{a \cdot \left(-c\right)} + a \cdot c\right)\right)}}{a} \]
      19. fma-def72.3%

        \[\leadsto \frac{\left(-b_2\right) - \sqrt{\left(b_2 \cdot b_2 - a \cdot c\right) + \left(\mathsf{fma}\left(a, -c, a \cdot c\right) + \color{blue}{\mathsf{fma}\left(a, -c, a \cdot c\right)}\right)}}{a} \]
    3. Applied egg-rr72.3%

      \[\leadsto \frac{\left(-b_2\right) - \sqrt{\color{blue}{\left(b_2 \cdot b_2 - a \cdot c\right) + \left(\mathsf{fma}\left(a, -c, a \cdot c\right) + \mathsf{fma}\left(a, -c, a \cdot c\right)\right)}}}{a} \]
    4. Step-by-step derivation
      1. count-272.3%

        \[\leadsto \frac{\left(-b_2\right) - \sqrt{\left(b_2 \cdot b_2 - a \cdot c\right) + \color{blue}{2 \cdot \mathsf{fma}\left(a, -c, a \cdot c\right)}}}{a} \]
    5. Simplified72.3%

      \[\leadsto \frac{\left(-b_2\right) - \sqrt{\color{blue}{\left(b_2 \cdot b_2 - a \cdot c\right) + 2 \cdot \mathsf{fma}\left(a, -c, a \cdot c\right)}}}{a} \]
    6. Taylor expanded in b_2 around 0 60.4%

      \[\leadsto \frac{\color{blue}{-1 \cdot \sqrt{2 \cdot \left(-1 \cdot \left(a \cdot c\right) + a \cdot c\right) - a \cdot c}}}{a} \]
    7. Step-by-step derivation
      1. mul-1-neg60.4%

        \[\leadsto \frac{\color{blue}{-\sqrt{2 \cdot \left(-1 \cdot \left(a \cdot c\right) + a \cdot c\right) - a \cdot c}}}{a} \]
      2. distribute-lft1-in60.4%

        \[\leadsto \frac{-\sqrt{2 \cdot \color{blue}{\left(\left(-1 + 1\right) \cdot \left(a \cdot c\right)\right)} - a \cdot c}}{a} \]
      3. metadata-eval60.4%

        \[\leadsto \frac{-\sqrt{2 \cdot \left(\color{blue}{0} \cdot \left(a \cdot c\right)\right) - a \cdot c}}{a} \]
      4. mul0-lft60.9%

        \[\leadsto \frac{-\sqrt{2 \cdot \color{blue}{0} - a \cdot c}}{a} \]
      5. metadata-eval60.9%

        \[\leadsto \frac{-\sqrt{\color{blue}{0} - a \cdot c}}{a} \]
      6. neg-sub060.9%

        \[\leadsto \frac{-\sqrt{\color{blue}{-a \cdot c}}}{a} \]
      7. distribute-rgt-neg-out60.9%

        \[\leadsto \frac{-\sqrt{\color{blue}{a \cdot \left(-c\right)}}}{a} \]
    8. Simplified60.9%

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

    if 9.99999999999999939e-12 < b_2

    1. Initial program 69.7%

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

      \[\leadsto \frac{\color{blue}{-2 \cdot b_2}}{a} \]
    3. Step-by-step derivation
      1. *-commutative89.6%

        \[\leadsto \frac{\color{blue}{b_2 \cdot -2}}{a} \]
    4. Simplified89.6%

      \[\leadsto \frac{\color{blue}{b_2 \cdot -2}}{a} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification79.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -1.15 \cdot 10^{-67}:\\ \;\;\;\;\frac{-0.5 \cdot c}{b_2}\\ \mathbf{elif}\;b_2 \leq 10^{-11}:\\ \;\;\;\;\frac{-\sqrt{a \cdot \left(-c\right)}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{b_2 \cdot -2}{a}\\ \end{array} \]

Alternative 4: 47.0% accurate, 15.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b_2 \leq -1.9 \cdot 10^{-237}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b_2}{a}\\ \end{array} \end{array} \]
(FPCore (a b_2 c)
 :precision binary64
 (if (<= b_2 -1.9e-237) (* -0.5 (/ c b_2)) (/ (- b_2) a)))
double code(double a, double b_2, double c) {
	double tmp;
	if (b_2 <= -1.9e-237) {
		tmp = -0.5 * (c / b_2);
	} else {
		tmp = -b_2 / a;
	}
	return tmp;
}
real(8) function code(a, b_2, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b_2
    real(8), intent (in) :: c
    real(8) :: tmp
    if (b_2 <= (-1.9d-237)) then
        tmp = (-0.5d0) * (c / b_2)
    else
        tmp = -b_2 / a
    end if
    code = tmp
end function
public static double code(double a, double b_2, double c) {
	double tmp;
	if (b_2 <= -1.9e-237) {
		tmp = -0.5 * (c / b_2);
	} else {
		tmp = -b_2 / a;
	}
	return tmp;
}
def code(a, b_2, c):
	tmp = 0
	if b_2 <= -1.9e-237:
		tmp = -0.5 * (c / b_2)
	else:
		tmp = -b_2 / a
	return tmp
function code(a, b_2, c)
	tmp = 0.0
	if (b_2 <= -1.9e-237)
		tmp = Float64(-0.5 * Float64(c / b_2));
	else
		tmp = Float64(Float64(-b_2) / a);
	end
	return tmp
end
function tmp_2 = code(a, b_2, c)
	tmp = 0.0;
	if (b_2 <= -1.9e-237)
		tmp = -0.5 * (c / b_2);
	else
		tmp = -b_2 / a;
	end
	tmp_2 = tmp;
end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -1.9e-237], N[(-0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision], N[((-b$95$2) / a), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -1.9 \cdot 10^{-237}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b_2}\\

\mathbf{else}:\\
\;\;\;\;\frac{-b_2}{a}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b_2 < -1.90000000000000012e-237

    1. Initial program 26.8%

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

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

    if -1.90000000000000012e-237 < b_2

    1. Initial program 72.2%

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a} \]
    2. Step-by-step derivation
      1. add-sqr-sqrt72.0%

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

        \[\leadsto \frac{\left(-b_2\right) - \color{blue}{{\left(\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}\right)}^{2}}}{a} \]
      3. pow1/272.0%

        \[\leadsto \frac{\left(-b_2\right) - {\left(\sqrt{\color{blue}{{\left(b_2 \cdot b_2 - a \cdot c\right)}^{0.5}}}\right)}^{2}}{a} \]
      4. sqrt-pow172.0%

        \[\leadsto \frac{\left(-b_2\right) - {\color{blue}{\left({\left(b_2 \cdot b_2 - a \cdot c\right)}^{\left(\frac{0.5}{2}\right)}\right)}}^{2}}{a} \]
      5. metadata-eval72.0%

        \[\leadsto \frac{\left(-b_2\right) - {\left({\left(b_2 \cdot b_2 - a \cdot c\right)}^{\color{blue}{0.25}}\right)}^{2}}{a} \]
    3. Applied egg-rr72.0%

      \[\leadsto \frac{\left(-b_2\right) - \color{blue}{{\left({\left(b_2 \cdot b_2 - a \cdot c\right)}^{0.25}\right)}^{2}}}{a} \]
    4. Taylor expanded in b_2 around inf 30.0%

      \[\leadsto \frac{\color{blue}{-1 \cdot b_2}}{a} \]
    5. Step-by-step derivation
      1. neg-mul-130.0%

        \[\leadsto \frac{\color{blue}{-b_2}}{a} \]
    6. Simplified30.0%

      \[\leadsto \frac{\color{blue}{-b_2}}{a} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification49.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -1.9 \cdot 10^{-237}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b_2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b_2}{a}\\ \end{array} \]

Alternative 5: 47.0% accurate, 15.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b_2 \leq -1.9 \cdot 10^{-237}:\\ \;\;\;\;\frac{-0.5 \cdot c}{b_2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b_2}{a}\\ \end{array} \end{array} \]
(FPCore (a b_2 c)
 :precision binary64
 (if (<= b_2 -1.9e-237) (/ (* -0.5 c) b_2) (/ (- b_2) a)))
double code(double a, double b_2, double c) {
	double tmp;
	if (b_2 <= -1.9e-237) {
		tmp = (-0.5 * c) / b_2;
	} else {
		tmp = -b_2 / a;
	}
	return tmp;
}
real(8) function code(a, b_2, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b_2
    real(8), intent (in) :: c
    real(8) :: tmp
    if (b_2 <= (-1.9d-237)) then
        tmp = ((-0.5d0) * c) / b_2
    else
        tmp = -b_2 / a
    end if
    code = tmp
end function
public static double code(double a, double b_2, double c) {
	double tmp;
	if (b_2 <= -1.9e-237) {
		tmp = (-0.5 * c) / b_2;
	} else {
		tmp = -b_2 / a;
	}
	return tmp;
}
def code(a, b_2, c):
	tmp = 0
	if b_2 <= -1.9e-237:
		tmp = (-0.5 * c) / b_2
	else:
		tmp = -b_2 / a
	return tmp
function code(a, b_2, c)
	tmp = 0.0
	if (b_2 <= -1.9e-237)
		tmp = Float64(Float64(-0.5 * c) / b_2);
	else
		tmp = Float64(Float64(-b_2) / a);
	end
	return tmp
end
function tmp_2 = code(a, b_2, c)
	tmp = 0.0;
	if (b_2 <= -1.9e-237)
		tmp = (-0.5 * c) / b_2;
	else
		tmp = -b_2 / a;
	end
	tmp_2 = tmp;
end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -1.9e-237], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision], N[((-b$95$2) / a), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -1.9 \cdot 10^{-237}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b_2}\\

\mathbf{else}:\\
\;\;\;\;\frac{-b_2}{a}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b_2 < -1.90000000000000012e-237

    1. Initial program 26.8%

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

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b_2}} \]
    3. Step-by-step derivation
      1. associate-*r/73.8%

        \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b_2}} \]
    4. Applied egg-rr73.8%

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

    if -1.90000000000000012e-237 < b_2

    1. Initial program 72.2%

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a} \]
    2. Step-by-step derivation
      1. add-sqr-sqrt72.0%

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

        \[\leadsto \frac{\left(-b_2\right) - \color{blue}{{\left(\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}\right)}^{2}}}{a} \]
      3. pow1/272.0%

        \[\leadsto \frac{\left(-b_2\right) - {\left(\sqrt{\color{blue}{{\left(b_2 \cdot b_2 - a \cdot c\right)}^{0.5}}}\right)}^{2}}{a} \]
      4. sqrt-pow172.0%

        \[\leadsto \frac{\left(-b_2\right) - {\color{blue}{\left({\left(b_2 \cdot b_2 - a \cdot c\right)}^{\left(\frac{0.5}{2}\right)}\right)}}^{2}}{a} \]
      5. metadata-eval72.0%

        \[\leadsto \frac{\left(-b_2\right) - {\left({\left(b_2 \cdot b_2 - a \cdot c\right)}^{\color{blue}{0.25}}\right)}^{2}}{a} \]
    3. Applied egg-rr72.0%

      \[\leadsto \frac{\left(-b_2\right) - \color{blue}{{\left({\left(b_2 \cdot b_2 - a \cdot c\right)}^{0.25}\right)}^{2}}}{a} \]
    4. Taylor expanded in b_2 around inf 30.0%

      \[\leadsto \frac{\color{blue}{-1 \cdot b_2}}{a} \]
    5. Step-by-step derivation
      1. neg-mul-130.0%

        \[\leadsto \frac{\color{blue}{-b_2}}{a} \]
    6. Simplified30.0%

      \[\leadsto \frac{\color{blue}{-b_2}}{a} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification49.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -1.9 \cdot 10^{-237}:\\ \;\;\;\;\frac{-0.5 \cdot c}{b_2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b_2}{a}\\ \end{array} \]

Alternative 6: 66.9% accurate, 15.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b_2 \leq -1.9 \cdot 10^{-237}:\\ \;\;\;\;\frac{-0.5 \cdot c}{b_2}\\ \mathbf{else}:\\ \;\;\;\;\frac{b_2 \cdot -2}{a}\\ \end{array} \end{array} \]
(FPCore (a b_2 c)
 :precision binary64
 (if (<= b_2 -1.9e-237) (/ (* -0.5 c) b_2) (/ (* b_2 -2.0) a)))
double code(double a, double b_2, double c) {
	double tmp;
	if (b_2 <= -1.9e-237) {
		tmp = (-0.5 * c) / b_2;
	} else {
		tmp = (b_2 * -2.0) / a;
	}
	return tmp;
}
real(8) function code(a, b_2, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b_2
    real(8), intent (in) :: c
    real(8) :: tmp
    if (b_2 <= (-1.9d-237)) then
        tmp = ((-0.5d0) * c) / b_2
    else
        tmp = (b_2 * (-2.0d0)) / a
    end if
    code = tmp
end function
public static double code(double a, double b_2, double c) {
	double tmp;
	if (b_2 <= -1.9e-237) {
		tmp = (-0.5 * c) / b_2;
	} else {
		tmp = (b_2 * -2.0) / a;
	}
	return tmp;
}
def code(a, b_2, c):
	tmp = 0
	if b_2 <= -1.9e-237:
		tmp = (-0.5 * c) / b_2
	else:
		tmp = (b_2 * -2.0) / a
	return tmp
function code(a, b_2, c)
	tmp = 0.0
	if (b_2 <= -1.9e-237)
		tmp = Float64(Float64(-0.5 * c) / b_2);
	else
		tmp = Float64(Float64(b_2 * -2.0) / a);
	end
	return tmp
end
function tmp_2 = code(a, b_2, c)
	tmp = 0.0;
	if (b_2 <= -1.9e-237)
		tmp = (-0.5 * c) / b_2;
	else
		tmp = (b_2 * -2.0) / a;
	end
	tmp_2 = tmp;
end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -1.9e-237], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision], N[(N[(b$95$2 * -2.0), $MachinePrecision] / a), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -1.9 \cdot 10^{-237}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b_2}\\

\mathbf{else}:\\
\;\;\;\;\frac{b_2 \cdot -2}{a}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b_2 < -1.90000000000000012e-237

    1. Initial program 26.8%

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

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b_2}} \]
    3. Step-by-step derivation
      1. associate-*r/73.8%

        \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b_2}} \]
    4. Applied egg-rr73.8%

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

    if -1.90000000000000012e-237 < b_2

    1. Initial program 72.2%

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

      \[\leadsto \frac{\color{blue}{-2 \cdot b_2}}{a} \]
    3. Step-by-step derivation
      1. *-commutative60.7%

        \[\leadsto \frac{\color{blue}{b_2 \cdot -2}}{a} \]
    4. Simplified60.7%

      \[\leadsto \frac{\color{blue}{b_2 \cdot -2}}{a} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification66.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -1.9 \cdot 10^{-237}:\\ \;\;\;\;\frac{-0.5 \cdot c}{b_2}\\ \mathbf{else}:\\ \;\;\;\;\frac{b_2 \cdot -2}{a}\\ \end{array} \]

Alternative 7: 23.6% accurate, 18.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b_2 \leq -2.02 \cdot 10^{-237}:\\ \;\;\;\;\frac{0}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b_2}{a}\\ \end{array} \end{array} \]
(FPCore (a b_2 c)
 :precision binary64
 (if (<= b_2 -2.02e-237) (/ 0.0 a) (/ (- b_2) a)))
double code(double a, double b_2, double c) {
	double tmp;
	if (b_2 <= -2.02e-237) {
		tmp = 0.0 / a;
	} else {
		tmp = -b_2 / a;
	}
	return tmp;
}
real(8) function code(a, b_2, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b_2
    real(8), intent (in) :: c
    real(8) :: tmp
    if (b_2 <= (-2.02d-237)) then
        tmp = 0.0d0 / a
    else
        tmp = -b_2 / a
    end if
    code = tmp
end function
public static double code(double a, double b_2, double c) {
	double tmp;
	if (b_2 <= -2.02e-237) {
		tmp = 0.0 / a;
	} else {
		tmp = -b_2 / a;
	}
	return tmp;
}
def code(a, b_2, c):
	tmp = 0
	if b_2 <= -2.02e-237:
		tmp = 0.0 / a
	else:
		tmp = -b_2 / a
	return tmp
function code(a, b_2, c)
	tmp = 0.0
	if (b_2 <= -2.02e-237)
		tmp = Float64(0.0 / a);
	else
		tmp = Float64(Float64(-b_2) / a);
	end
	return tmp
end
function tmp_2 = code(a, b_2, c)
	tmp = 0.0;
	if (b_2 <= -2.02e-237)
		tmp = 0.0 / a;
	else
		tmp = -b_2 / a;
	end
	tmp_2 = tmp;
end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -2.02e-237], N[(0.0 / a), $MachinePrecision], N[((-b$95$2) / a), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -2.02 \cdot 10^{-237}:\\
\;\;\;\;\frac{0}{a}\\

\mathbf{else}:\\
\;\;\;\;\frac{-b_2}{a}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b_2 < -2.02e-237

    1. Initial program 26.8%

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a} \]
    2. Step-by-step derivation
      1. add-sqr-sqrt25.2%

        \[\leadsto \frac{\left(-b_2\right) - \color{blue}{\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}} \cdot \sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}}}{a} \]
      2. pow225.2%

        \[\leadsto \frac{\left(-b_2\right) - \color{blue}{{\left(\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}\right)}^{2}}}{a} \]
      3. pow1/225.2%

        \[\leadsto \frac{\left(-b_2\right) - {\left(\sqrt{\color{blue}{{\left(b_2 \cdot b_2 - a \cdot c\right)}^{0.5}}}\right)}^{2}}{a} \]
      4. sqrt-pow125.3%

        \[\leadsto \frac{\left(-b_2\right) - {\color{blue}{\left({\left(b_2 \cdot b_2 - a \cdot c\right)}^{\left(\frac{0.5}{2}\right)}\right)}}^{2}}{a} \]
      5. metadata-eval25.3%

        \[\leadsto \frac{\left(-b_2\right) - {\left({\left(b_2 \cdot b_2 - a \cdot c\right)}^{\color{blue}{0.25}}\right)}^{2}}{a} \]
    3. Applied egg-rr25.3%

      \[\leadsto \frac{\left(-b_2\right) - \color{blue}{{\left({\left(b_2 \cdot b_2 - a \cdot c\right)}^{0.25}\right)}^{2}}}{a} \]
    4. Taylor expanded in b_2 around -inf 21.2%

      \[\leadsto \frac{\color{blue}{b_2 + -1 \cdot b_2}}{a} \]
    5. Step-by-step derivation
      1. distribute-rgt1-in21.2%

        \[\leadsto \frac{\color{blue}{\left(-1 + 1\right) \cdot b_2}}{a} \]
      2. metadata-eval21.2%

        \[\leadsto \frac{\color{blue}{0} \cdot b_2}{a} \]
      3. mul0-lft21.2%

        \[\leadsto \frac{\color{blue}{0}}{a} \]
    6. Simplified21.2%

      \[\leadsto \frac{\color{blue}{0}}{a} \]

    if -2.02e-237 < b_2

    1. Initial program 72.2%

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a} \]
    2. Step-by-step derivation
      1. add-sqr-sqrt72.0%

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

        \[\leadsto \frac{\left(-b_2\right) - \color{blue}{{\left(\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}\right)}^{2}}}{a} \]
      3. pow1/272.0%

        \[\leadsto \frac{\left(-b_2\right) - {\left(\sqrt{\color{blue}{{\left(b_2 \cdot b_2 - a \cdot c\right)}^{0.5}}}\right)}^{2}}{a} \]
      4. sqrt-pow172.0%

        \[\leadsto \frac{\left(-b_2\right) - {\color{blue}{\left({\left(b_2 \cdot b_2 - a \cdot c\right)}^{\left(\frac{0.5}{2}\right)}\right)}}^{2}}{a} \]
      5. metadata-eval72.0%

        \[\leadsto \frac{\left(-b_2\right) - {\left({\left(b_2 \cdot b_2 - a \cdot c\right)}^{\color{blue}{0.25}}\right)}^{2}}{a} \]
    3. Applied egg-rr72.0%

      \[\leadsto \frac{\left(-b_2\right) - \color{blue}{{\left({\left(b_2 \cdot b_2 - a \cdot c\right)}^{0.25}\right)}^{2}}}{a} \]
    4. Taylor expanded in b_2 around inf 30.0%

      \[\leadsto \frac{\color{blue}{-1 \cdot b_2}}{a} \]
    5. Step-by-step derivation
      1. neg-mul-130.0%

        \[\leadsto \frac{\color{blue}{-b_2}}{a} \]
    6. Simplified30.0%

      \[\leadsto \frac{\color{blue}{-b_2}}{a} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification26.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -2.02 \cdot 10^{-237}:\\ \;\;\;\;\frac{0}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b_2}{a}\\ \end{array} \]

Alternative 8: 10.8% accurate, 37.3× speedup?

\[\begin{array}{l} \\ \frac{0}{a} \end{array} \]
(FPCore (a b_2 c) :precision binary64 (/ 0.0 a))
double code(double a, double b_2, double c) {
	return 0.0 / a;
}
real(8) function code(a, b_2, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b_2
    real(8), intent (in) :: c
    code = 0.0d0 / a
end function
public static double code(double a, double b_2, double c) {
	return 0.0 / a;
}
def code(a, b_2, c):
	return 0.0 / a
function code(a, b_2, c)
	return Float64(0.0 / a)
end
function tmp = code(a, b_2, c)
	tmp = 0.0 / a;
end
code[a_, b$95$2_, c_] := N[(0.0 / a), $MachinePrecision]
\begin{array}{l}

\\
\frac{0}{a}
\end{array}
Derivation
  1. Initial program 52.2%

    \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a} \]
  2. Step-by-step derivation
    1. add-sqr-sqrt51.4%

      \[\leadsto \frac{\left(-b_2\right) - \color{blue}{\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}} \cdot \sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}}}{a} \]
    2. pow251.4%

      \[\leadsto \frac{\left(-b_2\right) - \color{blue}{{\left(\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}\right)}^{2}}}{a} \]
    3. pow1/251.4%

      \[\leadsto \frac{\left(-b_2\right) - {\left(\sqrt{\color{blue}{{\left(b_2 \cdot b_2 - a \cdot c\right)}^{0.5}}}\right)}^{2}}{a} \]
    4. sqrt-pow151.4%

      \[\leadsto \frac{\left(-b_2\right) - {\color{blue}{\left({\left(b_2 \cdot b_2 - a \cdot c\right)}^{\left(\frac{0.5}{2}\right)}\right)}}^{2}}{a} \]
    5. metadata-eval51.4%

      \[\leadsto \frac{\left(-b_2\right) - {\left({\left(b_2 \cdot b_2 - a \cdot c\right)}^{\color{blue}{0.25}}\right)}^{2}}{a} \]
  3. Applied egg-rr51.4%

    \[\leadsto \frac{\left(-b_2\right) - \color{blue}{{\left({\left(b_2 \cdot b_2 - a \cdot c\right)}^{0.25}\right)}^{2}}}{a} \]
  4. Taylor expanded in b_2 around -inf 10.8%

    \[\leadsto \frac{\color{blue}{b_2 + -1 \cdot b_2}}{a} \]
  5. Step-by-step derivation
    1. distribute-rgt1-in10.8%

      \[\leadsto \frac{\color{blue}{\left(-1 + 1\right) \cdot b_2}}{a} \]
    2. metadata-eval10.8%

      \[\leadsto \frac{\color{blue}{0} \cdot b_2}{a} \]
    3. mul0-lft10.8%

      \[\leadsto \frac{\color{blue}{0}}{a} \]
  6. Simplified10.8%

    \[\leadsto \frac{\color{blue}{0}}{a} \]
  7. Final simplification10.8%

    \[\leadsto \frac{0}{a} \]

Developer target: 59.8% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{\left|a\right|} \cdot \sqrt{\left|c\right|}\\ t_1 := \begin{array}{l} \mathbf{if}\;\mathsf{copysign}\left(a, c\right) = a:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;\left|b_2\right| > t_0:\\ \;\;\;\;\sqrt{\left|b_2\right| - t_0} \cdot \sqrt{\left|b_2\right| + t_0}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{NaN}\\ \end{array}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{hypot}\left(b_2, t_0\right)\\ \end{array}\\ \mathbf{if}\;b_2 < 0:\\ \;\;\;\;\frac{c}{t_1 - \frac{b_2}{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{b_2}{2} + t_1}{-a}\\ \end{array} \end{array} \]
(FPCore (a b_2 c)
 :precision binary64
 (let* ((t_0 (* (sqrt (fabs a)) (sqrt (fabs c))))
        (t_1
         (if (== (copysign a c) a)
           (if (> (fabs b_2) t_0)
             (* (sqrt (- (fabs b_2) t_0)) (sqrt (+ (fabs b_2) t_0)))
             NAN)
           (hypot b_2 t_0))))
   (if (< b_2 0.0) (/ c (- t_1 (/ b_2 2.0))) (/ (+ (/ b_2 2.0) t_1) (- a)))))
double code(double a, double b_2, double c) {
	double t_0 = sqrt(fabs(a)) * sqrt(fabs(c));
	double tmp_1;
	if (copysign(a, c) == a) {
		double tmp_2;
		if (fabs(b_2) > t_0) {
			tmp_2 = sqrt((fabs(b_2) - t_0)) * sqrt((fabs(b_2) + t_0));
		} else {
			tmp_2 = (double) NAN;
		}
		tmp_1 = tmp_2;
	} else {
		tmp_1 = hypot(b_2, t_0);
	}
	double t_1 = tmp_1;
	double tmp_3;
	if (b_2 < 0.0) {
		tmp_3 = c / (t_1 - (b_2 / 2.0));
	} else {
		tmp_3 = ((b_2 / 2.0) + t_1) / -a;
	}
	return tmp_3;
}
public static double code(double a, double b_2, double c) {
	double t_0 = Math.sqrt(Math.abs(a)) * Math.sqrt(Math.abs(c));
	double tmp_1;
	if (Math.copySign(a, c) == a) {
		double tmp_2;
		if (Math.abs(b_2) > t_0) {
			tmp_2 = Math.sqrt((Math.abs(b_2) - t_0)) * Math.sqrt((Math.abs(b_2) + t_0));
		} else {
			tmp_2 = Double.NaN;
		}
		tmp_1 = tmp_2;
	} else {
		tmp_1 = Math.hypot(b_2, t_0);
	}
	double t_1 = tmp_1;
	double tmp_3;
	if (b_2 < 0.0) {
		tmp_3 = c / (t_1 - (b_2 / 2.0));
	} else {
		tmp_3 = ((b_2 / 2.0) + t_1) / -a;
	}
	return tmp_3;
}
def code(a, b_2, c):
	t_0 = math.sqrt(math.fabs(a)) * math.sqrt(math.fabs(c))
	tmp_1 = 0
	if math.copysign(a, c) == a:
		tmp_2 = 0
		if math.fabs(b_2) > t_0:
			tmp_2 = math.sqrt((math.fabs(b_2) - t_0)) * math.sqrt((math.fabs(b_2) + t_0))
		else:
			tmp_2 = math.nan
		tmp_1 = tmp_2
	else:
		tmp_1 = math.hypot(b_2, t_0)
	t_1 = tmp_1
	tmp_3 = 0
	if b_2 < 0.0:
		tmp_3 = c / (t_1 - (b_2 / 2.0))
	else:
		tmp_3 = ((b_2 / 2.0) + t_1) / -a
	return tmp_3
function code(a, b_2, c)
	t_0 = Float64(sqrt(abs(a)) * sqrt(abs(c)))
	tmp_1 = 0.0
	if (copysign(a, c) == a)
		tmp_2 = 0.0
		if (abs(b_2) > t_0)
			tmp_2 = Float64(sqrt(Float64(abs(b_2) - t_0)) * sqrt(Float64(abs(b_2) + t_0)));
		else
			tmp_2 = NaN;
		end
		tmp_1 = tmp_2;
	else
		tmp_1 = hypot(b_2, t_0);
	end
	t_1 = tmp_1
	tmp_3 = 0.0
	if (b_2 < 0.0)
		tmp_3 = Float64(c / Float64(t_1 - Float64(b_2 / 2.0)));
	else
		tmp_3 = Float64(Float64(Float64(b_2 / 2.0) + t_1) / Float64(-a));
	end
	return tmp_3
end
function tmp_5 = code(a, b_2, c)
	t_0 = sqrt(abs(a)) * sqrt(abs(c));
	tmp_2 = 0.0;
	if ((sign(c) * abs(a)) == a)
		tmp_3 = 0.0;
		if (abs(b_2) > t_0)
			tmp_3 = sqrt((abs(b_2) - t_0)) * sqrt((abs(b_2) + t_0));
		else
			tmp_3 = NaN;
		end
		tmp_2 = tmp_3;
	else
		tmp_2 = hypot(b_2, t_0);
	end
	t_1 = tmp_2;
	tmp_4 = 0.0;
	if (b_2 < 0.0)
		tmp_4 = c / (t_1 - (b_2 / 2.0));
	else
		tmp_4 = ((b_2 / 2.0) + t_1) / -a;
	end
	tmp_5 = tmp_4;
end
code[a_, b$95$2_, c_] := Block[{t$95$0 = N[(N[Sqrt[N[Abs[a], $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[Abs[c], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = If[Equal[N[With[{TMP1 = Abs[a], TMP2 = Sign[c]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], a], If[Greater[N[Abs[b$95$2], $MachinePrecision], t$95$0], N[(N[Sqrt[N[(N[Abs[b$95$2], $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(N[Abs[b$95$2], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], Indeterminate], N[Sqrt[b$95$2 ^ 2 + t$95$0 ^ 2], $MachinePrecision]]}, If[Less[b$95$2, 0.0], N[(c / N[(t$95$1 - N[(b$95$2 / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(b$95$2 / 2.0), $MachinePrecision] + t$95$1), $MachinePrecision] / (-a)), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sqrt{\left|a\right|} \cdot \sqrt{\left|c\right|}\\
t_1 := \begin{array}{l}
\mathbf{if}\;\mathsf{copysign}\left(a, c\right) = a:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;\left|b_2\right| > t_0:\\
\;\;\;\;\sqrt{\left|b_2\right| - t_0} \cdot \sqrt{\left|b_2\right| + t_0}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{NaN}\\


\end{array}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{hypot}\left(b_2, t_0\right)\\


\end{array}\\
\mathbf{if}\;b_2 < 0:\\
\;\;\;\;\frac{c}{t_1 - \frac{b_2}{2}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{b_2}{2} + t_1}{-a}\\


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2023287 
(FPCore (a b_2 c)
  :name "quad2m (problem 3.2.1, negative)"
  :precision binary64

  :herbie-target
  (if (< b_2 0.0) (/ c (- (if (== (copysign a c) a) (if (> (fabs b_2) (* (sqrt (fabs a)) (sqrt (fabs c)))) (* (sqrt (- (fabs b_2) (* (sqrt (fabs a)) (sqrt (fabs c))))) (sqrt (+ (fabs b_2) (* (sqrt (fabs a)) (sqrt (fabs c)))))) NAN) (hypot b_2 (* (sqrt (fabs a)) (sqrt (fabs c))))) (/ b_2 2.0))) (/ (+ (/ b_2 2.0) (if (== (copysign a c) a) (if (> (fabs b_2) (* (sqrt (fabs a)) (sqrt (fabs c)))) (* (sqrt (- (fabs b_2) (* (sqrt (fabs a)) (sqrt (fabs c))))) (sqrt (+ (fabs b_2) (* (sqrt (fabs a)) (sqrt (fabs c)))))) NAN) (hypot b_2 (* (sqrt (fabs a)) (sqrt (fabs c)))))) (- a)))

  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))