quadp (p42, positive)

Percentage Accurate: 52.2% → 86.2%
Time: 16.9s
Alternatives: 9
Speedup: 19.1×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

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

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

Alternative 1: 86.2% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 45.5%

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

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

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

        \[\leadsto \frac{\color{blue}{-b}}{a} \]
    4. Simplified98.1%

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

    if -3e120 < b < 1.55000000000000008e-53

    1. Initial program 87.5%

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

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

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

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

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

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

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

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

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

    if 1.55000000000000008e-53 < b

    1. Initial program 15.6%

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

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

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

        \[\leadsto \frac{\color{blue}{-c}}{b} \]
    4. Simplified85.0%

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

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

Alternative 2: 86.2% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 45.5%

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

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

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

        \[\leadsto \frac{\color{blue}{-b}}{a} \]
    4. Simplified98.1%

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

    if -4.99999999999999989e122 < b < 3.09999999999999999e-59

    1. Initial program 87.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.09999999999999999e-59 < b

    1. Initial program 15.6%

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

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

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

        \[\leadsto \frac{\color{blue}{-c}}{b} \]
    4. Simplified85.0%

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

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

Alternative 3: 81.1% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 70.4%

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

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

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

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

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

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

    if -5.7999999999999997e-71 < b < 7.0000000000000002e-59

    1. Initial program 81.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 7.0000000000000002e-59 < b

    1. Initial program 15.6%

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

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

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

        \[\leadsto \frac{\color{blue}{-c}}{b} \]
    4. Simplified85.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -5.8 \cdot 10^{-71}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \leq 7 \cdot 10^{-59}:\\ \;\;\;\;\frac{0.5}{a} \cdot \left(b + \sqrt{a \cdot \left(c \cdot -4\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array} \]

Alternative 4: 81.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -1.14 \cdot 10^{-69}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \leq 1.6 \cdot 10^{-58}:\\ \;\;\;\;\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 -1.14e-69)
   (- (/ c b) (/ b a))
   (if (<= b 1.6e-58)
     (/ (+ b (sqrt (* c (* a -4.0)))) (* a 2.0))
     (/ (- c) b))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -1.14e-69) {
		tmp = (c / b) - (b / a);
	} else if (b <= 1.6e-58) {
		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 <= (-1.14d-69)) then
        tmp = (c / b) - (b / a)
    else if (b <= 1.6d-58) 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 <= -1.14e-69) {
		tmp = (c / b) - (b / a);
	} else if (b <= 1.6e-58) {
		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 <= -1.14e-69:
		tmp = (c / b) - (b / a)
	elif b <= 1.6e-58:
		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 <= -1.14e-69)
		tmp = Float64(Float64(c / b) - Float64(b / a));
	elseif (b <= 1.6e-58)
		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 <= -1.14e-69)
		tmp = (c / b) - (b / a);
	elseif (b <= 1.6e-58)
		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, -1.14e-69], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.6e-58], 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 -1.14 \cdot 10^{-69}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\

\mathbf{elif}\;b \leq 1.6 \cdot 10^{-58}:\\
\;\;\;\;\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 < -1.14000000000000006e-69

    1. Initial program 70.4%

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

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

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

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

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

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

    if -1.14000000000000006e-69 < b < 1.6e-58

    1. Initial program 81.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.6e-58 < b

    1. Initial program 15.6%

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

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

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

        \[\leadsto \frac{\color{blue}{-c}}{b} \]
    4. Simplified85.0%

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

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

Alternative 5: 81.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -4.4 \cdot 10^{-41}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \leq 1.24 \cdot 10^{-54}:\\ \;\;\;\;\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.4e-41)
   (- (/ c b) (/ b a))
   (if (<= b 1.24e-54)
     (/ (- (sqrt (* a (* c -4.0))) b) (* a 2.0))
     (/ (- c) b))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -4.4e-41) {
		tmp = (c / b) - (b / a);
	} else if (b <= 1.24e-54) {
		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.4d-41)) then
        tmp = (c / b) - (b / a)
    else if (b <= 1.24d-54) 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.4e-41) {
		tmp = (c / b) - (b / a);
	} else if (b <= 1.24e-54) {
		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.4e-41:
		tmp = (c / b) - (b / a)
	elif b <= 1.24e-54:
		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.4e-41)
		tmp = Float64(Float64(c / b) - Float64(b / a));
	elseif (b <= 1.24e-54)
		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.4e-41)
		tmp = (c / b) - (b / a);
	elseif (b <= 1.24e-54)
		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.4e-41], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.24e-54], 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.4 \cdot 10^{-41}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\

\mathbf{elif}\;b \leq 1.24 \cdot 10^{-54}:\\
\;\;\;\;\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.4e-41

    1. Initial program 69.2%

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

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

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

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

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

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

    if -4.4e-41 < b < 1.23999999999999999e-54

    1. Initial program 82.4%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a} \]
    2. Taylor expanded in b around 0 77.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. *-commutative77.5%

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

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

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

    if 1.23999999999999999e-54 < b

    1. Initial program 15.6%

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

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

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

        \[\leadsto \frac{\color{blue}{-c}}{b} \]
    4. Simplified85.0%

      \[\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 -4.4 \cdot 10^{-41}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \leq 1.24 \cdot 10^{-54}:\\ \;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -4\right)} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array} \]

Alternative 6: 68.3% accurate, 12.8× speedup?

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

    1. Initial program 73.7%

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

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

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

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

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

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

    if -9.99999999999948e-312 < b

    1. Initial program 33.5%

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

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

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

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

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

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

Alternative 7: 68.2% accurate, 19.1× speedup?

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

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

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


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

    1. Initial program 73.7%

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

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

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

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

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

    if -9.99999999999948e-312 < b

    1. Initial program 33.5%

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

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

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

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

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

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

Alternative 8: 35.6% accurate, 29.0× speedup?

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{-b}{a}} \]
  5. Final simplification35.6%

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

Alternative 9: 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 53.3%

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

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

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

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

Developer target: 70.6% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}

Reproduce

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

  :herbie-target
  (if (< b 0.0) (/ (+ (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)) (/ c (* a (/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))))

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