Quadratic roots, full range

Percentage Accurate: 52.9% → 86.5%
Time: 13.7s
Alternatives: 8
Speedup: 12.9×

Specification

?
\[\begin{array}{l} \\ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{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(Float64(4.0 * 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[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{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 8 alternatives:

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

Initial Program: 52.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{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(Float64(4.0 * 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[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Alternative 1: 86.5% accurate, 0.9× speedup?

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

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

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


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

    1. Initial program 41.9%

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

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

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

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

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

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

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

    if -2.7999999999999998e139 < b < 1.20000000000000001e-50

    1. Initial program 81.0%

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

    if 1.20000000000000001e-50 < b

    1. Initial program 16.1%

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

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

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

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

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

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

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

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

Alternative 2: 77.5% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{a \cdot \left(c \cdot -4\right)}\\ t_1 := \frac{c}{b} - \frac{b}{a}\\ \mathbf{if}\;b \leq -1.18 \cdot 10^{+80}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq -7.2 \cdot 10^{+14}:\\ \;\;\;\;\frac{t_0 - b}{a \cdot 2}\\ \mathbf{elif}\;b \leq -2.1 \cdot 10^{-8}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq 2.8 \cdot 10^{-53}:\\ \;\;\;\;0.5 \cdot \left(\frac{t_0}{a} - \frac{b}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (sqrt (* a (* c -4.0)))) (t_1 (- (/ c b) (/ b a))))
   (if (<= b -1.18e+80)
     t_1
     (if (<= b -7.2e+14)
       (/ (- t_0 b) (* a 2.0))
       (if (<= b -2.1e-8)
         t_1
         (if (<= b 2.8e-53) (* 0.5 (- (/ t_0 a) (/ b a))) (/ (- c) b)))))))
double code(double a, double b, double c) {
	double t_0 = sqrt((a * (c * -4.0)));
	double t_1 = (c / b) - (b / a);
	double tmp;
	if (b <= -1.18e+80) {
		tmp = t_1;
	} else if (b <= -7.2e+14) {
		tmp = (t_0 - b) / (a * 2.0);
	} else if (b <= -2.1e-8) {
		tmp = t_1;
	} else if (b <= 2.8e-53) {
		tmp = 0.5 * ((t_0 / a) - (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) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = sqrt((a * (c * (-4.0d0))))
    t_1 = (c / b) - (b / a)
    if (b <= (-1.18d+80)) then
        tmp = t_1
    else if (b <= (-7.2d+14)) then
        tmp = (t_0 - b) / (a * 2.0d0)
    else if (b <= (-2.1d-8)) then
        tmp = t_1
    else if (b <= 2.8d-53) then
        tmp = 0.5d0 * ((t_0 / a) - (b / a))
    else
        tmp = -c / b
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	double t_0 = Math.sqrt((a * (c * -4.0)));
	double t_1 = (c / b) - (b / a);
	double tmp;
	if (b <= -1.18e+80) {
		tmp = t_1;
	} else if (b <= -7.2e+14) {
		tmp = (t_0 - b) / (a * 2.0);
	} else if (b <= -2.1e-8) {
		tmp = t_1;
	} else if (b <= 2.8e-53) {
		tmp = 0.5 * ((t_0 / a) - (b / a));
	} else {
		tmp = -c / b;
	}
	return tmp;
}
def code(a, b, c):
	t_0 = math.sqrt((a * (c * -4.0)))
	t_1 = (c / b) - (b / a)
	tmp = 0
	if b <= -1.18e+80:
		tmp = t_1
	elif b <= -7.2e+14:
		tmp = (t_0 - b) / (a * 2.0)
	elif b <= -2.1e-8:
		tmp = t_1
	elif b <= 2.8e-53:
		tmp = 0.5 * ((t_0 / a) - (b / a))
	else:
		tmp = -c / b
	return tmp
function code(a, b, c)
	t_0 = sqrt(Float64(a * Float64(c * -4.0)))
	t_1 = Float64(Float64(c / b) - Float64(b / a))
	tmp = 0.0
	if (b <= -1.18e+80)
		tmp = t_1;
	elseif (b <= -7.2e+14)
		tmp = Float64(Float64(t_0 - b) / Float64(a * 2.0));
	elseif (b <= -2.1e-8)
		tmp = t_1;
	elseif (b <= 2.8e-53)
		tmp = Float64(0.5 * Float64(Float64(t_0 / a) - Float64(b / a)));
	else
		tmp = Float64(Float64(-c) / b);
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	t_0 = sqrt((a * (c * -4.0)));
	t_1 = (c / b) - (b / a);
	tmp = 0.0;
	if (b <= -1.18e+80)
		tmp = t_1;
	elseif (b <= -7.2e+14)
		tmp = (t_0 - b) / (a * 2.0);
	elseif (b <= -2.1e-8)
		tmp = t_1;
	elseif (b <= 2.8e-53)
		tmp = 0.5 * ((t_0 / a) - (b / a));
	else
		tmp = -c / b;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -1.18e+80], t$95$1, If[LessEqual[b, -7.2e+14], N[(N[(t$95$0 - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, -2.1e-8], t$95$1, If[LessEqual[b, 2.8e-53], N[(0.5 * N[(N[(t$95$0 / a), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sqrt{a \cdot \left(c \cdot -4\right)}\\
t_1 := \frac{c}{b} - \frac{b}{a}\\
\mathbf{if}\;b \leq -1.18 \cdot 10^{+80}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;b \leq -7.2 \cdot 10^{+14}:\\
\;\;\;\;\frac{t_0 - b}{a \cdot 2}\\

\mathbf{elif}\;b \leq -2.1 \cdot 10^{-8}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;b \leq 2.8 \cdot 10^{-53}:\\
\;\;\;\;0.5 \cdot \left(\frac{t_0}{a} - \frac{b}{a}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if b < -1.18e80 or -7.2e14 < b < -2.09999999999999994e-8

    1. Initial program 60.9%

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

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

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

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

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

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

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

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

    if -1.18e80 < b < -7.2e14

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{\left(\left(a \cdot c\right) \cdot -4 + \color{blue}{\left(a \cdot c\right) \cdot -4}\right) + \left(\left(c \cdot 4\right) \cdot a + {b}^{2}\right)}}{a \cdot 2} \]
      6. distribute-lft-out99.8%

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

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

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

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

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

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

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\left(a \cdot c\right) \cdot -8 + \mathsf{fma}\left(b, b, c \cdot \left(a \cdot 4\right)\right)}}}{a \cdot 2} \]
    9. Taylor expanded in b around 0 81.0%

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

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

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

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

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

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

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

    if -2.09999999999999994e-8 < b < 2.79999999999999985e-53

    1. Initial program 74.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\left(a \cdot c\right) \cdot -8 + \mathsf{fma}\left(b, b, c \cdot \left(a \cdot 4\right)\right)}}}{a \cdot 2} \]
    9. Step-by-step derivation
      1. associate-*l*74.6%

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

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\mathsf{fma}\left(a, c \cdot -8, \mathsf{fma}\left(b, b, c \cdot \left(a \cdot 4\right)\right)\right)}}}{a \cdot 2} \]
    11. Taylor expanded in b around 0 68.1%

      \[\leadsto \color{blue}{-0.5 \cdot \frac{b}{a} + 0.5 \cdot \left(\frac{1}{a} \cdot \sqrt{-8 \cdot \left(a \cdot c\right) + 4 \cdot \left(a \cdot c\right)}\right)} \]
    12. Step-by-step derivation
      1. +-commutative68.1%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{0.5 \cdot \frac{\sqrt{\left(a \cdot c\right) \cdot -4}}{a} - 0.5 \cdot \frac{b}{a}} \]
      9. distribute-lft-out--68.6%

        \[\leadsto \color{blue}{0.5 \cdot \left(\frac{\sqrt{\left(a \cdot c\right) \cdot -4}}{a} - \frac{b}{a}\right)} \]
      10. associate-*l*68.6%

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

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

    if 2.79999999999999985e-53 < b

    1. Initial program 16.1%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -1.18 \cdot 10^{+80}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \leq -7.2 \cdot 10^{+14}:\\ \;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -4\right)} - b}{a \cdot 2}\\ \mathbf{elif}\;b \leq -2.1 \cdot 10^{-8}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \leq 2.8 \cdot 10^{-53}:\\ \;\;\;\;0.5 \cdot \left(\frac{\sqrt{a \cdot \left(c \cdot -4\right)}}{a} - \frac{b}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 77.4% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{c}{b} - \frac{b}{a}\\
t_1 := \frac{\sqrt{a \cdot \left(c \cdot -4\right)} - b}{a \cdot 2}\\
\mathbf{if}\;b \leq -1.18 \cdot 10^{+80}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;b \leq -7.2 \cdot 10^{+14}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;b \leq -2.1 \cdot 10^{-8}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;b \leq 1.9 \cdot 10^{-50}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b < -1.18e80 or -7.2e14 < b < -2.09999999999999994e-8

    1. Initial program 60.9%

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

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

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

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

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

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

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

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

    if -1.18e80 < b < -7.2e14 or -2.09999999999999994e-8 < b < 1.9e-50

    1. Initial program 78.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\left(a \cdot c\right) \cdot -8 + \mathsf{fma}\left(b, b, c \cdot \left(a \cdot 4\right)\right)}}}{a \cdot 2} \]
    9. Taylor expanded in b around 0 70.0%

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

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

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

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

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

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

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

    if 1.9e-50 < b

    1. Initial program 16.1%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -1.18 \cdot 10^{+80}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \leq -7.2 \cdot 10^{+14}:\\ \;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -4\right)} - b}{a \cdot 2}\\ \mathbf{elif}\;b \leq -2.1 \cdot 10^{-8}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \leq 1.9 \cdot 10^{-50}:\\ \;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -4\right)} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 79.0% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c}{b} - \frac{b}{a}\\ t_1 := 0.5 \cdot \frac{\sqrt{a \cdot \left(c \cdot -4\right)}}{a}\\ \mathbf{if}\;b \leq -8.6 \cdot 10^{+38}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;b \leq -7.2 \cdot 10^{+14}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq -5.5 \cdot 10^{-7}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;b \leq 8.4 \cdot 10^{-53}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (- (/ c b) (/ b a))) (t_1 (* 0.5 (/ (sqrt (* a (* c -4.0))) a))))
   (if (<= b -8.6e+38)
     t_0
     (if (<= b -7.2e+14)
       t_1
       (if (<= b -5.5e-7) t_0 (if (<= b 8.4e-53) t_1 (/ (- c) b)))))))
double code(double a, double b, double c) {
	double t_0 = (c / b) - (b / a);
	double t_1 = 0.5 * (sqrt((a * (c * -4.0))) / a);
	double tmp;
	if (b <= -8.6e+38) {
		tmp = t_0;
	} else if (b <= -7.2e+14) {
		tmp = t_1;
	} else if (b <= -5.5e-7) {
		tmp = t_0;
	} else if (b <= 8.4e-53) {
		tmp = t_1;
	} 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) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (c / b) - (b / a)
    t_1 = 0.5d0 * (sqrt((a * (c * (-4.0d0)))) / a)
    if (b <= (-8.6d+38)) then
        tmp = t_0
    else if (b <= (-7.2d+14)) then
        tmp = t_1
    else if (b <= (-5.5d-7)) then
        tmp = t_0
    else if (b <= 8.4d-53) then
        tmp = t_1
    else
        tmp = -c / b
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	double t_0 = (c / b) - (b / a);
	double t_1 = 0.5 * (Math.sqrt((a * (c * -4.0))) / a);
	double tmp;
	if (b <= -8.6e+38) {
		tmp = t_0;
	} else if (b <= -7.2e+14) {
		tmp = t_1;
	} else if (b <= -5.5e-7) {
		tmp = t_0;
	} else if (b <= 8.4e-53) {
		tmp = t_1;
	} else {
		tmp = -c / b;
	}
	return tmp;
}
def code(a, b, c):
	t_0 = (c / b) - (b / a)
	t_1 = 0.5 * (math.sqrt((a * (c * -4.0))) / a)
	tmp = 0
	if b <= -8.6e+38:
		tmp = t_0
	elif b <= -7.2e+14:
		tmp = t_1
	elif b <= -5.5e-7:
		tmp = t_0
	elif b <= 8.4e-53:
		tmp = t_1
	else:
		tmp = -c / b
	return tmp
function code(a, b, c)
	t_0 = Float64(Float64(c / b) - Float64(b / a))
	t_1 = Float64(0.5 * Float64(sqrt(Float64(a * Float64(c * -4.0))) / a))
	tmp = 0.0
	if (b <= -8.6e+38)
		tmp = t_0;
	elseif (b <= -7.2e+14)
		tmp = t_1;
	elseif (b <= -5.5e-7)
		tmp = t_0;
	elseif (b <= 8.4e-53)
		tmp = t_1;
	else
		tmp = Float64(Float64(-c) / b);
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	t_0 = (c / b) - (b / a);
	t_1 = 0.5 * (sqrt((a * (c * -4.0))) / a);
	tmp = 0.0;
	if (b <= -8.6e+38)
		tmp = t_0;
	elseif (b <= -7.2e+14)
		tmp = t_1;
	elseif (b <= -5.5e-7)
		tmp = t_0;
	elseif (b <= 8.4e-53)
		tmp = t_1;
	else
		tmp = -c / b;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 * N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -8.6e+38], t$95$0, If[LessEqual[b, -7.2e+14], t$95$1, If[LessEqual[b, -5.5e-7], t$95$0, If[LessEqual[b, 8.4e-53], t$95$1, N[((-c) / b), $MachinePrecision]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{c}{b} - \frac{b}{a}\\
t_1 := 0.5 \cdot \frac{\sqrt{a \cdot \left(c \cdot -4\right)}}{a}\\
\mathbf{if}\;b \leq -8.6 \cdot 10^{+38}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;b \leq -7.2 \cdot 10^{+14}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;b \leq -5.5 \cdot 10^{-7}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;b \leq 8.4 \cdot 10^{-53}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b < -8.5999999999999994e38 or -7.2e14 < b < -5.5000000000000003e-7

    1. Initial program 64.1%

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

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

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

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

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

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

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

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

    if -8.5999999999999994e38 < b < -7.2e14 or -5.5000000000000003e-7 < b < 8.3999999999999991e-53

    1. Initial program 77.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\left(a \cdot c\right) \cdot -8 + \mathsf{fma}\left(b, b, c \cdot \left(a \cdot 4\right)\right)}}}{a \cdot 2} \]
    9. Taylor expanded in b around 0 68.1%

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\sqrt{\left(a \cdot c\right) \cdot \color{blue}{-4}}}{a} \]
      5. associate-*r*68.6%

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

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

    if 8.3999999999999991e-53 < b

    1. Initial program 16.1%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -8.6 \cdot 10^{+38}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \leq -7.2 \cdot 10^{+14}:\\ \;\;\;\;0.5 \cdot \frac{\sqrt{a \cdot \left(c \cdot -4\right)}}{a}\\ \mathbf{elif}\;b \leq -5.5 \cdot 10^{-7}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \leq 8.4 \cdot 10^{-53}:\\ \;\;\;\;0.5 \cdot \frac{\sqrt{a \cdot \left(c \cdot -4\right)}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 68.6% accurate, 9.7× speedup?

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

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

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


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

    1. Initial program 74.5%

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < b

    1. Initial program 33.6%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-c}{b}} \]
    7. Simplified63.2%

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

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

Alternative 6: 45.1% accurate, 12.9× speedup?

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

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

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


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

    1. Initial program 74.5%

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < b

    1. Initial program 33.6%

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

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

      \[\leadsto \color{blue}{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a \cdot 2}} \]
    4. Add Preprocessing
    5. Applied egg-rr31.8%

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{\mathsf{fma}\left(a, c \cdot -4, {b}^{2}\right)}, \frac{0.5}{a}, \frac{-\frac{b}{2}}{a}\right)} \]
    8. Taylor expanded in a around 0 16.1%

      \[\leadsto \color{blue}{\frac{-0.5 \cdot b + 0.5 \cdot b}{a}} \]
    9. Step-by-step derivation
      1. distribute-rgt-out16.1%

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

        \[\leadsto \frac{b \cdot \color{blue}{0}}{a} \]
      3. associate-*l/14.3%

        \[\leadsto \color{blue}{\frac{b}{a} \cdot 0} \]
      4. mul0-rgt16.1%

        \[\leadsto \color{blue}{0} \]
    10. Simplified16.1%

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

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

Alternative 7: 68.4% accurate, 12.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq 7 \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 < 6.99999999999999963e-290

    1. Initial program 74.3%

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-b}}{a} \]
    7. Simplified60.5%

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

    if 6.99999999999999963e-290 < b

    1. Initial program 32.9%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-c}{b}} \]
    7. Simplified64.5%

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

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

Alternative 8: 11.1% 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 51.2%

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

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

    \[\leadsto \color{blue}{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a \cdot 2}} \]
  4. Add Preprocessing
  5. Applied egg-rr50.1%

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

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

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{\mathsf{fma}\left(a, c \cdot -4, {b}^{2}\right)}, \frac{0.5}{a}, \frac{-\frac{b}{2}}{a}\right)} \]
  8. Taylor expanded in a around 0 10.3%

    \[\leadsto \color{blue}{\frac{-0.5 \cdot b + 0.5 \cdot b}{a}} \]
  9. Step-by-step derivation
    1. distribute-rgt-out10.3%

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

      \[\leadsto \frac{b \cdot \color{blue}{0}}{a} \]
    3. associate-*l/9.2%

      \[\leadsto \color{blue}{\frac{b}{a} \cdot 0} \]
    4. mul0-rgt10.3%

      \[\leadsto \color{blue}{0} \]
  10. Simplified10.3%

    \[\leadsto \color{blue}{0} \]
  11. Final simplification10.3%

    \[\leadsto 0 \]
  12. Add Preprocessing

Reproduce

?
herbie shell --seed 2024019 
(FPCore (a b c)
  :name "Quadratic roots, full range"
  :precision binary64
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))