jeff quadratic root 2

Percentage Accurate: 72.1% → 90.1%
Time: 31.0s
Alternatives: 6
Speedup: 1.0×

Specification

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

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

\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + t\_0}{2 \cdot a}\\


\end{array}
\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 6 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: 72.1% accurate, 1.0× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + t\_0}{2 \cdot a}\\


\end{array}
\end{array}

Alternative 1: 90.1% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\
\mathbf{if}\;b \leq -1.35 \cdot 10^{+154} \lor \neg \left(b \leq 7.5 \cdot 10^{+75}\right):\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\

\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\


\end{array}\\

\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t\_0}\\

\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - b}{2 \cdot a}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -1.35000000000000003e154 or 7.4999999999999995e75 < b

    1. Initial program 47.8%

      \[\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
    2. Add Preprocessing
    3. Taylor expanded in b around inf 76.1%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \color{blue}{b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
    4. Taylor expanded in b around -inf 96.6%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{-2 \cdot b}{2 \cdot a}\\ \end{array} \]
    5. Step-by-step derivation
      1. *-commutative96.6%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\ \end{array} \]
    6. Simplified96.6%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\ \end{array} \]

    if -1.35000000000000003e154 < b < 7.4999999999999995e75

    1. Initial program 90.9%

      \[\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
    2. Add Preprocessing
  3. Recombined 2 regimes into one program.
  4. Final simplification93.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -1.35 \cdot 10^{+154} \lor \neg \left(b \leq 7.5 \cdot 10^{+75}\right):\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{2 \cdot a}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 90.1% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\ t_1 := \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\ \end{array}\\ \mathbf{if}\;b \leq -5 \cdot 10^{+154}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;b \leq -1 \cdot 10^{-310}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{1}{\frac{\left(b - b\right) - b \cdot \left(-2 \cdot \left(\frac{c}{b} \cdot \frac{a}{b}\right)\right)}{2 \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{t\_0 - b}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \leq 7.5 \cdot 10^{+75}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t\_0}\\ \mathbf{else}:\\ \;\;\;\;b \cdot \left(\frac{-1}{a} - c \cdot \frac{\frac{-1}{b}}{b}\right)\\ \end{array}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (sqrt (- (* b b) (* c (* a 4.0)))))
        (t_1
         (if (>= b 0.0) (/ (* 2.0 c) (- (- b) b)) (/ (* b -2.0) (* 2.0 a)))))
   (if (<= b -5e+154)
     t_1
     (if (<= b -1e-310)
       (if (>= b 0.0)
         (/ 1.0 (/ (- (- b b) (* b (* -2.0 (* (/ c b) (/ a b))))) (* 2.0 c)))
         (/ (- t_0 b) (* 2.0 a)))
       (if (<= b 7.5e+75)
         (if (>= b 0.0)
           (/ (* 2.0 c) (- (- b) t_0))
           (* b (- (/ -1.0 a) (* c (/ (/ -1.0 b) b)))))
         t_1)))))
double code(double a, double b, double c) {
	double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
	double tmp;
	if (b >= 0.0) {
		tmp = (2.0 * c) / (-b - b);
	} else {
		tmp = (b * -2.0) / (2.0 * a);
	}
	double t_1 = tmp;
	double tmp_1;
	if (b <= -5e+154) {
		tmp_1 = t_1;
	} else if (b <= -1e-310) {
		double tmp_2;
		if (b >= 0.0) {
			tmp_2 = 1.0 / (((b - b) - (b * (-2.0 * ((c / b) * (a / b))))) / (2.0 * c));
		} else {
			tmp_2 = (t_0 - b) / (2.0 * a);
		}
		tmp_1 = tmp_2;
	} else if (b <= 7.5e+75) {
		double tmp_3;
		if (b >= 0.0) {
			tmp_3 = (2.0 * c) / (-b - t_0);
		} else {
			tmp_3 = b * ((-1.0 / a) - (c * ((-1.0 / b) / b)));
		}
		tmp_1 = tmp_3;
	} else {
		tmp_1 = t_1;
	}
	return tmp_1;
}
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) :: t_1
    real(8) :: tmp
    real(8) :: tmp_1
    real(8) :: tmp_2
    real(8) :: tmp_3
    t_0 = sqrt(((b * b) - (c * (a * 4.0d0))))
    if (b >= 0.0d0) then
        tmp = (2.0d0 * c) / (-b - b)
    else
        tmp = (b * (-2.0d0)) / (2.0d0 * a)
    end if
    t_1 = tmp
    if (b <= (-5d+154)) then
        tmp_1 = t_1
    else if (b <= (-1d-310)) then
        if (b >= 0.0d0) then
            tmp_2 = 1.0d0 / (((b - b) - (b * ((-2.0d0) * ((c / b) * (a / b))))) / (2.0d0 * c))
        else
            tmp_2 = (t_0 - b) / (2.0d0 * a)
        end if
        tmp_1 = tmp_2
    else if (b <= 7.5d+75) then
        if (b >= 0.0d0) then
            tmp_3 = (2.0d0 * c) / (-b - t_0)
        else
            tmp_3 = b * (((-1.0d0) / a) - (c * (((-1.0d0) / b) / b)))
        end if
        tmp_1 = tmp_3
    else
        tmp_1 = t_1
    end if
    code = tmp_1
end function
public static double code(double a, double b, double c) {
	double t_0 = Math.sqrt(((b * b) - (c * (a * 4.0))));
	double tmp;
	if (b >= 0.0) {
		tmp = (2.0 * c) / (-b - b);
	} else {
		tmp = (b * -2.0) / (2.0 * a);
	}
	double t_1 = tmp;
	double tmp_1;
	if (b <= -5e+154) {
		tmp_1 = t_1;
	} else if (b <= -1e-310) {
		double tmp_2;
		if (b >= 0.0) {
			tmp_2 = 1.0 / (((b - b) - (b * (-2.0 * ((c / b) * (a / b))))) / (2.0 * c));
		} else {
			tmp_2 = (t_0 - b) / (2.0 * a);
		}
		tmp_1 = tmp_2;
	} else if (b <= 7.5e+75) {
		double tmp_3;
		if (b >= 0.0) {
			tmp_3 = (2.0 * c) / (-b - t_0);
		} else {
			tmp_3 = b * ((-1.0 / a) - (c * ((-1.0 / b) / b)));
		}
		tmp_1 = tmp_3;
	} else {
		tmp_1 = t_1;
	}
	return tmp_1;
}
def code(a, b, c):
	t_0 = math.sqrt(((b * b) - (c * (a * 4.0))))
	tmp = 0
	if b >= 0.0:
		tmp = (2.0 * c) / (-b - b)
	else:
		tmp = (b * -2.0) / (2.0 * a)
	t_1 = tmp
	tmp_1 = 0
	if b <= -5e+154:
		tmp_1 = t_1
	elif b <= -1e-310:
		tmp_2 = 0
		if b >= 0.0:
			tmp_2 = 1.0 / (((b - b) - (b * (-2.0 * ((c / b) * (a / b))))) / (2.0 * c))
		else:
			tmp_2 = (t_0 - b) / (2.0 * a)
		tmp_1 = tmp_2
	elif b <= 7.5e+75:
		tmp_3 = 0
		if b >= 0.0:
			tmp_3 = (2.0 * c) / (-b - t_0)
		else:
			tmp_3 = b * ((-1.0 / a) - (c * ((-1.0 / b) / b)))
		tmp_1 = tmp_3
	else:
		tmp_1 = t_1
	return tmp_1
function code(a, b, c)
	t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0))))
	tmp = 0.0
	if (b >= 0.0)
		tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) - b));
	else
		tmp = Float64(Float64(b * -2.0) / Float64(2.0 * a));
	end
	t_1 = tmp
	tmp_1 = 0.0
	if (b <= -5e+154)
		tmp_1 = t_1;
	elseif (b <= -1e-310)
		tmp_2 = 0.0
		if (b >= 0.0)
			tmp_2 = Float64(1.0 / Float64(Float64(Float64(b - b) - Float64(b * Float64(-2.0 * Float64(Float64(c / b) * Float64(a / b))))) / Float64(2.0 * c)));
		else
			tmp_2 = Float64(Float64(t_0 - b) / Float64(2.0 * a));
		end
		tmp_1 = tmp_2;
	elseif (b <= 7.5e+75)
		tmp_3 = 0.0
		if (b >= 0.0)
			tmp_3 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0));
		else
			tmp_3 = Float64(b * Float64(Float64(-1.0 / a) - Float64(c * Float64(Float64(-1.0 / b) / b))));
		end
		tmp_1 = tmp_3;
	else
		tmp_1 = t_1;
	end
	return tmp_1
end
function tmp_5 = code(a, b, c)
	t_0 = sqrt(((b * b) - (c * (a * 4.0))));
	tmp = 0.0;
	if (b >= 0.0)
		tmp = (2.0 * c) / (-b - b);
	else
		tmp = (b * -2.0) / (2.0 * a);
	end
	t_1 = tmp;
	tmp_2 = 0.0;
	if (b <= -5e+154)
		tmp_2 = t_1;
	elseif (b <= -1e-310)
		tmp_3 = 0.0;
		if (b >= 0.0)
			tmp_3 = 1.0 / (((b - b) - (b * (-2.0 * ((c / b) * (a / b))))) / (2.0 * c));
		else
			tmp_3 = (t_0 - b) / (2.0 * a);
		end
		tmp_2 = tmp_3;
	elseif (b <= 7.5e+75)
		tmp_4 = 0.0;
		if (b >= 0.0)
			tmp_4 = (2.0 * c) / (-b - t_0);
		else
			tmp_4 = b * ((-1.0 / a) - (c * ((-1.0 / b) / b)));
		end
		tmp_2 = tmp_4;
	else
		tmp_2 = t_1;
	end
	tmp_5 = tmp_2;
end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - b), $MachinePrecision]), $MachinePrecision], N[(N[(b * -2.0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]}, If[LessEqual[b, -5e+154], t$95$1, If[LessEqual[b, -1e-310], If[GreaterEqual[b, 0.0], N[(1.0 / N[(N[(N[(b - b), $MachinePrecision] - N[(b * N[(-2.0 * N[(N[(c / b), $MachinePrecision] * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 7.5e+75], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], N[(b * N[(N[(-1.0 / a), $MachinePrecision] - N[(c * N[(N[(-1.0 / b), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], t$95$1]]]]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\


\end{array}\\
\mathbf{if}\;b \leq -5 \cdot 10^{+154}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;b \leq -1 \cdot 10^{-310}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{1}{\frac{\left(b - b\right) - b \cdot \left(-2 \cdot \left(\frac{c}{b} \cdot \frac{a}{b}\right)\right)}{2 \cdot c}}\\

\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - b}{2 \cdot a}\\


\end{array}\\

\mathbf{elif}\;b \leq 7.5 \cdot 10^{+75}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t\_0}\\

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


\end{array}\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b < -5.00000000000000004e154 or 7.4999999999999995e75 < b

    1. Initial program 47.8%

      \[\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
    2. Add Preprocessing
    3. Taylor expanded in b around inf 76.1%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \color{blue}{b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
    4. Taylor expanded in b around -inf 96.6%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{-2 \cdot b}{2 \cdot a}\\ \end{array} \]
    5. Step-by-step derivation
      1. *-commutative96.6%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\ \end{array} \]
    6. Simplified96.6%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\ \end{array} \]

    if -5.00000000000000004e154 < b < -9.999999999999969e-311

    1. Initial program 88.7%

      \[\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
    2. Add Preprocessing
    3. Taylor expanded in b around inf 88.7%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \color{blue}{b \cdot \left(1 + -2 \cdot \frac{a \cdot c}{{b}^{2}}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
    4. Step-by-step derivation
      1. distribute-lft-in88.7%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \color{blue}{\left(b \cdot 1 + b \cdot \left(-2 \cdot \frac{a \cdot c}{{b}^{2}}\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
      2. *-rgt-identity88.7%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left(\color{blue}{b} + b \cdot \left(-2 \cdot \frac{a \cdot c}{{b}^{2}}\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
      3. *-commutative88.7%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left(b + b \cdot \left(-2 \cdot \frac{\color{blue}{c \cdot a}}{{b}^{2}}\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
      4. unpow288.7%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left(b + b \cdot \left(-2 \cdot \frac{c \cdot a}{\color{blue}{b \cdot b}}\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
      5. times-frac88.7%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left(b + b \cdot \left(-2 \cdot \color{blue}{\left(\frac{c}{b} \cdot \frac{a}{b}\right)}\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
    5. Simplified88.7%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \color{blue}{\left(b + b \cdot \left(-2 \cdot \left(\frac{c}{b} \cdot \frac{a}{b}\right)\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
    6. Step-by-step derivation
      1. clear-num88.7%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\color{blue}{\frac{1}{\frac{\left(-b\right) - \left(b + b \cdot \left(-2 \cdot \left(\frac{c}{b} \cdot \frac{a}{b}\right)\right)\right)}{2 \cdot c}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
      2. clear-num88.7%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\color{blue}{\frac{1}{\frac{\frac{\left(-b\right) - \left(b + b \cdot \left(-2 \cdot \left(\frac{c}{b} \cdot \frac{a}{b}\right)\right)\right)}{2 \cdot c}}{1}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
      3. associate--r+88.7%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{1}{\frac{\frac{\color{blue}{\left(\left(-b\right) - b\right) - b \cdot \left(-2 \cdot \left(\frac{c}{b} \cdot \frac{a}{b}\right)\right)}}{2 \cdot c}}{1}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
      4. add-sqr-sqrt88.7%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{1}{\frac{\frac{\left(\color{blue}{\sqrt{-b} \cdot \sqrt{-b}} - b\right) - b \cdot \left(-2 \cdot \left(\frac{c}{b} \cdot \frac{a}{b}\right)\right)}{2 \cdot c}}{1}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
      5. sqrt-unprod88.7%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{1}{\frac{\frac{\left(\color{blue}{\sqrt{\left(-b\right) \cdot \left(-b\right)}} - b\right) - b \cdot \left(-2 \cdot \left(\frac{c}{b} \cdot \frac{a}{b}\right)\right)}{2 \cdot c}}{1}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
      6. sqr-neg88.7%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{1}{\frac{\frac{\left(\sqrt{\color{blue}{b \cdot b}} - b\right) - b \cdot \left(-2 \cdot \left(\frac{c}{b} \cdot \frac{a}{b}\right)\right)}{2 \cdot c}}{1}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
      7. sqrt-prod88.7%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{1}{\frac{\frac{\left(\color{blue}{\sqrt{b} \cdot \sqrt{b}} - b\right) - b \cdot \left(-2 \cdot \left(\frac{c}{b} \cdot \frac{a}{b}\right)\right)}{2 \cdot c}}{1}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
      8. add-sqr-sqrt88.7%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{1}{\frac{\frac{\left(\color{blue}{b} - b\right) - b \cdot \left(-2 \cdot \left(\frac{c}{b} \cdot \frac{a}{b}\right)\right)}{2 \cdot c}}{1}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
      9. *-commutative88.7%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{1}{\frac{\frac{\left(b - b\right) - b \cdot \left(-2 \cdot \left(\frac{c}{b} \cdot \frac{a}{b}\right)\right)}{\color{blue}{c \cdot 2}}}{1}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
    7. Applied egg-rr88.7%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\color{blue}{\frac{1}{\frac{\frac{\left(b - b\right) - b \cdot \left(-2 \cdot \left(\frac{c}{b} \cdot \frac{a}{b}\right)\right)}{c \cdot 2}}{1}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]

    if -9.999999999999969e-311 < b < 7.4999999999999995e75

    1. Initial program 93.6%

      \[\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
    2. Add Preprocessing
    3. Taylor expanded in b around -inf 93.6%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \left(b \cdot \left(-1 \cdot \frac{c}{{b}^{2}} + \frac{1}{a}\right)\right)\\ \end{array} \]
    4. Step-by-step derivation
      1. mul-1-neg93.6%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;-b \cdot \left(-1 \cdot \frac{c}{{b}^{2}} + \frac{1}{a}\right)\\ \end{array} \]
      2. *-commutative93.6%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;-\left(-1 \cdot \frac{c}{{b}^{2}} + \frac{1}{a}\right) \cdot b\\ \end{array} \]
      3. distribute-rgt-neg-in93.6%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\left(-1 \cdot \frac{c}{{b}^{2}} + \frac{1}{a}\right) \cdot \left(-b\right)\\ \end{array} \]
      4. +-commutative93.6%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{a} + -1 \cdot \frac{c}{{b}^{2}}\right) \cdot \left(-b\right)\\ \end{array} \]
      5. mul-1-neg93.6%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{a} + \left(-\frac{c}{{b}^{2}}\right)\right) \cdot \left(-b\right)\\ \end{array} \]
      6. unsub-neg93.6%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{a} - \frac{c}{{b}^{2}}\right) \cdot \left(-b\right)\\ \end{array} \]
      7. unpow293.6%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{a} - \frac{c}{b \cdot b}\right) \cdot \left(-b\right)\\ \end{array} \]
    5. Simplified93.6%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{a} - \frac{c}{b \cdot b}\right) \cdot \left(-b\right)\\ \end{array} \]
    6. Step-by-step derivation
      1. associate-/r*93.6%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{a} - \frac{\frac{c}{b}}{b}\right) \cdot \left(-b\right)\\ \end{array} \]
      2. div-inv93.6%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{a} - \frac{c \cdot \frac{1}{b}}{b}\right) \cdot \left(-b\right)\\ \end{array} \]
      3. *-un-lft-identity93.6%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{a} - \frac{c \cdot \frac{1}{b}}{1 \cdot b}\right) \cdot \left(-b\right)\\ \end{array} \]
      4. times-frac93.6%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{a} - \frac{c}{1} \cdot \frac{\frac{1}{b}}{b}\right) \cdot \left(-b\right)\\ \end{array} \]
    7. Applied egg-rr93.6%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{a} - \frac{c}{1} \cdot \frac{\frac{1}{b}}{b}\right) \cdot \left(-b\right)\\ \end{array} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification93.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -5 \cdot 10^{+154}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \leq -1 \cdot 10^{-310}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{1}{\frac{\left(b - b\right) - b \cdot \left(-2 \cdot \left(\frac{c}{b} \cdot \frac{a}{b}\right)\right)}{2 \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \leq 7.5 \cdot 10^{+75}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}}\\ \mathbf{else}:\\ \;\;\;\;b \cdot \left(\frac{-1}{a} - c \cdot \frac{\frac{-1}{b}}{b}\right)\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 85.1% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(-b\right) - b\\ t_1 := \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{t\_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\ \end{array}\\ \mathbf{if}\;b \leq -1 \cdot 10^{+154}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;b \leq -9.5 \cdot 10^{-304}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{1}{\frac{\left(b - b\right) - b \cdot \left(-2 \cdot \left(\frac{c}{b} \cdot \frac{a}{b}\right)\right)}{2 \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \leq 3.4 \cdot 10^{-38}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{-4 \cdot \left(c \cdot a\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{t\_0}{2 \cdot a}\\ \end{array}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (- (- b) b))
        (t_1 (if (>= b 0.0) (/ (* 2.0 c) t_0) (/ (* b -2.0) (* 2.0 a)))))
   (if (<= b -1e+154)
     t_1
     (if (<= b -9.5e-304)
       (if (>= b 0.0)
         (/ 1.0 (/ (- (- b b) (* b (* -2.0 (* (/ c b) (/ a b))))) (* 2.0 c)))
         (/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* 2.0 a)))
       (if (<= b 3.4e-38)
         (if (>= b 0.0)
           (/ (* 2.0 c) (- (- b) (sqrt (* -4.0 (* c a)))))
           (/ t_0 (* 2.0 a)))
         t_1)))))
double code(double a, double b, double c) {
	double t_0 = -b - b;
	double tmp;
	if (b >= 0.0) {
		tmp = (2.0 * c) / t_0;
	} else {
		tmp = (b * -2.0) / (2.0 * a);
	}
	double t_1 = tmp;
	double tmp_1;
	if (b <= -1e+154) {
		tmp_1 = t_1;
	} else if (b <= -9.5e-304) {
		double tmp_2;
		if (b >= 0.0) {
			tmp_2 = 1.0 / (((b - b) - (b * (-2.0 * ((c / b) * (a / b))))) / (2.0 * c));
		} else {
			tmp_2 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (2.0 * a);
		}
		tmp_1 = tmp_2;
	} else if (b <= 3.4e-38) {
		double tmp_3;
		if (b >= 0.0) {
			tmp_3 = (2.0 * c) / (-b - sqrt((-4.0 * (c * a))));
		} else {
			tmp_3 = t_0 / (2.0 * a);
		}
		tmp_1 = tmp_3;
	} else {
		tmp_1 = t_1;
	}
	return tmp_1;
}
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) :: t_1
    real(8) :: tmp
    real(8) :: tmp_1
    real(8) :: tmp_2
    real(8) :: tmp_3
    t_0 = -b - b
    if (b >= 0.0d0) then
        tmp = (2.0d0 * c) / t_0
    else
        tmp = (b * (-2.0d0)) / (2.0d0 * a)
    end if
    t_1 = tmp
    if (b <= (-1d+154)) then
        tmp_1 = t_1
    else if (b <= (-9.5d-304)) then
        if (b >= 0.0d0) then
            tmp_2 = 1.0d0 / (((b - b) - (b * ((-2.0d0) * ((c / b) * (a / b))))) / (2.0d0 * c))
        else
            tmp_2 = (sqrt(((b * b) - (c * (a * 4.0d0)))) - b) / (2.0d0 * a)
        end if
        tmp_1 = tmp_2
    else if (b <= 3.4d-38) then
        if (b >= 0.0d0) then
            tmp_3 = (2.0d0 * c) / (-b - sqrt(((-4.0d0) * (c * a))))
        else
            tmp_3 = t_0 / (2.0d0 * a)
        end if
        tmp_1 = tmp_3
    else
        tmp_1 = t_1
    end if
    code = tmp_1
end function
public static double code(double a, double b, double c) {
	double t_0 = -b - b;
	double tmp;
	if (b >= 0.0) {
		tmp = (2.0 * c) / t_0;
	} else {
		tmp = (b * -2.0) / (2.0 * a);
	}
	double t_1 = tmp;
	double tmp_1;
	if (b <= -1e+154) {
		tmp_1 = t_1;
	} else if (b <= -9.5e-304) {
		double tmp_2;
		if (b >= 0.0) {
			tmp_2 = 1.0 / (((b - b) - (b * (-2.0 * ((c / b) * (a / b))))) / (2.0 * c));
		} else {
			tmp_2 = (Math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (2.0 * a);
		}
		tmp_1 = tmp_2;
	} else if (b <= 3.4e-38) {
		double tmp_3;
		if (b >= 0.0) {
			tmp_3 = (2.0 * c) / (-b - Math.sqrt((-4.0 * (c * a))));
		} else {
			tmp_3 = t_0 / (2.0 * a);
		}
		tmp_1 = tmp_3;
	} else {
		tmp_1 = t_1;
	}
	return tmp_1;
}
def code(a, b, c):
	t_0 = -b - b
	tmp = 0
	if b >= 0.0:
		tmp = (2.0 * c) / t_0
	else:
		tmp = (b * -2.0) / (2.0 * a)
	t_1 = tmp
	tmp_1 = 0
	if b <= -1e+154:
		tmp_1 = t_1
	elif b <= -9.5e-304:
		tmp_2 = 0
		if b >= 0.0:
			tmp_2 = 1.0 / (((b - b) - (b * (-2.0 * ((c / b) * (a / b))))) / (2.0 * c))
		else:
			tmp_2 = (math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (2.0 * a)
		tmp_1 = tmp_2
	elif b <= 3.4e-38:
		tmp_3 = 0
		if b >= 0.0:
			tmp_3 = (2.0 * c) / (-b - math.sqrt((-4.0 * (c * a))))
		else:
			tmp_3 = t_0 / (2.0 * a)
		tmp_1 = tmp_3
	else:
		tmp_1 = t_1
	return tmp_1
function code(a, b, c)
	t_0 = Float64(Float64(-b) - b)
	tmp = 0.0
	if (b >= 0.0)
		tmp = Float64(Float64(2.0 * c) / t_0);
	else
		tmp = Float64(Float64(b * -2.0) / Float64(2.0 * a));
	end
	t_1 = tmp
	tmp_1 = 0.0
	if (b <= -1e+154)
		tmp_1 = t_1;
	elseif (b <= -9.5e-304)
		tmp_2 = 0.0
		if (b >= 0.0)
			tmp_2 = Float64(1.0 / Float64(Float64(Float64(b - b) - Float64(b * Float64(-2.0 * Float64(Float64(c / b) * Float64(a / b))))) / Float64(2.0 * c)));
		else
			tmp_2 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(2.0 * a));
		end
		tmp_1 = tmp_2;
	elseif (b <= 3.4e-38)
		tmp_3 = 0.0
		if (b >= 0.0)
			tmp_3 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - sqrt(Float64(-4.0 * Float64(c * a)))));
		else
			tmp_3 = Float64(t_0 / Float64(2.0 * a));
		end
		tmp_1 = tmp_3;
	else
		tmp_1 = t_1;
	end
	return tmp_1
end
function tmp_5 = code(a, b, c)
	t_0 = -b - b;
	tmp = 0.0;
	if (b >= 0.0)
		tmp = (2.0 * c) / t_0;
	else
		tmp = (b * -2.0) / (2.0 * a);
	end
	t_1 = tmp;
	tmp_2 = 0.0;
	if (b <= -1e+154)
		tmp_2 = t_1;
	elseif (b <= -9.5e-304)
		tmp_3 = 0.0;
		if (b >= 0.0)
			tmp_3 = 1.0 / (((b - b) - (b * (-2.0 * ((c / b) * (a / b))))) / (2.0 * c));
		else
			tmp_3 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (2.0 * a);
		end
		tmp_2 = tmp_3;
	elseif (b <= 3.4e-38)
		tmp_4 = 0.0;
		if (b >= 0.0)
			tmp_4 = (2.0 * c) / (-b - sqrt((-4.0 * (c * a))));
		else
			tmp_4 = t_0 / (2.0 * a);
		end
		tmp_2 = tmp_4;
	else
		tmp_2 = t_1;
	end
	tmp_5 = tmp_2;
end
code[a_, b_, c_] := Block[{t$95$0 = N[((-b) - b), $MachinePrecision]}, Block[{t$95$1 = If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(b * -2.0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]}, If[LessEqual[b, -1e+154], t$95$1, If[LessEqual[b, -9.5e-304], If[GreaterEqual[b, 0.0], N[(1.0 / N[(N[(N[(b - b), $MachinePrecision] - N[(b * N[(-2.0 * N[(N[(c / b), $MachinePrecision] * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 3.4e-38], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - N[Sqrt[N[(-4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], t$95$1]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(-b\right) - b\\
t_1 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{t\_0}\\

\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\


\end{array}\\
\mathbf{if}\;b \leq -1 \cdot 10^{+154}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;b \leq -9.5 \cdot 10^{-304}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{1}{\frac{\left(b - b\right) - b \cdot \left(-2 \cdot \left(\frac{c}{b} \cdot \frac{a}{b}\right)\right)}{2 \cdot c}}\\

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


\end{array}\\

\mathbf{elif}\;b \leq 3.4 \cdot 10^{-38}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{-4 \cdot \left(c \cdot a\right)}}\\

\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{2 \cdot a}\\


\end{array}\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b < -1.00000000000000004e154 or 3.4000000000000002e-38 < b

    1. Initial program 56.2%

      \[\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
    2. Add Preprocessing
    3. Taylor expanded in b around inf 75.4%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \color{blue}{b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
    4. Taylor expanded in b around -inf 92.2%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{-2 \cdot b}{2 \cdot a}\\ \end{array} \]
    5. Step-by-step derivation
      1. *-commutative92.2%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\ \end{array} \]
    6. Simplified92.2%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\ \end{array} \]

    if -1.00000000000000004e154 < b < -9.50000000000000023e-304

    1. Initial program 89.7%

      \[\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
    2. Add Preprocessing
    3. Taylor expanded in b around inf 89.7%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \color{blue}{b \cdot \left(1 + -2 \cdot \frac{a \cdot c}{{b}^{2}}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
    4. Step-by-step derivation
      1. distribute-lft-in89.7%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \color{blue}{\left(b \cdot 1 + b \cdot \left(-2 \cdot \frac{a \cdot c}{{b}^{2}}\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
      2. *-rgt-identity89.7%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left(\color{blue}{b} + b \cdot \left(-2 \cdot \frac{a \cdot c}{{b}^{2}}\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
      3. *-commutative89.7%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left(b + b \cdot \left(-2 \cdot \frac{\color{blue}{c \cdot a}}{{b}^{2}}\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
      4. unpow289.7%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left(b + b \cdot \left(-2 \cdot \frac{c \cdot a}{\color{blue}{b \cdot b}}\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
      5. times-frac89.7%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left(b + b \cdot \left(-2 \cdot \color{blue}{\left(\frac{c}{b} \cdot \frac{a}{b}\right)}\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
    5. Simplified89.7%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \color{blue}{\left(b + b \cdot \left(-2 \cdot \left(\frac{c}{b} \cdot \frac{a}{b}\right)\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
    6. Step-by-step derivation
      1. clear-num89.7%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\color{blue}{\frac{1}{\frac{\left(-b\right) - \left(b + b \cdot \left(-2 \cdot \left(\frac{c}{b} \cdot \frac{a}{b}\right)\right)\right)}{2 \cdot c}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
      2. clear-num89.7%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\color{blue}{\frac{1}{\frac{\frac{\left(-b\right) - \left(b + b \cdot \left(-2 \cdot \left(\frac{c}{b} \cdot \frac{a}{b}\right)\right)\right)}{2 \cdot c}}{1}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
      3. associate--r+89.7%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{1}{\frac{\frac{\color{blue}{\left(\left(-b\right) - b\right) - b \cdot \left(-2 \cdot \left(\frac{c}{b} \cdot \frac{a}{b}\right)\right)}}{2 \cdot c}}{1}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
      4. add-sqr-sqrt89.7%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{1}{\frac{\frac{\left(\color{blue}{\sqrt{-b} \cdot \sqrt{-b}} - b\right) - b \cdot \left(-2 \cdot \left(\frac{c}{b} \cdot \frac{a}{b}\right)\right)}{2 \cdot c}}{1}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
      5. sqrt-unprod89.7%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{1}{\frac{\frac{\left(\color{blue}{\sqrt{\left(-b\right) \cdot \left(-b\right)}} - b\right) - b \cdot \left(-2 \cdot \left(\frac{c}{b} \cdot \frac{a}{b}\right)\right)}{2 \cdot c}}{1}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
      6. sqr-neg89.7%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{1}{\frac{\frac{\left(\sqrt{\color{blue}{b \cdot b}} - b\right) - b \cdot \left(-2 \cdot \left(\frac{c}{b} \cdot \frac{a}{b}\right)\right)}{2 \cdot c}}{1}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
      7. sqrt-prod89.7%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{1}{\frac{\frac{\left(\color{blue}{\sqrt{b} \cdot \sqrt{b}} - b\right) - b \cdot \left(-2 \cdot \left(\frac{c}{b} \cdot \frac{a}{b}\right)\right)}{2 \cdot c}}{1}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
      8. add-sqr-sqrt89.7%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{1}{\frac{\frac{\left(\color{blue}{b} - b\right) - b \cdot \left(-2 \cdot \left(\frac{c}{b} \cdot \frac{a}{b}\right)\right)}{2 \cdot c}}{1}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
      9. *-commutative89.7%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{1}{\frac{\frac{\left(b - b\right) - b \cdot \left(-2 \cdot \left(\frac{c}{b} \cdot \frac{a}{b}\right)\right)}{\color{blue}{c \cdot 2}}}{1}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
    7. Applied egg-rr89.7%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\color{blue}{\frac{1}{\frac{\frac{\left(b - b\right) - b \cdot \left(-2 \cdot \left(\frac{c}{b} \cdot \frac{a}{b}\right)\right)}{c \cdot 2}}{1}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]

    if -9.50000000000000023e-304 < b < 3.4000000000000002e-38

    1. Initial program 90.7%

      \[\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
    2. Add Preprocessing
    3. Taylor expanded in b around -inf 90.7%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + -1 \cdot b}{2 \cdot a}\\ \end{array} \]
    4. Taylor expanded in b around 0 80.8%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\color{blue}{-4 \cdot \left(a \cdot c\right)}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + -1 \cdot b}{2 \cdot a}\\ \end{array} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification89.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -1 \cdot 10^{+154}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \leq -9.5 \cdot 10^{-304}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{1}{\frac{\left(b - b\right) - b \cdot \left(-2 \cdot \left(\frac{c}{b} \cdot \frac{a}{b}\right)\right)}{2 \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \leq 3.4 \cdot 10^{-38}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{-4 \cdot \left(c \cdot a\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 80.0% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{-4 \cdot \left(c \cdot a\right)}\\ t_1 := \left(-b\right) - b\\ t_2 := \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{t\_1}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\ \end{array}\\ \mathbf{if}\;b \leq -9 \cdot 10^{-61}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;b \leq -9.5 \cdot 10^{-304}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left(b + b \cdot \left(-2 \cdot \left(\frac{c}{b} \cdot \frac{a}{b}\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{t\_0 - b}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \leq 1.02 \cdot 10^{-41}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t\_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{t\_1}{2 \cdot a}\\ \end{array}\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (sqrt (* -4.0 (* c a))))
        (t_1 (- (- b) b))
        (t_2 (if (>= b 0.0) (/ (* 2.0 c) t_1) (/ (* b -2.0) (* 2.0 a)))))
   (if (<= b -9e-61)
     t_2
     (if (<= b -9.5e-304)
       (if (>= b 0.0)
         (/ (* 2.0 c) (- (- b) (+ b (* b (* -2.0 (* (/ c b) (/ a b)))))))
         (/ (- t_0 b) (* 2.0 a)))
       (if (<= b 1.02e-41)
         (if (>= b 0.0) (/ (* 2.0 c) (- (- b) t_0)) (/ t_1 (* 2.0 a)))
         t_2)))))
double code(double a, double b, double c) {
	double t_0 = sqrt((-4.0 * (c * a)));
	double t_1 = -b - b;
	double tmp;
	if (b >= 0.0) {
		tmp = (2.0 * c) / t_1;
	} else {
		tmp = (b * -2.0) / (2.0 * a);
	}
	double t_2 = tmp;
	double tmp_1;
	if (b <= -9e-61) {
		tmp_1 = t_2;
	} else if (b <= -9.5e-304) {
		double tmp_2;
		if (b >= 0.0) {
			tmp_2 = (2.0 * c) / (-b - (b + (b * (-2.0 * ((c / b) * (a / b))))));
		} else {
			tmp_2 = (t_0 - b) / (2.0 * a);
		}
		tmp_1 = tmp_2;
	} else if (b <= 1.02e-41) {
		double tmp_3;
		if (b >= 0.0) {
			tmp_3 = (2.0 * c) / (-b - t_0);
		} else {
			tmp_3 = t_1 / (2.0 * a);
		}
		tmp_1 = tmp_3;
	} else {
		tmp_1 = t_2;
	}
	return tmp_1;
}
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) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    real(8) :: tmp_1
    real(8) :: tmp_2
    real(8) :: tmp_3
    t_0 = sqrt(((-4.0d0) * (c * a)))
    t_1 = -b - b
    if (b >= 0.0d0) then
        tmp = (2.0d0 * c) / t_1
    else
        tmp = (b * (-2.0d0)) / (2.0d0 * a)
    end if
    t_2 = tmp
    if (b <= (-9d-61)) then
        tmp_1 = t_2
    else if (b <= (-9.5d-304)) then
        if (b >= 0.0d0) then
            tmp_2 = (2.0d0 * c) / (-b - (b + (b * ((-2.0d0) * ((c / b) * (a / b))))))
        else
            tmp_2 = (t_0 - b) / (2.0d0 * a)
        end if
        tmp_1 = tmp_2
    else if (b <= 1.02d-41) then
        if (b >= 0.0d0) then
            tmp_3 = (2.0d0 * c) / (-b - t_0)
        else
            tmp_3 = t_1 / (2.0d0 * a)
        end if
        tmp_1 = tmp_3
    else
        tmp_1 = t_2
    end if
    code = tmp_1
end function
public static double code(double a, double b, double c) {
	double t_0 = Math.sqrt((-4.0 * (c * a)));
	double t_1 = -b - b;
	double tmp;
	if (b >= 0.0) {
		tmp = (2.0 * c) / t_1;
	} else {
		tmp = (b * -2.0) / (2.0 * a);
	}
	double t_2 = tmp;
	double tmp_1;
	if (b <= -9e-61) {
		tmp_1 = t_2;
	} else if (b <= -9.5e-304) {
		double tmp_2;
		if (b >= 0.0) {
			tmp_2 = (2.0 * c) / (-b - (b + (b * (-2.0 * ((c / b) * (a / b))))));
		} else {
			tmp_2 = (t_0 - b) / (2.0 * a);
		}
		tmp_1 = tmp_2;
	} else if (b <= 1.02e-41) {
		double tmp_3;
		if (b >= 0.0) {
			tmp_3 = (2.0 * c) / (-b - t_0);
		} else {
			tmp_3 = t_1 / (2.0 * a);
		}
		tmp_1 = tmp_3;
	} else {
		tmp_1 = t_2;
	}
	return tmp_1;
}
def code(a, b, c):
	t_0 = math.sqrt((-4.0 * (c * a)))
	t_1 = -b - b
	tmp = 0
	if b >= 0.0:
		tmp = (2.0 * c) / t_1
	else:
		tmp = (b * -2.0) / (2.0 * a)
	t_2 = tmp
	tmp_1 = 0
	if b <= -9e-61:
		tmp_1 = t_2
	elif b <= -9.5e-304:
		tmp_2 = 0
		if b >= 0.0:
			tmp_2 = (2.0 * c) / (-b - (b + (b * (-2.0 * ((c / b) * (a / b))))))
		else:
			tmp_2 = (t_0 - b) / (2.0 * a)
		tmp_1 = tmp_2
	elif b <= 1.02e-41:
		tmp_3 = 0
		if b >= 0.0:
			tmp_3 = (2.0 * c) / (-b - t_0)
		else:
			tmp_3 = t_1 / (2.0 * a)
		tmp_1 = tmp_3
	else:
		tmp_1 = t_2
	return tmp_1
function code(a, b, c)
	t_0 = sqrt(Float64(-4.0 * Float64(c * a)))
	t_1 = Float64(Float64(-b) - b)
	tmp = 0.0
	if (b >= 0.0)
		tmp = Float64(Float64(2.0 * c) / t_1);
	else
		tmp = Float64(Float64(b * -2.0) / Float64(2.0 * a));
	end
	t_2 = tmp
	tmp_1 = 0.0
	if (b <= -9e-61)
		tmp_1 = t_2;
	elseif (b <= -9.5e-304)
		tmp_2 = 0.0
		if (b >= 0.0)
			tmp_2 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - Float64(b + Float64(b * Float64(-2.0 * Float64(Float64(c / b) * Float64(a / b)))))));
		else
			tmp_2 = Float64(Float64(t_0 - b) / Float64(2.0 * a));
		end
		tmp_1 = tmp_2;
	elseif (b <= 1.02e-41)
		tmp_3 = 0.0
		if (b >= 0.0)
			tmp_3 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0));
		else
			tmp_3 = Float64(t_1 / Float64(2.0 * a));
		end
		tmp_1 = tmp_3;
	else
		tmp_1 = t_2;
	end
	return tmp_1
end
function tmp_5 = code(a, b, c)
	t_0 = sqrt((-4.0 * (c * a)));
	t_1 = -b - b;
	tmp = 0.0;
	if (b >= 0.0)
		tmp = (2.0 * c) / t_1;
	else
		tmp = (b * -2.0) / (2.0 * a);
	end
	t_2 = tmp;
	tmp_2 = 0.0;
	if (b <= -9e-61)
		tmp_2 = t_2;
	elseif (b <= -9.5e-304)
		tmp_3 = 0.0;
		if (b >= 0.0)
			tmp_3 = (2.0 * c) / (-b - (b + (b * (-2.0 * ((c / b) * (a / b))))));
		else
			tmp_3 = (t_0 - b) / (2.0 * a);
		end
		tmp_2 = tmp_3;
	elseif (b <= 1.02e-41)
		tmp_4 = 0.0;
		if (b >= 0.0)
			tmp_4 = (2.0 * c) / (-b - t_0);
		else
			tmp_4 = t_1 / (2.0 * a);
		end
		tmp_2 = tmp_4;
	else
		tmp_2 = t_2;
	end
	tmp_5 = tmp_2;
end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(-4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[((-b) - b), $MachinePrecision]}, Block[{t$95$2 = If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / t$95$1), $MachinePrecision], N[(N[(b * -2.0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]}, If[LessEqual[b, -9e-61], t$95$2, If[LessEqual[b, -9.5e-304], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - N[(b + N[(b * N[(-2.0 * N[(N[(c / b), $MachinePrecision] * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 1.02e-41], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], N[(t$95$1 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], t$95$2]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sqrt{-4 \cdot \left(c \cdot a\right)}\\
t_1 := \left(-b\right) - b\\
t_2 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{t\_1}\\

\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\


\end{array}\\
\mathbf{if}\;b \leq -9 \cdot 10^{-61}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;b \leq -9.5 \cdot 10^{-304}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left(b + b \cdot \left(-2 \cdot \left(\frac{c}{b} \cdot \frac{a}{b}\right)\right)\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - b}{2 \cdot a}\\


\end{array}\\

\mathbf{elif}\;b \leq 1.02 \cdot 10^{-41}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t\_0}\\

\mathbf{else}:\\
\;\;\;\;\frac{t\_1}{2 \cdot a}\\


\end{array}\\

\mathbf{else}:\\
\;\;\;\;t\_2\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b < -9e-61 or 1.02e-41 < b

    1. Initial program 66.5%

      \[\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
    2. Add Preprocessing
    3. Taylor expanded in b around inf 80.2%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \color{blue}{b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
    4. Taylor expanded in b around -inf 87.3%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{-2 \cdot b}{2 \cdot a}\\ \end{array} \]
    5. Step-by-step derivation
      1. *-commutative87.3%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\ \end{array} \]
    6. Simplified87.3%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\ \end{array} \]

    if -9e-61 < b < -9.50000000000000023e-304

    1. Initial program 84.9%

      \[\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
    2. Add Preprocessing
    3. Taylor expanded in b around inf 84.9%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \color{blue}{b \cdot \left(1 + -2 \cdot \frac{a \cdot c}{{b}^{2}}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
    4. Step-by-step derivation
      1. distribute-lft-in84.9%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \color{blue}{\left(b \cdot 1 + b \cdot \left(-2 \cdot \frac{a \cdot c}{{b}^{2}}\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
      2. *-rgt-identity84.9%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left(\color{blue}{b} + b \cdot \left(-2 \cdot \frac{a \cdot c}{{b}^{2}}\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
      3. *-commutative84.9%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left(b + b \cdot \left(-2 \cdot \frac{\color{blue}{c \cdot a}}{{b}^{2}}\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
      4. unpow284.9%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left(b + b \cdot \left(-2 \cdot \frac{c \cdot a}{\color{blue}{b \cdot b}}\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
      5. times-frac84.9%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left(b + b \cdot \left(-2 \cdot \color{blue}{\left(\frac{c}{b} \cdot \frac{a}{b}\right)}\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
    5. Simplified84.9%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \color{blue}{\left(b + b \cdot \left(-2 \cdot \left(\frac{c}{b} \cdot \frac{a}{b}\right)\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
    6. Taylor expanded in b around 0 82.2%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left(b + b \cdot \left(-2 \cdot \left(\frac{c}{b} \cdot \frac{a}{b}\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{-4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\\ \end{array} \]

    if -9.50000000000000023e-304 < b < 1.02e-41

    1. Initial program 90.7%

      \[\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
    2. Add Preprocessing
    3. Taylor expanded in b around -inf 90.7%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + -1 \cdot b}{2 \cdot a}\\ \end{array} \]
    4. Taylor expanded in b around 0 80.8%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\color{blue}{-4 \cdot \left(a \cdot c\right)}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + -1 \cdot b}{2 \cdot a}\\ \end{array} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification85.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -9 \cdot 10^{-61}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \leq -9.5 \cdot 10^{-304}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left(b + b \cdot \left(-2 \cdot \left(\frac{c}{b} \cdot \frac{a}{b}\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{-4 \cdot \left(c \cdot a\right)} - b}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \leq 1.02 \cdot 10^{-41}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{-4 \cdot \left(c \cdot a\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 73.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(-b\right) - b\\ \mathbf{if}\;b \leq 5.3 \cdot 10^{-40}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{-4 \cdot \left(c \cdot a\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{t\_0}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{t\_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (- (- b) b)))
   (if (<= b 5.3e-40)
     (if (>= b 0.0)
       (/ (* 2.0 c) (- (- b) (sqrt (* -4.0 (* c a)))))
       (/ t_0 (* 2.0 a)))
     (if (>= b 0.0) (/ (* 2.0 c) t_0) (/ (* b -2.0) (* 2.0 a))))))
double code(double a, double b, double c) {
	double t_0 = -b - b;
	double tmp_1;
	if (b <= 5.3e-40) {
		double tmp_2;
		if (b >= 0.0) {
			tmp_2 = (2.0 * c) / (-b - sqrt((-4.0 * (c * a))));
		} else {
			tmp_2 = t_0 / (2.0 * a);
		}
		tmp_1 = tmp_2;
	} else if (b >= 0.0) {
		tmp_1 = (2.0 * c) / t_0;
	} else {
		tmp_1 = (b * -2.0) / (2.0 * a);
	}
	return tmp_1;
}
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
    real(8) :: tmp_1
    real(8) :: tmp_2
    t_0 = -b - b
    if (b <= 5.3d-40) then
        if (b >= 0.0d0) then
            tmp_2 = (2.0d0 * c) / (-b - sqrt(((-4.0d0) * (c * a))))
        else
            tmp_2 = t_0 / (2.0d0 * a)
        end if
        tmp_1 = tmp_2
    else if (b >= 0.0d0) then
        tmp_1 = (2.0d0 * c) / t_0
    else
        tmp_1 = (b * (-2.0d0)) / (2.0d0 * a)
    end if
    code = tmp_1
end function
public static double code(double a, double b, double c) {
	double t_0 = -b - b;
	double tmp_1;
	if (b <= 5.3e-40) {
		double tmp_2;
		if (b >= 0.0) {
			tmp_2 = (2.0 * c) / (-b - Math.sqrt((-4.0 * (c * a))));
		} else {
			tmp_2 = t_0 / (2.0 * a);
		}
		tmp_1 = tmp_2;
	} else if (b >= 0.0) {
		tmp_1 = (2.0 * c) / t_0;
	} else {
		tmp_1 = (b * -2.0) / (2.0 * a);
	}
	return tmp_1;
}
def code(a, b, c):
	t_0 = -b - b
	tmp_1 = 0
	if b <= 5.3e-40:
		tmp_2 = 0
		if b >= 0.0:
			tmp_2 = (2.0 * c) / (-b - math.sqrt((-4.0 * (c * a))))
		else:
			tmp_2 = t_0 / (2.0 * a)
		tmp_1 = tmp_2
	elif b >= 0.0:
		tmp_1 = (2.0 * c) / t_0
	else:
		tmp_1 = (b * -2.0) / (2.0 * a)
	return tmp_1
function code(a, b, c)
	t_0 = Float64(Float64(-b) - b)
	tmp_1 = 0.0
	if (b <= 5.3e-40)
		tmp_2 = 0.0
		if (b >= 0.0)
			tmp_2 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - sqrt(Float64(-4.0 * Float64(c * a)))));
		else
			tmp_2 = Float64(t_0 / Float64(2.0 * a));
		end
		tmp_1 = tmp_2;
	elseif (b >= 0.0)
		tmp_1 = Float64(Float64(2.0 * c) / t_0);
	else
		tmp_1 = Float64(Float64(b * -2.0) / Float64(2.0 * a));
	end
	return tmp_1
end
function tmp_4 = code(a, b, c)
	t_0 = -b - b;
	tmp_2 = 0.0;
	if (b <= 5.3e-40)
		tmp_3 = 0.0;
		if (b >= 0.0)
			tmp_3 = (2.0 * c) / (-b - sqrt((-4.0 * (c * a))));
		else
			tmp_3 = t_0 / (2.0 * a);
		end
		tmp_2 = tmp_3;
	elseif (b >= 0.0)
		tmp_2 = (2.0 * c) / t_0;
	else
		tmp_2 = (b * -2.0) / (2.0 * a);
	end
	tmp_4 = tmp_2;
end
code[a_, b_, c_] := Block[{t$95$0 = N[((-b) - b), $MachinePrecision]}, If[LessEqual[b, 5.3e-40], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - N[Sqrt[N[(-4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(b * -2.0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{2 \cdot a}\\


\end{array}\\

\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{t\_0}\\

\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\


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

    1. Initial program 79.2%

      \[\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
    2. Add Preprocessing
    3. Taylor expanded in b around -inf 74.2%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + -1 \cdot b}{2 \cdot a}\\ \end{array} \]
    4. Taylor expanded in b around 0 71.6%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\color{blue}{-4 \cdot \left(a \cdot c\right)}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + -1 \cdot b}{2 \cdot a}\\ \end{array} \]

    if 5.3000000000000002e-40 < b

    1. Initial program 60.8%

      \[\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
    2. Add Preprocessing
    3. Taylor expanded in b around inf 88.7%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \color{blue}{b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
    4. Taylor expanded in b around -inf 88.7%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{-2 \cdot b}{2 \cdot a}\\ \end{array} \]
    5. Step-by-step derivation
      1. *-commutative88.7%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\ \end{array} \]
    6. Simplified88.7%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\ \end{array} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification77.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 5.3 \cdot 10^{-40}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{-4 \cdot \left(c \cdot a\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 68.2% accurate, 9.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (>= b 0.0) (/ (* 2.0 c) (- (- b) b)) (/ (* b -2.0) (* 2.0 a))))
double code(double a, double b, double c) {
	double tmp;
	if (b >= 0.0) {
		tmp = (2.0 * c) / (-b - b);
	} else {
		tmp = (b * -2.0) / (2.0 * a);
	}
	return tmp;
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8) :: tmp
    if (b >= 0.0d0) then
        tmp = (2.0d0 * c) / (-b - b)
    else
        tmp = (b * (-2.0d0)) / (2.0d0 * a)
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	double tmp;
	if (b >= 0.0) {
		tmp = (2.0 * c) / (-b - b);
	} else {
		tmp = (b * -2.0) / (2.0 * a);
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b >= 0.0:
		tmp = (2.0 * c) / (-b - b)
	else:
		tmp = (b * -2.0) / (2.0 * a)
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b >= 0.0)
		tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) - b));
	else
		tmp = Float64(Float64(b * -2.0) / Float64(2.0 * a));
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	tmp = 0.0;
	if (b >= 0.0)
		tmp = (2.0 * c) / (-b - b);
	else
		tmp = (b * -2.0) / (2.0 * a);
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - b), $MachinePrecision]), $MachinePrecision], N[(N[(b * -2.0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\

\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\


\end{array}
\end{array}
Derivation
  1. Initial program 72.7%

    \[\begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
  2. Add Preprocessing
  3. Taylor expanded in b around inf 69.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \color{blue}{b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array} \]
  4. Taylor expanded in b around -inf 66.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{-2 \cdot b}{2 \cdot a}\\ \end{array} \]
  5. Step-by-step derivation
    1. *-commutative66.7%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\ \end{array} \]
  6. Simplified66.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \geq 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\ \end{array} \]
  7. Add Preprocessing

Reproduce

?
herbie shell --seed 2024097 
(FPCore (a b c)
  :name "jeff quadratic root 2"
  :precision binary64
  (if (>= b 0.0) (/ (* 2.0 c) (- (- b) (sqrt (- (* b b) (* (* 4.0 a) c))))) (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a))))