quad2p (problem 3.2.1, positive)

Percentage Accurate: 53.7% → 86.1%
Time: 9.1s
Alternatives: 9
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 9 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.7% 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: 86.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b_2 \leq -1 \cdot 10^{+154}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \leq 2.3 \cdot 10^{-40}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b_2}\\ \end{array} \end{array} \]
(FPCore (a b_2 c)
 :precision binary64
 (if (<= b_2 -1e+154)
   (+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2)))
   (if (<= b_2 2.3e-40)
     (/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)
     (/ (* c -0.5) b_2))))
double code(double a, double b_2, double c) {
	double tmp;
	if (b_2 <= -1e+154) {
		tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
	} else if (b_2 <= 2.3e-40) {
		tmp = (sqrt(((b_2 * b_2) - (a * c))) - b_2) / a;
	} else {
		tmp = (c * -0.5) / b_2;
	}
	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 <= (-1d+154)) then
        tmp = ((-2.0d0) * (b_2 / a)) + (0.5d0 * (c / b_2))
    else if (b_2 <= 2.3d-40) then
        tmp = (sqrt(((b_2 * b_2) - (a * c))) - b_2) / a
    else
        tmp = (c * (-0.5d0)) / b_2
    end if
    code = tmp
end function
public static double code(double a, double b_2, double c) {
	double tmp;
	if (b_2 <= -1e+154) {
		tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
	} else if (b_2 <= 2.3e-40) {
		tmp = (Math.sqrt(((b_2 * b_2) - (a * c))) - b_2) / a;
	} else {
		tmp = (c * -0.5) / b_2;
	}
	return tmp;
}
def code(a, b_2, c):
	tmp = 0
	if b_2 <= -1e+154:
		tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2))
	elif b_2 <= 2.3e-40:
		tmp = (math.sqrt(((b_2 * b_2) - (a * c))) - b_2) / a
	else:
		tmp = (c * -0.5) / b_2
	return tmp
function code(a, b_2, c)
	tmp = 0.0
	if (b_2 <= -1e+154)
		tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2)));
	elseif (b_2 <= 2.3e-40)
		tmp = Float64(Float64(sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c))) - b_2) / a);
	else
		tmp = Float64(Float64(c * -0.5) / b_2);
	end
	return tmp
end
function tmp_2 = code(a, b_2, c)
	tmp = 0.0;
	if (b_2 <= -1e+154)
		tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
	elseif (b_2 <= 2.3e-40)
		tmp = (sqrt(((b_2 * b_2) - (a * c))) - b_2) / a;
	else
		tmp = (c * -0.5) / b_2;
	end
	tmp_2 = tmp;
end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -1e+154], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 2.3e-40], N[(N[(N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b$95$2), $MachinePrecision] / a), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b$95$2), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -1 \cdot 10^{+154}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b_2 < -1.00000000000000004e154

    1. Initial program 42.0%

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

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

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a} \]
    3. Simplified42.0%

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}} \]
    4. Taylor expanded in b_2 around -inf 98.1%

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

    if -1.00000000000000004e154 < b_2 < 2.3e-40

    1. Initial program 81.2%

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

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

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a} \]
    3. Simplified81.2%

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

    if 2.3e-40 < b_2

    1. Initial program 11.8%

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

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

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a} \]
    3. Simplified11.8%

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}} \]
    4. Step-by-step derivation
      1. prod-diff11.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{0.5 \cdot \left(c + -2 \cdot c\right)}{b_2}} \]
      2. distribute-rgt1-in91.0%

        \[\leadsto \frac{0.5 \cdot \color{blue}{\left(\left(-2 + 1\right) \cdot c\right)}}{b_2} \]
      3. metadata-eval91.0%

        \[\leadsto \frac{0.5 \cdot \left(\color{blue}{-1} \cdot c\right)}{b_2} \]
      4. associate-*r*91.0%

        \[\leadsto \frac{\color{blue}{\left(0.5 \cdot -1\right) \cdot c}}{b_2} \]
      5. metadata-eval91.0%

        \[\leadsto \frac{\color{blue}{-0.5} \cdot c}{b_2} \]
      6. associate-*r/91.0%

        \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b_2}} \]
      7. *-commutative91.0%

        \[\leadsto \color{blue}{\frac{c}{b_2} \cdot -0.5} \]
      8. associate-*l/91.0%

        \[\leadsto \color{blue}{\frac{c \cdot -0.5}{b_2}} \]
    8. Simplified91.0%

      \[\leadsto \color{blue}{\frac{c \cdot -0.5}{b_2}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification87.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -1 \cdot 10^{+154}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \leq 2.3 \cdot 10^{-40}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b_2}\\ \end{array} \]

Alternative 2: 80.1% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -1.6 \cdot 10^{-123}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\

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

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


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

    1. Initial program 65.3%

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

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

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a} \]
    3. Simplified65.3%

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}} \]
    4. Taylor expanded in b_2 around -inf 85.5%

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

    if -1.59999999999999989e-123 < b_2 < 1.8999999999999999e-40

    1. Initial program 76.2%

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

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

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a} \]
    3. Simplified76.2%

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}} \]
    4. Taylor expanded in b_2 around 0 74.0%

      \[\leadsto \frac{\sqrt{\color{blue}{-1 \cdot \left(c \cdot a\right)}} - b_2}{a} \]
    5. Step-by-step derivation
      1. mul-1-neg74.0%

        \[\leadsto \frac{\sqrt{\color{blue}{-c \cdot a}} - b_2}{a} \]
      2. distribute-rgt-neg-out74.0%

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

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

    if 1.8999999999999999e-40 < b_2

    1. Initial program 11.8%

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

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

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a} \]
    3. Simplified11.8%

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}} \]
    4. Step-by-step derivation
      1. prod-diff11.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{0.5 \cdot \left(c + -2 \cdot c\right)}{b_2}} \]
      2. distribute-rgt1-in91.0%

        \[\leadsto \frac{0.5 \cdot \color{blue}{\left(\left(-2 + 1\right) \cdot c\right)}}{b_2} \]
      3. metadata-eval91.0%

        \[\leadsto \frac{0.5 \cdot \left(\color{blue}{-1} \cdot c\right)}{b_2} \]
      4. associate-*r*91.0%

        \[\leadsto \frac{\color{blue}{\left(0.5 \cdot -1\right) \cdot c}}{b_2} \]
      5. metadata-eval91.0%

        \[\leadsto \frac{\color{blue}{-0.5} \cdot c}{b_2} \]
      6. associate-*r/91.0%

        \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b_2}} \]
      7. *-commutative91.0%

        \[\leadsto \color{blue}{\frac{c}{b_2} \cdot -0.5} \]
      8. associate-*l/91.0%

        \[\leadsto \color{blue}{\frac{c \cdot -0.5}{b_2}} \]
    8. Simplified91.0%

      \[\leadsto \color{blue}{\frac{c \cdot -0.5}{b_2}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification84.3%

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

Alternative 3: 79.9% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -1.6 \cdot 10^{-123}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\

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

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


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

    1. Initial program 65.3%

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

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

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a} \]
    3. Simplified65.3%

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}} \]
    4. Taylor expanded in b_2 around -inf 85.5%

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

    if -1.59999999999999989e-123 < b_2 < 3.7000000000000002e-41

    1. Initial program 76.2%

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

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

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a} \]
    3. Simplified76.2%

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}} \]
    4. Step-by-step derivation
      1. prod-diff75.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{a} \cdot \sqrt{c \cdot a + -2 \cdot \left(c \cdot a\right)}} \]
    7. Step-by-step derivation
      1. associate-*l/73.5%

        \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{c \cdot a + -2 \cdot \left(c \cdot a\right)}}{a}} \]
      2. *-lft-identity73.5%

        \[\leadsto \frac{\color{blue}{\sqrt{c \cdot a + -2 \cdot \left(c \cdot a\right)}}}{a} \]
      3. distribute-rgt1-in73.7%

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

        \[\leadsto \frac{\sqrt{\color{blue}{-1} \cdot \left(c \cdot a\right)}}{a} \]
      5. mul-1-neg73.7%

        \[\leadsto \frac{\sqrt{\color{blue}{-c \cdot a}}}{a} \]
      6. *-commutative73.7%

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

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

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

    if 3.7000000000000002e-41 < b_2

    1. Initial program 11.8%

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

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

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a} \]
    3. Simplified11.8%

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}} \]
    4. Step-by-step derivation
      1. prod-diff11.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{0.5 \cdot \left(c + -2 \cdot c\right)}{b_2}} \]
      2. distribute-rgt1-in91.0%

        \[\leadsto \frac{0.5 \cdot \color{blue}{\left(\left(-2 + 1\right) \cdot c\right)}}{b_2} \]
      3. metadata-eval91.0%

        \[\leadsto \frac{0.5 \cdot \left(\color{blue}{-1} \cdot c\right)}{b_2} \]
      4. associate-*r*91.0%

        \[\leadsto \frac{\color{blue}{\left(0.5 \cdot -1\right) \cdot c}}{b_2} \]
      5. metadata-eval91.0%

        \[\leadsto \frac{\color{blue}{-0.5} \cdot c}{b_2} \]
      6. associate-*r/91.0%

        \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b_2}} \]
      7. *-commutative91.0%

        \[\leadsto \color{blue}{\frac{c}{b_2} \cdot -0.5} \]
      8. associate-*l/91.0%

        \[\leadsto \color{blue}{\frac{c \cdot -0.5}{b_2}} \]
    8. Simplified91.0%

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

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

Alternative 4: 67.4% accurate, 8.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -5 \cdot 10^{-310}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\

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


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

    1. Initial program 69.9%

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

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

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a} \]
    3. Simplified69.9%

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}} \]
    4. Taylor expanded in b_2 around -inf 68.6%

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

    if -4.999999999999985e-310 < b_2

    1. Initial program 31.0%

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

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

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a} \]
    3. Simplified31.0%

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}} \]
    4. Step-by-step derivation
      1. prod-diff30.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{0.5 \cdot \left(c + -2 \cdot c\right)}{b_2}} \]
      2. distribute-rgt1-in69.7%

        \[\leadsto \frac{0.5 \cdot \color{blue}{\left(\left(-2 + 1\right) \cdot c\right)}}{b_2} \]
      3. metadata-eval69.7%

        \[\leadsto \frac{0.5 \cdot \left(\color{blue}{-1} \cdot c\right)}{b_2} \]
      4. associate-*r*69.7%

        \[\leadsto \frac{\color{blue}{\left(0.5 \cdot -1\right) \cdot c}}{b_2} \]
      5. metadata-eval69.7%

        \[\leadsto \frac{\color{blue}{-0.5} \cdot c}{b_2} \]
      6. associate-*r/69.7%

        \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b_2}} \]
      7. *-commutative69.7%

        \[\leadsto \color{blue}{\frac{c}{b_2} \cdot -0.5} \]
      8. associate-*l/69.7%

        \[\leadsto \color{blue}{\frac{c \cdot -0.5}{b_2}} \]
    8. Simplified69.7%

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

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

Alternative 5: 42.9% accurate, 15.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b_2 \leq 1.15 \cdot 10^{-216}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
(FPCore (a b_2 c)
 :precision binary64
 (if (<= b_2 1.15e-216) (* -2.0 (/ b_2 a)) 0.0))
double code(double a, double b_2, double c) {
	double tmp;
	if (b_2 <= 1.15e-216) {
		tmp = -2.0 * (b_2 / a);
	} else {
		tmp = 0.0;
	}
	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-216) then
        tmp = (-2.0d0) * (b_2 / a)
    else
        tmp = 0.0d0
    end if
    code = tmp
end function
public static double code(double a, double b_2, double c) {
	double tmp;
	if (b_2 <= 1.15e-216) {
		tmp = -2.0 * (b_2 / a);
	} else {
		tmp = 0.0;
	}
	return tmp;
}
def code(a, b_2, c):
	tmp = 0
	if b_2 <= 1.15e-216:
		tmp = -2.0 * (b_2 / a)
	else:
		tmp = 0.0
	return tmp
function code(a, b_2, c)
	tmp = 0.0
	if (b_2 <= 1.15e-216)
		tmp = Float64(-2.0 * Float64(b_2 / a));
	else
		tmp = 0.0;
	end
	return tmp
end
function tmp_2 = code(a, b_2, c)
	tmp = 0.0;
	if (b_2 <= 1.15e-216)
		tmp = -2.0 * (b_2 / a);
	else
		tmp = 0.0;
	end
	tmp_2 = tmp;
end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, 1.15e-216], N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq 1.15 \cdot 10^{-216}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a}\\

\mathbf{else}:\\
\;\;\;\;0\\


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

    1. Initial program 70.9%

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

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

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a} \]
    3. Simplified70.9%

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}} \]
    4. Taylor expanded in b_2 around -inf 60.0%

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

    if 1.14999999999999998e-216 < b_2

    1. Initial program 24.5%

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

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

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a} \]
    3. Simplified24.5%

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}} \]
    4. Step-by-step derivation
      1. add-sqr-sqrt23.2%

        \[\leadsto \frac{\color{blue}{\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}} \cdot \sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}} - b_2}{a} \]
      2. pow223.2%

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

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

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

        \[\leadsto \frac{{\left({\color{blue}{\left(\mathsf{fma}\left(b_2, b_2, -a \cdot c\right)\right)}}^{\left(\frac{0.5}{2}\right)}\right)}^{2} - b_2}{a} \]
      6. *-commutative23.3%

        \[\leadsto \frac{{\left({\left(\mathsf{fma}\left(b_2, b_2, -\color{blue}{c \cdot a}\right)\right)}^{\left(\frac{0.5}{2}\right)}\right)}^{2} - b_2}{a} \]
      7. distribute-rgt-neg-in23.3%

        \[\leadsto \frac{{\left({\left(\mathsf{fma}\left(b_2, b_2, \color{blue}{c \cdot \left(-a\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)}\right)}^{2} - b_2}{a} \]
      8. metadata-eval23.3%

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

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

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

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

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

        \[\leadsto \color{blue}{0} \]
    8. Simplified19.6%

      \[\leadsto \color{blue}{0} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification40.9%

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

Alternative 6: 67.1% accurate, 15.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq 2 \cdot 10^{-249}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a}\\

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


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

    1. Initial program 71.6%

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

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

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a} \]
    3. Simplified71.6%

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}} \]
    4. Taylor expanded in b_2 around -inf 64.4%

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

    if 2.00000000000000011e-249 < b_2

    1. Initial program 27.3%

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

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

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a} \]
    3. Simplified27.3%

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}} \]
    4. Taylor expanded in b_2 around inf 73.2%

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b_2}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification68.9%

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

Alternative 7: 67.2% accurate, 15.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq 2 \cdot 10^{-249}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a}\\

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


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

    1. Initial program 71.6%

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

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

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a} \]
    3. Simplified71.6%

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}} \]
    4. Taylor expanded in b_2 around -inf 64.4%

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

    if 2.00000000000000011e-249 < b_2

    1. Initial program 27.3%

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

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

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a} \]
    3. Simplified27.3%

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}} \]
    4. Step-by-step derivation
      1. prod-diff27.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{0.5 \cdot \left(c + -2 \cdot c\right)}{b_2}} \]
      2. distribute-rgt1-in73.2%

        \[\leadsto \frac{0.5 \cdot \color{blue}{\left(\left(-2 + 1\right) \cdot c\right)}}{b_2} \]
      3. metadata-eval73.2%

        \[\leadsto \frac{0.5 \cdot \left(\color{blue}{-1} \cdot c\right)}{b_2} \]
      4. associate-*r*73.2%

        \[\leadsto \frac{\color{blue}{\left(0.5 \cdot -1\right) \cdot c}}{b_2} \]
      5. metadata-eval73.2%

        \[\leadsto \frac{\color{blue}{-0.5} \cdot c}{b_2} \]
      6. associate-*r/73.2%

        \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b_2}} \]
      7. *-commutative73.2%

        \[\leadsto \color{blue}{\frac{c}{b_2} \cdot -0.5} \]
      8. associate-*l/73.2%

        \[\leadsto \color{blue}{\frac{c \cdot -0.5}{b_2}} \]
    8. Simplified73.2%

      \[\leadsto \color{blue}{\frac{c \cdot -0.5}{b_2}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification68.9%

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

Alternative 8: 23.5% accurate, 18.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b_2 \leq 1.15 \cdot 10^{-216}:\\ \;\;\;\;\frac{-b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
(FPCore (a b_2 c)
 :precision binary64
 (if (<= b_2 1.15e-216) (/ (- b_2) a) 0.0))
double code(double a, double b_2, double c) {
	double tmp;
	if (b_2 <= 1.15e-216) {
		tmp = -b_2 / a;
	} else {
		tmp = 0.0;
	}
	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-216) then
        tmp = -b_2 / a
    else
        tmp = 0.0d0
    end if
    code = tmp
end function
public static double code(double a, double b_2, double c) {
	double tmp;
	if (b_2 <= 1.15e-216) {
		tmp = -b_2 / a;
	} else {
		tmp = 0.0;
	}
	return tmp;
}
def code(a, b_2, c):
	tmp = 0
	if b_2 <= 1.15e-216:
		tmp = -b_2 / a
	else:
		tmp = 0.0
	return tmp
function code(a, b_2, c)
	tmp = 0.0
	if (b_2 <= 1.15e-216)
		tmp = Float64(Float64(-b_2) / a);
	else
		tmp = 0.0;
	end
	return tmp
end
function tmp_2 = code(a, b_2, c)
	tmp = 0.0;
	if (b_2 <= 1.15e-216)
		tmp = -b_2 / a;
	else
		tmp = 0.0;
	end
	tmp_2 = tmp;
end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, 1.15e-216], N[((-b$95$2) / a), $MachinePrecision], 0.0]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq 1.15 \cdot 10^{-216}:\\
\;\;\;\;\frac{-b_2}{a}\\

\mathbf{else}:\\
\;\;\;\;0\\


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

    1. Initial program 70.9%

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

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

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a} \]
    3. Simplified70.9%

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}} \]
    4. Step-by-step derivation
      1. add-sqr-sqrt70.7%

        \[\leadsto \frac{\color{blue}{\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}} \cdot \sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}} - b_2}{a} \]
      2. pow270.7%

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

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

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

        \[\leadsto \frac{{\left({\color{blue}{\left(\mathsf{fma}\left(b_2, b_2, -a \cdot c\right)\right)}}^{\left(\frac{0.5}{2}\right)}\right)}^{2} - b_2}{a} \]
      6. *-commutative70.8%

        \[\leadsto \frac{{\left({\left(\mathsf{fma}\left(b_2, b_2, -\color{blue}{c \cdot a}\right)\right)}^{\left(\frac{0.5}{2}\right)}\right)}^{2} - b_2}{a} \]
      7. distribute-rgt-neg-in70.8%

        \[\leadsto \frac{{\left({\left(\mathsf{fma}\left(b_2, b_2, \color{blue}{c \cdot \left(-a\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)}\right)}^{2} - b_2}{a} \]
      8. metadata-eval70.8%

        \[\leadsto \frac{{\left({\left(\mathsf{fma}\left(b_2, b_2, c \cdot \left(-a\right)\right)\right)}^{\color{blue}{0.25}}\right)}^{2} - b_2}{a} \]
    5. Applied egg-rr70.8%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{b_2}{a}} \]
    7. Step-by-step derivation
      1. associate-*r/25.6%

        \[\leadsto \color{blue}{\frac{-1 \cdot b_2}{a}} \]
      2. mul-1-neg25.6%

        \[\leadsto \frac{\color{blue}{-b_2}}{a} \]
    8. Simplified25.6%

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

    if 1.14999999999999998e-216 < b_2

    1. Initial program 24.5%

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

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

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a} \]
    3. Simplified24.5%

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}} \]
    4. Step-by-step derivation
      1. add-sqr-sqrt23.2%

        \[\leadsto \frac{\color{blue}{\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}} \cdot \sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}} - b_2}{a} \]
      2. pow223.2%

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

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

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

        \[\leadsto \frac{{\left({\color{blue}{\left(\mathsf{fma}\left(b_2, b_2, -a \cdot c\right)\right)}}^{\left(\frac{0.5}{2}\right)}\right)}^{2} - b_2}{a} \]
      6. *-commutative23.3%

        \[\leadsto \frac{{\left({\left(\mathsf{fma}\left(b_2, b_2, -\color{blue}{c \cdot a}\right)\right)}^{\left(\frac{0.5}{2}\right)}\right)}^{2} - b_2}{a} \]
      7. distribute-rgt-neg-in23.3%

        \[\leadsto \frac{{\left({\left(\mathsf{fma}\left(b_2, b_2, \color{blue}{c \cdot \left(-a\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)}\right)}^{2} - b_2}{a} \]
      8. metadata-eval23.3%

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

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

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

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

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

        \[\leadsto \color{blue}{0} \]
    8. Simplified19.6%

      \[\leadsto \color{blue}{0} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification22.8%

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

Alternative 9: 11.2% accurate, 112.0× speedup?

\[\begin{array}{l} \\ 0 \end{array} \]
(FPCore (a b_2 c) :precision binary64 0.0)
double code(double a, double b_2, double c) {
	return 0.0;
}
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
end function
public static double code(double a, double b_2, double c) {
	return 0.0;
}
def code(a, b_2, c):
	return 0.0
function code(a, b_2, c)
	return 0.0
end
function tmp = code(a, b_2, c)
	tmp = 0.0;
end
code[a_, b$95$2_, c_] := 0.0
\begin{array}{l}

\\
0
\end{array}
Derivation
  1. Initial program 48.9%

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

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

      \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a} \]
  3. Simplified48.9%

    \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}} \]
  4. Step-by-step derivation
    1. add-sqr-sqrt48.2%

      \[\leadsto \frac{\color{blue}{\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}} \cdot \sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}} - b_2}{a} \]
    2. pow248.2%

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

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

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

      \[\leadsto \frac{{\left({\color{blue}{\left(\mathsf{fma}\left(b_2, b_2, -a \cdot c\right)\right)}}^{\left(\frac{0.5}{2}\right)}\right)}^{2} - b_2}{a} \]
    6. *-commutative48.4%

      \[\leadsto \frac{{\left({\left(\mathsf{fma}\left(b_2, b_2, -\color{blue}{c \cdot a}\right)\right)}^{\left(\frac{0.5}{2}\right)}\right)}^{2} - b_2}{a} \]
    7. distribute-rgt-neg-in48.4%

      \[\leadsto \frac{{\left({\left(\mathsf{fma}\left(b_2, b_2, \color{blue}{c \cdot \left(-a\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)}\right)}^{2} - b_2}{a} \]
    8. metadata-eval48.4%

      \[\leadsto \frac{{\left({\left(\mathsf{fma}\left(b_2, b_2, c \cdot \left(-a\right)\right)\right)}^{\color{blue}{0.25}}\right)}^{2} - b_2}{a} \]
  5. Applied egg-rr48.4%

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

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

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

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

      \[\leadsto \color{blue}{0} \]
  8. Simplified10.7%

    \[\leadsto \color{blue}{0} \]
  9. Final simplification10.7%

    \[\leadsto 0 \]

Reproduce

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