quadp (p42, positive)

Percentage Accurate: 53.2% → 85.4%
Time: 10.3s
Alternatives: 5
Speedup: 12.9×

Specification

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

\\
\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot 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 5 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.2% accurate, 1.0× speedup?

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

\\
\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}
\end{array}

Alternative 1: 85.4% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -6 \cdot 10^{+153}:\\
\;\;\;\;-\frac{b}{a}\\

\mathbf{elif}\;b \leq 4.2 \cdot 10^{-57}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} - b}{a \cdot 2}\\

\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b < -6.00000000000000037e153

    1. Initial program 46.6%

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

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

      \[\leadsto \color{blue}{\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{a \cdot 2}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-neg46.6%

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

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, \color{blue}{-4} \cdot \left(a \cdot c\right)\right)}}{a \cdot 2} \]
      4. associate-*r*46.6%

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, \color{blue}{c \cdot \left(-4 \cdot a\right)}\right)}}{a \cdot 2} \]
      6. add-sqr-sqrt46.6%

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

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

        \[\leadsto \frac{\left(-b\right) + {\left(\sqrt{\sqrt{\color{blue}{b \cdot b + c \cdot \left(-4 \cdot a\right)}}}\right)}^{2}}{a \cdot 2} \]
      9. add-sqr-sqrt33.3%

        \[\leadsto \frac{\left(-b\right) + {\left(\sqrt{\sqrt{b \cdot b + \color{blue}{\sqrt{c \cdot \left(-4 \cdot a\right)} \cdot \sqrt{c \cdot \left(-4 \cdot a\right)}}}}\right)}^{2}}{a \cdot 2} \]
      10. hypot-define56.9%

        \[\leadsto \frac{\left(-b\right) + {\left(\sqrt{\color{blue}{\mathsf{hypot}\left(b, \sqrt{c \cdot \left(-4 \cdot a\right)}\right)}}\right)}^{2}}{a \cdot 2} \]
      11. associate-*r*56.9%

        \[\leadsto \frac{\left(-b\right) + {\left(\sqrt{\mathsf{hypot}\left(b, \sqrt{\color{blue}{\left(c \cdot -4\right) \cdot a}}\right)}\right)}^{2}}{a \cdot 2} \]
      12. *-commutative56.9%

        \[\leadsto \frac{\left(-b\right) + {\left(\sqrt{\mathsf{hypot}\left(b, \sqrt{\color{blue}{a \cdot \left(c \cdot -4\right)}}\right)}\right)}^{2}}{a \cdot 2} \]
    6. Applied egg-rr56.9%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{b}{a}} \]
    8. Step-by-step derivation
      1. associate-*r/91.6%

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

        \[\leadsto \frac{\color{blue}{-b}}{a} \]
    9. Simplified91.6%

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

    if -6.00000000000000037e153 < b < 4.1999999999999999e-57

    1. Initial program 86.3%

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

    if 4.1999999999999999e-57 < b

    1. Initial program 8.6%

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

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

      \[\leadsto \color{blue}{\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{a \cdot 2}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-cube-cbrt8.6%

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{{\left(\sqrt[3]{4 \cdot \left(a \cdot c\right)}\right)}^{3}}}}{a \cdot 2} \]
      3. *-commutative8.6%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\left(\sqrt[3]{\color{blue}{\left(a \cdot c\right) \cdot 4}}\right)}^{3}}}{a \cdot 2} \]
      4. associate-*l*8.6%

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{{\left(\sqrt[3]{a \cdot \left(c \cdot 4\right)}\right)}^{3}}}}{a \cdot 2} \]
    7. Step-by-step derivation
      1. pow1/35.1%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\color{blue}{\left({\left(a \cdot \left(c \cdot 4\right)\right)}^{0.3333333333333333}\right)}}^{3}}}{a \cdot 2} \]
      2. associate-*r*5.1%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\left({\color{blue}{\left(\left(a \cdot c\right) \cdot 4\right)}}^{0.3333333333333333}\right)}^{3}}}{a \cdot 2} \]
      3. add-cube-cbrt5.1%

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\left({\left(\color{blue}{{\left(\sqrt[3]{a \cdot c}\right)}^{3}} \cdot 4\right)}^{0.3333333333333333}\right)}^{3}}}{a \cdot 2} \]
      5. *-commutative5.1%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\left({\color{blue}{\left(4 \cdot {\left(\sqrt[3]{a \cdot c}\right)}^{3}\right)}}^{0.3333333333333333}\right)}^{3}}}{a \cdot 2} \]
      6. unpow-prod-down5.1%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\color{blue}{\left({4}^{0.3333333333333333} \cdot {\left({\left(\sqrt[3]{a \cdot c}\right)}^{3}\right)}^{0.3333333333333333}\right)}}^{3}}}{a \cdot 2} \]
      7. pow1/38.6%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\left({4}^{0.3333333333333333} \cdot \color{blue}{\sqrt[3]{{\left(\sqrt[3]{a \cdot c}\right)}^{3}}}\right)}^{3}}}{a \cdot 2} \]
      8. rem-cbrt-cube8.6%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\left({4}^{0.3333333333333333} \cdot \color{blue}{\sqrt[3]{a \cdot c}}\right)}^{3}}}{a \cdot 2} \]
    8. Applied egg-rr8.6%

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\color{blue}{\left({4}^{0.3333333333333333} \cdot \sqrt[3]{a \cdot c}\right)}}^{3}}}{a \cdot 2} \]
    9. Taylor expanded in b around inf 28.9%

      \[\leadsto \frac{\left(-b\right) + \color{blue}{b \cdot \left(1 + -0.5 \cdot \frac{a \cdot \left(c \cdot {\left(\sqrt[3]{4}\right)}^{3}\right)}{{b}^{2}}\right)}}{a \cdot 2} \]
    10. Step-by-step derivation
      1. associate-/l*29.1%

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}} \]
    13. Step-by-step derivation
      1. associate-*r/93.9%

        \[\leadsto \color{blue}{\frac{-1 \cdot c}{b}} \]
      2. neg-mul-193.9%

        \[\leadsto \frac{\color{blue}{-c}}{b} \]
    14. Simplified93.9%

      \[\leadsto \color{blue}{\frac{-c}{b}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification89.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -6 \cdot 10^{+153}:\\ \;\;\;\;-\frac{b}{a}\\ \mathbf{elif}\;b \leq 4.2 \cdot 10^{-57}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 79.9% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.8 \cdot 10^{-127}:\\
\;\;\;\;-\frac{b}{a}\\

\mathbf{elif}\;b \leq 5.2 \cdot 10^{-47}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -4\right)} - b}{a \cdot 2}\\

\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b < -5.8000000000000001e-127

    1. Initial program 80.1%

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

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

      \[\leadsto \color{blue}{\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{a \cdot 2}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-neg80.1%

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

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, \color{blue}{-4} \cdot \left(a \cdot c\right)\right)}}{a \cdot 2} \]
      4. associate-*r*80.1%

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, \color{blue}{c \cdot \left(-4 \cdot a\right)}\right)}}{a \cdot 2} \]
      6. add-sqr-sqrt79.8%

        \[\leadsto \frac{\left(-b\right) + \color{blue}{\sqrt{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-4 \cdot a\right)\right)}} \cdot \sqrt{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-4 \cdot a\right)\right)}}}}{a \cdot 2} \]
      7. pow279.8%

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

        \[\leadsto \frac{\left(-b\right) + {\left(\sqrt{\sqrt{\color{blue}{b \cdot b + c \cdot \left(-4 \cdot a\right)}}}\right)}^{2}}{a \cdot 2} \]
      9. add-sqr-sqrt61.9%

        \[\leadsto \frac{\left(-b\right) + {\left(\sqrt{\sqrt{b \cdot b + \color{blue}{\sqrt{c \cdot \left(-4 \cdot a\right)} \cdot \sqrt{c \cdot \left(-4 \cdot a\right)}}}}\right)}^{2}}{a \cdot 2} \]
      10. hypot-define69.8%

        \[\leadsto \frac{\left(-b\right) + {\left(\sqrt{\color{blue}{\mathsf{hypot}\left(b, \sqrt{c \cdot \left(-4 \cdot a\right)}\right)}}\right)}^{2}}{a \cdot 2} \]
      11. associate-*r*69.8%

        \[\leadsto \frac{\left(-b\right) + {\left(\sqrt{\mathsf{hypot}\left(b, \sqrt{\color{blue}{\left(c \cdot -4\right) \cdot a}}\right)}\right)}^{2}}{a \cdot 2} \]
      12. *-commutative69.8%

        \[\leadsto \frac{\left(-b\right) + {\left(\sqrt{\mathsf{hypot}\left(b, \sqrt{\color{blue}{a \cdot \left(c \cdot -4\right)}}\right)}\right)}^{2}}{a \cdot 2} \]
    6. Applied egg-rr69.8%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{b}{a}} \]
    8. Step-by-step derivation
      1. associate-*r/81.3%

        \[\leadsto \color{blue}{\frac{-1 \cdot b}{a}} \]
      2. mul-1-neg81.3%

        \[\leadsto \frac{\color{blue}{-b}}{a} \]
    9. Simplified81.3%

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

    if -5.8000000000000001e-127 < b < 5.2e-47

    1. Initial program 75.6%

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

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

      \[\leadsto \color{blue}{\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{a \cdot 2}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-cube-cbrt74.8%

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{{\left(\sqrt[3]{4 \cdot \left(a \cdot c\right)}\right)}^{3}}}}{a \cdot 2} \]
      3. *-commutative74.8%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\left(\sqrt[3]{\color{blue}{\left(a \cdot c\right) \cdot 4}}\right)}^{3}}}{a \cdot 2} \]
      4. associate-*l*74.8%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\left(\sqrt[3]{\color{blue}{a \cdot \left(c \cdot 4\right)}}\right)}^{3}}}{a \cdot 2} \]
    6. Applied egg-rr74.8%

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{{\left(\sqrt[3]{a \cdot \left(c \cdot 4\right)}\right)}^{3}}}}{a \cdot 2} \]
    7. Taylor expanded in a around -inf 0.0%

      \[\leadsto \frac{\left(-b\right) + \color{blue}{-1 \cdot \left(\sqrt{a \cdot \left(c \cdot {\left(\sqrt[3]{-4}\right)}^{3}\right)} \cdot {\left(\sqrt{-1}\right)}^{2}\right)}}{a \cdot 2} \]
    8. Step-by-step derivation
      1. mul-1-neg0.0%

        \[\leadsto \frac{\left(-b\right) + \color{blue}{\left(-\sqrt{a \cdot \left(c \cdot {\left(\sqrt[3]{-4}\right)}^{3}\right)} \cdot {\left(\sqrt{-1}\right)}^{2}\right)}}{a \cdot 2} \]
      2. *-commutative0.0%

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

        \[\leadsto \frac{\left(-b\right) + \left(-\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot \sqrt{a \cdot \left(c \cdot {\left(\sqrt[3]{-4}\right)}^{3}\right)}\right)}{a \cdot 2} \]
      4. rem-square-sqrt71.0%

        \[\leadsto \frac{\left(-b\right) + \left(-\color{blue}{-1} \cdot \sqrt{a \cdot \left(c \cdot {\left(\sqrt[3]{-4}\right)}^{3}\right)}\right)}{a \cdot 2} \]
      5. distribute-lft-neg-in71.0%

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

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

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

      \[\leadsto \frac{\left(-b\right) + \color{blue}{1 \cdot \sqrt{a \cdot \left(c \cdot -4\right)}}}{a \cdot 2} \]

    if 5.2e-47 < b

    1. Initial program 8.6%

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

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

      \[\leadsto \color{blue}{\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{a \cdot 2}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-cube-cbrt8.6%

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{{\left(\sqrt[3]{4 \cdot \left(a \cdot c\right)}\right)}^{3}}}}{a \cdot 2} \]
      3. *-commutative8.6%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\left(\sqrt[3]{\color{blue}{\left(a \cdot c\right) \cdot 4}}\right)}^{3}}}{a \cdot 2} \]
      4. associate-*l*8.6%

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{{\left(\sqrt[3]{a \cdot \left(c \cdot 4\right)}\right)}^{3}}}}{a \cdot 2} \]
    7. Step-by-step derivation
      1. pow1/35.1%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\color{blue}{\left({\left(a \cdot \left(c \cdot 4\right)\right)}^{0.3333333333333333}\right)}}^{3}}}{a \cdot 2} \]
      2. associate-*r*5.1%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\left({\color{blue}{\left(\left(a \cdot c\right) \cdot 4\right)}}^{0.3333333333333333}\right)}^{3}}}{a \cdot 2} \]
      3. add-cube-cbrt5.1%

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\left({\left(\color{blue}{{\left(\sqrt[3]{a \cdot c}\right)}^{3}} \cdot 4\right)}^{0.3333333333333333}\right)}^{3}}}{a \cdot 2} \]
      5. *-commutative5.1%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\left({\color{blue}{\left(4 \cdot {\left(\sqrt[3]{a \cdot c}\right)}^{3}\right)}}^{0.3333333333333333}\right)}^{3}}}{a \cdot 2} \]
      6. unpow-prod-down5.1%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\color{blue}{\left({4}^{0.3333333333333333} \cdot {\left({\left(\sqrt[3]{a \cdot c}\right)}^{3}\right)}^{0.3333333333333333}\right)}}^{3}}}{a \cdot 2} \]
      7. pow1/38.6%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\left({4}^{0.3333333333333333} \cdot \color{blue}{\sqrt[3]{{\left(\sqrt[3]{a \cdot c}\right)}^{3}}}\right)}^{3}}}{a \cdot 2} \]
      8. rem-cbrt-cube8.6%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\left({4}^{0.3333333333333333} \cdot \color{blue}{\sqrt[3]{a \cdot c}}\right)}^{3}}}{a \cdot 2} \]
    8. Applied egg-rr8.6%

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\color{blue}{\left({4}^{0.3333333333333333} \cdot \sqrt[3]{a \cdot c}\right)}}^{3}}}{a \cdot 2} \]
    9. Taylor expanded in b around inf 28.9%

      \[\leadsto \frac{\left(-b\right) + \color{blue}{b \cdot \left(1 + -0.5 \cdot \frac{a \cdot \left(c \cdot {\left(\sqrt[3]{4}\right)}^{3}\right)}{{b}^{2}}\right)}}{a \cdot 2} \]
    10. Step-by-step derivation
      1. associate-/l*29.1%

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}} \]
    13. Step-by-step derivation
      1. associate-*r/93.9%

        \[\leadsto \color{blue}{\frac{-1 \cdot c}{b}} \]
      2. neg-mul-193.9%

        \[\leadsto \frac{\color{blue}{-c}}{b} \]
    14. Simplified93.9%

      \[\leadsto \color{blue}{\frac{-c}{b}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification83.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -5.8 \cdot 10^{-127}:\\ \;\;\;\;-\frac{b}{a}\\ \mathbf{elif}\;b \leq 5.2 \cdot 10^{-47}:\\ \;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -4\right)} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 71.1% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.2 \cdot 10^{-186}:\\
\;\;\;\;-\frac{b}{a}\\

\mathbf{elif}\;b \leq 5.2 \cdot 10^{-105}:\\
\;\;\;\;-0.5 \cdot \left(-\sqrt{c \cdot \frac{-4}{a}}\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b < -5.19999999999999986e-186

    1. Initial program 79.4%

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

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

      \[\leadsto \color{blue}{\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{a \cdot 2}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-neg79.4%

        \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\mathsf{fma}\left(b, b, -4 \cdot \left(a \cdot c\right)\right)}}}{a \cdot 2} \]
      2. distribute-lft-neg-in79.4%

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, \color{blue}{-4} \cdot \left(a \cdot c\right)\right)}}{a \cdot 2} \]
      4. associate-*r*79.4%

        \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, \color{blue}{\left(-4 \cdot a\right) \cdot c}\right)}}{a \cdot 2} \]
      5. *-commutative79.4%

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

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

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

        \[\leadsto \frac{\left(-b\right) + {\left(\sqrt{\sqrt{\color{blue}{b \cdot b + c \cdot \left(-4 \cdot a\right)}}}\right)}^{2}}{a \cdot 2} \]
      9. add-sqr-sqrt62.7%

        \[\leadsto \frac{\left(-b\right) + {\left(\sqrt{\sqrt{b \cdot b + \color{blue}{\sqrt{c \cdot \left(-4 \cdot a\right)} \cdot \sqrt{c \cdot \left(-4 \cdot a\right)}}}}\right)}^{2}}{a \cdot 2} \]
      10. hypot-define71.4%

        \[\leadsto \frac{\left(-b\right) + {\left(\sqrt{\color{blue}{\mathsf{hypot}\left(b, \sqrt{c \cdot \left(-4 \cdot a\right)}\right)}}\right)}^{2}}{a \cdot 2} \]
      11. associate-*r*71.4%

        \[\leadsto \frac{\left(-b\right) + {\left(\sqrt{\mathsf{hypot}\left(b, \sqrt{\color{blue}{\left(c \cdot -4\right) \cdot a}}\right)}\right)}^{2}}{a \cdot 2} \]
      12. *-commutative71.4%

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{b}{a}} \]
    8. Step-by-step derivation
      1. associate-*r/77.5%

        \[\leadsto \color{blue}{\frac{-1 \cdot b}{a}} \]
      2. mul-1-neg77.5%

        \[\leadsto \frac{\color{blue}{-b}}{a} \]
    9. Simplified77.5%

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

    if -5.19999999999999986e-186 < b < 5.1999999999999997e-105

    1. Initial program 78.9%

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

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

      \[\leadsto \color{blue}{\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{a \cdot 2}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-cube-cbrt78.2%

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

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\left(\sqrt[3]{\color{blue}{\left(a \cdot c\right) \cdot 4}}\right)}^{3}}}{a \cdot 2} \]
      4. associate-*l*78.1%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\left(\sqrt[3]{\color{blue}{a \cdot \left(c \cdot 4\right)}}\right)}^{3}}}{a \cdot 2} \]
    6. Applied egg-rr78.1%

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{{\left(\sqrt[3]{a \cdot \left(c \cdot 4\right)}\right)}^{3}}}}{a \cdot 2} \]
    7. Step-by-step derivation
      1. pow1/30.6%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\color{blue}{\left({\left(a \cdot \left(c \cdot 4\right)\right)}^{0.3333333333333333}\right)}}^{3}}}{a \cdot 2} \]
      2. associate-*r*0.6%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\left({\color{blue}{\left(\left(a \cdot c\right) \cdot 4\right)}}^{0.3333333333333333}\right)}^{3}}}{a \cdot 2} \]
      3. add-cube-cbrt0.6%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\left({\left(\color{blue}{\left(\left(\sqrt[3]{a \cdot c} \cdot \sqrt[3]{a \cdot c}\right) \cdot \sqrt[3]{a \cdot c}\right)} \cdot 4\right)}^{0.3333333333333333}\right)}^{3}}}{a \cdot 2} \]
      4. unpow30.6%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\left({\left(\color{blue}{{\left(\sqrt[3]{a \cdot c}\right)}^{3}} \cdot 4\right)}^{0.3333333333333333}\right)}^{3}}}{a \cdot 2} \]
      5. *-commutative0.6%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\left({\color{blue}{\left(4 \cdot {\left(\sqrt[3]{a \cdot c}\right)}^{3}\right)}}^{0.3333333333333333}\right)}^{3}}}{a \cdot 2} \]
      6. unpow-prod-down0.6%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\color{blue}{\left({4}^{0.3333333333333333} \cdot {\left({\left(\sqrt[3]{a \cdot c}\right)}^{3}\right)}^{0.3333333333333333}\right)}}^{3}}}{a \cdot 2} \]
      7. pow1/378.0%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\left({4}^{0.3333333333333333} \cdot \color{blue}{\sqrt[3]{{\left(\sqrt[3]{a \cdot c}\right)}^{3}}}\right)}^{3}}}{a \cdot 2} \]
      8. rem-cbrt-cube78.2%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\left({4}^{0.3333333333333333} \cdot \color{blue}{\sqrt[3]{a \cdot c}}\right)}^{3}}}{a \cdot 2} \]
    8. Applied egg-rr78.2%

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\color{blue}{\left({4}^{0.3333333333333333} \cdot \sqrt[3]{a \cdot c}\right)}}^{3}}}{a \cdot 2} \]
    9. Taylor expanded in a around -inf 0.0%

      \[\leadsto \color{blue}{-0.5 \cdot \left(\sqrt{\frac{c \cdot \left({\left(\sqrt[3]{-1}\right)}^{3} \cdot {\left(\sqrt[3]{4}\right)}^{3}\right)}{a}} \cdot {\left(\sqrt{-1}\right)}^{2}\right)} \]
    10. Step-by-step derivation
      1. *-commutative0.0%

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

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

        \[\leadsto -0.5 \cdot \left(\color{blue}{-1} \cdot \sqrt{\frac{c \cdot \left({\left(\sqrt[3]{-1}\right)}^{3} \cdot {\left(\sqrt[3]{4}\right)}^{3}\right)}{a}}\right) \]
      4. associate-/l*30.2%

        \[\leadsto -0.5 \cdot \left(-1 \cdot \sqrt{\color{blue}{c \cdot \frac{{\left(\sqrt[3]{-1}\right)}^{3} \cdot {\left(\sqrt[3]{4}\right)}^{3}}{a}}}\right) \]
      5. rem-cube-cbrt30.2%

        \[\leadsto -0.5 \cdot \left(-1 \cdot \sqrt{c \cdot \frac{\color{blue}{-1} \cdot {\left(\sqrt[3]{4}\right)}^{3}}{a}}\right) \]
      6. rem-cube-cbrt30.4%

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

        \[\leadsto -0.5 \cdot \left(-1 \cdot \sqrt{c \cdot \frac{\color{blue}{-4}}{a}}\right) \]
    11. Simplified30.4%

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

    if 5.1999999999999997e-105 < b

    1. Initial program 13.3%

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

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

      \[\leadsto \color{blue}{\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{a \cdot 2}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-cube-cbrt13.2%

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{{\left(\sqrt[3]{4 \cdot \left(a \cdot c\right)}\right)}^{3}}}}{a \cdot 2} \]
      3. *-commutative13.2%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\left(\sqrt[3]{\color{blue}{\left(a \cdot c\right) \cdot 4}}\right)}^{3}}}{a \cdot 2} \]
      4. associate-*l*13.2%

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{{\left(\sqrt[3]{a \cdot \left(c \cdot 4\right)}\right)}^{3}}}}{a \cdot 2} \]
    7. Step-by-step derivation
      1. pow1/35.3%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\color{blue}{\left({\left(a \cdot \left(c \cdot 4\right)\right)}^{0.3333333333333333}\right)}}^{3}}}{a \cdot 2} \]
      2. associate-*r*5.3%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\left({\color{blue}{\left(\left(a \cdot c\right) \cdot 4\right)}}^{0.3333333333333333}\right)}^{3}}}{a \cdot 2} \]
      3. add-cube-cbrt5.3%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\left({\left(\color{blue}{\left(\left(\sqrt[3]{a \cdot c} \cdot \sqrt[3]{a \cdot c}\right) \cdot \sqrt[3]{a \cdot c}\right)} \cdot 4\right)}^{0.3333333333333333}\right)}^{3}}}{a \cdot 2} \]
      4. unpow35.3%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\left({\left(\color{blue}{{\left(\sqrt[3]{a \cdot c}\right)}^{3}} \cdot 4\right)}^{0.3333333333333333}\right)}^{3}}}{a \cdot 2} \]
      5. *-commutative5.3%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\left({\color{blue}{\left(4 \cdot {\left(\sqrt[3]{a \cdot c}\right)}^{3}\right)}}^{0.3333333333333333}\right)}^{3}}}{a \cdot 2} \]
      6. unpow-prod-down5.3%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\color{blue}{\left({4}^{0.3333333333333333} \cdot {\left({\left(\sqrt[3]{a \cdot c}\right)}^{3}\right)}^{0.3333333333333333}\right)}}^{3}}}{a \cdot 2} \]
      7. pow1/313.2%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\left({4}^{0.3333333333333333} \cdot \color{blue}{\sqrt[3]{{\left(\sqrt[3]{a \cdot c}\right)}^{3}}}\right)}^{3}}}{a \cdot 2} \]
      8. rem-cbrt-cube13.2%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\left({4}^{0.3333333333333333} \cdot \color{blue}{\sqrt[3]{a \cdot c}}\right)}^{3}}}{a \cdot 2} \]
    8. Applied egg-rr13.2%

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\color{blue}{\left({4}^{0.3333333333333333} \cdot \sqrt[3]{a \cdot c}\right)}}^{3}}}{a \cdot 2} \]
    9. Taylor expanded in b around inf 27.4%

      \[\leadsto \frac{\left(-b\right) + \color{blue}{b \cdot \left(1 + -0.5 \cdot \frac{a \cdot \left(c \cdot {\left(\sqrt[3]{4}\right)}^{3}\right)}{{b}^{2}}\right)}}{a \cdot 2} \]
    10. Step-by-step derivation
      1. associate-/l*27.5%

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}} \]
    13. Step-by-step derivation
      1. associate-*r/89.7%

        \[\leadsto \color{blue}{\frac{-1 \cdot c}{b}} \]
      2. neg-mul-189.7%

        \[\leadsto \frac{\color{blue}{-c}}{b} \]
    14. Simplified89.7%

      \[\leadsto \color{blue}{\frac{-c}{b}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification74.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -5.2 \cdot 10^{-186}:\\ \;\;\;\;-\frac{b}{a}\\ \mathbf{elif}\;b \leq 5.2 \cdot 10^{-105}:\\ \;\;\;\;-0.5 \cdot \left(-\sqrt{c \cdot \frac{-4}{a}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 67.4% accurate, 12.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.85 \cdot 10^{-290}:\\
\;\;\;\;-\frac{b}{a}\\

\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 1.84999999999999989e-290

    1. Initial program 79.9%

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

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

      \[\leadsto \color{blue}{\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{a \cdot 2}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-neg79.9%

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

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, \color{blue}{-4} \cdot \left(a \cdot c\right)\right)}}{a \cdot 2} \]
      4. associate-*r*79.9%

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, \color{blue}{c \cdot \left(-4 \cdot a\right)}\right)}}{a \cdot 2} \]
      6. add-sqr-sqrt79.5%

        \[\leadsto \frac{\left(-b\right) + \color{blue}{\sqrt{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-4 \cdot a\right)\right)}} \cdot \sqrt{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-4 \cdot a\right)\right)}}}}{a \cdot 2} \]
      7. pow279.5%

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

        \[\leadsto \frac{\left(-b\right) + {\left(\sqrt{\sqrt{\color{blue}{b \cdot b + c \cdot \left(-4 \cdot a\right)}}}\right)}^{2}}{a \cdot 2} \]
      9. add-sqr-sqrt65.5%

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

        \[\leadsto \frac{\left(-b\right) + {\left(\sqrt{\color{blue}{\mathsf{hypot}\left(b, \sqrt{c \cdot \left(-4 \cdot a\right)}\right)}}\right)}^{2}}{a \cdot 2} \]
      11. associate-*r*73.0%

        \[\leadsto \frac{\left(-b\right) + {\left(\sqrt{\mathsf{hypot}\left(b, \sqrt{\color{blue}{\left(c \cdot -4\right) \cdot a}}\right)}\right)}^{2}}{a \cdot 2} \]
      12. *-commutative73.0%

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{b}{a}} \]
    8. Step-by-step derivation
      1. associate-*r/67.3%

        \[\leadsto \color{blue}{\frac{-1 \cdot b}{a}} \]
      2. mul-1-neg67.3%

        \[\leadsto \frac{\color{blue}{-b}}{a} \]
    9. Simplified67.3%

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

    if 1.84999999999999989e-290 < b

    1. Initial program 27.0%

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

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

      \[\leadsto \color{blue}{\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{a \cdot 2}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-cube-cbrt26.7%

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{{\left(\sqrt[3]{4 \cdot \left(a \cdot c\right)}\right)}^{3}}}}{a \cdot 2} \]
      3. *-commutative26.7%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\left(\sqrt[3]{\color{blue}{\left(a \cdot c\right) \cdot 4}}\right)}^{3}}}{a \cdot 2} \]
      4. associate-*l*26.7%

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{{\left(\sqrt[3]{a \cdot \left(c \cdot 4\right)}\right)}^{3}}}}{a \cdot 2} \]
    7. Step-by-step derivation
      1. pow1/34.3%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\color{blue}{\left({\left(a \cdot \left(c \cdot 4\right)\right)}^{0.3333333333333333}\right)}}^{3}}}{a \cdot 2} \]
      2. associate-*r*4.3%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\left({\color{blue}{\left(\left(a \cdot c\right) \cdot 4\right)}}^{0.3333333333333333}\right)}^{3}}}{a \cdot 2} \]
      3. add-cube-cbrt4.3%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\left({\left(\color{blue}{\left(\left(\sqrt[3]{a \cdot c} \cdot \sqrt[3]{a \cdot c}\right) \cdot \sqrt[3]{a \cdot c}\right)} \cdot 4\right)}^{0.3333333333333333}\right)}^{3}}}{a \cdot 2} \]
      4. unpow34.3%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\left({\left(\color{blue}{{\left(\sqrt[3]{a \cdot c}\right)}^{3}} \cdot 4\right)}^{0.3333333333333333}\right)}^{3}}}{a \cdot 2} \]
      5. *-commutative4.3%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\left({\color{blue}{\left(4 \cdot {\left(\sqrt[3]{a \cdot c}\right)}^{3}\right)}}^{0.3333333333333333}\right)}^{3}}}{a \cdot 2} \]
      6. unpow-prod-down4.3%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\color{blue}{\left({4}^{0.3333333333333333} \cdot {\left({\left(\sqrt[3]{a \cdot c}\right)}^{3}\right)}^{0.3333333333333333}\right)}}^{3}}}{a \cdot 2} \]
      7. pow1/326.7%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\left({4}^{0.3333333333333333} \cdot \color{blue}{\sqrt[3]{{\left(\sqrt[3]{a \cdot c}\right)}^{3}}}\right)}^{3}}}{a \cdot 2} \]
      8. rem-cbrt-cube26.8%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\left({4}^{0.3333333333333333} \cdot \color{blue}{\sqrt[3]{a \cdot c}}\right)}^{3}}}{a \cdot 2} \]
    8. Applied egg-rr26.8%

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\color{blue}{\left({4}^{0.3333333333333333} \cdot \sqrt[3]{a \cdot c}\right)}}^{3}}}{a \cdot 2} \]
    9. Taylor expanded in b around inf 22.5%

      \[\leadsto \frac{\left(-b\right) + \color{blue}{b \cdot \left(1 + -0.5 \cdot \frac{a \cdot \left(c \cdot {\left(\sqrt[3]{4}\right)}^{3}\right)}{{b}^{2}}\right)}}{a \cdot 2} \]
    10. Step-by-step derivation
      1. associate-/l*22.6%

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

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

        \[\leadsto \frac{\left(-b\right) + b \cdot \left(1 + -0.5 \cdot \left(a \cdot \color{blue}{\left(c \cdot \frac{4}{{b}^{2}}\right)}\right)\right)}{a \cdot 2} \]
    11. Simplified22.6%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}} \]
    13. Step-by-step derivation
      1. associate-*r/73.4%

        \[\leadsto \color{blue}{\frac{-1 \cdot c}{b}} \]
      2. neg-mul-173.4%

        \[\leadsto \frac{\color{blue}{-c}}{b} \]
    14. Simplified73.4%

      \[\leadsto \color{blue}{\frac{-c}{b}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification70.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 1.85 \cdot 10^{-290}:\\ \;\;\;\;-\frac{b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 35.9% accurate, 29.0× speedup?

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

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

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

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

    \[\leadsto \color{blue}{\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{a \cdot 2}} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. fma-neg52.2%

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\mathsf{fma}\left(b, b, -4 \cdot \left(a \cdot c\right)\right)}}}{a \cdot 2} \]
    2. distribute-lft-neg-in52.2%

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, \color{blue}{-4} \cdot \left(a \cdot c\right)\right)}}{a \cdot 2} \]
    4. associate-*r*52.2%

      \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, \color{blue}{\left(-4 \cdot a\right) \cdot c}\right)}}{a \cdot 2} \]
    5. *-commutative52.2%

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

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

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

      \[\leadsto \frac{\left(-b\right) + {\left(\sqrt{\sqrt{\color{blue}{b \cdot b + c \cdot \left(-4 \cdot a\right)}}}\right)}^{2}}{a \cdot 2} \]
    9. add-sqr-sqrt43.6%

      \[\leadsto \frac{\left(-b\right) + {\left(\sqrt{\sqrt{b \cdot b + \color{blue}{\sqrt{c \cdot \left(-4 \cdot a\right)} \cdot \sqrt{c \cdot \left(-4 \cdot a\right)}}}}\right)}^{2}}{a \cdot 2} \]
    10. hypot-define49.1%

      \[\leadsto \frac{\left(-b\right) + {\left(\sqrt{\color{blue}{\mathsf{hypot}\left(b, \sqrt{c \cdot \left(-4 \cdot a\right)}\right)}}\right)}^{2}}{a \cdot 2} \]
    11. associate-*r*49.1%

      \[\leadsto \frac{\left(-b\right) + {\left(\sqrt{\mathsf{hypot}\left(b, \sqrt{\color{blue}{\left(c \cdot -4\right) \cdot a}}\right)}\right)}^{2}}{a \cdot 2} \]
    12. *-commutative49.1%

      \[\leadsto \frac{\left(-b\right) + {\left(\sqrt{\mathsf{hypot}\left(b, \sqrt{\color{blue}{a \cdot \left(c \cdot -4\right)}}\right)}\right)}^{2}}{a \cdot 2} \]
  6. Applied egg-rr49.1%

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

    \[\leadsto \color{blue}{-1 \cdot \frac{b}{a}} \]
  8. Step-by-step derivation
    1. associate-*r/33.4%

      \[\leadsto \color{blue}{\frac{-1 \cdot b}{a}} \]
    2. mul-1-neg33.4%

      \[\leadsto \frac{\color{blue}{-b}}{a} \]
  9. Simplified33.4%

    \[\leadsto \color{blue}{\frac{-b}{a}} \]
  10. Final simplification33.4%

    \[\leadsto -\frac{b}{a} \]
  11. Add Preprocessing

Developer target: 99.7% accurate, 0.1× speedup?

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

\\
\begin{array}{l}
t_0 := \left|\frac{b}{2}\right|\\
t_1 := \sqrt{\left|a\right|} \cdot \sqrt{\left|c\right|}\\
t_2 := \begin{array}{l}
\mathbf{if}\;\mathsf{copysign}\left(a, c\right) = a:\\
\;\;\;\;\sqrt{t\_0 - t\_1} \cdot \sqrt{t\_0 + t\_1}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{hypot}\left(\frac{b}{2}, t\_1\right)\\


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

\mathbf{else}:\\
\;\;\;\;\frac{-c}{\frac{b}{2} + t\_2}\\


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2024111 
(FPCore (a b c)
  :name "quadp (p42, positive)"
  :precision binary64
  :herbie-expected 10

  :alt
  (if (< b 0.0) (/ (- (if (== (copysign a c) a) (* (sqrt (- (fabs (/ b 2.0)) (* (sqrt (fabs a)) (sqrt (fabs c))))) (sqrt (+ (fabs (/ b 2.0)) (* (sqrt (fabs a)) (sqrt (fabs c)))))) (hypot (/ b 2.0) (* (sqrt (fabs a)) (sqrt (fabs c))))) (/ b 2.0)) a) (/ (- c) (+ (/ b 2.0) (if (== (copysign a c) a) (* (sqrt (- (fabs (/ b 2.0)) (* (sqrt (fabs a)) (sqrt (fabs c))))) (sqrt (+ (fabs (/ b 2.0)) (* (sqrt (fabs a)) (sqrt (fabs c)))))) (hypot (/ b 2.0) (* (sqrt (fabs a)) (sqrt (fabs c))))))))

  (/ (+ (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))