Quadratic roots, full range

Percentage Accurate: 51.8% → 85.4%
Time: 13.2s
Alternatives: 8
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 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: 51.8% 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: 85.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -5 \cdot 10^{+93}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \leq 1.95 \cdot 10^{-57}:\\ \;\;\;\;\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 -5e+93)
   (- (/ c b) (/ b a))
   (if (<= b 1.95e-57)
     (/ (- (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 <= -5e+93) {
		tmp = (c / b) - (b / a);
	} else if (b <= 1.95e-57) {
		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 <= (-5d+93)) then
        tmp = (c / b) - (b / a)
    else if (b <= 1.95d-57) 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 <= -5e+93) {
		tmp = (c / b) - (b / a);
	} else if (b <= 1.95e-57) {
		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 <= -5e+93:
		tmp = (c / b) - (b / a)
	elif b <= 1.95e-57:
		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 <= -5e+93)
		tmp = Float64(Float64(c / b) - Float64(b / a));
	elseif (b <= 1.95e-57)
		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 <= -5e+93)
		tmp = (c / b) - (b / a);
	elseif (b <= 1.95e-57)
		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, -5e+93], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.95e-57], 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 -5 \cdot 10^{+93}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\

\mathbf{elif}\;b \leq 1.95 \cdot 10^{-57}:\\
\;\;\;\;\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 < -5.0000000000000001e93

    1. Initial program 52.9%

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

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

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

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

        \[\leadsto \color{blue}{\frac{c}{b} - \frac{b}{a}} \]
    4. Simplified93.5%

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

    if -5.0000000000000001e93 < b < 1.95000000000000003e-57

    1. Initial program 77.5%

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

    if 1.95000000000000003e-57 < b

    1. Initial program 14.4%

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

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

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

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

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

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

Alternative 2: 80.1% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 67.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-b\right) + \left(\frac{\color{blue}{a \cdot 2}}{\frac{b}{c}} - b\right)}{2 \cdot a} \]
    6. Simplified89.0%

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

    if -4.50000000000000009e-69 < b < 4.89999999999999988e-57

    1. Initial program 70.6%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
    2. Taylor expanded in b around 0 65.5%

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

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

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

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{-b} \cdot \sqrt{-b}} + \sqrt{c \cdot \left(a \cdot -4\right)}}{2 \cdot a}\right)} - 1 \]
      4. sqrt-unprod18.9%

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

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

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

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

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

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

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

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

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

    if 4.89999999999999988e-57 < b

    1. Initial program 14.4%

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

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

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

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

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

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

Alternative 3: 80.5% accurate, 1.0× speedup?

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

\mathbf{elif}\;b \leq 9.2 \cdot 10^{-57}:\\
\;\;\;\;\frac{\sqrt{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 < -4.3e-69

    1. Initial program 67.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-b\right) + \left(\frac{\color{blue}{a \cdot 2}}{\frac{b}{c}} - b\right)}{2 \cdot a} \]
    6. Simplified89.0%

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

    if -4.3e-69 < b < 9.2000000000000001e-57

    1. Initial program 70.6%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
    2. Taylor expanded in b around 0 65.5%

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

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

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

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

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

    if 9.2000000000000001e-57 < b

    1. Initial program 14.4%

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

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

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

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

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

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

Alternative 4: 67.4% accurate, 12.8× speedup?

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

    1. Initial program 68.1%

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

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

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

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

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

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

    if -9.999999999999969e-311 < b

    1. Initial program 30.0%

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

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

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

        \[\leadsto \frac{\color{blue}{-c}}{b} \]
    4. Simplified67.9%

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

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

Alternative 5: 42.9% accurate, 19.1× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 9.5000000000000003e33

    1. Initial program 65.6%

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

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

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

        \[\leadsto \frac{\color{blue}{-b}}{a} \]
    4. Simplified46.0%

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

    if 9.5000000000000003e33 < b

    1. Initial program 9.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. clear-num9.3%

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

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

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

      \[\leadsto {\color{blue}{\left(-4 \cdot \frac{b}{c \cdot {\left(\sqrt{-4}\right)}^{2}}\right)}}^{-1} \]
    5. Step-by-step derivation
      1. associate-*r/0.0%

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

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

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

        \[\leadsto {\left(\frac{{\left(\sqrt{-4}\right)}^{2} \cdot b}{\color{blue}{{\left(\sqrt{-4}\right)}^{2} \cdot c}}\right)}^{-1} \]
      5. times-frac0.0%

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

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

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

        \[\leadsto {\left(\frac{-4}{\color{blue}{\sqrt{-4} \cdot \sqrt{-4}}} \cdot \frac{b}{c}\right)}^{-1} \]
      9. rem-square-sqrt31.6%

        \[\leadsto {\left(\frac{-4}{\color{blue}{-4}} \cdot \frac{b}{c}\right)}^{-1} \]
      10. metadata-eval31.6%

        \[\leadsto {\left(\color{blue}{1} \cdot \frac{b}{c}\right)}^{-1} \]
    6. Simplified31.6%

      \[\leadsto {\color{blue}{\left(1 \cdot \frac{b}{c}\right)}}^{-1} \]
    7. Taylor expanded in b around 0 31.6%

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

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

Alternative 6: 67.1% accurate, 19.1× speedup?

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

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

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


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

    1. Initial program 68.6%

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

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

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

        \[\leadsto \frac{\color{blue}{-b}}{a} \]
    4. Simplified61.8%

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

    if 9.99999999999999984e-262 < b

    1. Initial program 28.0%

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

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

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

        \[\leadsto \frac{\color{blue}{-c}}{b} \]
    4. Simplified70.5%

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

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

Alternative 7: 2.6% 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.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. clear-num48.8%

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

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

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

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

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

Alternative 8: 10.9% 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.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. clear-num48.8%

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

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

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

    \[\leadsto {\color{blue}{\left(-4 \cdot \frac{b}{c \cdot {\left(\sqrt{-4}\right)}^{2}}\right)}}^{-1} \]
  5. Step-by-step derivation
    1. associate-*r/0.0%

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

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

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

      \[\leadsto {\left(\frac{{\left(\sqrt{-4}\right)}^{2} \cdot b}{\color{blue}{{\left(\sqrt{-4}\right)}^{2} \cdot c}}\right)}^{-1} \]
    5. times-frac0.0%

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

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

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

      \[\leadsto {\left(\frac{-4}{\color{blue}{\sqrt{-4} \cdot \sqrt{-4}}} \cdot \frac{b}{c}\right)}^{-1} \]
    9. rem-square-sqrt11.7%

      \[\leadsto {\left(\frac{-4}{\color{blue}{-4}} \cdot \frac{b}{c}\right)}^{-1} \]
    10. metadata-eval11.7%

      \[\leadsto {\left(\color{blue}{1} \cdot \frac{b}{c}\right)}^{-1} \]
  6. Simplified11.7%

    \[\leadsto {\color{blue}{\left(1 \cdot \frac{b}{c}\right)}}^{-1} \]
  7. Taylor expanded in b around 0 11.7%

    \[\leadsto \color{blue}{\frac{c}{b}} \]
  8. Final simplification11.7%

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

Reproduce

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