Quadratic roots, full range

Percentage Accurate: 51.4% → 84.7%
Time: 12.1s
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: 51.4% 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: 84.7% accurate, 0.9× speedup?

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

\mathbf{elif}\;b \leq 2.2 \cdot 10^{-50}:\\
\;\;\;\;\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 < -6.5000000000000004e31

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

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

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

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

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

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

    if -6.5000000000000004e31 < b < 2.1999999999999999e-50

    1. Initial program 74.2%

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

    if 2.1999999999999999e-50 < b

    1. Initial program 15.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. *-commutative15.8%

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

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

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

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

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

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

Alternative 2: 80.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -2.05 \cdot 10^{-64}:\\ \;\;\;\;\frac{b}{-a}\\ \mathbf{elif}\;b \leq 1.2 \cdot 10^{-49}:\\ \;\;\;\;\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.05e-64)
   (/ b (- a))
   (if (<= b 1.2e-49)
     (/ (- (sqrt (* a (* c -4.0))) b) (* a 2.0))
     (/ c (- b)))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -2.05e-64) {
		tmp = b / -a;
	} else if (b <= 1.2e-49) {
		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.05d-64)) then
        tmp = b / -a
    else if (b <= 1.2d-49) 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.05e-64) {
		tmp = b / -a;
	} else if (b <= 1.2e-49) {
		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.05e-64:
		tmp = b / -a
	elif b <= 1.2e-49:
		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.05e-64)
		tmp = Float64(b / Float64(-a));
	elseif (b <= 1.2e-49)
		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.05e-64)
		tmp = b / -a;
	elseif (b <= 1.2e-49)
		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.05e-64], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 1.2e-49], 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.05 \cdot 10^{-64}:\\
\;\;\;\;\frac{b}{-a}\\

\mathbf{elif}\;b \leq 1.2 \cdot 10^{-49}:\\
\;\;\;\;\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.05e-64

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

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

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

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

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

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

    if -2.05e-64 < b < 1.19999999999999996e-49

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

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

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

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

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

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

    if 1.19999999999999996e-49 < b

    1. Initial program 15.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. *-commutative15.8%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -2.05 \cdot 10^{-64}:\\ \;\;\;\;\frac{b}{-a}\\ \mathbf{elif}\;b \leq 1.2 \cdot 10^{-49}:\\ \;\;\;\;\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: 79.7% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 80.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. *-commutative80.4%

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

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

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

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

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

    if -1.05000000000000004e-139 < b < 2.1499999999999999e-51

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.1499999999999999e-51 < b

    1. Initial program 15.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. *-commutative15.8%

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

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

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

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

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

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

Alternative 4: 72.0% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 80.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. *-commutative80.4%

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

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

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

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

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

    if -1.05000000000000004e-139 < b < 5.50000000000000054e-175

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{a \cdot 2}} \]
    3. Simplified77.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. Step-by-step derivation
      1. add-cube-cbrt76.7%

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

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

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

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

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

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

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

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

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

    if 5.50000000000000054e-175 < b

    1. Initial program 22.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. *-commutative22.4%

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

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

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

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

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

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

Alternative 5: 68.1% accurate, 12.9× speedup?

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

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

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


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

    1. Initial program 80.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. *-commutative80.0%

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

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

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

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

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

    if -1.999999999999994e-310 < b

    1. Initial program 29.2%

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

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

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

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

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

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

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

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

Alternative 6: 42.2% accurate, 12.9× speedup?

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

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

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


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

    1. Initial program 71.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. *-commutative71.6%

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

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

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

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

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

    if 6.19999999999999977e72 < b

    1. Initial program 8.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. *-commutative8.6%

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{\left(-2 \cdot a\right) \cdot c}}{b}}{a \cdot 2} \]
      3. *-commutative77.6%

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

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

      \[\leadsto \frac{\color{blue}{\frac{a \cdot -2}{b} \cdot c}}{a \cdot 2} \]
    8. Step-by-step derivation
      1. associate-/l*71.1%

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

      \[\leadsto \color{blue}{\frac{a \cdot -2}{b} \cdot \frac{c}{a \cdot 2}} \]
    10. Step-by-step derivation
      1. clear-num71.0%

        \[\leadsto \frac{a \cdot -2}{b} \cdot \color{blue}{\frac{1}{\frac{a \cdot 2}{c}}} \]
      2. un-div-inv71.0%

        \[\leadsto \color{blue}{\frac{\frac{a \cdot -2}{b}}{\frac{a \cdot 2}{c}}} \]
      3. associate-/l*71.1%

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

        \[\leadsto \frac{a \cdot \color{blue}{\frac{--2}{-b}}}{\frac{a \cdot 2}{c}} \]
      5. metadata-eval71.1%

        \[\leadsto \frac{a \cdot \frac{\color{blue}{2}}{-b}}{\frac{a \cdot 2}{c}} \]
      6. add-sqr-sqrt0.0%

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

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

        \[\leadsto \frac{a \cdot \frac{2}{\sqrt{\color{blue}{b \cdot b}}}}{\frac{a \cdot 2}{c}} \]
      9. sqrt-prod24.5%

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

        \[\leadsto \frac{a \cdot \frac{2}{\color{blue}{b}}}{\frac{a \cdot 2}{c}} \]
      11. *-commutative24.5%

        \[\leadsto \frac{a \cdot \frac{2}{b}}{\frac{\color{blue}{2 \cdot a}}{c}} \]
      12. *-un-lft-identity24.5%

        \[\leadsto \frac{a \cdot \frac{2}{b}}{\frac{2 \cdot a}{\color{blue}{1 \cdot c}}} \]
      13. times-frac24.5%

        \[\leadsto \frac{a \cdot \frac{2}{b}}{\color{blue}{\frac{2}{1} \cdot \frac{a}{c}}} \]
      14. metadata-eval24.5%

        \[\leadsto \frac{a \cdot \frac{2}{b}}{\color{blue}{2} \cdot \frac{a}{c}} \]
    11. Applied egg-rr24.5%

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

        \[\leadsto \frac{\color{blue}{\frac{a \cdot 2}{b}}}{2 \cdot \frac{a}{c}} \]
      2. metadata-eval24.5%

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

        \[\leadsto \frac{\frac{\color{blue}{-a \cdot -2}}{b}}{2 \cdot \frac{a}{c}} \]
      4. associate-/r*24.8%

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

        \[\leadsto \frac{\color{blue}{a \cdot \left(--2\right)}}{b \cdot \left(2 \cdot \frac{a}{c}\right)} \]
      6. metadata-eval24.8%

        \[\leadsto \frac{a \cdot \color{blue}{2}}{b \cdot \left(2 \cdot \frac{a}{c}\right)} \]
    13. Simplified24.8%

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

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

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

Alternative 7: 10.9% 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.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. *-commutative55.4%

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

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

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

      \[\leadsto \frac{\frac{\color{blue}{\left(-2 \cdot a\right) \cdot c}}{b}}{a \cdot 2} \]
    3. *-commutative27.0%

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

      \[\leadsto \frac{\color{blue}{\frac{a \cdot -2}{b} \cdot c}}{a \cdot 2} \]
  7. Simplified26.8%

    \[\leadsto \frac{\color{blue}{\frac{a \cdot -2}{b} \cdot c}}{a \cdot 2} \]
  8. Step-by-step derivation
    1. associate-/l*26.4%

      \[\leadsto \color{blue}{\frac{a \cdot -2}{b} \cdot \frac{c}{a \cdot 2}} \]
  9. Applied egg-rr26.4%

    \[\leadsto \color{blue}{\frac{a \cdot -2}{b} \cdot \frac{c}{a \cdot 2}} \]
  10. Step-by-step derivation
    1. clear-num26.3%

      \[\leadsto \frac{a \cdot -2}{b} \cdot \color{blue}{\frac{1}{\frac{a \cdot 2}{c}}} \]
    2. un-div-inv26.3%

      \[\leadsto \color{blue}{\frac{\frac{a \cdot -2}{b}}{\frac{a \cdot 2}{c}}} \]
    3. associate-/l*26.3%

      \[\leadsto \frac{\color{blue}{a \cdot \frac{-2}{b}}}{\frac{a \cdot 2}{c}} \]
    4. frac-2neg26.3%

      \[\leadsto \frac{a \cdot \color{blue}{\frac{--2}{-b}}}{\frac{a \cdot 2}{c}} \]
    5. metadata-eval26.3%

      \[\leadsto \frac{a \cdot \frac{\color{blue}{2}}{-b}}{\frac{a \cdot 2}{c}} \]
    6. add-sqr-sqrt1.0%

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

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

      \[\leadsto \frac{a \cdot \frac{2}{\sqrt{\color{blue}{b \cdot b}}}}{\frac{a \cdot 2}{c}} \]
    9. sqrt-prod6.6%

      \[\leadsto \frac{a \cdot \frac{2}{\color{blue}{\sqrt{b} \cdot \sqrt{b}}}}{\frac{a \cdot 2}{c}} \]
    10. add-sqr-sqrt8.2%

      \[\leadsto \frac{a \cdot \frac{2}{\color{blue}{b}}}{\frac{a \cdot 2}{c}} \]
    11. *-commutative8.2%

      \[\leadsto \frac{a \cdot \frac{2}{b}}{\frac{\color{blue}{2 \cdot a}}{c}} \]
    12. *-un-lft-identity8.2%

      \[\leadsto \frac{a \cdot \frac{2}{b}}{\frac{2 \cdot a}{\color{blue}{1 \cdot c}}} \]
    13. times-frac8.2%

      \[\leadsto \frac{a \cdot \frac{2}{b}}{\color{blue}{\frac{2}{1} \cdot \frac{a}{c}}} \]
    14. metadata-eval8.2%

      \[\leadsto \frac{a \cdot \frac{2}{b}}{\color{blue}{2} \cdot \frac{a}{c}} \]
  11. Applied egg-rr8.2%

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

      \[\leadsto \frac{\color{blue}{\frac{a \cdot 2}{b}}}{2 \cdot \frac{a}{c}} \]
    2. metadata-eval8.2%

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

      \[\leadsto \frac{\frac{\color{blue}{-a \cdot -2}}{b}}{2 \cdot \frac{a}{c}} \]
    4. associate-/r*10.9%

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

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

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

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

    \[\leadsto \color{blue}{\frac{c}{b}} \]
  15. 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 55.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. *-commutative55.4%

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

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

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

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

    \[\leadsto \color{blue}{\frac{-b}{a}} \]
  8. Step-by-step derivation
    1. div-inv36.1%

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

      \[\leadsto \color{blue}{\left(\sqrt{-b} \cdot \sqrt{-b}\right)} \cdot \frac{1}{a} \]
    3. sqrt-unprod30.0%

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

      \[\leadsto \sqrt{\color{blue}{b \cdot b}} \cdot \frac{1}{a} \]
    5. sqrt-prod1.8%

      \[\leadsto \color{blue}{\left(\sqrt{b} \cdot \sqrt{b}\right)} \cdot \frac{1}{a} \]
    6. add-sqr-sqrt2.6%

      \[\leadsto \color{blue}{b} \cdot \frac{1}{a} \]
  9. Applied egg-rr2.6%

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

      \[\leadsto \color{blue}{\frac{b \cdot 1}{a}} \]
    2. *-rgt-identity2.6%

      \[\leadsto \frac{\color{blue}{b}}{a} \]
  11. Simplified2.6%

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

Reproduce

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