quad2m (problem 3.2.1, negative)

Percentage Accurate: 51.5% → 86.0%
Time: 14.1s
Alternatives: 9
Speedup: 0.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: 51.5% 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.0% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -7.6 \cdot 10^{-68}:\\
\;\;\;\;\frac{c \cdot \left(0.5 + 0.125 \cdot \left(c \cdot \frac{a}{{b\_2}^{2}}\right)\right)}{-b\_2}\\

\mathbf{elif}\;b\_2 \leq 6 \cdot 10^{+110}:\\
\;\;\;\;\frac{\frac{{b\_2}^{2}}{-b\_2} - \sqrt{b\_2 \cdot b\_2 - c \cdot a}}{a}\\

\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a} + 0.5 \cdot \frac{c}{b\_2}\\


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

    1. Initial program 15.3%

      \[\frac{\left(-b\_2\right) - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. prod-diff15.0%

        \[\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. *-commutative15.0%

        \[\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. fmm-def15.0%

        \[\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-diff15.0%

        \[\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. *-commutative15.0%

        \[\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. fmm-def15.0%

        \[\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+15.0%

        \[\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. sub-neg15.0%

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\color{blue}{\left(b\_2 \cdot b\_2 + \left(-a \cdot c\right)\right)} + \left(\mathsf{fma}\left(-c, a, c \cdot a\right) + \mathsf{fma}\left(-c, a, c \cdot a\right)\right)}}{a} \]
      9. +-commutative15.0%

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\color{blue}{\left(\left(-a \cdot c\right) + b\_2 \cdot b\_2\right)} + \left(\mathsf{fma}\left(-c, a, c \cdot a\right) + \mathsf{fma}\left(-c, a, c \cdot a\right)\right)}}{a} \]
      10. distribute-rgt-neg-in15.0%

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\left(\color{blue}{a \cdot \left(-c\right)} + b\_2 \cdot b\_2\right) + \left(\mathsf{fma}\left(-c, a, c \cdot a\right) + \mathsf{fma}\left(-c, a, c \cdot a\right)\right)}}{a} \]
      11. fma-define15.0%

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

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\mathsf{fma}\left(a, -c, \color{blue}{{b\_2}^{2}}\right) + \left(\mathsf{fma}\left(-c, a, c \cdot a\right) + \mathsf{fma}\left(-c, a, c \cdot a\right)\right)}}{a} \]
      13. *-commutative15.0%

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\mathsf{fma}\left(a, -c, {b\_2}^{2}\right) + \left(\mathsf{fma}\left(-c, a, \color{blue}{a \cdot c}\right) + \mathsf{fma}\left(-c, a, c \cdot a\right)\right)}}{a} \]
      14. fma-undefine15.0%

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\mathsf{fma}\left(a, -c, {b\_2}^{2}\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} \]
      15. distribute-lft-neg-in15.0%

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\mathsf{fma}\left(a, -c, {b\_2}^{2}\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} \]
      16. *-commutative15.0%

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\mathsf{fma}\left(a, -c, {b\_2}^{2}\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} \]
      17. distribute-rgt-neg-in15.0%

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\mathsf{fma}\left(a, -c, {b\_2}^{2}\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} \]
      18. fma-define15.0%

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\mathsf{fma}\left(a, -c, {b\_2}^{2}\right) + \left(\color{blue}{\mathsf{fma}\left(a, -c, a \cdot c\right)} + \mathsf{fma}\left(-c, a, c \cdot a\right)\right)}}{a} \]
      19. *-commutative15.0%

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\mathsf{fma}\left(a, -c, {b\_2}^{2}\right) + \left(\mathsf{fma}\left(a, -c, a \cdot c\right) + \mathsf{fma}\left(-c, a, \color{blue}{a \cdot c}\right)\right)}}{a} \]
    4. Applied egg-rr15.0%

      \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\color{blue}{\mathsf{fma}\left(a, -c, {b\_2}^{2}\right) + \left(\mathsf{fma}\left(a, -c, a \cdot c\right) + \mathsf{fma}\left(a, -c, a \cdot c\right)\right)}}}{a} \]
    5. Step-by-step derivation
      1. fma-define15.0%

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\color{blue}{\left(a \cdot \left(-c\right) + {b\_2}^{2}\right)} + \left(\mathsf{fma}\left(a, -c, a \cdot c\right) + \mathsf{fma}\left(a, -c, a \cdot c\right)\right)}}{a} \]
      2. +-commutative15.0%

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\color{blue}{\left({b\_2}^{2} + a \cdot \left(-c\right)\right)} + \left(\mathsf{fma}\left(a, -c, a \cdot c\right) + \mathsf{fma}\left(a, -c, a \cdot c\right)\right)}}{a} \]
      3. *-commutative15.0%

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\left({b\_2}^{2} + \color{blue}{\left(-c\right) \cdot a}\right) + \left(\mathsf{fma}\left(a, -c, a \cdot c\right) + \mathsf{fma}\left(a, -c, a \cdot c\right)\right)}}{a} \]
      4. cancel-sign-sub-inv15.0%

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\color{blue}{\left({b\_2}^{2} - c \cdot a\right)} + \left(\mathsf{fma}\left(a, -c, a \cdot c\right) + \mathsf{fma}\left(a, -c, a \cdot c\right)\right)}}{a} \]
      5. count-215.0%

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\left({b\_2}^{2} - c \cdot a\right) + \color{blue}{2 \cdot \mathsf{fma}\left(a, -c, a \cdot c\right)}}}{a} \]
      6. *-commutative15.0%

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\left({b\_2}^{2} - c \cdot a\right) + 2 \cdot \mathsf{fma}\left(a, -c, \color{blue}{c \cdot a}\right)}}{a} \]
    6. Simplified15.0%

      \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\color{blue}{\left({b\_2}^{2} - c \cdot a\right) + 2 \cdot \mathsf{fma}\left(a, -c, c \cdot a\right)}}}{a} \]
    7. Taylor expanded in b_2 around -inf 69.3%

      \[\leadsto \color{blue}{-1 \cdot \frac{-0.5 \cdot \frac{2 \cdot \left(-1 \cdot \left(a \cdot c\right) + a \cdot c\right) - a \cdot c}{a} + 0.125 \cdot \frac{{\left(2 \cdot \left(-1 \cdot \left(a \cdot c\right) + a \cdot c\right) - a \cdot c\right)}^{2}}{a \cdot {b\_2}^{2}}}{b\_2}} \]
    8. Taylor expanded in c around 0 68.9%

      \[\leadsto -1 \cdot \frac{\color{blue}{c \cdot \left(-0.5 \cdot \frac{2 \cdot \left(a + -1 \cdot a\right) - a}{a} + 0.125 \cdot \frac{c \cdot {\left(2 \cdot \left(a + -1 \cdot a\right) - a\right)}^{2}}{a \cdot {b\_2}^{2}}\right)}}{b\_2} \]
    9. Simplified85.4%

      \[\leadsto -1 \cdot \frac{\color{blue}{c \cdot \left(0.5 + 0.125 \cdot \left(c \cdot \left(1 \cdot \frac{a}{{b\_2}^{2}}\right)\right)\right)}}{b\_2} \]

    if -7.60000000000000075e-68 < b_2 < 6.00000000000000014e110

    1. Initial program 79.9%

      \[\frac{\left(-b\_2\right) - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. neg-sub079.9%

        \[\leadsto \frac{\color{blue}{\left(0 - b\_2\right)} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      2. flip--79.9%

        \[\leadsto \frac{\color{blue}{\frac{0 \cdot 0 - b\_2 \cdot b\_2}{0 + b\_2}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      3. metadata-eval79.9%

        \[\leadsto \frac{\frac{\color{blue}{0} - b\_2 \cdot b\_2}{0 + b\_2} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      4. pow279.9%

        \[\leadsto \frac{\frac{0 - \color{blue}{{b\_2}^{2}}}{0 + b\_2} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      5. add-sqr-sqrt54.1%

        \[\leadsto \frac{\frac{0 - {b\_2}^{2}}{0 + \color{blue}{\sqrt{b\_2} \cdot \sqrt{b\_2}}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      6. sqrt-prod52.7%

        \[\leadsto \frac{\frac{0 - {b\_2}^{2}}{0 + \color{blue}{\sqrt{b\_2 \cdot b\_2}}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      7. sqr-neg52.7%

        \[\leadsto \frac{\frac{0 - {b\_2}^{2}}{0 + \sqrt{\color{blue}{\left(-b\_2\right) \cdot \left(-b\_2\right)}}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      8. sqrt-unprod25.7%

        \[\leadsto \frac{\frac{0 - {b\_2}^{2}}{0 + \color{blue}{\sqrt{-b\_2} \cdot \sqrt{-b\_2}}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      9. add-sqr-sqrt49.5%

        \[\leadsto \frac{\frac{0 - {b\_2}^{2}}{0 + \color{blue}{\left(-b\_2\right)}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      10. sub-neg49.5%

        \[\leadsto \frac{\frac{0 - {b\_2}^{2}}{\color{blue}{0 - b\_2}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      11. neg-sub049.5%

        \[\leadsto \frac{\frac{0 - {b\_2}^{2}}{\color{blue}{-b\_2}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      12. add-sqr-sqrt25.7%

        \[\leadsto \frac{\frac{0 - {b\_2}^{2}}{\color{blue}{\sqrt{-b\_2} \cdot \sqrt{-b\_2}}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      13. sqrt-unprod52.7%

        \[\leadsto \frac{\frac{0 - {b\_2}^{2}}{\color{blue}{\sqrt{\left(-b\_2\right) \cdot \left(-b\_2\right)}}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      14. sqr-neg52.7%

        \[\leadsto \frac{\frac{0 - {b\_2}^{2}}{\sqrt{\color{blue}{b\_2 \cdot b\_2}}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      15. sqrt-prod54.1%

        \[\leadsto \frac{\frac{0 - {b\_2}^{2}}{\color{blue}{\sqrt{b\_2} \cdot \sqrt{b\_2}}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      16. add-sqr-sqrt79.9%

        \[\leadsto \frac{\frac{0 - {b\_2}^{2}}{\color{blue}{b\_2}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
    4. Applied egg-rr79.9%

      \[\leadsto \frac{\color{blue}{\frac{0 - {b\_2}^{2}}{b\_2}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
    5. Step-by-step derivation
      1. sub0-neg79.9%

        \[\leadsto \frac{\frac{\color{blue}{-{b\_2}^{2}}}{b\_2} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
    6. Simplified79.9%

      \[\leadsto \frac{\color{blue}{\frac{-{b\_2}^{2}}{b\_2}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]

    if 6.00000000000000014e110 < b_2

    1. Initial program 51.4%

      \[\frac{\left(-b\_2\right) - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
    2. Add Preprocessing
    3. Taylor expanded in c around 0 98.0%

      \[\leadsto \color{blue}{-2 \cdot \frac{b\_2}{a} + 0.5 \cdot \frac{c}{b\_2}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification85.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b\_2 \leq -7.6 \cdot 10^{-68}:\\ \;\;\;\;\frac{c \cdot \left(0.5 + 0.125 \cdot \left(c \cdot \frac{a}{{b\_2}^{2}}\right)\right)}{-b\_2}\\ \mathbf{elif}\;b\_2 \leq 6 \cdot 10^{+110}:\\ \;\;\;\;\frac{\frac{{b\_2}^{2}}{-b\_2} - \sqrt{b\_2 \cdot b\_2 - c \cdot a}}{a}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b\_2}{a} + 0.5 \cdot \frac{c}{b\_2}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 86.1% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -3.2 \cdot 10^{-69}:\\
\;\;\;\;\frac{c \cdot \left(0.5 + 0.125 \cdot \left(c \cdot \frac{a}{{b\_2}^{2}}\right)\right)}{-b\_2}\\

\mathbf{elif}\;b\_2 \leq 2.25 \cdot 10^{+108}:\\
\;\;\;\;\frac{\left(-b\_2\right) - \sqrt{b\_2 \cdot b\_2 - c \cdot a}}{a}\\

\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a} + 0.5 \cdot \frac{c}{b\_2}\\


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

    1. Initial program 15.3%

      \[\frac{\left(-b\_2\right) - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. prod-diff15.0%

        \[\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. *-commutative15.0%

        \[\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. fmm-def15.0%

        \[\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-diff15.0%

        \[\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. *-commutative15.0%

        \[\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. fmm-def15.0%

        \[\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+15.0%

        \[\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. sub-neg15.0%

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\color{blue}{\left(b\_2 \cdot b\_2 + \left(-a \cdot c\right)\right)} + \left(\mathsf{fma}\left(-c, a, c \cdot a\right) + \mathsf{fma}\left(-c, a, c \cdot a\right)\right)}}{a} \]
      9. +-commutative15.0%

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\color{blue}{\left(\left(-a \cdot c\right) + b\_2 \cdot b\_2\right)} + \left(\mathsf{fma}\left(-c, a, c \cdot a\right) + \mathsf{fma}\left(-c, a, c \cdot a\right)\right)}}{a} \]
      10. distribute-rgt-neg-in15.0%

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\left(\color{blue}{a \cdot \left(-c\right)} + b\_2 \cdot b\_2\right) + \left(\mathsf{fma}\left(-c, a, c \cdot a\right) + \mathsf{fma}\left(-c, a, c \cdot a\right)\right)}}{a} \]
      11. fma-define15.0%

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

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\mathsf{fma}\left(a, -c, \color{blue}{{b\_2}^{2}}\right) + \left(\mathsf{fma}\left(-c, a, c \cdot a\right) + \mathsf{fma}\left(-c, a, c \cdot a\right)\right)}}{a} \]
      13. *-commutative15.0%

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\mathsf{fma}\left(a, -c, {b\_2}^{2}\right) + \left(\mathsf{fma}\left(-c, a, \color{blue}{a \cdot c}\right) + \mathsf{fma}\left(-c, a, c \cdot a\right)\right)}}{a} \]
      14. fma-undefine15.0%

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\mathsf{fma}\left(a, -c, {b\_2}^{2}\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} \]
      15. distribute-lft-neg-in15.0%

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\mathsf{fma}\left(a, -c, {b\_2}^{2}\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} \]
      16. *-commutative15.0%

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\mathsf{fma}\left(a, -c, {b\_2}^{2}\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} \]
      17. distribute-rgt-neg-in15.0%

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\mathsf{fma}\left(a, -c, {b\_2}^{2}\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} \]
      18. fma-define15.0%

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\mathsf{fma}\left(a, -c, {b\_2}^{2}\right) + \left(\color{blue}{\mathsf{fma}\left(a, -c, a \cdot c\right)} + \mathsf{fma}\left(-c, a, c \cdot a\right)\right)}}{a} \]
      19. *-commutative15.0%

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\mathsf{fma}\left(a, -c, {b\_2}^{2}\right) + \left(\mathsf{fma}\left(a, -c, a \cdot c\right) + \mathsf{fma}\left(-c, a, \color{blue}{a \cdot c}\right)\right)}}{a} \]
    4. Applied egg-rr15.0%

      \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\color{blue}{\mathsf{fma}\left(a, -c, {b\_2}^{2}\right) + \left(\mathsf{fma}\left(a, -c, a \cdot c\right) + \mathsf{fma}\left(a, -c, a \cdot c\right)\right)}}}{a} \]
    5. Step-by-step derivation
      1. fma-define15.0%

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\color{blue}{\left(a \cdot \left(-c\right) + {b\_2}^{2}\right)} + \left(\mathsf{fma}\left(a, -c, a \cdot c\right) + \mathsf{fma}\left(a, -c, a \cdot c\right)\right)}}{a} \]
      2. +-commutative15.0%

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\color{blue}{\left({b\_2}^{2} + a \cdot \left(-c\right)\right)} + \left(\mathsf{fma}\left(a, -c, a \cdot c\right) + \mathsf{fma}\left(a, -c, a \cdot c\right)\right)}}{a} \]
      3. *-commutative15.0%

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\left({b\_2}^{2} + \color{blue}{\left(-c\right) \cdot a}\right) + \left(\mathsf{fma}\left(a, -c, a \cdot c\right) + \mathsf{fma}\left(a, -c, a \cdot c\right)\right)}}{a} \]
      4. cancel-sign-sub-inv15.0%

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\color{blue}{\left({b\_2}^{2} - c \cdot a\right)} + \left(\mathsf{fma}\left(a, -c, a \cdot c\right) + \mathsf{fma}\left(a, -c, a \cdot c\right)\right)}}{a} \]
      5. count-215.0%

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\left({b\_2}^{2} - c \cdot a\right) + \color{blue}{2 \cdot \mathsf{fma}\left(a, -c, a \cdot c\right)}}}{a} \]
      6. *-commutative15.0%

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\left({b\_2}^{2} - c \cdot a\right) + 2 \cdot \mathsf{fma}\left(a, -c, \color{blue}{c \cdot a}\right)}}{a} \]
    6. Simplified15.0%

      \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\color{blue}{\left({b\_2}^{2} - c \cdot a\right) + 2 \cdot \mathsf{fma}\left(a, -c, c \cdot a\right)}}}{a} \]
    7. Taylor expanded in b_2 around -inf 69.3%

      \[\leadsto \color{blue}{-1 \cdot \frac{-0.5 \cdot \frac{2 \cdot \left(-1 \cdot \left(a \cdot c\right) + a \cdot c\right) - a \cdot c}{a} + 0.125 \cdot \frac{{\left(2 \cdot \left(-1 \cdot \left(a \cdot c\right) + a \cdot c\right) - a \cdot c\right)}^{2}}{a \cdot {b\_2}^{2}}}{b\_2}} \]
    8. Taylor expanded in c around 0 68.9%

      \[\leadsto -1 \cdot \frac{\color{blue}{c \cdot \left(-0.5 \cdot \frac{2 \cdot \left(a + -1 \cdot a\right) - a}{a} + 0.125 \cdot \frac{c \cdot {\left(2 \cdot \left(a + -1 \cdot a\right) - a\right)}^{2}}{a \cdot {b\_2}^{2}}\right)}}{b\_2} \]
    9. Simplified85.4%

      \[\leadsto -1 \cdot \frac{\color{blue}{c \cdot \left(0.5 + 0.125 \cdot \left(c \cdot \left(1 \cdot \frac{a}{{b\_2}^{2}}\right)\right)\right)}}{b\_2} \]

    if -3.19999999999999999e-69 < b_2 < 2.25e108

    1. Initial program 79.9%

      \[\frac{\left(-b\_2\right) - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
    2. Add Preprocessing

    if 2.25e108 < b_2

    1. Initial program 51.4%

      \[\frac{\left(-b\_2\right) - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
    2. Add Preprocessing
    3. Taylor expanded in c around 0 98.0%

      \[\leadsto \color{blue}{-2 \cdot \frac{b\_2}{a} + 0.5 \cdot \frac{c}{b\_2}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification85.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b\_2 \leq -3.2 \cdot 10^{-69}:\\ \;\;\;\;\frac{c \cdot \left(0.5 + 0.125 \cdot \left(c \cdot \frac{a}{{b\_2}^{2}}\right)\right)}{-b\_2}\\ \mathbf{elif}\;b\_2 \leq 2.25 \cdot 10^{+108}:\\ \;\;\;\;\frac{\left(-b\_2\right) - \sqrt{b\_2 \cdot b\_2 - c \cdot a}}{a}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b\_2}{a} + 0.5 \cdot \frac{c}{b\_2}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 67.9% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -1.35 \cdot 10^{+154}:\\
\;\;\;\;c \cdot \left(0.125 \cdot \frac{c \cdot a}{{b\_2}^{3}} + 0.5 \cdot \frac{1}{b\_2}\right)\\

\mathbf{elif}\;b\_2 \leq 1.3 \cdot 10^{+112}:\\
\;\;\;\;\frac{\left(-b\_2\right) - \sqrt{b\_2 \cdot b\_2 - c \cdot a}}{a}\\

\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a} + 0.5 \cdot \frac{c}{b\_2}\\


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

    1. Initial program 1.7%

      \[\frac{\left(-b\_2\right) - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt1.7%

        \[\leadsto \frac{\color{blue}{\sqrt{-b\_2} \cdot \sqrt{-b\_2}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      2. sqrt-unprod0.0%

        \[\leadsto \frac{\color{blue}{\sqrt{\left(-b\_2\right) \cdot \left(-b\_2\right)}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      3. sqr-neg0.0%

        \[\leadsto \frac{\sqrt{\color{blue}{b\_2 \cdot b\_2}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      4. sqrt-prod0.0%

        \[\leadsto \frac{\color{blue}{\sqrt{b\_2} \cdot \sqrt{b\_2}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      5. add-sqr-sqrt1.7%

        \[\leadsto \frac{\color{blue}{b\_2} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      6. add-cube-cbrt1.7%

        \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{b\_2} \cdot \sqrt[3]{b\_2}\right) \cdot \sqrt[3]{b\_2}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      7. pow31.7%

        \[\leadsto \frac{\color{blue}{{\left(\sqrt[3]{b\_2}\right)}^{3}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
    4. Applied egg-rr1.7%

      \[\leadsto \frac{\color{blue}{{\left(\sqrt[3]{b\_2}\right)}^{3}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
    5. Taylor expanded in c around 0 44.1%

      \[\leadsto \color{blue}{c \cdot \left(0.125 \cdot \frac{a \cdot c}{{b\_2}^{3}} + 0.5 \cdot \frac{1}{b\_2}\right)} \]

    if -1.35000000000000003e154 < b_2 < 1.3e112

    1. Initial program 60.1%

      \[\frac{\left(-b\_2\right) - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
    2. Add Preprocessing

    if 1.3e112 < b_2

    1. Initial program 51.4%

      \[\frac{\left(-b\_2\right) - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
    2. Add Preprocessing
    3. Taylor expanded in c around 0 98.0%

      \[\leadsto \color{blue}{-2 \cdot \frac{b\_2}{a} + 0.5 \cdot \frac{c}{b\_2}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification64.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b\_2 \leq -1.35 \cdot 10^{+154}:\\ \;\;\;\;c \cdot \left(0.125 \cdot \frac{c \cdot a}{{b\_2}^{3}} + 0.5 \cdot \frac{1}{b\_2}\right)\\ \mathbf{elif}\;b\_2 \leq 1.3 \cdot 10^{+112}:\\ \;\;\;\;\frac{\left(-b\_2\right) - \sqrt{b\_2 \cdot b\_2 - c \cdot a}}{a}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b\_2}{a} + 0.5 \cdot \frac{c}{b\_2}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 63.2% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -1.35 \cdot 10^{+154}:\\
\;\;\;\;c \cdot \left(\frac{b\_2 \cdot 2}{c \cdot a} - \frac{0.5}{b\_2}\right)\\

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

\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a} + 0.5 \cdot \frac{c}{b\_2}\\


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

    1. Initial program 1.7%

      \[\frac{\left(-b\_2\right) - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt1.7%

        \[\leadsto \frac{\color{blue}{\sqrt{-b\_2} \cdot \sqrt{-b\_2}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      2. sqrt-unprod0.0%

        \[\leadsto \frac{\color{blue}{\sqrt{\left(-b\_2\right) \cdot \left(-b\_2\right)}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      3. sqr-neg0.0%

        \[\leadsto \frac{\sqrt{\color{blue}{b\_2 \cdot b\_2}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      4. sqrt-prod0.0%

        \[\leadsto \frac{\color{blue}{\sqrt{b\_2} \cdot \sqrt{b\_2}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      5. add-sqr-sqrt1.7%

        \[\leadsto \frac{\color{blue}{b\_2} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      6. add-cube-cbrt1.7%

        \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{b\_2} \cdot \sqrt[3]{b\_2}\right) \cdot \sqrt[3]{b\_2}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      7. pow31.7%

        \[\leadsto \frac{\color{blue}{{\left(\sqrt[3]{b\_2}\right)}^{3}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
    4. Applied egg-rr1.7%

      \[\leadsto \frac{\color{blue}{{\left(\sqrt[3]{b\_2}\right)}^{3}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
    5. Taylor expanded in b_2 around -inf 1.8%

      \[\leadsto \frac{\color{blue}{-1 \cdot \left(b\_2 \cdot \left(\left(0.5 \cdot \frac{a \cdot c}{{b\_2}^{2}} + {\left(\sqrt[3]{-1}\right)}^{3}\right) - 1\right)\right)}}{a} \]
    6. Step-by-step derivation
      1. associate-*r*1.8%

        \[\leadsto \frac{\color{blue}{\left(-1 \cdot b\_2\right) \cdot \left(\left(0.5 \cdot \frac{a \cdot c}{{b\_2}^{2}} + {\left(\sqrt[3]{-1}\right)}^{3}\right) - 1\right)}}{a} \]
      2. neg-mul-11.8%

        \[\leadsto \frac{\color{blue}{\left(-b\_2\right)} \cdot \left(\left(0.5 \cdot \frac{a \cdot c}{{b\_2}^{2}} + {\left(\sqrt[3]{-1}\right)}^{3}\right) - 1\right)}{a} \]
      3. rem-cube-cbrt1.8%

        \[\leadsto \frac{\left(-b\_2\right) \cdot \left(\left(0.5 \cdot \frac{a \cdot c}{{b\_2}^{2}} + \color{blue}{-1}\right) - 1\right)}{a} \]
      4. associate--l+1.8%

        \[\leadsto \frac{\left(-b\_2\right) \cdot \color{blue}{\left(0.5 \cdot \frac{a \cdot c}{{b\_2}^{2}} + \left(-1 - 1\right)\right)}}{a} \]
      5. metadata-eval1.8%

        \[\leadsto \frac{\left(-b\_2\right) \cdot \left(0.5 \cdot \frac{a \cdot c}{{b\_2}^{2}} + \color{blue}{-2}\right)}{a} \]
    7. Simplified1.8%

      \[\leadsto \frac{\color{blue}{\left(-b\_2\right) \cdot \left(0.5 \cdot \frac{a \cdot c}{{b\_2}^{2}} + -2\right)}}{a} \]
    8. Taylor expanded in c around inf 16.0%

      \[\leadsto \color{blue}{c \cdot \left(2 \cdot \frac{b\_2}{a \cdot c} - 0.5 \cdot \frac{1}{b\_2}\right)} \]
    9. Step-by-step derivation
      1. associate-*r/16.0%

        \[\leadsto c \cdot \left(\color{blue}{\frac{2 \cdot b\_2}{a \cdot c}} - 0.5 \cdot \frac{1}{b\_2}\right) \]
      2. associate-*r/16.0%

        \[\leadsto c \cdot \left(\frac{2 \cdot b\_2}{a \cdot c} - \color{blue}{\frac{0.5 \cdot 1}{b\_2}}\right) \]
      3. metadata-eval16.0%

        \[\leadsto c \cdot \left(\frac{2 \cdot b\_2}{a \cdot c} - \frac{\color{blue}{0.5}}{b\_2}\right) \]
    10. Simplified16.0%

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

    if -1.35000000000000003e154 < b_2 < 1.99999999999999996e109

    1. Initial program 60.1%

      \[\frac{\left(-b\_2\right) - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
    2. Add Preprocessing

    if 1.99999999999999996e109 < b_2

    1. Initial program 51.4%

      \[\frac{\left(-b\_2\right) - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
    2. Add Preprocessing
    3. Taylor expanded in c around 0 98.0%

      \[\leadsto \color{blue}{-2 \cdot \frac{b\_2}{a} + 0.5 \cdot \frac{c}{b\_2}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification59.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b\_2 \leq -1.35 \cdot 10^{+154}:\\ \;\;\;\;c \cdot \left(\frac{b\_2 \cdot 2}{c \cdot a} - \frac{0.5}{b\_2}\right)\\ \mathbf{elif}\;b\_2 \leq 2 \cdot 10^{+109}:\\ \;\;\;\;\frac{\left(-b\_2\right) - \sqrt{b\_2 \cdot b\_2 - c \cdot a}}{a}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b\_2}{a} + 0.5 \cdot \frac{c}{b\_2}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 55.7% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -2.6 \cdot 10^{+131}:\\
\;\;\;\;c \cdot \left(\frac{b\_2 \cdot 2}{c \cdot a} - \frac{0.5}{b\_2}\right)\\

\mathbf{elif}\;b\_2 \leq 1.35 \cdot 10^{-81}:\\
\;\;\;\;\frac{b\_2 - \sqrt{b\_2 \cdot b\_2 - c \cdot a}}{a}\\

\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a} + 0.5 \cdot \frac{c}{b\_2}\\


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

    1. Initial program 6.3%

      \[\frac{\left(-b\_2\right) - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt4.0%

        \[\leadsto \frac{\color{blue}{\sqrt{-b\_2} \cdot \sqrt{-b\_2}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      2. sqrt-unprod4.8%

        \[\leadsto \frac{\color{blue}{\sqrt{\left(-b\_2\right) \cdot \left(-b\_2\right)}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      3. sqr-neg4.8%

        \[\leadsto \frac{\sqrt{\color{blue}{b\_2 \cdot b\_2}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      4. sqrt-prod0.0%

        \[\leadsto \frac{\color{blue}{\sqrt{b\_2} \cdot \sqrt{b\_2}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      5. add-sqr-sqrt1.9%

        \[\leadsto \frac{\color{blue}{b\_2} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      6. add-cube-cbrt1.9%

        \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{b\_2} \cdot \sqrt[3]{b\_2}\right) \cdot \sqrt[3]{b\_2}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      7. pow31.9%

        \[\leadsto \frac{\color{blue}{{\left(\sqrt[3]{b\_2}\right)}^{3}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
    4. Applied egg-rr1.9%

      \[\leadsto \frac{\color{blue}{{\left(\sqrt[3]{b\_2}\right)}^{3}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
    5. Taylor expanded in b_2 around -inf 1.9%

      \[\leadsto \frac{\color{blue}{-1 \cdot \left(b\_2 \cdot \left(\left(0.5 \cdot \frac{a \cdot c}{{b\_2}^{2}} + {\left(\sqrt[3]{-1}\right)}^{3}\right) - 1\right)\right)}}{a} \]
    6. Step-by-step derivation
      1. associate-*r*1.9%

        \[\leadsto \frac{\color{blue}{\left(-1 \cdot b\_2\right) \cdot \left(\left(0.5 \cdot \frac{a \cdot c}{{b\_2}^{2}} + {\left(\sqrt[3]{-1}\right)}^{3}\right) - 1\right)}}{a} \]
      2. neg-mul-11.9%

        \[\leadsto \frac{\color{blue}{\left(-b\_2\right)} \cdot \left(\left(0.5 \cdot \frac{a \cdot c}{{b\_2}^{2}} + {\left(\sqrt[3]{-1}\right)}^{3}\right) - 1\right)}{a} \]
      3. rem-cube-cbrt1.9%

        \[\leadsto \frac{\left(-b\_2\right) \cdot \left(\left(0.5 \cdot \frac{a \cdot c}{{b\_2}^{2}} + \color{blue}{-1}\right) - 1\right)}{a} \]
      4. associate--l+1.9%

        \[\leadsto \frac{\left(-b\_2\right) \cdot \color{blue}{\left(0.5 \cdot \frac{a \cdot c}{{b\_2}^{2}} + \left(-1 - 1\right)\right)}}{a} \]
      5. metadata-eval1.9%

        \[\leadsto \frac{\left(-b\_2\right) \cdot \left(0.5 \cdot \frac{a \cdot c}{{b\_2}^{2}} + \color{blue}{-2}\right)}{a} \]
    7. Simplified1.9%

      \[\leadsto \frac{\color{blue}{\left(-b\_2\right) \cdot \left(0.5 \cdot \frac{a \cdot c}{{b\_2}^{2}} + -2\right)}}{a} \]
    8. Taylor expanded in c around inf 13.9%

      \[\leadsto \color{blue}{c \cdot \left(2 \cdot \frac{b\_2}{a \cdot c} - 0.5 \cdot \frac{1}{b\_2}\right)} \]
    9. Step-by-step derivation
      1. associate-*r/13.9%

        \[\leadsto c \cdot \left(\color{blue}{\frac{2 \cdot b\_2}{a \cdot c}} - 0.5 \cdot \frac{1}{b\_2}\right) \]
      2. associate-*r/13.9%

        \[\leadsto c \cdot \left(\frac{2 \cdot b\_2}{a \cdot c} - \color{blue}{\frac{0.5 \cdot 1}{b\_2}}\right) \]
      3. metadata-eval13.9%

        \[\leadsto c \cdot \left(\frac{2 \cdot b\_2}{a \cdot c} - \frac{\color{blue}{0.5}}{b\_2}\right) \]
    10. Simplified13.9%

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

    if -2.6e131 < b_2 < 1.34999999999999995e-81

    1. Initial program 50.8%

      \[\frac{\left(-b\_2\right) - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. neg-sub050.8%

        \[\leadsto \frac{\color{blue}{\left(0 - b\_2\right)} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      2. sub-neg50.8%

        \[\leadsto \frac{\color{blue}{\left(0 + \left(-b\_2\right)\right)} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      3. add-sqr-sqrt32.1%

        \[\leadsto \frac{\left(0 + \color{blue}{\sqrt{-b\_2} \cdot \sqrt{-b\_2}}\right) - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      4. sqrt-unprod49.2%

        \[\leadsto \frac{\left(0 + \color{blue}{\sqrt{\left(-b\_2\right) \cdot \left(-b\_2\right)}}\right) - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      5. sqr-neg49.2%

        \[\leadsto \frac{\left(0 + \sqrt{\color{blue}{b\_2 \cdot b\_2}}\right) - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      6. sqrt-prod15.9%

        \[\leadsto \frac{\left(0 + \color{blue}{\sqrt{b\_2} \cdot \sqrt{b\_2}}\right) - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      7. add-sqr-sqrt46.7%

        \[\leadsto \frac{\left(0 + \color{blue}{b\_2}\right) - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
    4. Applied egg-rr46.7%

      \[\leadsto \frac{\color{blue}{\left(0 + b\_2\right)} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
    5. Step-by-step derivation
      1. +-lft-identity46.7%

        \[\leadsto \frac{\color{blue}{b\_2} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
    6. Simplified46.7%

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

    if 1.34999999999999995e-81 < b_2

    1. Initial program 71.1%

      \[\frac{\left(-b\_2\right) - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
    2. Add Preprocessing
    3. Taylor expanded in c around 0 89.3%

      \[\leadsto \color{blue}{-2 \cdot \frac{b\_2}{a} + 0.5 \cdot \frac{c}{b\_2}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification54.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b\_2 \leq -2.6 \cdot 10^{+131}:\\ \;\;\;\;c \cdot \left(\frac{b\_2 \cdot 2}{c \cdot a} - \frac{0.5}{b\_2}\right)\\ \mathbf{elif}\;b\_2 \leq 1.35 \cdot 10^{-81}:\\ \;\;\;\;\frac{b\_2 - \sqrt{b\_2 \cdot b\_2 - c \cdot a}}{a}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b\_2}{a} + 0.5 \cdot \frac{c}{b\_2}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 55.9% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -9.5 \cdot 10^{+131}:\\
\;\;\;\;c \cdot \left(\frac{b\_2 \cdot 2}{c \cdot a} - \frac{0.5}{b\_2}\right)\\

\mathbf{elif}\;b\_2 \leq 2.5 \cdot 10^{-80}:\\
\;\;\;\;\frac{b\_2}{-a} - \frac{\sqrt{c \cdot \left(-a\right)}}{a}\\

\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a} + 0.5 \cdot \frac{c}{b\_2}\\


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

    1. Initial program 6.3%

      \[\frac{\left(-b\_2\right) - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt4.0%

        \[\leadsto \frac{\color{blue}{\sqrt{-b\_2} \cdot \sqrt{-b\_2}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      2. sqrt-unprod4.8%

        \[\leadsto \frac{\color{blue}{\sqrt{\left(-b\_2\right) \cdot \left(-b\_2\right)}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      3. sqr-neg4.8%

        \[\leadsto \frac{\sqrt{\color{blue}{b\_2 \cdot b\_2}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      4. sqrt-prod0.0%

        \[\leadsto \frac{\color{blue}{\sqrt{b\_2} \cdot \sqrt{b\_2}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      5. add-sqr-sqrt1.9%

        \[\leadsto \frac{\color{blue}{b\_2} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      6. add-cube-cbrt1.9%

        \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{b\_2} \cdot \sqrt[3]{b\_2}\right) \cdot \sqrt[3]{b\_2}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      7. pow31.9%

        \[\leadsto \frac{\color{blue}{{\left(\sqrt[3]{b\_2}\right)}^{3}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
    4. Applied egg-rr1.9%

      \[\leadsto \frac{\color{blue}{{\left(\sqrt[3]{b\_2}\right)}^{3}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
    5. Taylor expanded in b_2 around -inf 1.9%

      \[\leadsto \frac{\color{blue}{-1 \cdot \left(b\_2 \cdot \left(\left(0.5 \cdot \frac{a \cdot c}{{b\_2}^{2}} + {\left(\sqrt[3]{-1}\right)}^{3}\right) - 1\right)\right)}}{a} \]
    6. Step-by-step derivation
      1. associate-*r*1.9%

        \[\leadsto \frac{\color{blue}{\left(-1 \cdot b\_2\right) \cdot \left(\left(0.5 \cdot \frac{a \cdot c}{{b\_2}^{2}} + {\left(\sqrt[3]{-1}\right)}^{3}\right) - 1\right)}}{a} \]
      2. neg-mul-11.9%

        \[\leadsto \frac{\color{blue}{\left(-b\_2\right)} \cdot \left(\left(0.5 \cdot \frac{a \cdot c}{{b\_2}^{2}} + {\left(\sqrt[3]{-1}\right)}^{3}\right) - 1\right)}{a} \]
      3. rem-cube-cbrt1.9%

        \[\leadsto \frac{\left(-b\_2\right) \cdot \left(\left(0.5 \cdot \frac{a \cdot c}{{b\_2}^{2}} + \color{blue}{-1}\right) - 1\right)}{a} \]
      4. associate--l+1.9%

        \[\leadsto \frac{\left(-b\_2\right) \cdot \color{blue}{\left(0.5 \cdot \frac{a \cdot c}{{b\_2}^{2}} + \left(-1 - 1\right)\right)}}{a} \]
      5. metadata-eval1.9%

        \[\leadsto \frac{\left(-b\_2\right) \cdot \left(0.5 \cdot \frac{a \cdot c}{{b\_2}^{2}} + \color{blue}{-2}\right)}{a} \]
    7. Simplified1.9%

      \[\leadsto \frac{\color{blue}{\left(-b\_2\right) \cdot \left(0.5 \cdot \frac{a \cdot c}{{b\_2}^{2}} + -2\right)}}{a} \]
    8. Taylor expanded in c around inf 13.9%

      \[\leadsto \color{blue}{c \cdot \left(2 \cdot \frac{b\_2}{a \cdot c} - 0.5 \cdot \frac{1}{b\_2}\right)} \]
    9. Step-by-step derivation
      1. associate-*r/13.9%

        \[\leadsto c \cdot \left(\color{blue}{\frac{2 \cdot b\_2}{a \cdot c}} - 0.5 \cdot \frac{1}{b\_2}\right) \]
      2. associate-*r/13.9%

        \[\leadsto c \cdot \left(\frac{2 \cdot b\_2}{a \cdot c} - \color{blue}{\frac{0.5 \cdot 1}{b\_2}}\right) \]
      3. metadata-eval13.9%

        \[\leadsto c \cdot \left(\frac{2 \cdot b\_2}{a \cdot c} - \frac{\color{blue}{0.5}}{b\_2}\right) \]
    10. Simplified13.9%

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

    if -9.50000000000000015e131 < b_2 < 2.5e-80

    1. Initial program 50.8%

      \[\frac{\left(-b\_2\right) - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. prod-diff50.4%

        \[\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. *-commutative50.4%

        \[\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. fmm-def50.4%

        \[\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-diff50.4%

        \[\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. *-commutative50.4%

        \[\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. fmm-def50.4%

        \[\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+50.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. sub-neg50.3%

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

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

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

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

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\mathsf{fma}\left(a, -c, \color{blue}{{b\_2}^{2}}\right) + \left(\mathsf{fma}\left(-c, a, c \cdot a\right) + \mathsf{fma}\left(-c, a, c \cdot a\right)\right)}}{a} \]
      13. *-commutative50.3%

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\mathsf{fma}\left(a, -c, {b\_2}^{2}\right) + \left(\mathsf{fma}\left(-c, a, \color{blue}{a \cdot c}\right) + \mathsf{fma}\left(-c, a, c \cdot a\right)\right)}}{a} \]
      14. fma-undefine50.4%

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\mathsf{fma}\left(a, -c, {b\_2}^{2}\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} \]
      15. distribute-lft-neg-in50.4%

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\mathsf{fma}\left(a, -c, {b\_2}^{2}\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} \]
      16. *-commutative50.4%

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\mathsf{fma}\left(a, -c, {b\_2}^{2}\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} \]
      17. distribute-rgt-neg-in50.4%

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\mathsf{fma}\left(a, -c, {b\_2}^{2}\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} \]
      18. fma-define50.3%

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\mathsf{fma}\left(a, -c, {b\_2}^{2}\right) + \left(\color{blue}{\mathsf{fma}\left(a, -c, a \cdot c\right)} + \mathsf{fma}\left(-c, a, c \cdot a\right)\right)}}{a} \]
      19. *-commutative50.3%

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\mathsf{fma}\left(a, -c, {b\_2}^{2}\right) + \left(\mathsf{fma}\left(a, -c, a \cdot c\right) + \mathsf{fma}\left(-c, a, \color{blue}{a \cdot c}\right)\right)}}{a} \]
    4. Applied egg-rr50.3%

      \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\color{blue}{\mathsf{fma}\left(a, -c, {b\_2}^{2}\right) + \left(\mathsf{fma}\left(a, -c, a \cdot c\right) + \mathsf{fma}\left(a, -c, a \cdot c\right)\right)}}}{a} \]
    5. Step-by-step derivation
      1. fma-define50.3%

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\color{blue}{\left(a \cdot \left(-c\right) + {b\_2}^{2}\right)} + \left(\mathsf{fma}\left(a, -c, a \cdot c\right) + \mathsf{fma}\left(a, -c, a \cdot c\right)\right)}}{a} \]
      2. +-commutative50.3%

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

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\left({b\_2}^{2} + \color{blue}{\left(-c\right) \cdot a}\right) + \left(\mathsf{fma}\left(a, -c, a \cdot c\right) + \mathsf{fma}\left(a, -c, a \cdot c\right)\right)}}{a} \]
      4. cancel-sign-sub-inv50.3%

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\color{blue}{\left({b\_2}^{2} - c \cdot a\right)} + \left(\mathsf{fma}\left(a, -c, a \cdot c\right) + \mathsf{fma}\left(a, -c, a \cdot c\right)\right)}}{a} \]
      5. count-250.3%

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\left({b\_2}^{2} - c \cdot a\right) + \color{blue}{2 \cdot \mathsf{fma}\left(a, -c, a \cdot c\right)}}}{a} \]
      6. *-commutative50.3%

        \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\left({b\_2}^{2} - c \cdot a\right) + 2 \cdot \mathsf{fma}\left(a, -c, \color{blue}{c \cdot a}\right)}}{a} \]
    6. Simplified50.3%

      \[\leadsto \frac{\left(-b\_2\right) - \sqrt{\color{blue}{\left({b\_2}^{2} - c \cdot a\right) + 2 \cdot \mathsf{fma}\left(a, -c, c \cdot a\right)}}}{a} \]
    7. Taylor expanded in c around inf 21.3%

      \[\leadsto \color{blue}{c \cdot \left(-1 \cdot \left(\frac{1}{a} \cdot \sqrt{\frac{2 \cdot \left(a + -1 \cdot a\right) - a}{c}}\right) + -1 \cdot \frac{b\_2}{a \cdot c}\right)} \]
    8. Taylor expanded in c around 0 45.8%

      \[\leadsto \color{blue}{-1 \cdot \left(\frac{1}{a} \cdot \sqrt{c \cdot \left(2 \cdot \left(a + -1 \cdot a\right) - a\right)}\right) + -1 \cdot \frac{b\_2}{a}} \]
    9. Step-by-step derivation
      1. +-commutative45.8%

        \[\leadsto \color{blue}{-1 \cdot \frac{b\_2}{a} + -1 \cdot \left(\frac{1}{a} \cdot \sqrt{c \cdot \left(2 \cdot \left(a + -1 \cdot a\right) - a\right)}\right)} \]
      2. mul-1-neg45.8%

        \[\leadsto -1 \cdot \frac{b\_2}{a} + \color{blue}{\left(-\frac{1}{a} \cdot \sqrt{c \cdot \left(2 \cdot \left(a + -1 \cdot a\right) - a\right)}\right)} \]
      3. unsub-neg45.8%

        \[\leadsto \color{blue}{-1 \cdot \frac{b\_2}{a} - \frac{1}{a} \cdot \sqrt{c \cdot \left(2 \cdot \left(a + -1 \cdot a\right) - a\right)}} \]
      4. associate-*r/45.8%

        \[\leadsto \color{blue}{\frac{-1 \cdot b\_2}{a}} - \frac{1}{a} \cdot \sqrt{c \cdot \left(2 \cdot \left(a + -1 \cdot a\right) - a\right)} \]
      5. mul-1-neg45.8%

        \[\leadsto \frac{\color{blue}{-b\_2}}{a} - \frac{1}{a} \cdot \sqrt{c \cdot \left(2 \cdot \left(a + -1 \cdot a\right) - a\right)} \]
      6. associate-*l/45.9%

        \[\leadsto \frac{-b\_2}{a} - \color{blue}{\frac{1 \cdot \sqrt{c \cdot \left(2 \cdot \left(a + -1 \cdot a\right) - a\right)}}{a}} \]
      7. *-lft-identity45.9%

        \[\leadsto \frac{-b\_2}{a} - \frac{\color{blue}{\sqrt{c \cdot \left(2 \cdot \left(a + -1 \cdot a\right) - a\right)}}}{a} \]
      8. distribute-rgt1-in45.9%

        \[\leadsto \frac{-b\_2}{a} - \frac{\sqrt{c \cdot \left(2 \cdot \color{blue}{\left(\left(-1 + 1\right) \cdot a\right)} - a\right)}}{a} \]
      9. metadata-eval45.9%

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

        \[\leadsto \frac{-b\_2}{a} - \frac{\sqrt{c \cdot \left(2 \cdot \color{blue}{0} - a\right)}}{a} \]
      11. metadata-eval45.9%

        \[\leadsto \frac{-b\_2}{a} - \frac{\sqrt{c \cdot \left(\color{blue}{0} - a\right)}}{a} \]
      12. neg-sub045.9%

        \[\leadsto \frac{-b\_2}{a} - \frac{\sqrt{c \cdot \color{blue}{\left(-a\right)}}}{a} \]
    10. Simplified45.9%

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

    if 2.5e-80 < b_2

    1. Initial program 71.1%

      \[\frac{\left(-b\_2\right) - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
    2. Add Preprocessing
    3. Taylor expanded in c around 0 89.3%

      \[\leadsto \color{blue}{-2 \cdot \frac{b\_2}{a} + 0.5 \cdot \frac{c}{b\_2}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification54.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b\_2 \leq -9.5 \cdot 10^{+131}:\\ \;\;\;\;c \cdot \left(\frac{b\_2 \cdot 2}{c \cdot a} - \frac{0.5}{b\_2}\right)\\ \mathbf{elif}\;b\_2 \leq 2.5 \cdot 10^{-80}:\\ \;\;\;\;\frac{b\_2}{-a} - \frac{\sqrt{c \cdot \left(-a\right)}}{a}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b\_2}{a} + 0.5 \cdot \frac{c}{b\_2}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 38.2% accurate, 6.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -5 \cdot 10^{-310}:\\
\;\;\;\;c \cdot \left(\frac{b\_2 \cdot 2}{c \cdot a} - \frac{0.5}{b\_2}\right)\\

\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a} + 0.5 \cdot \left(c \cdot \frac{1}{b\_2}\right)\\


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

    1. Initial program 29.5%

      \[\frac{\left(-b\_2\right) - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt27.8%

        \[\leadsto \frac{\color{blue}{\sqrt{-b\_2} \cdot \sqrt{-b\_2}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      2. sqrt-unprod29.0%

        \[\leadsto \frac{\color{blue}{\sqrt{\left(-b\_2\right) \cdot \left(-b\_2\right)}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      3. sqr-neg29.0%

        \[\leadsto \frac{\sqrt{\color{blue}{b\_2 \cdot b\_2}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      4. sqrt-prod0.0%

        \[\leadsto \frac{\color{blue}{\sqrt{b\_2} \cdot \sqrt{b\_2}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      5. add-sqr-sqrt25.9%

        \[\leadsto \frac{\color{blue}{b\_2} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      6. add-cube-cbrt25.9%

        \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{b\_2} \cdot \sqrt[3]{b\_2}\right) \cdot \sqrt[3]{b\_2}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      7. pow325.9%

        \[\leadsto \frac{\color{blue}{{\left(\sqrt[3]{b\_2}\right)}^{3}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
    4. Applied egg-rr25.9%

      \[\leadsto \frac{\color{blue}{{\left(\sqrt[3]{b\_2}\right)}^{3}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
    5. Taylor expanded in b_2 around -inf 3.1%

      \[\leadsto \frac{\color{blue}{-1 \cdot \left(b\_2 \cdot \left(\left(0.5 \cdot \frac{a \cdot c}{{b\_2}^{2}} + {\left(\sqrt[3]{-1}\right)}^{3}\right) - 1\right)\right)}}{a} \]
    6. Step-by-step derivation
      1. associate-*r*3.1%

        \[\leadsto \frac{\color{blue}{\left(-1 \cdot b\_2\right) \cdot \left(\left(0.5 \cdot \frac{a \cdot c}{{b\_2}^{2}} + {\left(\sqrt[3]{-1}\right)}^{3}\right) - 1\right)}}{a} \]
      2. neg-mul-13.1%

        \[\leadsto \frac{\color{blue}{\left(-b\_2\right)} \cdot \left(\left(0.5 \cdot \frac{a \cdot c}{{b\_2}^{2}} + {\left(\sqrt[3]{-1}\right)}^{3}\right) - 1\right)}{a} \]
      3. rem-cube-cbrt3.1%

        \[\leadsto \frac{\left(-b\_2\right) \cdot \left(\left(0.5 \cdot \frac{a \cdot c}{{b\_2}^{2}} + \color{blue}{-1}\right) - 1\right)}{a} \]
      4. associate--l+3.1%

        \[\leadsto \frac{\left(-b\_2\right) \cdot \color{blue}{\left(0.5 \cdot \frac{a \cdot c}{{b\_2}^{2}} + \left(-1 - 1\right)\right)}}{a} \]
      5. metadata-eval3.1%

        \[\leadsto \frac{\left(-b\_2\right) \cdot \left(0.5 \cdot \frac{a \cdot c}{{b\_2}^{2}} + \color{blue}{-2}\right)}{a} \]
    7. Simplified3.1%

      \[\leadsto \frac{\color{blue}{\left(-b\_2\right) \cdot \left(0.5 \cdot \frac{a \cdot c}{{b\_2}^{2}} + -2\right)}}{a} \]
    8. Taylor expanded in c around inf 7.3%

      \[\leadsto \color{blue}{c \cdot \left(2 \cdot \frac{b\_2}{a \cdot c} - 0.5 \cdot \frac{1}{b\_2}\right)} \]
    9. Step-by-step derivation
      1. associate-*r/7.3%

        \[\leadsto c \cdot \left(\color{blue}{\frac{2 \cdot b\_2}{a \cdot c}} - 0.5 \cdot \frac{1}{b\_2}\right) \]
      2. associate-*r/7.3%

        \[\leadsto c \cdot \left(\frac{2 \cdot b\_2}{a \cdot c} - \color{blue}{\frac{0.5 \cdot 1}{b\_2}}\right) \]
      3. metadata-eval7.3%

        \[\leadsto c \cdot \left(\frac{2 \cdot b\_2}{a \cdot c} - \frac{\color{blue}{0.5}}{b\_2}\right) \]
    10. Simplified7.3%

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

    if -4.999999999999985e-310 < b_2

    1. Initial program 74.7%

      \[\frac{\left(-b\_2\right) - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
    2. Add Preprocessing
    3. Taylor expanded in c around 0 72.6%

      \[\leadsto \color{blue}{-2 \cdot \frac{b\_2}{a} + 0.5 \cdot \frac{c}{b\_2}} \]
    4. Step-by-step derivation
      1. div-inv72.6%

        \[\leadsto -2 \cdot \frac{b\_2}{a} + 0.5 \cdot \color{blue}{\left(c \cdot \frac{1}{b\_2}\right)} \]
    5. Applied egg-rr72.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b\_2 \leq -5 \cdot 10^{-310}:\\ \;\;\;\;c \cdot \left(\frac{b\_2 \cdot 2}{c \cdot a} - \frac{0.5}{b\_2}\right)\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b\_2}{a} + 0.5 \cdot \left(c \cdot \frac{1}{b\_2}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 38.2% accurate, 6.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b\_2 \leq -5 \cdot 10^{-310}:\\
\;\;\;\;c \cdot \left(\frac{b\_2 \cdot 2}{c \cdot a} - \frac{0.5}{b\_2}\right)\\

\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b\_2}{a} + 0.5 \cdot \frac{c}{b\_2}\\


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

    1. Initial program 29.5%

      \[\frac{\left(-b\_2\right) - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt27.8%

        \[\leadsto \frac{\color{blue}{\sqrt{-b\_2} \cdot \sqrt{-b\_2}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      2. sqrt-unprod29.0%

        \[\leadsto \frac{\color{blue}{\sqrt{\left(-b\_2\right) \cdot \left(-b\_2\right)}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      3. sqr-neg29.0%

        \[\leadsto \frac{\sqrt{\color{blue}{b\_2 \cdot b\_2}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      4. sqrt-prod0.0%

        \[\leadsto \frac{\color{blue}{\sqrt{b\_2} \cdot \sqrt{b\_2}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      5. add-sqr-sqrt25.9%

        \[\leadsto \frac{\color{blue}{b\_2} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      6. add-cube-cbrt25.9%

        \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{b\_2} \cdot \sqrt[3]{b\_2}\right) \cdot \sqrt[3]{b\_2}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
      7. pow325.9%

        \[\leadsto \frac{\color{blue}{{\left(\sqrt[3]{b\_2}\right)}^{3}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
    4. Applied egg-rr25.9%

      \[\leadsto \frac{\color{blue}{{\left(\sqrt[3]{b\_2}\right)}^{3}} - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
    5. Taylor expanded in b_2 around -inf 3.1%

      \[\leadsto \frac{\color{blue}{-1 \cdot \left(b\_2 \cdot \left(\left(0.5 \cdot \frac{a \cdot c}{{b\_2}^{2}} + {\left(\sqrt[3]{-1}\right)}^{3}\right) - 1\right)\right)}}{a} \]
    6. Step-by-step derivation
      1. associate-*r*3.1%

        \[\leadsto \frac{\color{blue}{\left(-1 \cdot b\_2\right) \cdot \left(\left(0.5 \cdot \frac{a \cdot c}{{b\_2}^{2}} + {\left(\sqrt[3]{-1}\right)}^{3}\right) - 1\right)}}{a} \]
      2. neg-mul-13.1%

        \[\leadsto \frac{\color{blue}{\left(-b\_2\right)} \cdot \left(\left(0.5 \cdot \frac{a \cdot c}{{b\_2}^{2}} + {\left(\sqrt[3]{-1}\right)}^{3}\right) - 1\right)}{a} \]
      3. rem-cube-cbrt3.1%

        \[\leadsto \frac{\left(-b\_2\right) \cdot \left(\left(0.5 \cdot \frac{a \cdot c}{{b\_2}^{2}} + \color{blue}{-1}\right) - 1\right)}{a} \]
      4. associate--l+3.1%

        \[\leadsto \frac{\left(-b\_2\right) \cdot \color{blue}{\left(0.5 \cdot \frac{a \cdot c}{{b\_2}^{2}} + \left(-1 - 1\right)\right)}}{a} \]
      5. metadata-eval3.1%

        \[\leadsto \frac{\left(-b\_2\right) \cdot \left(0.5 \cdot \frac{a \cdot c}{{b\_2}^{2}} + \color{blue}{-2}\right)}{a} \]
    7. Simplified3.1%

      \[\leadsto \frac{\color{blue}{\left(-b\_2\right) \cdot \left(0.5 \cdot \frac{a \cdot c}{{b\_2}^{2}} + -2\right)}}{a} \]
    8. Taylor expanded in c around inf 7.3%

      \[\leadsto \color{blue}{c \cdot \left(2 \cdot \frac{b\_2}{a \cdot c} - 0.5 \cdot \frac{1}{b\_2}\right)} \]
    9. Step-by-step derivation
      1. associate-*r/7.3%

        \[\leadsto c \cdot \left(\color{blue}{\frac{2 \cdot b\_2}{a \cdot c}} - 0.5 \cdot \frac{1}{b\_2}\right) \]
      2. associate-*r/7.3%

        \[\leadsto c \cdot \left(\frac{2 \cdot b\_2}{a \cdot c} - \color{blue}{\frac{0.5 \cdot 1}{b\_2}}\right) \]
      3. metadata-eval7.3%

        \[\leadsto c \cdot \left(\frac{2 \cdot b\_2}{a \cdot c} - \frac{\color{blue}{0.5}}{b\_2}\right) \]
    10. Simplified7.3%

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

    if -4.999999999999985e-310 < b_2

    1. Initial program 74.7%

      \[\frac{\left(-b\_2\right) - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
    2. Add Preprocessing
    3. Taylor expanded in c around 0 72.6%

      \[\leadsto \color{blue}{-2 \cdot \frac{b\_2}{a} + 0.5 \cdot \frac{c}{b\_2}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification35.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b\_2 \leq -5 \cdot 10^{-310}:\\ \;\;\;\;c \cdot \left(\frac{b\_2 \cdot 2}{c \cdot a} - \frac{0.5}{b\_2}\right)\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b\_2}{a} + 0.5 \cdot \frac{c}{b\_2}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 36.2% accurate, 10.2× speedup?

\[\begin{array}{l} \\ -2 \cdot \frac{b\_2}{a} + 0.5 \cdot \frac{c}{b\_2} \end{array} \]
(FPCore (a b_2 c) :precision binary64 (+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2))))
double code(double a, double b_2, double c) {
	return (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
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 = ((-2.0d0) * (b_2 / a)) + (0.5d0 * (c / b_2))
end function
public static double code(double a, double b_2, double c) {
	return (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
def code(a, b_2, c):
	return (-2.0 * (b_2 / a)) + (0.5 * (c / b_2))
function code(a, b_2, c)
	return Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2)))
end
function tmp = code(a, b_2, c)
	tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
end
code[a_, b$95$2_, c_] := N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
-2 \cdot \frac{b\_2}{a} + 0.5 \cdot \frac{c}{b\_2}
\end{array}
Derivation
  1. Initial program 48.9%

    \[\frac{\left(-b\_2\right) - \sqrt{b\_2 \cdot b\_2 - a \cdot c}}{a} \]
  2. Add Preprocessing
  3. Taylor expanded in c around 0 32.4%

    \[\leadsto \color{blue}{-2 \cdot \frac{b\_2}{a} + 0.5 \cdot \frac{c}{b\_2}} \]
  4. Add Preprocessing

Developer Target 1: 99.7% 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:\\ \;\;\;\;\sqrt{\left|b\_2\right| - t\_0} \cdot \sqrt{\left|b\_2\right| + t\_0}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{hypot}\left(b\_2, t\_0\right)\\ \end{array}\\ \mathbf{if}\;b\_2 < 0:\\ \;\;\;\;\frac{c}{t\_1 - b\_2}\\ \mathbf{else}:\\ \;\;\;\;\frac{b\_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)
           (* (sqrt (- (fabs b_2) t_0)) (sqrt (+ (fabs b_2) t_0)))
           (hypot b_2 t_0))))
   (if (< b_2 0.0) (/ c (- t_1 b_2)) (/ (+ b_2 t_1) (- a)))))
double code(double a, double b_2, double c) {
	double t_0 = sqrt(fabs(a)) * sqrt(fabs(c));
	double tmp;
	if (copysign(a, c) == a) {
		tmp = sqrt((fabs(b_2) - t_0)) * sqrt((fabs(b_2) + t_0));
	} else {
		tmp = hypot(b_2, t_0);
	}
	double t_1 = tmp;
	double tmp_1;
	if (b_2 < 0.0) {
		tmp_1 = c / (t_1 - b_2);
	} else {
		tmp_1 = (b_2 + t_1) / -a;
	}
	return tmp_1;
}
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;
	if (Math.copySign(a, c) == a) {
		tmp = Math.sqrt((Math.abs(b_2) - t_0)) * Math.sqrt((Math.abs(b_2) + t_0));
	} else {
		tmp = Math.hypot(b_2, t_0);
	}
	double t_1 = tmp;
	double tmp_1;
	if (b_2 < 0.0) {
		tmp_1 = c / (t_1 - b_2);
	} else {
		tmp_1 = (b_2 + t_1) / -a;
	}
	return tmp_1;
}
def code(a, b_2, c):
	t_0 = math.sqrt(math.fabs(a)) * math.sqrt(math.fabs(c))
	tmp = 0
	if math.copysign(a, c) == a:
		tmp = math.sqrt((math.fabs(b_2) - t_0)) * math.sqrt((math.fabs(b_2) + t_0))
	else:
		tmp = math.hypot(b_2, t_0)
	t_1 = tmp
	tmp_1 = 0
	if b_2 < 0.0:
		tmp_1 = c / (t_1 - b_2)
	else:
		tmp_1 = (b_2 + t_1) / -a
	return tmp_1
function code(a, b_2, c)
	t_0 = Float64(sqrt(abs(a)) * sqrt(abs(c)))
	tmp = 0.0
	if (copysign(a, c) == a)
		tmp = Float64(sqrt(Float64(abs(b_2) - t_0)) * sqrt(Float64(abs(b_2) + t_0)));
	else
		tmp = hypot(b_2, t_0);
	end
	t_1 = tmp
	tmp_1 = 0.0
	if (b_2 < 0.0)
		tmp_1 = Float64(c / Float64(t_1 - b_2));
	else
		tmp_1 = Float64(Float64(b_2 + t_1) / Float64(-a));
	end
	return tmp_1
end
function tmp_3 = code(a, b_2, c)
	t_0 = sqrt(abs(a)) * sqrt(abs(c));
	tmp = 0.0;
	if ((sign(c) * abs(a)) == a)
		tmp = sqrt((abs(b_2) - t_0)) * sqrt((abs(b_2) + t_0));
	else
		tmp = hypot(b_2, t_0);
	end
	t_1 = tmp;
	tmp_2 = 0.0;
	if (b_2 < 0.0)
		tmp_2 = c / (t_1 - b_2);
	else
		tmp_2 = (b_2 + t_1) / -a;
	end
	tmp_3 = tmp_2;
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], 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], N[Sqrt[b$95$2 ^ 2 + t$95$0 ^ 2], $MachinePrecision]]}, If[Less[b$95$2, 0.0], N[(c / N[(t$95$1 - b$95$2), $MachinePrecision]), $MachinePrecision], N[(N[(b$95$2 + 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:\\
\;\;\;\;\sqrt{\left|b\_2\right| - t\_0} \cdot \sqrt{\left|b\_2\right| + t\_0}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{hypot}\left(b\_2, t\_0\right)\\


\end{array}\\
\mathbf{if}\;b\_2 < 0:\\
\;\;\;\;\frac{c}{t\_1 - b\_2}\\

\mathbf{else}:\\
\;\;\;\;\frac{b\_2 + t\_1}{-a}\\


\end{array}
\end{array}

Reproduce

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

  :alt
  (! :herbie-platform default (let ((sqtD (let ((x (* (sqrt (fabs a)) (sqrt (fabs c))))) (if (== (copysign a c) a) (* (sqrt (- (fabs b_2) x)) (sqrt (+ (fabs b_2) x))) (hypot b_2 x))))) (if (< b_2 0) (/ c (- sqtD b_2)) (/ (+ b_2 sqtD) (- a)))))

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