quadp (p42, positive)

Percentage Accurate: 57.4% → 91.9%
Time: 30.4s
Alternatives: 7
Speedup: 19.1×

Specification

?
\[\begin{array}{l} \\ \frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{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(4.0 * Float64(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[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{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 7 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: 57.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{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(4.0 * Float64(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[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Alternative 1: 91.9% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
t_0 := c \cdot \left(a \cdot 4\right)\\
t_1 := \sqrt{b \cdot b - t_0}\\
\mathbf{if}\;b \leq -2 \cdot 10^{+154}:\\
\;\;\;\;\frac{-b}{a}\\

\mathbf{elif}\;b \leq 1.65 \cdot 10^{-209}:\\
\;\;\;\;\frac{t_1 - b}{a \cdot 2}\\

\mathbf{elif}\;b \leq 1.95 \cdot 10^{-16}:\\
\;\;\;\;\frac{\frac{t_0 + \left(b \cdot b - b \cdot b\right)}{\left(-b\right) - t_1}}{a \cdot 2}\\

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


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

    1. Initial program 54.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-b}}{a} \]
    6. Simplified100.0%

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

    if -2.00000000000000007e154 < b < 1.64999999999999987e-209

    1. Initial program 91.9%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a} \]
    2. Taylor expanded in a around 0 91.9%

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.64999999999999987e-209 < b < 1.94999999999999989e-16

    1. Initial program 51.8%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a} \]
    2. Taylor expanded in a around 0 51.8%

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

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

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

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

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

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

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

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

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

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

    if 1.94999999999999989e-16 < b

    1. Initial program 10.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}} \]
    5. Step-by-step derivation
      1. mul-1-neg98.7%

        \[\leadsto \color{blue}{-\frac{c}{b}} \]
      2. distribute-neg-frac98.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -2 \cdot 10^{+154}:\\ \;\;\;\;\frac{-b}{a}\\ \mathbf{elif}\;b \leq 1.65 \cdot 10^{-209}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\ \mathbf{elif}\;b \leq 1.95 \cdot 10^{-16}:\\ \;\;\;\;\frac{\frac{c \cdot \left(a \cdot 4\right) + \left(b \cdot b - b \cdot b\right)}{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}}}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array} \]

Alternative 2: 91.2% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 54.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-b}}{a} \]
    6. Simplified100.0%

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

    if -2.00000000000000007e154 < b < 2.75000000000000016e-108

    1. Initial program 88.1%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a} \]
    2. Taylor expanded in a around 0 88.1%

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.75000000000000016e-108 < b

    1. Initial program 19.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-\frac{c}{b}} \]
      2. distribute-neg-frac88.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -2 \cdot 10^{+154}:\\ \;\;\;\;\frac{-b}{a}\\ \mathbf{elif}\;b \leq 2.75 \cdot 10^{-108}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array} \]

Alternative 3: 77.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -4 \cdot 10^{-310}:\\ \;\;\;\;\frac{\mathsf{fma}\left(2, \frac{c}{\frac{b}{a}}, b \cdot -2\right)}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b -4e-310)
   (/ (fma 2.0 (/ c (/ b a)) (* b -2.0)) (* a 2.0))
   (/ (- c) b)))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -4e-310) {
		tmp = fma(2.0, (c / (b / a)), (b * -2.0)) / (a * 2.0);
	} else {
		tmp = -c / b;
	}
	return tmp;
}
function code(a, b, c)
	tmp = 0.0
	if (b <= -4e-310)
		tmp = Float64(fma(2.0, Float64(c / Float64(b / a)), Float64(b * -2.0)) / Float64(a * 2.0));
	else
		tmp = Float64(Float64(-c) / b);
	end
	return tmp
end
code[a_, b_, c_] := If[LessEqual[b, -4e-310], N[(N[(2.0 * N[(c / N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(b * -2.0), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\frac{\mathsf{fma}\left(2, \frac{c}{\frac{b}{a}}, b \cdot -2\right)}{a \cdot 2}\\

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


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

    1. Initial program 80.2%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a} \]
    2. Taylor expanded in a around 0 80.2%

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(2, \color{blue}{\frac{c}{\frac{b}{a}}}, -2 \cdot b\right)}{2 \cdot a} \]
      3. *-commutative79.7%

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

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

    if -3.999999999999988e-310 < b

    1. Initial program 32.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}} \]
    5. Step-by-step derivation
      1. mul-1-neg72.2%

        \[\leadsto \color{blue}{-\frac{c}{b}} \]
      2. distribute-neg-frac72.2%

        \[\leadsto \color{blue}{\frac{-c}{b}} \]
    6. Simplified72.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -4 \cdot 10^{-310}:\\ \;\;\;\;\frac{\mathsf{fma}\left(2, \frac{c}{\frac{b}{a}}, b \cdot -2\right)}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array} \]

Alternative 4: 77.4% accurate, 12.8× speedup?

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

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

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


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

    1. Initial program 80.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.999999999999988e-310 < b

    1. Initial program 32.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}} \]
    5. Step-by-step derivation
      1. mul-1-neg72.2%

        \[\leadsto \color{blue}{-\frac{c}{b}} \]
      2. distribute-neg-frac72.2%

        \[\leadsto \color{blue}{\frac{-c}{b}} \]
    6. Simplified72.2%

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

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

Alternative 5: 77.2% accurate, 19.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -4 \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 < -3.999999999999988e-310

    1. Initial program 80.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-b}}{a} \]
    6. Simplified79.3%

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

    if -3.999999999999988e-310 < b

    1. Initial program 32.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}} \]
    5. Step-by-step derivation
      1. mul-1-neg72.2%

        \[\leadsto \color{blue}{-\frac{c}{b}} \]
      2. distribute-neg-frac72.2%

        \[\leadsto \color{blue}{\frac{-c}{b}} \]
    6. Simplified72.2%

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

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

Alternative 6: 39.3% accurate, 29.0× 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(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 56.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 1.9% 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 56.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -4\right)}\right) + \left(b + \left(\color{blue}{b} + b\right)\right)\right) \cdot \frac{0.5}{a} \]
  7. Simplified23.8%

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

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

    \[\leadsto \frac{b}{a} \]

Developer target: 79.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\\ \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(4.0 * Float64(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[(4.0 * N[(a * c), $MachinePrecision]), $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 - 4 \cdot \left(a \cdot c\right)}\\
\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 2023278 
(FPCore (a b c)
  :name "quadp (p42, positive)"
  :precision binary64

  :herbie-target
  (if (< b 0.0) (/ (+ (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)) (/ c (* a (/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))))

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