Quadratic roots, full range

Percentage Accurate: 52.2% → 86.1%
Time: 13.0s
Alternatives: 11
Speedup: 19.1×

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 11 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.2% 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.1% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -2.95 \cdot 10^{+156}:\\ \;\;\;\;\frac{-b}{a}\\ \mathbf{elif}\;b \leq 2.4 \cdot 10^{-103}:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(a, c \cdot -4, {b}^{2}\right)} \cdot \frac{0.5}{a} - \frac{\frac{b}{2}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b -2.95e+156)
   (/ (- b) a)
   (if (<= b 2.4e-103)
     (- (* (sqrt (fma a (* c -4.0) (pow b 2.0))) (/ 0.5 a)) (/ (/ b 2.0) a))
     (/ (- c) b))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -2.95e+156) {
		tmp = -b / a;
	} else if (b <= 2.4e-103) {
		tmp = (sqrt(fma(a, (c * -4.0), pow(b, 2.0))) * (0.5 / a)) - ((b / 2.0) / a);
	} else {
		tmp = -c / b;
	}
	return tmp;
}
function code(a, b, c)
	tmp = 0.0
	if (b <= -2.95e+156)
		tmp = Float64(Float64(-b) / a);
	elseif (b <= 2.4e-103)
		tmp = Float64(Float64(sqrt(fma(a, Float64(c * -4.0), (b ^ 2.0))) * Float64(0.5 / a)) - Float64(Float64(b / 2.0) / a));
	else
		tmp = Float64(Float64(-c) / b);
	end
	return tmp
end
code[a_, b_, c_] := If[LessEqual[b, -2.95e+156], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 2.4e-103], N[(N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision] + N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision] - N[(N[(b / 2.0), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}

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

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

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


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

    1. Initial program 35.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. *-commutative35.9%

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

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

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

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

        \[\leadsto \frac{\color{blue}{-b}}{a} \]
    6. Simplified100.0%

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

    if -2.9499999999999998e156 < b < 2.4000000000000002e-103

    1. Initial program 84.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. *-commutative84.3%

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

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

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

    if 2.4000000000000002e-103 < b

    1. Initial program 15.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. *-commutative15.5%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -2.95 \cdot 10^{+156}:\\ \;\;\;\;\frac{-b}{a}\\ \mathbf{elif}\;b \leq 2.4 \cdot 10^{-103}:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(a, c \cdot -4, {b}^{2}\right)} \cdot \frac{0.5}{a} - \frac{\frac{b}{2}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array} \]

Alternative 2: 86.2% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -2.95 \cdot 10^{+156}:\\ \;\;\;\;\frac{-b}{a}\\ \mathbf{elif}\;b \leq 7 \cdot 10^{-103}:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b -2.95e+156)
   (/ (- b) a)
   (if (<= b 7e-103)
     (/ (- (sqrt (fma a (* c -4.0) (* b b))) b) (* a 2.0))
     (/ (- c) b))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -2.95e+156) {
		tmp = -b / a;
	} else if (b <= 7e-103) {
		tmp = (sqrt(fma(a, (c * -4.0), (b * b))) - b) / (a * 2.0);
	} else {
		tmp = -c / b;
	}
	return tmp;
}
function code(a, b, c)
	tmp = 0.0
	if (b <= -2.95e+156)
		tmp = Float64(Float64(-b) / a);
	elseif (b <= 7e-103)
		tmp = Float64(Float64(sqrt(fma(a, Float64(c * -4.0), Float64(b * b))) - b) / Float64(a * 2.0));
	else
		tmp = Float64(Float64(-c) / b);
	end
	return tmp
end
code[a_, b_, c_] := If[LessEqual[b, -2.95e+156], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 7e-103], N[(N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision] + N[(b * b), $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.95 \cdot 10^{+156}:\\
\;\;\;\;\frac{-b}{a}\\

\mathbf{elif}\;b \leq 7 \cdot 10^{-103}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)} - b}{a \cdot 2}\\

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


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

    1. Initial program 35.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. *-commutative35.9%

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

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

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

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

        \[\leadsto \frac{\color{blue}{-b}}{a} \]
    6. Simplified100.0%

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

    if -2.9499999999999998e156 < b < 7.00000000000000032e-103

    1. Initial program 84.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. Simplified84.4%

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

      if 7.00000000000000032e-103 < b

      1. Initial program 15.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. *-commutative15.5%

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

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

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

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -2.95 \cdot 10^{+156}:\\ \;\;\;\;\frac{-b}{a}\\ \mathbf{elif}\;b \leq 7 \cdot 10^{-103}:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array} \]

    Alternative 3: 86.2% accurate, 1.0× speedup?

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

      1. Initial program 35.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. *-commutative35.9%

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

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

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

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

          \[\leadsto \frac{\color{blue}{-b}}{a} \]
      6. Simplified100.0%

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

      if -2.9499999999999998e156 < b < 4.5e-103

      1. Initial program 84.3%

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

      if 4.5e-103 < b

      1. Initial program 15.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. *-commutative15.5%

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

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

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

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -2.95 \cdot 10^{+156}:\\ \;\;\;\;\frac{-b}{a}\\ \mathbf{elif}\;b \leq 4.5 \cdot 10^{-103}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array} \]

    Alternative 4: 80.5% accurate, 1.0× speedup?

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

      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. Taylor expanded in b around -inf 95.3%

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

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

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

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

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

      if -4.59999999999999981e-15 < b < 7.99999999999999966e-103

      1. Initial program 79.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\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} \]
      5. Applied egg-rr78.7%

        \[\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} \]
      6. Step-by-step derivation
        1. fma-def78.7%

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

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

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

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

        \[\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)} \]
      9. Step-by-step derivation
        1. associate-*r*66.9%

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

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

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

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

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

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

      if 7.99999999999999966e-103 < b

      1. Initial program 15.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. *-commutative15.5%

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

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

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

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -4.6 \cdot 10^{-15}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \leq 8 \cdot 10^{-103}:\\ \;\;\;\;\sqrt{a \cdot \left(c \cdot -4\right)} \cdot \left(0.5 \cdot \frac{1}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array} \]

    Alternative 5: 81.1% accurate, 1.0× speedup?

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

      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. Taylor expanded in b around -inf 95.3%

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

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

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

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

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

      if -4.59999999999999981e-15 < b < 3.9000000000000002e-103

      1. Initial program 79.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\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} \]
      5. Applied egg-rr78.7%

        \[\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} \]
      6. Step-by-step derivation
        1. fma-def78.7%

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

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

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

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

        \[\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} \]
      9. Step-by-step derivation
        1. mul-1-neg69.2%

          \[\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-neg69.2%

          \[\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-out69.5%

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

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

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

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

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

      if 3.9000000000000002e-103 < b

      1. Initial program 15.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. *-commutative15.5%

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

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

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

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -4.6 \cdot 10^{-15}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \leq 3.9 \cdot 10^{-103}:\\ \;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -4\right)} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array} \]

    Alternative 6: 80.5% accurate, 1.0× speedup?

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

      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. Taylor expanded in b around -inf 95.3%

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

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

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

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

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

      if -4.59999999999999981e-15 < b < 3.5999999999999998e-103

      1. Initial program 79.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\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} \]
      5. Applied egg-rr78.7%

        \[\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} \]
      6. Step-by-step derivation
        1. fma-def78.7%

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

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

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

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

        \[\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)} \]
      9. Step-by-step derivation
        1. associate-*l/66.9%

          \[\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-identity66.9%

          \[\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-out67.2%

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

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

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

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

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

      if 3.5999999999999998e-103 < b

      1. Initial program 15.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. *-commutative15.5%

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

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

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

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -4.6 \cdot 10^{-15}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \leq 3.6 \cdot 10^{-103}:\\ \;\;\;\;0.5 \cdot \frac{\sqrt{a \cdot \left(c \cdot -4\right)}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array} \]

    Alternative 7: 67.4% accurate, 12.8× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -2 \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 -2e-310) (- (/ c b) (/ b a)) (/ (- c) b)))
    double code(double a, double b, double c) {
    	double tmp;
    	if (b <= -2e-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 <= (-2d-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 <= -2e-310) {
    		tmp = (c / b) - (b / a);
    	} else {
    		tmp = -c / b;
    	}
    	return tmp;
    }
    
    def code(a, b, c):
    	tmp = 0
    	if b <= -2e-310:
    		tmp = (c / b) - (b / a)
    	else:
    		tmp = -c / b
    	return tmp
    
    function code(a, b, c)
    	tmp = 0.0
    	if (b <= -2e-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 <= -2e-310)
    		tmp = (c / b) - (b / a);
    	else
    		tmp = -c / b;
    	end
    	tmp_2 = tmp;
    end
    
    code[a_, b_, c_] := If[LessEqual[b, -2e-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 -2 \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 < -1.999999999999994e-310

      1. Initial program 70.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. *-commutative70.1%

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

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

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

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

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

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

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

      if -1.999999999999994e-310 < b

      1. Initial program 27.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. *-commutative27.5%

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

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

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

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

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

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

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

    Alternative 8: 41.7% accurate, 19.1× speedup?

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

      1. Initial program 67.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. *-commutative67.3%

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

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

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

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

          \[\leadsto \frac{\color{blue}{-b}}{a} \]
      6. Simplified55.4%

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

      if 1e-13 < b

      1. Initial program 12.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. *-commutative12.5%

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

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 10^{-13}:\\ \;\;\;\;\frac{-b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b}\\ \end{array} \]

    Alternative 9: 67.2% accurate, 19.1× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 1.9 \cdot 10^{-279}:\\ \;\;\;\;\frac{-b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array} \end{array} \]
    (FPCore (a b c)
     :precision binary64
     (if (<= b 1.9e-279) (/ (- b) a) (/ (- c) b)))
    double code(double a, double b, double c) {
    	double tmp;
    	if (b <= 1.9e-279) {
    		tmp = -b / a;
    	} else {
    		tmp = -c / b;
    	}
    	return tmp;
    }
    
    real(8) function code(a, b, c)
        real(8), intent (in) :: a
        real(8), intent (in) :: b
        real(8), intent (in) :: c
        real(8) :: tmp
        if (b <= 1.9d-279) then
            tmp = -b / a
        else
            tmp = -c / b
        end if
        code = tmp
    end function
    
    public static double code(double a, double b, double c) {
    	double tmp;
    	if (b <= 1.9e-279) {
    		tmp = -b / a;
    	} else {
    		tmp = -c / b;
    	}
    	return tmp;
    }
    
    def code(a, b, c):
    	tmp = 0
    	if b <= 1.9e-279:
    		tmp = -b / a
    	else:
    		tmp = -c / b
    	return tmp
    
    function code(a, b, c)
    	tmp = 0.0
    	if (b <= 1.9e-279)
    		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 <= 1.9e-279)
    		tmp = -b / a;
    	else
    		tmp = -c / b;
    	end
    	tmp_2 = tmp;
    end
    
    code[a_, b_, c_] := If[LessEqual[b, 1.9e-279], N[((-b) / a), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;b \leq 1.9 \cdot 10^{-279}:\\
    \;\;\;\;\frac{-b}{a}\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{-c}{b}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if b < 1.90000000000000016e-279

      1. Initial program 70.0%

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

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

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

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

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

          \[\leadsto \frac{\color{blue}{-b}}{a} \]
      6. Simplified71.3%

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

      if 1.90000000000000016e-279 < b

      1. Initial program 26.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. *-commutative26.6%

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

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

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

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

          \[\leadsto \color{blue}{\frac{-c}{b}} \]
      6. Simplified75.1%

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 1.9 \cdot 10^{-279}:\\ \;\;\;\;\frac{-b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array} \]

    Alternative 10: 2.5% accurate, 38.7× speedup?

    \[\begin{array}{l} \\ \frac{b}{a} \end{array} \]
    (FPCore (a b c) :precision binary64 (/ b a))
    double code(double a, double b, double c) {
    	return b / a;
    }
    
    real(8) function code(a, b, c)
        real(8), intent (in) :: a
        real(8), intent (in) :: b
        real(8), intent (in) :: c
        code = b / a
    end function
    
    public static double code(double a, double b, double c) {
    	return b / a;
    }
    
    def code(a, b, c):
    	return b / a
    
    function code(a, b, c)
    	return Float64(b / a)
    end
    
    function tmp = code(a, b, c)
    	tmp = b / a;
    end
    
    code[a_, b_, c_] := N[(b / a), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \frac{b}{a}
    \end{array}
    
    Derivation
    1. Initial program 48.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. *-commutative48.5%

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

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

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

      \[\leadsto \color{blue}{\frac{b}{a}} \]
    6. Final simplification2.3%

      \[\leadsto \frac{b}{a} \]

    Alternative 11: 10.0% accurate, 38.7× 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 / 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 48.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. *-commutative48.5%

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

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

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

      \[\leadsto \color{blue}{\frac{c}{b}} \]
    6. Final simplification12.0%

      \[\leadsto \frac{c}{b} \]

    Reproduce

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