Quadratic roots, full range

Percentage Accurate: 53.2% → 85.7%
Time: 10.6s
Alternatives: 8
Speedup: 19.1×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 8 alternatives:

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

Initial Program: 53.2% accurate, 1.0× speedup?

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

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

Alternative 1: 85.7% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := b - \sqrt{b \cdot b - a \cdot \left(c \cdot 4\right)}\\ \mathbf{if}\;b \leq -2 \cdot 10^{+146}:\\ \;\;\;\;\frac{-b}{a}\\ \mathbf{elif}\;b \leq 5 \cdot 10^{-121}:\\ \;\;\;\;\frac{t_0 \cdot -0.5}{a}\\ \mathbf{elif}\;b \leq 1.3 \cdot 10^{-17} \lor \neg \left(b \leq 2.2\right):\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot \frac{-0.5}{a}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (- b (sqrt (- (* b b) (* a (* c 4.0)))))))
   (if (<= b -2e+146)
     (/ (- b) a)
     (if (<= b 5e-121)
       (/ (* t_0 -0.5) a)
       (if (or (<= b 1.3e-17) (not (<= b 2.2)))
         (/ (- c) b)
         (* t_0 (/ -0.5 a)))))))
double code(double a, double b, double c) {
	double t_0 = b - sqrt(((b * b) - (a * (c * 4.0))));
	double tmp;
	if (b <= -2e+146) {
		tmp = -b / a;
	} else if (b <= 5e-121) {
		tmp = (t_0 * -0.5) / a;
	} else if ((b <= 1.3e-17) || !(b <= 2.2)) {
		tmp = -c / b;
	} else {
		tmp = t_0 * (-0.5 / 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 = b - sqrt(((b * b) - (a * (c * 4.0d0))))
    if (b <= (-2d+146)) then
        tmp = -b / a
    else if (b <= 5d-121) then
        tmp = (t_0 * (-0.5d0)) / a
    else if ((b <= 1.3d-17) .or. (.not. (b <= 2.2d0))) then
        tmp = -c / b
    else
        tmp = t_0 * ((-0.5d0) / a)
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	double t_0 = b - Math.sqrt(((b * b) - (a * (c * 4.0))));
	double tmp;
	if (b <= -2e+146) {
		tmp = -b / a;
	} else if (b <= 5e-121) {
		tmp = (t_0 * -0.5) / a;
	} else if ((b <= 1.3e-17) || !(b <= 2.2)) {
		tmp = -c / b;
	} else {
		tmp = t_0 * (-0.5 / a);
	}
	return tmp;
}
def code(a, b, c):
	t_0 = b - math.sqrt(((b * b) - (a * (c * 4.0))))
	tmp = 0
	if b <= -2e+146:
		tmp = -b / a
	elif b <= 5e-121:
		tmp = (t_0 * -0.5) / a
	elif (b <= 1.3e-17) or not (b <= 2.2):
		tmp = -c / b
	else:
		tmp = t_0 * (-0.5 / a)
	return tmp
function code(a, b, c)
	t_0 = Float64(b - sqrt(Float64(Float64(b * b) - Float64(a * Float64(c * 4.0)))))
	tmp = 0.0
	if (b <= -2e+146)
		tmp = Float64(Float64(-b) / a);
	elseif (b <= 5e-121)
		tmp = Float64(Float64(t_0 * -0.5) / a);
	elseif ((b <= 1.3e-17) || !(b <= 2.2))
		tmp = Float64(Float64(-c) / b);
	else
		tmp = Float64(t_0 * Float64(-0.5 / a));
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	t_0 = b - sqrt(((b * b) - (a * (c * 4.0))));
	tmp = 0.0;
	if (b <= -2e+146)
		tmp = -b / a;
	elseif (b <= 5e-121)
		tmp = (t_0 * -0.5) / a;
	elseif ((b <= 1.3e-17) || ~((b <= 2.2)))
		tmp = -c / b;
	else
		tmp = t_0 * (-0.5 / a);
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := Block[{t$95$0 = N[(b - N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(a * N[(c * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -2e+146], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 5e-121], N[(N[(t$95$0 * -0.5), $MachinePrecision] / a), $MachinePrecision], If[Or[LessEqual[b, 1.3e-17], N[Not[LessEqual[b, 2.2]], $MachinePrecision]], N[((-c) / b), $MachinePrecision], N[(t$95$0 * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

\mathbf{elif}\;b \leq 5 \cdot 10^{-121}:\\
\;\;\;\;\frac{t_0 \cdot -0.5}{a}\\

\mathbf{elif}\;b \leq 1.3 \cdot 10^{-17} \lor \neg \left(b \leq 2.2\right):\\
\;\;\;\;\frac{-c}{b}\\

\mathbf{else}:\\
\;\;\;\;t_0 \cdot \frac{-0.5}{a}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if b < -1.99999999999999987e146

    1. Initial program 57.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. neg-sub057.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.99999999999999987e146 < b < 4.99999999999999989e-121

    1. Initial program 79.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(b - \sqrt{\left(-\color{blue}{4 \cdot a}\right) \cdot c + b \cdot b}\right) \cdot \frac{-0.5}{a} \]
      7. distribute-lft-neg-in78.8%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\left(b - \sqrt{b \cdot b - a \cdot \left(c \cdot 4\right)}\right) \cdot -0.5}{a}} \]
    9. Applied egg-rr79.0%

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

    if 4.99999999999999989e-121 < b < 1.30000000000000002e-17 or 2.2000000000000002 < b

    1. Initial program 19.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.30000000000000002e-17 < b < 2.2000000000000002

    1. Initial program 83.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(b - \sqrt{\left(-\color{blue}{4 \cdot a}\right) \cdot c + b \cdot b}\right) \cdot \frac{-0.5}{a} \]
      7. distribute-lft-neg-in83.1%

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

        \[\leadsto \left(b - \sqrt{\color{blue}{b \cdot b + \left(-\left(4 \cdot a\right) \cdot c\right)}}\right) \cdot \frac{-0.5}{a} \]
      9. sub-neg83.1%

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

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

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

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

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

      \[\leadsto \left(b - \sqrt{\color{blue}{b \cdot b - a \cdot \left(c \cdot 4\right)}}\right) \cdot \frac{-0.5}{a} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification83.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -2 \cdot 10^{+146}:\\ \;\;\;\;\frac{-b}{a}\\ \mathbf{elif}\;b \leq 5 \cdot 10^{-121}:\\ \;\;\;\;\frac{\left(b - \sqrt{b \cdot b - a \cdot \left(c \cdot 4\right)}\right) \cdot -0.5}{a}\\ \mathbf{elif}\;b \leq 1.3 \cdot 10^{-17} \lor \neg \left(b \leq 2.2\right):\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{else}:\\ \;\;\;\;\left(b - \sqrt{b \cdot b - a \cdot \left(c \cdot 4\right)}\right) \cdot \frac{-0.5}{a}\\ \end{array} \]

Alternative 2: 85.6% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -6.6 \cdot 10^{+145}:\\ \;\;\;\;\frac{-b}{a}\\ \mathbf{elif}\;b \leq 5.6 \cdot 10^{-121} \lor \neg \left(b \leq 2.1 \cdot 10^{-17}\right) \land b \leq 2.2:\\ \;\;\;\;\left(b - \sqrt{b \cdot b - a \cdot \left(c \cdot 4\right)}\right) \cdot \frac{-0.5}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b -6.6e+145)
   (/ (- b) a)
   (if (or (<= b 5.6e-121) (and (not (<= b 2.1e-17)) (<= b 2.2)))
     (* (- b (sqrt (- (* b b) (* a (* c 4.0))))) (/ -0.5 a))
     (/ (- c) b))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -6.6e+145) {
		tmp = -b / a;
	} else if ((b <= 5.6e-121) || (!(b <= 2.1e-17) && (b <= 2.2))) {
		tmp = (b - sqrt(((b * b) - (a * (c * 4.0))))) * (-0.5 / 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 <= (-6.6d+145)) then
        tmp = -b / a
    else if ((b <= 5.6d-121) .or. (.not. (b <= 2.1d-17)) .and. (b <= 2.2d0)) then
        tmp = (b - sqrt(((b * b) - (a * (c * 4.0d0))))) * ((-0.5d0) / 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 <= -6.6e+145) {
		tmp = -b / a;
	} else if ((b <= 5.6e-121) || (!(b <= 2.1e-17) && (b <= 2.2))) {
		tmp = (b - Math.sqrt(((b * b) - (a * (c * 4.0))))) * (-0.5 / a);
	} else {
		tmp = -c / b;
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b <= -6.6e+145:
		tmp = -b / a
	elif (b <= 5.6e-121) or (not (b <= 2.1e-17) and (b <= 2.2)):
		tmp = (b - math.sqrt(((b * b) - (a * (c * 4.0))))) * (-0.5 / a)
	else:
		tmp = -c / b
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b <= -6.6e+145)
		tmp = Float64(Float64(-b) / a);
	elseif ((b <= 5.6e-121) || (!(b <= 2.1e-17) && (b <= 2.2)))
		tmp = Float64(Float64(b - sqrt(Float64(Float64(b * b) - Float64(a * Float64(c * 4.0))))) * Float64(-0.5 / a));
	else
		tmp = Float64(Float64(-c) / b);
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	tmp = 0.0;
	if (b <= -6.6e+145)
		tmp = -b / a;
	elseif ((b <= 5.6e-121) || (~((b <= 2.1e-17)) && (b <= 2.2)))
		tmp = (b - sqrt(((b * b) - (a * (c * 4.0))))) * (-0.5 / a);
	else
		tmp = -c / b;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[LessEqual[b, -6.6e+145], N[((-b) / a), $MachinePrecision], If[Or[LessEqual[b, 5.6e-121], And[N[Not[LessEqual[b, 2.1e-17]], $MachinePrecision], LessEqual[b, 2.2]]], N[(N[(b - N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(a * N[(c * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;b \leq 5.6 \cdot 10^{-121} \lor \neg \left(b \leq 2.1 \cdot 10^{-17}\right) \land b \leq 2.2:\\
\;\;\;\;\left(b - \sqrt{b \cdot b - a \cdot \left(c \cdot 4\right)}\right) \cdot \frac{-0.5}{a}\\

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


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

    1. Initial program 57.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. neg-sub057.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.60000000000000054e145 < b < 5.6000000000000002e-121 or 2.09999999999999992e-17 < b < 2.2000000000000002

    1. Initial program 79.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. neg-sub079.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(b - \sqrt{\left(-\color{blue}{4 \cdot a}\right) \cdot c + b \cdot b}\right) \cdot \frac{-0.5}{a} \]
      7. distribute-lft-neg-in79.0%

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

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

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

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

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

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

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

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

    if 5.6000000000000002e-121 < b < 2.09999999999999992e-17 or 2.2000000000000002 < b

    1. Initial program 19.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -6.6 \cdot 10^{+145}:\\ \;\;\;\;\frac{-b}{a}\\ \mathbf{elif}\;b \leq 5.6 \cdot 10^{-121} \lor \neg \left(b \leq 2.1 \cdot 10^{-17}\right) \land b \leq 2.2:\\ \;\;\;\;\left(b - \sqrt{b \cdot b - a \cdot \left(c \cdot 4\right)}\right) \cdot \frac{-0.5}{a}\\ \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 -1.95 \cdot 10^{-60}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \leq 6 \cdot 10^{-121} \lor \neg \left(b \leq 2.2 \cdot 10^{-17}\right) \land b \leq 2.2:\\ \;\;\;\;\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 -1.95e-60)
   (- (/ c b) (/ b a))
   (if (or (<= b 6e-121) (and (not (<= b 2.2e-17)) (<= b 2.2)))
     (* (/ -0.5 a) (- b (sqrt (* a (* c -4.0)))))
     (/ (- c) b))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -1.95e-60) {
		tmp = (c / b) - (b / a);
	} else if ((b <= 6e-121) || (!(b <= 2.2e-17) && (b <= 2.2))) {
		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 <= (-1.95d-60)) then
        tmp = (c / b) - (b / a)
    else if ((b <= 6d-121) .or. (.not. (b <= 2.2d-17)) .and. (b <= 2.2d0)) 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 <= -1.95e-60) {
		tmp = (c / b) - (b / a);
	} else if ((b <= 6e-121) || (!(b <= 2.2e-17) && (b <= 2.2))) {
		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 <= -1.95e-60:
		tmp = (c / b) - (b / a)
	elif (b <= 6e-121) or (not (b <= 2.2e-17) and (b <= 2.2)):
		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 <= -1.95e-60)
		tmp = Float64(Float64(c / b) - Float64(b / a));
	elseif ((b <= 6e-121) || (!(b <= 2.2e-17) && (b <= 2.2)))
		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 <= -1.95e-60)
		tmp = (c / b) - (b / a);
	elseif ((b <= 6e-121) || (~((b <= 2.2e-17)) && (b <= 2.2)))
		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, -1.95e-60], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[b, 6e-121], And[N[Not[LessEqual[b, 2.2e-17]], $MachinePrecision], LessEqual[b, 2.2]]], 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 -1.95 \cdot 10^{-60}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\

\mathbf{elif}\;b \leq 6 \cdot 10^{-121} \lor \neg \left(b \leq 2.2 \cdot 10^{-17}\right) \land b \leq 2.2:\\
\;\;\;\;\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 < -1.9500000000000001e-60

    1. Initial program 74.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. neg-sub074.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.9500000000000001e-60 < b < 5.9999999999999999e-121 or 2.2e-17 < b < 2.2000000000000002

    1. Initial program 73.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. neg-sub073.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.9999999999999999e-121 < b < 2.2e-17 or 2.2000000000000002 < b

    1. Initial program 19.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -1.95 \cdot 10^{-60}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \leq 6 \cdot 10^{-121} \lor \neg \left(b \leq 2.2 \cdot 10^{-17}\right) \land b \leq 2.2:\\ \;\;\;\;\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 -4.8 \cdot 10^{-66}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \leq 6 \cdot 10^{-121}:\\ \;\;\;\;\frac{-0.5 \cdot \left(b - \sqrt{c \cdot \left(a \cdot -4\right)}\right)}{a}\\ \mathbf{elif}\;b \leq 2.2 \cdot 10^{-17} \lor \neg \left(b \leq 2.2\right):\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{else}:\\ \;\;\;\;\frac{-0.5}{a} \cdot \left(b - \sqrt{a \cdot \left(c \cdot -4\right)}\right)\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b -4.8e-66)
   (- (/ c b) (/ b a))
   (if (<= b 6e-121)
     (/ (* -0.5 (- b (sqrt (* c (* a -4.0))))) a)
     (if (or (<= b 2.2e-17) (not (<= b 2.2)))
       (/ (- c) b)
       (* (/ -0.5 a) (- b (sqrt (* a (* c -4.0)))))))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -4.8e-66) {
		tmp = (c / b) - (b / a);
	} else if (b <= 6e-121) {
		tmp = (-0.5 * (b - sqrt((c * (a * -4.0))))) / a;
	} else if ((b <= 2.2e-17) || !(b <= 2.2)) {
		tmp = -c / b;
	} else {
		tmp = (-0.5 / a) * (b - sqrt((a * (c * -4.0))));
	}
	return tmp;
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8) :: tmp
    if (b <= (-4.8d-66)) then
        tmp = (c / b) - (b / a)
    else if (b <= 6d-121) then
        tmp = ((-0.5d0) * (b - sqrt((c * (a * (-4.0d0)))))) / a
    else if ((b <= 2.2d-17) .or. (.not. (b <= 2.2d0))) then
        tmp = -c / b
    else
        tmp = ((-0.5d0) / a) * (b - sqrt((a * (c * (-4.0d0)))))
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	double tmp;
	if (b <= -4.8e-66) {
		tmp = (c / b) - (b / a);
	} else if (b <= 6e-121) {
		tmp = (-0.5 * (b - Math.sqrt((c * (a * -4.0))))) / a;
	} else if ((b <= 2.2e-17) || !(b <= 2.2)) {
		tmp = -c / b;
	} else {
		tmp = (-0.5 / a) * (b - Math.sqrt((a * (c * -4.0))));
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b <= -4.8e-66:
		tmp = (c / b) - (b / a)
	elif b <= 6e-121:
		tmp = (-0.5 * (b - math.sqrt((c * (a * -4.0))))) / a
	elif (b <= 2.2e-17) or not (b <= 2.2):
		tmp = -c / b
	else:
		tmp = (-0.5 / a) * (b - math.sqrt((a * (c * -4.0))))
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b <= -4.8e-66)
		tmp = Float64(Float64(c / b) - Float64(b / a));
	elseif (b <= 6e-121)
		tmp = Float64(Float64(-0.5 * Float64(b - sqrt(Float64(c * Float64(a * -4.0))))) / a);
	elseif ((b <= 2.2e-17) || !(b <= 2.2))
		tmp = Float64(Float64(-c) / b);
	else
		tmp = Float64(Float64(-0.5 / a) * Float64(b - sqrt(Float64(a * Float64(c * -4.0)))));
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	tmp = 0.0;
	if (b <= -4.8e-66)
		tmp = (c / b) - (b / a);
	elseif (b <= 6e-121)
		tmp = (-0.5 * (b - sqrt((c * (a * -4.0))))) / a;
	elseif ((b <= 2.2e-17) || ~((b <= 2.2)))
		tmp = -c / b;
	else
		tmp = (-0.5 / a) * (b - sqrt((a * (c * -4.0))));
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[LessEqual[b, -4.8e-66], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6e-121], N[(N[(-0.5 * N[(b - N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], If[Or[LessEqual[b, 2.2e-17], N[Not[LessEqual[b, 2.2]], $MachinePrecision]], N[((-c) / b), $MachinePrecision], N[(N[(-0.5 / a), $MachinePrecision] * N[(b - N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;b \leq 2.2 \cdot 10^{-17} \lor \neg \left(b \leq 2.2\right):\\
\;\;\;\;\frac{-c}{b}\\

\mathbf{else}:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b - \sqrt{a \cdot \left(c \cdot -4\right)}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if b < -4.80000000000000052e-66

    1. Initial program 74.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. neg-sub074.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.80000000000000052e-66 < b < 5.9999999999999999e-121

    1. Initial program 72.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. neg-sub072.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(b - \sqrt{\left(-\color{blue}{4 \cdot a}\right) \cdot c + b \cdot b}\right) \cdot \frac{-0.5}{a} \]
      7. distribute-lft-neg-in72.5%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\left(b - \sqrt{b \cdot b - a \cdot \left(c \cdot 4\right)}\right) \cdot -0.5}{a}} \]
    9. Applied egg-rr72.8%

      \[\leadsto \color{blue}{\frac{\left(b - \sqrt{b \cdot b - a \cdot \left(c \cdot 4\right)}\right) \cdot -0.5}{a}} \]
    10. Taylor expanded in b around 0 66.9%

      \[\leadsto \frac{\left(b - \sqrt{\color{blue}{-4 \cdot \left(c \cdot a\right)}}\right) \cdot -0.5}{a} \]
    11. Step-by-step derivation
      1. *-commutative66.9%

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

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

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

    if 5.9999999999999999e-121 < b < 2.2e-17 or 2.2000000000000002 < b

    1. Initial program 19.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.2e-17 < b < 2.2000000000000002

    1. Initial program 83.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(b - \sqrt{\color{blue}{a \cdot \left(c \cdot -4\right)}}\right) \cdot \frac{-0.5}{a} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification79.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -4.8 \cdot 10^{-66}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \leq 6 \cdot 10^{-121}:\\ \;\;\;\;\frac{-0.5 \cdot \left(b - \sqrt{c \cdot \left(a \cdot -4\right)}\right)}{a}\\ \mathbf{elif}\;b \leq 2.2 \cdot 10^{-17} \lor \neg \left(b \leq 2.2\right):\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{else}:\\ \;\;\;\;\frac{-0.5}{a} \cdot \left(b - \sqrt{a \cdot \left(c \cdot -4\right)}\right)\\ \end{array} \]

Alternative 5: 67.3% accurate, 12.8× speedup?

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

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


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

    1. Initial program 74.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.000000000000002e-309 < b

    1. Initial program 36.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. neg-sub036.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 42.7% accurate, 19.1× speedup?

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

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

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


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

    1. Initial program 74.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.000000000000002e-309 < b

    1. Initial program 36.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. neg-sub036.2%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(b - \sqrt{\color{blue}{b \cdot b}}\right) \cdot \frac{-0.5}{a} \]
    7. Taylor expanded in b around 0 21.1%

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

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

Alternative 7: 67.1% accurate, 19.1× speedup?

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

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

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


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

    1. Initial program 74.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.000000000000002e-309 < b

    1. Initial program 36.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. neg-sub036.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 10.9% accurate, 116.0× speedup?

\[\begin{array}{l} \\ 0 \end{array} \]
(FPCore (a b c) :precision binary64 0.0)
double code(double a, double b, double c) {
	return 0.0;
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    code = 0.0d0
end function
public static double code(double a, double b, double c) {
	return 0.0;
}
def code(a, b, c):
	return 0.0
function code(a, b, c)
	return 0.0
end
function tmp = code(a, b, c)
	tmp = 0.0;
end
code[a_, b_, c_] := 0.0
\begin{array}{l}

\\
0
\end{array}
Derivation
  1. Initial program 54.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. neg-sub054.8%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \left(b - \sqrt{\color{blue}{{b}^{2}}}\right) \cdot \frac{-0.5}{a} \]
  5. Step-by-step derivation
    1. unpow230.1%

      \[\leadsto \left(b - \sqrt{\color{blue}{b \cdot b}}\right) \cdot \frac{-0.5}{a} \]
  6. Simplified30.1%

    \[\leadsto \left(b - \sqrt{\color{blue}{b \cdot b}}\right) \cdot \frac{-0.5}{a} \]
  7. Taylor expanded in b around 0 12.1%

    \[\leadsto \color{blue}{0} \]
  8. Final simplification12.1%

    \[\leadsto 0 \]

Reproduce

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