The quadratic formula (r1)

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

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

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

Alternative 1: 85.8% accurate, 0.9× speedup?

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

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

\mathbf{elif}\;b \leq 6.5 \cdot 10^{-81}:\\
\;\;\;\;\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 < -9.9999999999999994e104

    1. Initial program 59.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. *-commutative59.5%

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

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

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

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

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

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

    if -9.9999999999999994e104 < b < 6.5000000000000002e-81

    1. Initial program 79.7%

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

    if 6.5000000000000002e-81 < b

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -1 \cdot 10^{+105}:\\ \;\;\;\;\frac{b}{-a}\\ \mathbf{elif}\;b \leq 6.5 \cdot 10^{-81}:\\ \;\;\;\;\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.4% accurate, 1.0× speedup?

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

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

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

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


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

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

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

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

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

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

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

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

    if -2.59999999999999999e-7 < b < 3.6999999999999999e-84

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

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

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

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

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

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

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

    if 3.6999999999999999e-84 < b

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

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

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

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

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

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

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

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

Alternative 3: 80.3% accurate, 1.0× speedup?

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

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

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

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


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

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

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

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

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

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

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

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

    if -1.5e-6 < b < 3.14999999999999983e-80

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{{\left({\left(a \cdot \left(c \cdot -4\right)\right)}^{0.25}\right)}^{2}} - b}{a \cdot 2} \]
    10. Step-by-step derivation
      1. frac-2neg64.7%

        \[\leadsto \color{blue}{\frac{-\left({\left({\left(a \cdot \left(c \cdot -4\right)\right)}^{0.25}\right)}^{2} - b\right)}{-a \cdot 2}} \]
      2. div-inv64.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.14999999999999983e-80 < b

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

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

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

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

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

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

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

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

Alternative 4: 72.1% accurate, 1.0× speedup?

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

\mathbf{elif}\;b \leq 9.5 \cdot 10^{-106}:\\
\;\;\;\;-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 < -6.59999999999999961e-127

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

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

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

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

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

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

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

    if -6.59999999999999961e-127 < b < 9.4999999999999994e-106

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

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

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

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

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

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

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

    if 9.4999999999999994e-106 < b

    1. Initial program 20.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. *-commutative20.9%

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

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

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

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

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

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

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

Alternative 5: 67.9% accurate, 12.9× speedup?

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

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

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


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

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

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

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

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

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

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

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

    if 8.0000000000000001e-264 < b

    1. Initial program 29.0%

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

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

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

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

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

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

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

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

Alternative 6: 43.9% accurate, 12.9× speedup?

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

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

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


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

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

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

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

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

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

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

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

    if 1.28e13 < b

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 12800000000000:\\ \;\;\;\;\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 51.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. *-commutative51.3%

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{c}{b}} \]
  9. 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 51.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. *-commutative51.3%

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

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

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

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

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

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

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

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

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

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

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


\end{array}
\end{array}

Reproduce

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

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

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