The quadratic formula (r1)

Percentage Accurate: 52.0% → 86.2%
Time: 12.8s
Alternatives: 9
Speedup: 12.9×

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 9 alternatives:

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

Initial Program: 52.0% 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: 86.2% accurate, 0.9× speedup?

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

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

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

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


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

    1. Initial program 47.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. *-commutative47.2%

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

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

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

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

        \[\leadsto \frac{\color{blue}{-b}}{a} \]
    7. Simplified96.5%

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

    if -1e94 < b < 2.8000000000000002e-41

    1. Initial program 79.9%

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

    if 2.8000000000000002e-41 < b

    1. Initial program 14.4%

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-c}}{b} \]
    7. Simplified89.0%

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

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

Alternative 2: 81.5% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 66.9%

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

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

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

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

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

        \[\leadsto -\color{blue}{\left(-1 \cdot \frac{c}{{b}^{2}} + \frac{1}{a}\right) \cdot b} \]
      3. distribute-rgt-neg-in86.0%

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

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

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

        \[\leadsto \color{blue}{\left(\frac{1}{a} - \frac{c}{{b}^{2}}\right)} \cdot \left(-b\right) \]
    7. Simplified86.0%

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

    if -2.40000000000000013e-54 < b < 7.7999999999999996e-87

    1. Initial program 78.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. *-commutative78.0%

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

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

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

    if 7.7999999999999996e-87 < b

    1. Initial program 18.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. *-commutative18.1%

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

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

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

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

        \[\leadsto \frac{\color{blue}{-c}}{b} \]
    7. Simplified83.3%

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

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

Alternative 3: 81.5% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;b \leq 7 \cdot 10^{-87}:\\
\;\;\;\;\left(\sqrt{-4 \cdot \left(a \cdot c\right)} - b\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 < -3.35e-59

    1. Initial program 66.9%

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

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

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

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

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

        \[\leadsto -\color{blue}{\left(-1 \cdot \frac{c}{{b}^{2}} + \frac{1}{a}\right) \cdot b} \]
      3. distribute-rgt-neg-in86.0%

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

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

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

        \[\leadsto \color{blue}{\left(\frac{1}{a} - \frac{c}{{b}^{2}}\right)} \cdot \left(-b\right) \]
    7. Simplified86.0%

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

    if -3.35e-59 < b < 7.00000000000000023e-87

    1. Initial program 78.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. *-commutative78.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\mathsf{fma}\left(a, c \cdot -4, {b}^{2}\right)} \cdot \frac{0.5}{a} + \left(-b \cdot \frac{1}{\color{blue}{2 \cdot a}}\right) \]
      10. associate-/r*76.6%

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

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

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

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

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

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

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

    if 7.00000000000000023e-87 < b

    1. Initial program 18.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. *-commutative18.1%

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

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

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

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

        \[\leadsto \frac{\color{blue}{-c}}{b} \]
    7. Simplified83.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -3.35 \cdot 10^{-59}:\\ \;\;\;\;b \cdot \left(\frac{c}{{b}^{2}} - \frac{1}{a}\right)\\ \mathbf{elif}\;b \leq 7 \cdot 10^{-87}:\\ \;\;\;\;\left(\sqrt{-4 \cdot \left(a \cdot c\right)} - b\right) \cdot \frac{0.5}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 81.1% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 66.9%

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

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

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

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

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

        \[\leadsto -\color{blue}{\left(-1 \cdot \frac{c}{{b}^{2}} + \frac{1}{a}\right) \cdot b} \]
      3. distribute-rgt-neg-in86.0%

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

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

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

        \[\leadsto \color{blue}{\left(\frac{1}{a} - \frac{c}{{b}^{2}}\right)} \cdot \left(-b\right) \]
    7. Simplified86.0%

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

    if -1.55e-59 < b < 8.00000000000000014e-87

    1. Initial program 78.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. *-commutative78.0%

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \left(\sqrt{a \cdot \left(c \cdot {\left(\sqrt[3]{-4}\right)}^{3}\right)} \cdot {\left(\sqrt{-1}\right)}^{2}\right)}}{a \cdot 2} \]
    8. Step-by-step derivation
      1. mul-1-neg0.0%

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

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

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

        \[\leadsto \frac{-\color{blue}{-1} \cdot \sqrt{a \cdot \left(c \cdot {\left(\sqrt[3]{-4}\right)}^{3}\right)}}{a \cdot 2} \]
      5. rem-cube-cbrt70.0%

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

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

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

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

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

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

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

    if 8.00000000000000014e-87 < b

    1. Initial program 18.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. *-commutative18.1%

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

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

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

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

        \[\leadsto \frac{\color{blue}{-c}}{b} \]
    7. Simplified83.3%

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

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

Alternative 5: 81.1% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 66.9%

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-b}}{a} \]
    7. Simplified85.8%

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

    if -2.8499999999999999e-56 < b < 7.29999999999999967e-87

    1. Initial program 78.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. *-commutative78.0%

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \left(\sqrt{a \cdot \left(c \cdot {\left(\sqrt[3]{-4}\right)}^{3}\right)} \cdot {\left(\sqrt{-1}\right)}^{2}\right)}}{a \cdot 2} \]
    8. Step-by-step derivation
      1. mul-1-neg0.0%

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

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

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

        \[\leadsto \frac{-\color{blue}{-1} \cdot \sqrt{a \cdot \left(c \cdot {\left(\sqrt[3]{-4}\right)}^{3}\right)}}{a \cdot 2} \]
      5. rem-cube-cbrt70.0%

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

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

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

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

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

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

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

    if 7.29999999999999967e-87 < b

    1. Initial program 18.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. *-commutative18.1%

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

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

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

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

        \[\leadsto \frac{\color{blue}{-c}}{b} \]
    7. Simplified83.3%

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

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

Alternative 6: 72.5% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 70.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. *-commutative70.5%

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

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

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

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

        \[\leadsto \frac{\color{blue}{-b}}{a} \]
    7. Simplified80.3%

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

    if -6.9999999999999996e-150 < b < 9.4999999999999999e-107

    1. Initial program 74.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. *-commutative74.1%

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

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

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

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

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

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

      \[\leadsto \color{blue}{-0.5 \cdot \left(\sqrt{\frac{c \cdot {\left(\sqrt[3]{-4}\right)}^{3}}{a}} \cdot {\left(\sqrt{-1}\right)}^{2}\right)} \]
    8. Step-by-step derivation
      1. *-commutative0.0%

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

        \[\leadsto -0.5 \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot \sqrt{\frac{c \cdot {\left(\sqrt[3]{-4}\right)}^{3}}{a}}\right) \]
      3. rem-square-sqrt37.5%

        \[\leadsto -0.5 \cdot \left(\color{blue}{-1} \cdot \sqrt{\frac{c \cdot {\left(\sqrt[3]{-4}\right)}^{3}}{a}}\right) \]
      4. rem-cube-cbrt37.8%

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

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

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

    if 9.4999999999999999e-107 < b

    1. Initial program 19.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. *-commutative19.8%

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

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

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

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

        \[\leadsto \frac{\color{blue}{-c}}{b} \]
    7. Simplified81.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -7 \cdot 10^{-150}:\\ \;\;\;\;-\frac{b}{a}\\ \mathbf{elif}\;b \leq 9.5 \cdot 10^{-107}:\\ \;\;\;\;\sqrt{c \cdot \frac{-4}{a}} \cdot \left(--0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 68.5% accurate, 12.9× speedup?

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

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

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


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

    1. Initial program 70.9%

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-b}}{a} \]
    7. Simplified67.0%

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

    if -9.999999999999969e-311 < b

    1. Initial program 34.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. *-commutative34.8%

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

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

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

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

        \[\leadsto \frac{\color{blue}{-c}}{b} \]
    7. Simplified64.2%

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

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

Alternative 8: 43.7% accurate, 12.9× speedup?

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

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

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


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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-b}}{a} \]
    7. Simplified48.9%

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

    if 7.0000000000000001e-15 < b

    1. Initial program 12.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. *-commutative12.4%

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

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

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

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

        \[\leadsto \frac{\color{blue}{-c}}{b} \]
    7. Simplified90.9%

      \[\leadsto \color{blue}{\frac{-c}{b}} \]
    8. Step-by-step derivation
      1. add-sqr-sqrt49.2%

        \[\leadsto \frac{\color{blue}{\sqrt{-c} \cdot \sqrt{-c}}}{b} \]
      2. sqrt-unprod45.7%

        \[\leadsto \frac{\color{blue}{\sqrt{\left(-c\right) \cdot \left(-c\right)}}}{b} \]
      3. sqr-neg45.7%

        \[\leadsto \frac{\sqrt{\color{blue}{c \cdot c}}}{b} \]
      4. sqrt-unprod13.3%

        \[\leadsto \frac{\color{blue}{\sqrt{c} \cdot \sqrt{c}}}{b} \]
      5. add-sqr-sqrt24.1%

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

        \[\leadsto \color{blue}{c \cdot \frac{1}{b}} \]
    9. Applied egg-rr24.1%

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

        \[\leadsto \color{blue}{\frac{c \cdot 1}{b}} \]
      2. *-rgt-identity24.1%

        \[\leadsto \frac{\color{blue}{c}}{b} \]
    11. Simplified24.1%

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

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

Alternative 9: 11.1% accurate, 38.7× speedup?

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{-c}{b}} \]
  8. Step-by-step derivation
    1. add-sqr-sqrt16.6%

      \[\leadsto \frac{\color{blue}{\sqrt{-c} \cdot \sqrt{-c}}}{b} \]
    2. sqrt-unprod17.3%

      \[\leadsto \frac{\color{blue}{\sqrt{\left(-c\right) \cdot \left(-c\right)}}}{b} \]
    3. sqr-neg17.3%

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

      \[\leadsto \frac{\color{blue}{\sqrt{c} \cdot \sqrt{c}}}{b} \]
    5. add-sqr-sqrt9.0%

      \[\leadsto \frac{\color{blue}{c}}{b} \]
    6. div-inv9.0%

      \[\leadsto \color{blue}{c \cdot \frac{1}{b}} \]
  9. Applied egg-rr9.0%

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

      \[\leadsto \color{blue}{\frac{c \cdot 1}{b}} \]
    2. *-rgt-identity9.0%

      \[\leadsto \frac{\color{blue}{c}}{b} \]
  11. Simplified9.0%

    \[\leadsto \color{blue}{\frac{c}{b}} \]
  12. Add Preprocessing

Developer Target 1: 71.0% accurate, 0.9× speedup?

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

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

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


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2024150 
(FPCore (a b c)
  :name "The quadratic formula (r1)"
  :precision binary64

  :alt
  (! :herbie-platform default (let ((d (- (* b b) (* (* 4 a) c)))) (let ((r1 (/ (+ (- b) (sqrt d)) (* 2 a)))) (let ((r2 (/ (- (- b) (sqrt d)) (* 2 a)))) (if (< b 0) r1 (/ c (* a r2)))))))

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