Quadratic roots, full range

Percentage Accurate: 51.3% → 85.8%
Time: 11.3s
Alternatives: 7
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 7 alternatives:

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

Initial Program: 51.3% 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.8% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 54.2%

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-b}}{a} \]
    6. Simplified96.1%

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

    if -1.76000000000000007e99 < b < 1.5999999999999999e-37

    1. Initial program 76.3%

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

    if 1.5999999999999999e-37 < b

    1. Initial program 12.8%

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

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

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

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

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

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

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

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

Alternative 2: 80.8% accurate, 1.0× speedup?

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

\mathbf{elif}\;b \leq 7.1 \cdot 10^{-37}:\\
\;\;\;\;\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 < -9.99999999999999943e-30

    1. Initial program 62.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. *-commutative62.9%

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

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

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

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

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

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

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

    if -9.99999999999999943e-30 < b < 7.09999999999999978e-37

    1. Initial program 75.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 7.09999999999999978e-37 < b

    1. Initial program 12.8%

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

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

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

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

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

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

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

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

Alternative 3: 80.3% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 62.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. *-commutative62.9%

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

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

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

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

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

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

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

    if -9.79999999999999942e-30 < b < 1.55000000000000006e-35

    1. Initial program 75.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.55000000000000006e-35 < b

    1. Initial program 12.8%

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

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

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

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

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

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

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

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

Alternative 4: 68.4% accurate, 12.8× speedup?

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

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

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


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

    1. Initial program 69.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. *-commutative69.3%

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < b

    1. Initial program 36.6%

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

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

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

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

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

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

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

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

Alternative 5: 43.9% accurate, 19.1× speedup?

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

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

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


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

    1. Initial program 68.6%

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

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

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

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

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

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

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

    if -6.6000000000000001e-301 < b

    1. Initial program 38.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(c \cdot \left(a \cdot -4\right) + \left(\color{blue}{\left(-c \cdot \left(4 \cdot a\right)\right)} + \left(4 \cdot a\right) \cdot c\right)\right)}}{a \cdot 2} \]
      14. distribute-rgt-neg-in37.7%

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{{b}^{2} + \left(c \cdot \left(a \cdot -4\right) + \left(c \cdot \left(-\color{blue}{a \cdot 4}\right) + \left(4 \cdot a\right) \cdot c\right)\right)}}{a \cdot 2} \]
      16. distribute-rgt-neg-in37.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\frac{a \cdot 2}{\mathsf{fma}\left(-1, b, \mathsf{hypot}\left(b, \sqrt{\mathsf{fma}\left(c, -4 \cdot a, c \cdot \left(\color{blue}{-4 \cdot a} + 4 \cdot a\right)\right)}\right)\right)}} \]
      14. distribute-rgt-out41.0%

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

        \[\leadsto \frac{1}{\frac{a \cdot 2}{\mathsf{fma}\left(-1, b, \mathsf{hypot}\left(b, \sqrt{\mathsf{fma}\left(c, -4 \cdot a, c \cdot \left(a \cdot \color{blue}{0}\right)\right)}\right)\right)}} \]
      16. mul0-rgt41.0%

        \[\leadsto \frac{1}{\frac{a \cdot 2}{\mathsf{fma}\left(-1, b, \mathsf{hypot}\left(b, \sqrt{\mathsf{fma}\left(c, -4 \cdot a, c \cdot \color{blue}{0}\right)}\right)\right)}} \]
      17. mul0-rgt41.0%

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

      \[\leadsto \color{blue}{\frac{1}{\frac{a \cdot 2}{\mathsf{fma}\left(-1, b, \mathsf{hypot}\left(b, \sqrt{\mathsf{fma}\left(c, -4 \cdot a, 0\right)}\right)\right)}}} \]
    12. Taylor expanded in a around 0 15.8%

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

        \[\leadsto \color{blue}{\frac{0.5 \cdot \left(b + -1 \cdot b\right)}{a}} \]
      2. distribute-rgt1-in15.8%

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

        \[\leadsto \frac{0.5 \cdot \left(\color{blue}{0} \cdot b\right)}{a} \]
      4. mul0-lft15.8%

        \[\leadsto \frac{0.5 \cdot \color{blue}{0}}{a} \]
      5. metadata-eval15.8%

        \[\leadsto \frac{\color{blue}{0}}{a} \]
    14. Simplified15.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -6.6 \cdot 10^{-301}:\\ \;\;\;\;\frac{-b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{0}{a}\\ \end{array} \]

Alternative 6: 68.2% accurate, 19.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 1.65 \cdot 10^{-292}:\\ \;\;\;\;\frac{-b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b 1.65e-292) (/ (- b) a) (/ (- c) b)))
double code(double a, double b, double c) {
	double tmp;
	if (b <= 1.65e-292) {
		tmp = -b / a;
	} else {
		tmp = -c / b;
	}
	return tmp;
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8) :: tmp
    if (b <= 1.65d-292) then
        tmp = -b / a
    else
        tmp = -c / b
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	double tmp;
	if (b <= 1.65e-292) {
		tmp = -b / a;
	} else {
		tmp = -c / b;
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b <= 1.65e-292:
		tmp = -b / a
	else:
		tmp = -c / b
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b <= 1.65e-292)
		tmp = Float64(Float64(-b) / a);
	else
		tmp = Float64(Float64(-c) / b);
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	tmp = 0.0;
	if (b <= 1.65e-292)
		tmp = -b / a;
	else
		tmp = -c / b;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[LessEqual[b, 1.65e-292], N[((-b) / a), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 69.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. *-commutative69.9%

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

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

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

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

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

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

    if 1.64999999999999997e-292 < b

    1. Initial program 35.7%

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

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

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

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

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

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

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

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

Alternative 7: 10.9% accurate, 38.7× speedup?

\[\begin{array}{l} \\ \frac{0}{a} \end{array} \]
(FPCore (a b c) :precision binary64 (/ 0.0 a))
double code(double a, double b, double c) {
	return 0.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 = 0.0d0 / a
end function
public static double code(double a, double b, double c) {
	return 0.0 / a;
}
def code(a, b, c):
	return 0.0 / a
function code(a, b, c)
	return Float64(0.0 / a)
end
function tmp = code(a, b, c)
	tmp = 0.0 / a;
end
code[a_, b_, c_] := N[(0.0 / a), $MachinePrecision]
\begin{array}{l}

\\
\frac{0}{a}
\end{array}
Derivation
  1. Initial program 51.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\frac{a \cdot 2}{\mathsf{fma}\left(-1, b, \mathsf{hypot}\left(b, \sqrt{\mathsf{fma}\left(c, -4 \cdot a, c \cdot \left(\color{blue}{-4 \cdot a} + 4 \cdot a\right)\right)}\right)\right)}} \]
    14. distribute-rgt-out50.3%

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

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

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

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

    \[\leadsto \color{blue}{\frac{1}{\frac{a \cdot 2}{\mathsf{fma}\left(-1, b, \mathsf{hypot}\left(b, \sqrt{\mathsf{fma}\left(c, -4 \cdot a, 0\right)}\right)\right)}}} \]
  12. Taylor expanded in a around 0 9.9%

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

      \[\leadsto \color{blue}{\frac{0.5 \cdot \left(b + -1 \cdot b\right)}{a}} \]
    2. distribute-rgt1-in9.9%

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

      \[\leadsto \frac{0.5 \cdot \left(\color{blue}{0} \cdot b\right)}{a} \]
    4. mul0-lft9.9%

      \[\leadsto \frac{0.5 \cdot \color{blue}{0}}{a} \]
    5. metadata-eval9.9%

      \[\leadsto \frac{\color{blue}{0}}{a} \]
  14. Simplified9.9%

    \[\leadsto \color{blue}{\frac{0}{a}} \]
  15. Final simplification9.9%

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

Reproduce

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