The quadratic formula (r2)

Percentage Accurate: 51.4% → 86.0%
Time: 12.8s
Alternatives: 7
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 7 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.4% 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: 86.0% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.5 \cdot 10^{-71}:\\
\;\;\;\;\frac{c}{-b}\\

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

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


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

    1. Initial program 14.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. div-sub13.7%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-0.5}}{a} \cdot \left(b + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right) \]
      13. sub-neg14.1%

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

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

      \[\leadsto \color{blue}{\frac{-0.5}{a} \cdot \left(b + \sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in b around -inf 83.4%

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}} \]
    6. Step-by-step derivation
      1. mul-1-neg83.4%

        \[\leadsto \color{blue}{-\frac{c}{b}} \]
      2. distribute-neg-frac283.4%

        \[\leadsto \color{blue}{\frac{c}{-b}} \]
    7. Simplified83.4%

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

    if -4.5000000000000002e-71 < b < 2.99999999999999996e84

    1. Initial program 84.6%

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

    if 2.99999999999999996e84 < b

    1. Initial program 61.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. div-sub61.6%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-0.5}}{a} \cdot \left(b + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right) \]
      13. sub-neg61.6%

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

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

      \[\leadsto \color{blue}{\frac{-0.5}{a} \cdot \left(b + \sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in a around 0 92.2%

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

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

        \[\leadsto \frac{\color{blue}{-b}}{a} \]
    7. Simplified92.2%

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

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

Alternative 2: 80.1% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.15 \cdot 10^{-65}:\\
\;\;\;\;\frac{c}{-b}\\

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

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


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

    1. Initial program 14.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. div-sub13.7%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-0.5}}{a} \cdot \left(b + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right) \]
      13. sub-neg14.1%

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

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

      \[\leadsto \color{blue}{\frac{-0.5}{a} \cdot \left(b + \sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in b around -inf 83.4%

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}} \]
    6. Step-by-step derivation
      1. mul-1-neg83.4%

        \[\leadsto \color{blue}{-\frac{c}{b}} \]
      2. distribute-neg-frac283.4%

        \[\leadsto \color{blue}{\frac{c}{-b}} \]
    7. Simplified83.4%

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

    if -1.15e-65 < b < 2.19999999999999997e-13

    1. Initial program 81.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. *-commutative81.2%

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

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

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

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

        \[\leadsto \frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \color{blue}{\left(c \cdot a\right)}}}{2 \cdot a} \]
      6. associate-*r*81.2%

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

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

      \[\leadsto \color{blue}{\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot c\right) \cdot a}}{a \cdot 2}} \]
    4. Add Preprocessing
    5. Taylor expanded in b around 0 74.3%

      \[\leadsto \frac{\left(-b\right) - \sqrt{\color{blue}{-4 \cdot \left(a \cdot c\right)}}}{a \cdot 2} \]
    6. Step-by-step derivation
      1. *-commutative74.3%

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

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

    if 2.19999999999999997e-13 < b

    1. Initial program 69.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. div-sub69.0%

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

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

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

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

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

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

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

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

        \[\leadsto b \cdot \frac{-1}{2 \cdot a} + \color{blue}{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} \cdot \frac{-1}{2 \cdot a}} \]
      10. distribute-rgt-out68.8%

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

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

        \[\leadsto \frac{\color{blue}{-0.5}}{a} \cdot \left(b + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right) \]
      13. sub-neg68.8%

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

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

      \[\leadsto \color{blue}{\frac{-0.5}{a} \cdot \left(b + \sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in a around 0 90.6%

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

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

        \[\leadsto \frac{\color{blue}{-b}}{a} \]
    7. Simplified90.6%

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

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

Alternative 3: 80.5% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.75 \cdot 10^{-68}:\\
\;\;\;\;\frac{c}{-b}\\

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

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


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

    1. Initial program 14.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. div-sub13.7%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-0.5}}{a} \cdot \left(b + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right) \]
      13. sub-neg14.1%

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

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

      \[\leadsto \color{blue}{\frac{-0.5}{a} \cdot \left(b + \sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in b around -inf 83.4%

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}} \]
    6. Step-by-step derivation
      1. mul-1-neg83.4%

        \[\leadsto \color{blue}{-\frac{c}{b}} \]
      2. distribute-neg-frac283.4%

        \[\leadsto \color{blue}{\frac{c}{-b}} \]
    7. Simplified83.4%

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

    if -1.75000000000000006e-68 < b < 3.39999999999999973e-55

    1. Initial program 81.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. *-commutative81.3%

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

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

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

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

        \[\leadsto \frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \color{blue}{\left(c \cdot a\right)}}}{2 \cdot a} \]
      6. associate-*r*81.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.39999999999999973e-55 < b

    1. Initial program 69.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. div-sub69.6%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-0.5}}{a} \cdot \left(b + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right) \]
      13. sub-neg69.4%

        \[\leadsto \frac{-0.5}{a} \cdot \left(b + \sqrt{\color{blue}{b \cdot b + \left(-4 \cdot \left(a \cdot c\right)\right)}}\right) \]
      14. +-commutative69.4%

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

      \[\leadsto \color{blue}{\frac{-0.5}{a} \cdot \left(b + \sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in a around 0 88.1%

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

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

        \[\leadsto \frac{\color{blue}{-b}}{a} \]
    7. Simplified88.1%

      \[\leadsto \color{blue}{\frac{-b}{a}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification82.7%

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

Alternative 4: 71.9% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.8 \cdot 10^{-82}:\\
\;\;\;\;\frac{c}{-b}\\

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

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


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

    1. Initial program 15.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. div-sub14.7%

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

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

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

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

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

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

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

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

        \[\leadsto b \cdot \frac{-1}{2 \cdot a} + \color{blue}{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} \cdot \frac{-1}{2 \cdot a}} \]
      10. distribute-rgt-out15.0%

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

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

        \[\leadsto \frac{\color{blue}{-0.5}}{a} \cdot \left(b + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right) \]
      13. sub-neg15.0%

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

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

      \[\leadsto \color{blue}{\frac{-0.5}{a} \cdot \left(b + \sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in b around -inf 82.6%

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}} \]
    6. Step-by-step derivation
      1. mul-1-neg82.6%

        \[\leadsto \color{blue}{-\frac{c}{b}} \]
      2. distribute-neg-frac282.6%

        \[\leadsto \color{blue}{\frac{c}{-b}} \]
    7. Simplified82.6%

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

    if -2.80000000000000024e-82 < b < 2.4e-102

    1. Initial program 82.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. *-commutative82.0%

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

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

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

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

        \[\leadsto \frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \color{blue}{\left(c \cdot a\right)}}}{2 \cdot a} \]
      6. associate-*r*82.0%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \left(\sqrt{\frac{c \cdot {\left(\sqrt[3]{-4}\right)}^{3}}{a}} \cdot {\left(\sqrt{-1}\right)}^{2}\right)} \]
    8. 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(\sqrt[3]{-4}\right)}^{3}}{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(\sqrt[3]{-4}\right)}^{3}}{a}}\right) \]
      3. rem-square-sqrt35.4%

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

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

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

        \[\leadsto 0.5 \cdot \left(-\sqrt{c \cdot \frac{\color{blue}{-4}}{a}}\right) \]
    9. Simplified35.6%

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

    if 2.4e-102 < b

    1. Initial program 69.7%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-0.5}}{a} \cdot \left(b + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right) \]
      13. sub-neg69.6%

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

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

      \[\leadsto \color{blue}{\frac{-0.5}{a} \cdot \left(b + \sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in c around 0 83.3%

      \[\leadsto \color{blue}{-1 \cdot \frac{b}{a} + \frac{c}{b}} \]
    6. Step-by-step derivation
      1. +-commutative83.3%

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

        \[\leadsto \frac{c}{b} + \color{blue}{\left(-\frac{b}{a}\right)} \]
      3. unsub-neg83.3%

        \[\leadsto \color{blue}{\frac{c}{b} - \frac{b}{a}} \]
    7. Simplified83.3%

      \[\leadsto \color{blue}{\frac{c}{b} - \frac{b}{a}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 5: 68.1% accurate, 12.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.4 \cdot 10^{-249}:\\
\;\;\;\;\frac{c}{-b}\\

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


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

    1. Initial program 26.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. div-sub26.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{-0.5}{a} \cdot \left(b + \sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in b around -inf 68.6%

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}} \]
    6. Step-by-step derivation
      1. mul-1-neg68.6%

        \[\leadsto \color{blue}{-\frac{c}{b}} \]
      2. distribute-neg-frac268.6%

        \[\leadsto \color{blue}{\frac{c}{-b}} \]
    7. Simplified68.6%

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

    if -3.3999999999999998e-249 < b

    1. Initial program 75.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. div-sub75.2%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-0.5}}{a} \cdot \left(b + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right) \]
      13. sub-neg75.1%

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

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

      \[\leadsto \color{blue}{\frac{-0.5}{a} \cdot \left(b + \sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in a around 0 62.9%

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

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

        \[\leadsto \frac{\color{blue}{-b}}{a} \]
    7. Simplified62.9%

      \[\leadsto \color{blue}{\frac{-b}{a}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 6: 36.0% accurate, 29.0× speedup?

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

\\
\frac{c}{-b}
\end{array}
Derivation
  1. Initial program 53.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. div-sub53.5%

      \[\leadsto \color{blue}{\frac{-b}{2 \cdot a} - \frac{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}} \]
    2. sub-neg53.5%

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

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

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

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

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

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

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

      \[\leadsto b \cdot \frac{-1}{2 \cdot a} + \color{blue}{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} \cdot \frac{-1}{2 \cdot a}} \]
    10. distribute-rgt-out53.5%

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

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

      \[\leadsto \frac{\color{blue}{-0.5}}{a} \cdot \left(b + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right) \]
    13. sub-neg53.5%

      \[\leadsto \frac{-0.5}{a} \cdot \left(b + \sqrt{\color{blue}{b \cdot b + \left(-4 \cdot \left(a \cdot c\right)\right)}}\right) \]
    14. +-commutative53.5%

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

    \[\leadsto \color{blue}{\frac{-0.5}{a} \cdot \left(b + \sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in b around -inf 31.4%

    \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}} \]
  6. Step-by-step derivation
    1. mul-1-neg31.4%

      \[\leadsto \color{blue}{-\frac{c}{b}} \]
    2. distribute-neg-frac231.4%

      \[\leadsto \color{blue}{\frac{c}{-b}} \]
  7. Simplified31.4%

    \[\leadsto \color{blue}{\frac{c}{-b}} \]
  8. Add Preprocessing

Alternative 7: 11.3% accurate, 116.0× speedup?

\[\begin{array}{l} \\ 0 \end{array} \]
(FPCore (a b c) :precision binary64 0.0)
double code(double a, double b, double c) {
	return 0.0;
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    code = 0.0d0
end function
public static double code(double a, double b, double c) {
	return 0.0;
}
def code(a, b, c):
	return 0.0
function code(a, b, c)
	return 0.0
end
function tmp = code(a, b, c)
	tmp = 0.0;
end
code[a_, b_, c_] := 0.0
\begin{array}{l}

\\
0
\end{array}
Derivation
  1. Initial program 53.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. div-sub53.5%

      \[\leadsto \color{blue}{\frac{-b}{2 \cdot a} - \frac{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}} \]
    2. sub-neg53.5%

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

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

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

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

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

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

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

      \[\leadsto b \cdot \frac{-1}{2 \cdot a} + \color{blue}{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} \cdot \frac{-1}{2 \cdot a}} \]
    10. distribute-rgt-out53.5%

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

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

      \[\leadsto \frac{\color{blue}{-0.5}}{a} \cdot \left(b + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right) \]
    13. sub-neg53.5%

      \[\leadsto \frac{-0.5}{a} \cdot \left(b + \sqrt{\color{blue}{b \cdot b + \left(-4 \cdot \left(a \cdot c\right)\right)}}\right) \]
    14. +-commutative53.5%

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

    \[\leadsto \color{blue}{\frac{-0.5}{a} \cdot \left(b + \sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in b around -inf 10.2%

    \[\leadsto \frac{-0.5}{a} \cdot \left(b + \color{blue}{-1 \cdot b}\right) \]
  6. Step-by-step derivation
    1. mul-1-neg10.2%

      \[\leadsto \frac{-0.5}{a} \cdot \left(b + \color{blue}{\left(-b\right)}\right) \]
  7. Simplified10.2%

    \[\leadsto \frac{-0.5}{a} \cdot \left(b + \color{blue}{\left(-b\right)}\right) \]
  8. Taylor expanded in a around 0 10.2%

    \[\leadsto \color{blue}{0} \]
  9. Add Preprocessing

Developer Target 1: 70.7% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\\ \mathbf{if}\;b < 0:\\ \;\;\;\;\frac{c}{a \cdot \frac{\left(-b\right) + t\_0}{2 \cdot a}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) - t\_0}{2 \cdot a}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (sqrt (- (* b b) (* 4.0 (* a c))))))
   (if (< b 0.0)
     (/ c (* a (/ (+ (- b) t_0) (* 2.0 a))))
     (/ (- (- b) t_0) (* 2.0 a)))))
double code(double a, double b, double c) {
	double t_0 = sqrt(((b * b) - (4.0 * (a * c))));
	double tmp;
	if (b < 0.0) {
		tmp = c / (a * ((-b + t_0) / (2.0 * a)));
	} else {
		tmp = (-b - t_0) / (2.0 * a);
	}
	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) :: t_0
    real(8) :: tmp
    t_0 = sqrt(((b * b) - (4.0d0 * (a * c))))
    if (b < 0.0d0) then
        tmp = c / (a * ((-b + t_0) / (2.0d0 * a)))
    else
        tmp = (-b - t_0) / (2.0d0 * a)
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	double t_0 = Math.sqrt(((b * b) - (4.0 * (a * c))));
	double tmp;
	if (b < 0.0) {
		tmp = c / (a * ((-b + t_0) / (2.0 * a)));
	} else {
		tmp = (-b - t_0) / (2.0 * a);
	}
	return tmp;
}
def code(a, b, c):
	t_0 = math.sqrt(((b * b) - (4.0 * (a * c))))
	tmp = 0
	if b < 0.0:
		tmp = c / (a * ((-b + t_0) / (2.0 * a)))
	else:
		tmp = (-b - t_0) / (2.0 * a)
	return tmp
function code(a, b, c)
	t_0 = sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(a * c))))
	tmp = 0.0
	if (b < 0.0)
		tmp = Float64(c / Float64(a * Float64(Float64(Float64(-b) + t_0) / Float64(2.0 * a))));
	else
		tmp = Float64(Float64(Float64(-b) - t_0) / Float64(2.0 * a));
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	t_0 = sqrt(((b * b) - (4.0 * (a * c))));
	tmp = 0.0;
	if (b < 0.0)
		tmp = c / (a * ((-b + t_0) / (2.0 * a)));
	else
		tmp = (-b - t_0) / (2.0 * a);
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Less[b, 0.0], N[(c / N[(a * N[(N[((-b) + t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\\
\mathbf{if}\;b < 0:\\
\;\;\;\;\frac{c}{a \cdot \frac{\left(-b\right) + t\_0}{2 \cdot a}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) - t\_0}{2 \cdot a}\\


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2024163 
(FPCore (a b c)
  :name "The quadratic formula (r2)"
  :precision binary64

  :alt
  (! :herbie-platform default (let ((d (sqrt (- (* b b) (* 4 (* a c)))))) (let ((r1 (/ (+ (- b) d) (* 2 a)))) (let ((r2 (/ (- (- b) d) (* 2 a)))) (if (< b 0) (/ c (* a r1)) r2)))))

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