Quadratic roots, full range

Percentage Accurate: 52.6% → 85.9%
Time: 13.9s
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.6% accurate, 1.0× speedup?

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

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

Alternative 1: 85.9% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -4 \cdot 10^{+119}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\

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

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


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

    1. Initial program 38.0%

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

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

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

      \[\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)} \]
    6. Step-by-step derivation
      1. sub-neg38.1%

        \[\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--38.1%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(\frac{1}{a} - \frac{c}{{b}^{2}}\right) \cdot \left(-b\right)} \]
    11. Taylor expanded in a around inf 90.6%

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

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

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

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

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

    if -3.99999999999999978e119 < b < 1.1500000000000001e-110

    1. Initial program 78.9%

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

    if 1.1500000000000001e-110 < b

    1. Initial program 16.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. *-commutative16.8%

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

      \[\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. Taylor expanded in b around inf 90.0%

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

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

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

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

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

Alternative 2: 80.8% accurate, 0.9× speedup?

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

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

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

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


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

    1. Initial program 68.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. *-commutative68.8%

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

      \[\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. Applied egg-rr68.7%

      \[\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)} \]
    6. Step-by-step derivation
      1. sub-neg68.7%

        \[\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--68.7%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(\frac{1}{a} - \frac{c}{{b}^{2}}\right) \cdot \left(-b\right)} \]
    11. Taylor expanded in a around inf 81.7%

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

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

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

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

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

    if -2.60000000000000005e-99 < b < 8.50000000000000029e-110

    1. Initial program 66.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. *-commutative66.8%

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

      \[\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. Taylor expanded in b around 0 62.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 8.50000000000000029e-110 < b

    1. Initial program 16.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. *-commutative16.8%

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

      \[\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. Taylor expanded in b around inf 90.0%

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

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

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

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

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

Alternative 3: 80.5% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 68.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. *-commutative68.8%

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

      \[\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. Applied egg-rr68.7%

      \[\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)} \]
    6. Step-by-step derivation
      1. sub-neg68.7%

        \[\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--68.7%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(\frac{1}{a} - \frac{c}{{b}^{2}}\right) \cdot \left(-b\right)} \]
    11. Taylor expanded in a around inf 81.7%

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

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

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

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

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

    if -6.79999999999999978e-101 < b < 6.80000000000000004e-108

    1. Initial program 66.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. *-commutative66.8%

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

      \[\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. Taylor expanded in b around 0 62.2%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-b\right) + {\left({\left(c \cdot \left(a \cdot -4\right)\right)}^{\color{blue}{1.5}}\right)}^{0.3333333333333333}}{a \cdot 2} \]
    9. Applied egg-rr50.4%

      \[\leadsto \frac{\left(-b\right) + \color{blue}{{\left({\left(c \cdot \left(a \cdot -4\right)\right)}^{1.5}\right)}^{0.3333333333333333}}}{a \cdot 2} \]
    10. Step-by-step derivation
      1. unpow1/353.9%

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

      \[\leadsto \frac{\left(-b\right) + \color{blue}{\sqrt[3]{{\left(c \cdot \left(a \cdot -4\right)\right)}^{1.5}}}}{a \cdot 2} \]
    12. Step-by-step derivation
      1. *-un-lft-identity53.9%

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

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

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

        \[\leadsto \color{blue}{0.5} \cdot \frac{\left(-b\right) + \sqrt[3]{{\left(c \cdot \left(a \cdot -4\right)\right)}^{1.5}}}{a} \]
      5. add-sqr-sqrt22.5%

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\sqrt{\left(-b\right) \cdot \left(-b\right)}} + \sqrt[3]{{\left(c \cdot \left(a \cdot -4\right)\right)}^{1.5}}}{a} \]
      7. sqr-neg53.5%

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\sqrt{b} \cdot \sqrt{b}} + \sqrt[3]{{\left(c \cdot \left(a \cdot -4\right)\right)}^{1.5}}}{a} \]
      9. add-sqr-sqrt52.6%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{b} + \sqrt[3]{{\left(c \cdot \left(a \cdot -4\right)\right)}^{1.5}}}{a} \]
      10. pow1/349.1%

        \[\leadsto 0.5 \cdot \frac{b + \color{blue}{{\left({\left(c \cdot \left(a \cdot -4\right)\right)}^{1.5}\right)}^{0.3333333333333333}}}{a} \]
      11. pow-pow60.8%

        \[\leadsto 0.5 \cdot \frac{b + \color{blue}{{\left(c \cdot \left(a \cdot -4\right)\right)}^{\left(1.5 \cdot 0.3333333333333333\right)}}}{a} \]
      12. metadata-eval60.8%

        \[\leadsto 0.5 \cdot \frac{b + {\left(c \cdot \left(a \cdot -4\right)\right)}^{\color{blue}{0.5}}}{a} \]
      13. pow1/260.8%

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

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

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

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

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

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

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

    if 6.80000000000000004e-108 < b

    1. Initial program 16.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. *-commutative16.8%

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

      \[\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. Taylor expanded in b around inf 90.0%

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

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

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

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

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

Alternative 4: 80.8% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 68.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. *-commutative68.8%

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

      \[\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. Applied egg-rr68.7%

      \[\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)} \]
    6. Step-by-step derivation
      1. sub-neg68.7%

        \[\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--68.7%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(\frac{1}{a} - \frac{c}{{b}^{2}}\right) \cdot \left(-b\right)} \]
    11. Taylor expanded in a around inf 81.7%

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

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

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

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

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

    if -6.39999999999999957e-101 < b < 7.9999999999999999e-109

    1. Initial program 66.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. *-commutative66.8%

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

      \[\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. Taylor expanded in b around 0 62.2%

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

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

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

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

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

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

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

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

    if 7.9999999999999999e-109 < b

    1. Initial program 16.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. *-commutative16.8%

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

      \[\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. Taylor expanded in b around inf 90.0%

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

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

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

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

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

Alternative 5: 69.0% accurate, 9.7× speedup?

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

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

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


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

    1. Initial program 67.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. *-commutative67.3%

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

      \[\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. Applied egg-rr67.3%

      \[\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)} \]
    6. Step-by-step derivation
      1. sub-neg67.3%

        \[\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--67.3%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(\frac{1}{a} - \frac{c}{{b}^{2}}\right) \cdot \left(-b\right)} \]
    11. Taylor expanded in a around inf 64.7%

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

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

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

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

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

    if -4.999999999999985e-310 < b

    1. Initial program 29.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. *-commutative29.5%

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

      \[\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. Taylor expanded in b around inf 71.8%

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

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

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

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

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

Alternative 6: 44.7% accurate, 12.9× speedup?

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

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

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


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

    1. Initial program 65.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. *-commutative65.8%

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

      \[\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. Taylor expanded in b around -inf 47.9%

      \[\leadsto \color{blue}{-1 \cdot \frac{b}{a}} \]
    6. Step-by-step derivation
      1. mul-1-neg47.9%

        \[\leadsto \color{blue}{-\frac{b}{a}} \]
      2. distribute-neg-frac247.9%

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

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

    if 2.5000000000000001e-28 < b

    1. Initial program 14.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. *-commutative14.6%

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

      \[\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. Applied egg-rr7.4%

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

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

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

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

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

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

Alternative 7: 68.8% accurate, 12.9× speedup?

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

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

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


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

    1. Initial program 67.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. *-commutative67.6%

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

      \[\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. Taylor expanded in b around -inf 64.1%

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

        \[\leadsto \color{blue}{-\frac{b}{a}} \]
      2. distribute-neg-frac264.1%

        \[\leadsto \color{blue}{\frac{b}{-a}} \]
    7. Simplified64.1%

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

    if 2.49999999999999977e-308 < b

    1. Initial program 29.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. *-commutative29.0%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{a \cdot 2}} \]
    3. Simplified29.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. Taylor expanded in b around inf 72.3%

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

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

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

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

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

Alternative 8: 2.5% accurate, 38.7× speedup?

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

\\
\frac{b}{a}
\end{array}
Derivation
  1. Initial program 46.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. *-commutative46.8%

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

    \[\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. Applied egg-rr25.5%

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

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

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

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

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

    \[\leadsto \frac{b}{a} \]
  10. Add Preprocessing

Alternative 9: 11.2% 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 46.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. *-commutative46.8%

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

    \[\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. Applied egg-rr25.5%

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

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

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

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

    \[\leadsto \color{blue}{\frac{c}{b}} \]
  9. Final simplification14.8%

    \[\leadsto \frac{c}{b} \]
  10. Add Preprocessing

Reproduce

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