Quadratic roots, full range

Percentage Accurate: 52.2% → 86.0%
Time: 14.6s
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.2% accurate, 1.0× speedup?

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

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

Alternative 1: 86.0% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -5 \cdot 10^{+154}:\\ \;\;\;\;0.5 \cdot \frac{\left|-2 \cdot \left(a \cdot \frac{c}{b} - b\right)\right|}{a}\\ \mathbf{elif}\;b \leq 3.4 \cdot 10^{-49}:\\ \;\;\;\;\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 -5e+154)
   (* 0.5 (/ (fabs (* -2.0 (- (* a (/ c b)) b))) a))
   (if (<= b 3.4e-49)
     (/ (- (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 <= -5e+154) {
		tmp = 0.5 * (fabs((-2.0 * ((a * (c / b)) - b))) / a);
	} else if (b <= 3.4e-49) {
		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 <= (-5d+154)) then
        tmp = 0.5d0 * (abs(((-2.0d0) * ((a * (c / b)) - b))) / a)
    else if (b <= 3.4d-49) 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 <= -5e+154) {
		tmp = 0.5 * (Math.abs((-2.0 * ((a * (c / b)) - b))) / a);
	} else if (b <= 3.4e-49) {
		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 <= -5e+154:
		tmp = 0.5 * (math.fabs((-2.0 * ((a * (c / b)) - b))) / a)
	elif b <= 3.4e-49:
		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 <= -5e+154)
		tmp = Float64(0.5 * Float64(abs(Float64(-2.0 * Float64(Float64(a * Float64(c / b)) - b))) / a));
	elseif (b <= 3.4e-49)
		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 <= -5e+154)
		tmp = 0.5 * (abs((-2.0 * ((a * (c / b)) - b))) / a);
	elseif (b <= 3.4e-49)
		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, -5e+154], N[(0.5 * N[(N[Abs[N[(-2.0 * N[(N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.4e-49], 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 -5 \cdot 10^{+154}:\\
\;\;\;\;0.5 \cdot \frac{\left|-2 \cdot \left(a \cdot \frac{c}{b} - b\right)\right|}{a}\\

\mathbf{elif}\;b \leq 3.4 \cdot 10^{-49}:\\
\;\;\;\;\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 < -5.00000000000000004e154

    1. Initial program 53.4%

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

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

      \[\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 a around 0 1.8%

      \[\leadsto \frac{\left(-b\right) + \color{blue}{\left(b + -2 \cdot \frac{a \cdot c}{b}\right)}}{a \cdot 2} \]
    6. Step-by-step derivation
      1. add-sqr-sqrt1.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left|b + \mathsf{fma}\left(-2, a \cdot \frac{c}{b}, b\right)\right|}}{a \cdot 2} \]
    9. Simplified94.7%

      \[\leadsto \frac{\color{blue}{\left|b + \mathsf{fma}\left(-2, a \cdot \frac{c}{b}, b\right)\right|}}{a \cdot 2} \]
    10. Taylor expanded in b around 0 83.5%

      \[\leadsto \color{blue}{0.5 \cdot \frac{\left|-2 \cdot \frac{a \cdot c}{b} + 2 \cdot b\right|}{a}} \]
    11. Step-by-step derivation
      1. metadata-eval83.5%

        \[\leadsto 0.5 \cdot \frac{\left|-2 \cdot \frac{a \cdot c}{b} + \color{blue}{\left(--2\right)} \cdot b\right|}{a} \]
      2. cancel-sign-sub-inv83.5%

        \[\leadsto 0.5 \cdot \frac{\left|\color{blue}{-2 \cdot \frac{a \cdot c}{b} - -2 \cdot b}\right|}{a} \]
      3. distribute-lft-out--83.5%

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

        \[\leadsto 0.5 \cdot \frac{\left|-2 \cdot \left(\color{blue}{a \cdot \frac{c}{b}} - b\right)\right|}{a} \]
    12. Simplified94.7%

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

    if -5.00000000000000004e154 < b < 3.40000000000000005e-49

    1. Initial program 81.6%

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

    if 3.40000000000000005e-49 < b

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -5 \cdot 10^{+154}:\\ \;\;\;\;0.5 \cdot \frac{\left|-2 \cdot \left(a \cdot \frac{c}{b} - b\right)\right|}{a}\\ \mathbf{elif}\;b \leq 3.4 \cdot 10^{-49}:\\ \;\;\;\;\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.9% accurate, 1.0× speedup?

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

\mathbf{elif}\;b \leq 3.4 \cdot 10^{-53}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \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 < -4.0999999999999998e-38

    1. Initial program 70.9%

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

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

      \[\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 a around 0 1.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left|b + \mathsf{fma}\left(-2, a \cdot \frac{c}{b}, b\right)\right|}}{a \cdot 2} \]
    9. Simplified87.7%

      \[\leadsto \frac{\color{blue}{\left|b + \mathsf{fma}\left(-2, a \cdot \frac{c}{b}, b\right)\right|}}{a \cdot 2} \]
    10. Taylor expanded in b around 0 81.9%

      \[\leadsto \color{blue}{0.5 \cdot \frac{\left|-2 \cdot \frac{a \cdot c}{b} + 2 \cdot b\right|}{a}} \]
    11. Step-by-step derivation
      1. metadata-eval81.9%

        \[\leadsto 0.5 \cdot \frac{\left|-2 \cdot \frac{a \cdot c}{b} + \color{blue}{\left(--2\right)} \cdot b\right|}{a} \]
      2. cancel-sign-sub-inv81.9%

        \[\leadsto 0.5 \cdot \frac{\left|\color{blue}{-2 \cdot \frac{a \cdot c}{b} - -2 \cdot b}\right|}{a} \]
      3. distribute-lft-out--81.9%

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

        \[\leadsto 0.5 \cdot \frac{\left|-2 \cdot \left(\color{blue}{a \cdot \frac{c}{b}} - b\right)\right|}{a} \]
    12. Simplified87.7%

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

    if -4.0999999999999998e-38 < b < 3.4e-53

    1. Initial program 77.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. *-commutative77.8%

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

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

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

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

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

    if 3.4e-53 < b

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -4.1 \cdot 10^{-38}:\\ \;\;\;\;0.5 \cdot \frac{\left|-2 \cdot \left(a \cdot \frac{c}{b} - b\right)\right|}{a}\\ \mathbf{elif}\;b \leq 3.4 \cdot 10^{-53}:\\ \;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -4\right)} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{-b}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 80.8% accurate, 1.0× speedup?

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

\mathbf{elif}\;b \leq 4.3 \cdot 10^{-52}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \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 < -2.49999999999999982e-40

    1. Initial program 70.9%

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

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

      \[\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{b}{a}} \]
    6. Step-by-step derivation
      1. mul-1-neg87.5%

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

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

    if -2.49999999999999982e-40 < b < 4.3000000000000003e-52

    1. Initial program 77.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. *-commutative77.8%

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

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

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

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

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

    if 4.3000000000000003e-52 < b

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

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

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

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

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

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

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

Alternative 4: 70.1% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 72.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. *-commutative72.0%

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

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

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

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

    if -3.00000000000000016e-55 < b < 1.15e-63

    1. Initial program 77.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.15e-63 < b

    1. Initial program 19.8%

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

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

      \[\leadsto \color{blue}{\frac{\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 85.3%

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

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

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

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

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

Alternative 5: 67.6% accurate, 12.9× speedup?

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

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

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


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

    1. Initial program 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. Taylor expanded in b around -inf 63.9%

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

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

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

    if -1.000000000000002e-309 < b

    1. Initial program 32.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. *-commutative32.5%

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

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

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

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

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

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

Alternative 6: 43.1% accurate, 12.9× speedup?

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

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

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


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

    1. Initial program 67.9%

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

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

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

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

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

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

    if 5.40000000000000007e48 < b

    1. Initial program 13.9%

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

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

      \[\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 a around 0 39.8%

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

        \[\leadsto \frac{\left(-b\right) + \left(b + -2 \cdot \color{blue}{\frac{-a \cdot c}{-b}}\right)}{a \cdot 2} \]
      2. div-inv39.8%

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

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

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

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

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

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

      \[\leadsto \frac{\left(-b\right) + \left(b + -2 \cdot \color{blue}{\left(\left(-a \cdot c\right) \cdot \frac{1}{b}\right)}\right)}{a \cdot 2} \]
    8. Step-by-step derivation
      1. distribute-lft-neg-out38.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-b\right) + \left(b + -2 \cdot \frac{a \cdot \color{blue}{\left(-1 \cdot c\right)}}{1 \cdot b}\right)}{a \cdot 2} \]
      16. times-frac38.9%

        \[\leadsto \frac{\left(-b\right) + \left(b + -2 \cdot \color{blue}{\left(\frac{a}{1} \cdot \frac{-1 \cdot c}{b}\right)}\right)}{a \cdot 2} \]
      17. /-rgt-identity38.9%

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

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

      \[\leadsto \frac{\left(-b\right) + \left(b + -2 \cdot \color{blue}{\left(a \cdot \frac{-c}{b}\right)}\right)}{a \cdot 2} \]
    10. Taylor expanded in b around 0 37.9%

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

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

Alternative 7: 11.0% accurate, 38.7× speedup?

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

\\
\frac{c}{b}
\end{array}
Derivation
  1. Initial program 53.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. *-commutative53.6%

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\left(-b\right) + \left(b + -2 \cdot \color{blue}{\left(\left(-a \cdot c\right) \cdot \frac{1}{b}\right)}\right)}{a \cdot 2} \]
  8. Step-by-step derivation
    1. distribute-lft-neg-out12.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\left(-b\right) + \left(b + -2 \cdot \color{blue}{\left(\frac{a}{1} \cdot \frac{-1 \cdot c}{b}\right)}\right)}{a \cdot 2} \]
    17. /-rgt-identity12.5%

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

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

    \[\leadsto \frac{\left(-b\right) + \left(b + -2 \cdot \color{blue}{\left(a \cdot \frac{-c}{b}\right)}\right)}{a \cdot 2} \]
  10. Taylor expanded in b around 0 12.3%

    \[\leadsto \color{blue}{\frac{c}{b}} \]
  11. 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 53.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. *-commutative53.6%

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

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

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

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

      \[\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. *-commutative53.6%

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

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

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

      \[\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. +-commutative53.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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+36.1%

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

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

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

    \[\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. Add Preprocessing

Reproduce

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