Quadratic roots, full range

Percentage Accurate: 52.1% → 87.3%
Time: 14.5s
Alternatives: 8
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 8 alternatives:

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

Initial Program: 52.1% 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: 87.3% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -2.4 \cdot 10^{+84}:\\ \;\;\;\;-\frac{b}{a}\\ \mathbf{elif}\;b \leq -3.5 \cdot 10^{-238}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c} - b}{a \cdot 2}\\ \mathbf{elif}\;b \leq 1.32 \cdot 10^{-14}:\\ \;\;\;\;\frac{\frac{0.5 \cdot \left(a \cdot \left(c \cdot -4\right)\right)}{a}}{b + \sqrt{\mathsf{fma}\left(a, c \cdot -4, {b}^{2}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b -2.4e+84)
   (- (/ b a))
   (if (<= b -3.5e-238)
     (/ (- (sqrt (- (* b b) (* (* a 4.0) c))) b) (* a 2.0))
     (if (<= b 1.32e-14)
       (/
        (/ (* 0.5 (* a (* c -4.0))) a)
        (+ b (sqrt (fma a (* c -4.0) (pow b 2.0)))))
       (/ c (- b))))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -2.4e+84) {
		tmp = -(b / a);
	} else if (b <= -3.5e-238) {
		tmp = (sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a * 2.0);
	} else if (b <= 1.32e-14) {
		tmp = ((0.5 * (a * (c * -4.0))) / a) / (b + sqrt(fma(a, (c * -4.0), pow(b, 2.0))));
	} else {
		tmp = c / -b;
	}
	return tmp;
}
function code(a, b, c)
	tmp = 0.0
	if (b <= -2.4e+84)
		tmp = Float64(-Float64(b / a));
	elseif (b <= -3.5e-238)
		tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 4.0) * c))) - b) / Float64(a * 2.0));
	elseif (b <= 1.32e-14)
		tmp = Float64(Float64(Float64(0.5 * Float64(a * Float64(c * -4.0))) / a) / Float64(b + sqrt(fma(a, Float64(c * -4.0), (b ^ 2.0)))));
	else
		tmp = Float64(c / Float64(-b));
	end
	return tmp
end
code[a_, b_, c_] := If[LessEqual[b, -2.4e+84], (-N[(b / a), $MachinePrecision]), If[LessEqual[b, -3.5e-238], 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], If[LessEqual[b, 1.32e-14], N[(N[(N[(0.5 * N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision] / N[(b + N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision] + N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;b \leq 1.32 \cdot 10^{-14}:\\
\;\;\;\;\frac{\frac{0.5 \cdot \left(a \cdot \left(c \cdot -4\right)\right)}{a}}{b + \sqrt{\mathsf{fma}\left(a, c \cdot -4, {b}^{2}\right)}}\\

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


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

    1. Initial program 51.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. *-commutative51.5%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{a \cdot 2}} \]
    3. Simplified51.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 94.7%

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

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

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

    if -2.4e84 < b < -3.49999999999999997e-238

    1. Initial program 85.4%

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

    if -3.49999999999999997e-238 < b < 1.32e-14

    1. Initial program 76.7%

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

        \[\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{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a \cdot 2}} \]
    4. Add Preprocessing
    5. Applied egg-rr76.8%

      \[\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-neg76.8%

        \[\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.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.32e-14 < b

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{a \cdot 2}} \]
    3. Simplified14.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 87.5%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -2.4 \cdot 10^{+84}:\\ \;\;\;\;-\frac{b}{a}\\ \mathbf{elif}\;b \leq -3.5 \cdot 10^{-238}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c} - b}{a \cdot 2}\\ \mathbf{elif}\;b \leq 1.32 \cdot 10^{-14}:\\ \;\;\;\;\frac{\frac{0.5 \cdot \left(a \cdot \left(c \cdot -4\right)\right)}{a}}{b + \sqrt{\mathsf{fma}\left(a, c \cdot -4, {b}^{2}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 85.6% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -4.5 \cdot 10^{+86}:\\ \;\;\;\;-\frac{b}{a}\\ \mathbf{elif}\;b \leq 2.5 \cdot 10^{-15}:\\ \;\;\;\;\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 -4.5e+86)
   (- (/ b a))
   (if (<= b 2.5e-15)
     (/ (- (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 <= -4.5e+86) {
		tmp = -(b / a);
	} else if (b <= 2.5e-15) {
		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 <= (-4.5d+86)) then
        tmp = -(b / a)
    else if (b <= 2.5d-15) 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 <= -4.5e+86) {
		tmp = -(b / a);
	} else if (b <= 2.5e-15) {
		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 <= -4.5e+86:
		tmp = -(b / a)
	elif b <= 2.5e-15:
		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 <= -4.5e+86)
		tmp = Float64(-Float64(b / a));
	elseif (b <= 2.5e-15)
		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 <= -4.5e+86)
		tmp = -(b / a);
	elseif (b <= 2.5e-15)
		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, -4.5e+86], (-N[(b / a), $MachinePrecision]), If[LessEqual[b, 2.5e-15], 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 -4.5 \cdot 10^{+86}:\\
\;\;\;\;-\frac{b}{a}\\

\mathbf{elif}\;b \leq 2.5 \cdot 10^{-15}:\\
\;\;\;\;\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 < -4.49999999999999993e86

    1. Initial program 51.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. *-commutative51.5%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{a \cdot 2}} \]
    3. Simplified51.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 94.7%

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

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

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

    if -4.49999999999999993e86 < b < 2.5e-15

    1. Initial program 81.1%

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

    if 2.5e-15 < b

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{a \cdot 2}} \]
    3. Simplified14.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 87.5%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -4.5 \cdot 10^{+86}:\\ \;\;\;\;-\frac{b}{a}\\ \mathbf{elif}\;b \leq 2.5 \cdot 10^{-15}:\\ \;\;\;\;\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 3: 80.2% accurate, 1.0× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b < -2.1999999999999999e-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 -inf 86.5%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{c}{b} - \frac{b}{a}} \]
    10. Simplified86.8%

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

    if -2.1999999999999999e-110 < b < 2.6500000000000001e-15

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -0.5 \cdot \frac{b}{a} - \sqrt{c \cdot \left(a \cdot -4\right)} \cdot \left(-\color{blue}{0.5 \cdot \frac{1}{a}}\right) \]
      10. cancel-sign-sub-inv76.3%

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

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

    if 2.6500000000000001e-15 < b

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{a \cdot 2}} \]
    3. Simplified14.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 87.5%

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

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

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

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

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

Alternative 4: 68.4% accurate, 9.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -2 \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 -2e-310) (- (/ c b) (/ b a)) (/ c (- b))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -2e-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 <= (-2d-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 <= -2e-310) {
		tmp = (c / b) - (b / a);
	} else {
		tmp = c / -b;
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b <= -2e-310:
		tmp = (c / b) - (b / a)
	else:
		tmp = c / -b
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b <= -2e-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 <= -2e-310)
		tmp = (c / b) - (b / a);
	else
		tmp = c / -b;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[LessEqual[b, -2e-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 -2 \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 < -1.999999999999994e-310

    1. Initial program 73.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. *-commutative73.3%

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

      \[\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-neg61.1%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{c}{b} - \frac{b}{a}} \]
    10. Simplified63.0%

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

    if -1.999999999999994e-310 < b

    1. Initial program 36.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. *-commutative36.0%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{a \cdot 2}} \]
    3. Simplified36.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 63.1%

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

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

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

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

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

Alternative 5: 43.4% accurate, 12.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq 28000000000000:\\
\;\;\;\;-\frac{b}{a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 2.8e13

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

        \[\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{\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 46.2%

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

        \[\leadsto \color{blue}{-\frac{b}{a}} \]
    7. Simplified46.2%

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

    if 2.8e13 < b

    1. Initial program 15.7%

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

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

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

      \[\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-neg2.2%

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

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

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

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

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

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

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

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

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

Alternative 6: 68.2% accurate, 12.9× speedup?

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

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

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


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

    1. Initial program 73.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. *-commutative73.5%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{a \cdot 2}} \]
    3. Simplified73.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 62.0%

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

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

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

    if 1.29999999999999998e-300 < b

    1. Initial program 35.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. *-commutative35.5%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{a \cdot 2}} \]
    3. Simplified35.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 63.6%

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

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

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

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

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

Alternative 7: 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 55.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. *-commutative55.8%

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{a \cdot 2}} \]
  3. Simplified55.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. Step-by-step derivation
    1. *-un-lft-identity55.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{b}{a}} \]
  10. Final simplification2.6%

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

Alternative 8: 10.6% 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 55.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. *-commutative55.8%

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{a \cdot 2}} \]
  3. Simplified55.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 33.4%

    \[\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-neg33.4%

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{c}{b}} \]
  9. Final simplification9.7%

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

Reproduce

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