quad2p (problem 3.2.1, positive)

Percentage Accurate: 52.4% → 85.6%
Time: 10.7s
Alternatives: 10
Speedup: 15.9×

Specification

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

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

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

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

Alternative 1: 85.6% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -2 \cdot 10^{+112}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \leq 4.9 \cdot 10^{-51}:\\
\;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\\

\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b_2 < -1.9999999999999999e112

    1. Initial program 51.6%

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a} \]
    2. Step-by-step derivation
      1. +-commutative51.6%

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

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a} \]
    3. Simplified51.6%

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}} \]
    4. Taylor expanded in b_2 around -inf 95.1%

      \[\leadsto \color{blue}{-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}} \]

    if -1.9999999999999999e112 < b_2 < 4.89999999999999974e-51

    1. Initial program 83.0%

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

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} + \left(-b_2\right)}}{a} \]
      2. unsub-neg83.0%

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a} \]
    3. Simplified83.0%

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}} \]

    if 4.89999999999999974e-51 < b_2

    1. Initial program 13.7%

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

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

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a} \]
    3. Simplified13.7%

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}} \]
    4. Step-by-step derivation
      1. pow1/213.7%

        \[\leadsto \frac{\color{blue}{{\left(b_2 \cdot b_2 - a \cdot c\right)}^{0.5}} - b_2}{a} \]
      2. pow-to-exp11.6%

        \[\leadsto \frac{\color{blue}{e^{\log \left(b_2 \cdot b_2 - a \cdot c\right) \cdot 0.5}} - b_2}{a} \]
      3. fma-neg11.6%

        \[\leadsto \frac{e^{\log \color{blue}{\left(\mathsf{fma}\left(b_2, b_2, -a \cdot c\right)\right)} \cdot 0.5} - b_2}{a} \]
      4. *-commutative11.6%

        \[\leadsto \frac{e^{\log \left(\mathsf{fma}\left(b_2, b_2, -\color{blue}{c \cdot a}\right)\right) \cdot 0.5} - b_2}{a} \]
      5. distribute-rgt-neg-in11.6%

        \[\leadsto \frac{e^{\log \left(\mathsf{fma}\left(b_2, b_2, \color{blue}{c \cdot \left(-a\right)}\right)\right) \cdot 0.5} - b_2}{a} \]
    5. Applied egg-rr11.6%

      \[\leadsto \frac{\color{blue}{e^{\log \left(\mathsf{fma}\left(b_2, b_2, c \cdot \left(-a\right)\right)\right) \cdot 0.5}} - b_2}{a} \]
    6. Taylor expanded in b_2 around inf 81.1%

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b_2}} \]
    7. Step-by-step derivation
      1. associate-*r/81.1%

        \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b_2}} \]
    8. Simplified81.1%

      \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b_2}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification85.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -2 \cdot 10^{+112}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \leq 4.9 \cdot 10^{-51}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b_2}\\ \end{array} \]

Alternative 2: 80.5% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -1.42 \cdot 10^{-18}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \leq 4.7 \cdot 10^{-49}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(-a\right)} - b_2}{a}\\

\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b_2 < -1.41999999999999996e-18

    1. Initial program 64.8%

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

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

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a} \]
    3. Simplified64.8%

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}} \]
    4. Taylor expanded in b_2 around -inf 90.0%

      \[\leadsto \color{blue}{-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}} \]

    if -1.41999999999999996e-18 < b_2 < 4.70000000000000021e-49

    1. Initial program 80.2%

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

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

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a} \]
    3. Simplified80.2%

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}} \]
    4. Taylor expanded in b_2 around 0 72.6%

      \[\leadsto \frac{\sqrt{\color{blue}{-1 \cdot \left(a \cdot c\right)}} - b_2}{a} \]
    5. Step-by-step derivation
      1. associate-*r*72.6%

        \[\leadsto \frac{\sqrt{\color{blue}{\left(-1 \cdot a\right) \cdot c}} - b_2}{a} \]
      2. neg-mul-172.6%

        \[\leadsto \frac{\sqrt{\color{blue}{\left(-a\right)} \cdot c} - b_2}{a} \]
      3. *-commutative72.6%

        \[\leadsto \frac{\sqrt{\color{blue}{c \cdot \left(-a\right)}} - b_2}{a} \]
    6. Simplified72.6%

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

    if 4.70000000000000021e-49 < b_2

    1. Initial program 13.7%

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

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

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a} \]
    3. Simplified13.7%

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}} \]
    4. Step-by-step derivation
      1. pow1/213.7%

        \[\leadsto \frac{\color{blue}{{\left(b_2 \cdot b_2 - a \cdot c\right)}^{0.5}} - b_2}{a} \]
      2. pow-to-exp11.6%

        \[\leadsto \frac{\color{blue}{e^{\log \left(b_2 \cdot b_2 - a \cdot c\right) \cdot 0.5}} - b_2}{a} \]
      3. fma-neg11.6%

        \[\leadsto \frac{e^{\log \color{blue}{\left(\mathsf{fma}\left(b_2, b_2, -a \cdot c\right)\right)} \cdot 0.5} - b_2}{a} \]
      4. *-commutative11.6%

        \[\leadsto \frac{e^{\log \left(\mathsf{fma}\left(b_2, b_2, -\color{blue}{c \cdot a}\right)\right) \cdot 0.5} - b_2}{a} \]
      5. distribute-rgt-neg-in11.6%

        \[\leadsto \frac{e^{\log \left(\mathsf{fma}\left(b_2, b_2, \color{blue}{c \cdot \left(-a\right)}\right)\right) \cdot 0.5} - b_2}{a} \]
    5. Applied egg-rr11.6%

      \[\leadsto \frac{\color{blue}{e^{\log \left(\mathsf{fma}\left(b_2, b_2, c \cdot \left(-a\right)\right)\right) \cdot 0.5}} - b_2}{a} \]
    6. Taylor expanded in b_2 around inf 81.1%

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b_2}} \]
    7. Step-by-step derivation
      1. associate-*r/81.1%

        \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b_2}} \]
    8. Simplified81.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -1.42 \cdot 10^{-18}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \leq 4.7 \cdot 10^{-49}:\\ \;\;\;\;\frac{\sqrt{c \cdot \left(-a\right)} - b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b_2}\\ \end{array} \]

Alternative 3: 79.1% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -1.5 \cdot 10^{-18}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \leq 1.08 \cdot 10^{-10}:\\
\;\;\;\;\frac{\sqrt{a \cdot \frac{c}{-1}}}{a}\\

\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b_2 < -1.49999999999999991e-18

    1. Initial program 64.8%

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

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

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a} \]
    3. Simplified64.8%

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}} \]
    4. Taylor expanded in b_2 around -inf 90.0%

      \[\leadsto \color{blue}{-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}} \]

    if -1.49999999999999991e-18 < b_2 < 1.08000000000000002e-10

    1. Initial program 77.8%

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

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} + \left(-b_2\right)}}{a} \]
      2. unsub-neg77.8%

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a} \]
    3. Simplified77.8%

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}} \]
    4. Step-by-step derivation
      1. pow1/277.8%

        \[\leadsto \frac{\color{blue}{{\left(b_2 \cdot b_2 - a \cdot c\right)}^{0.5}} - b_2}{a} \]
      2. pow-to-exp73.3%

        \[\leadsto \frac{\color{blue}{e^{\log \left(b_2 \cdot b_2 - a \cdot c\right) \cdot 0.5}} - b_2}{a} \]
      3. fma-neg73.3%

        \[\leadsto \frac{e^{\log \color{blue}{\left(\mathsf{fma}\left(b_2, b_2, -a \cdot c\right)\right)} \cdot 0.5} - b_2}{a} \]
      4. *-commutative73.3%

        \[\leadsto \frac{e^{\log \left(\mathsf{fma}\left(b_2, b_2, -\color{blue}{c \cdot a}\right)\right) \cdot 0.5} - b_2}{a} \]
      5. distribute-rgt-neg-in73.3%

        \[\leadsto \frac{e^{\log \left(\mathsf{fma}\left(b_2, b_2, \color{blue}{c \cdot \left(-a\right)}\right)\right) \cdot 0.5} - b_2}{a} \]
    5. Applied egg-rr73.3%

      \[\leadsto \frac{\color{blue}{e^{\log \left(\mathsf{fma}\left(b_2, b_2, c \cdot \left(-a\right)\right)\right) \cdot 0.5}} - b_2}{a} \]
    6. Taylor expanded in a around -inf 37.7%

      \[\leadsto \frac{e^{\color{blue}{\left(\log c + -1 \cdot \log \left(\frac{-1}{a}\right)\right)} \cdot 0.5} - b_2}{a} \]
    7. Step-by-step derivation
      1. mul-1-neg37.7%

        \[\leadsto \frac{e^{\left(\log c + \color{blue}{\left(-\log \left(\frac{-1}{a}\right)\right)}\right) \cdot 0.5} - b_2}{a} \]
      2. unsub-neg37.7%

        \[\leadsto \frac{e^{\color{blue}{\left(\log c - \log \left(\frac{-1}{a}\right)\right)} \cdot 0.5} - b_2}{a} \]
    8. Simplified37.7%

      \[\leadsto \frac{e^{\color{blue}{\left(\log c - \log \left(\frac{-1}{a}\right)\right)} \cdot 0.5} - b_2}{a} \]
    9. Taylor expanded in b_2 around 0 37.5%

      \[\leadsto \color{blue}{\frac{e^{0.5 \cdot \left(\log c - \log \left(\frac{-1}{a}\right)\right)}}{a}} \]
    10. Step-by-step derivation
      1. log-div65.6%

        \[\leadsto \frac{e^{0.5 \cdot \color{blue}{\log \left(\frac{c}{\frac{-1}{a}}\right)}}}{a} \]
      2. *-commutative65.6%

        \[\leadsto \frac{e^{\color{blue}{\log \left(\frac{c}{\frac{-1}{a}}\right) \cdot 0.5}}}{a} \]
      3. exp-to-pow69.6%

        \[\leadsto \frac{\color{blue}{{\left(\frac{c}{\frac{-1}{a}}\right)}^{0.5}}}{a} \]
      4. unpow1/269.6%

        \[\leadsto \frac{\color{blue}{\sqrt{\frac{c}{\frac{-1}{a}}}}}{a} \]
      5. associate-/r/69.7%

        \[\leadsto \frac{\sqrt{\color{blue}{\frac{c}{-1} \cdot a}}}{a} \]
      6. *-commutative69.7%

        \[\leadsto \frac{\sqrt{\color{blue}{a \cdot \frac{c}{-1}}}}{a} \]
    11. Simplified69.7%

      \[\leadsto \color{blue}{\frac{\sqrt{a \cdot \frac{c}{-1}}}{a}} \]

    if 1.08000000000000002e-10 < b_2

    1. Initial program 10.7%

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

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

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a} \]
    3. Simplified10.7%

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}} \]
    4. Step-by-step derivation
      1. pow1/210.7%

        \[\leadsto \frac{\color{blue}{{\left(b_2 \cdot b_2 - a \cdot c\right)}^{0.5}} - b_2}{a} \]
      2. pow-to-exp8.6%

        \[\leadsto \frac{\color{blue}{e^{\log \left(b_2 \cdot b_2 - a \cdot c\right) \cdot 0.5}} - b_2}{a} \]
      3. fma-neg8.6%

        \[\leadsto \frac{e^{\log \color{blue}{\left(\mathsf{fma}\left(b_2, b_2, -a \cdot c\right)\right)} \cdot 0.5} - b_2}{a} \]
      4. *-commutative8.6%

        \[\leadsto \frac{e^{\log \left(\mathsf{fma}\left(b_2, b_2, -\color{blue}{c \cdot a}\right)\right) \cdot 0.5} - b_2}{a} \]
      5. distribute-rgt-neg-in8.6%

        \[\leadsto \frac{e^{\log \left(\mathsf{fma}\left(b_2, b_2, \color{blue}{c \cdot \left(-a\right)}\right)\right) \cdot 0.5} - b_2}{a} \]
    5. Applied egg-rr8.6%

      \[\leadsto \frac{\color{blue}{e^{\log \left(\mathsf{fma}\left(b_2, b_2, c \cdot \left(-a\right)\right)\right) \cdot 0.5}} - b_2}{a} \]
    6. Taylor expanded in b_2 around inf 84.6%

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b_2}} \]
    7. Step-by-step derivation
      1. associate-*r/84.6%

        \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b_2}} \]
    8. Simplified84.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -1.5 \cdot 10^{-18}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \leq 1.08 \cdot 10^{-10}:\\ \;\;\;\;\frac{\sqrt{a \cdot \frac{c}{-1}}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b_2}\\ \end{array} \]

Alternative 4: 68.3% accurate, 7.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(\left(-\frac{c}{b_2} \cdot -0.5\right) - \frac{b_2}{a}\right) - \frac{b_2}{a}\\

\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\


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

    1. Initial program 70.6%

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

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

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a} \]
    3. Simplified70.6%

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}} \]
    4. Step-by-step derivation
      1. div-sub70.5%

        \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{a} - \frac{b_2}{a}} \]
      2. sub-neg70.5%

        \[\leadsto \frac{\sqrt{\color{blue}{b_2 \cdot b_2 + \left(-a \cdot c\right)}}}{a} - \frac{b_2}{a} \]
      3. add-sqr-sqrt52.7%

        \[\leadsto \frac{\sqrt{b_2 \cdot b_2 + \color{blue}{\sqrt{-a \cdot c} \cdot \sqrt{-a \cdot c}}}}{a} - \frac{b_2}{a} \]
      4. hypot-def63.0%

        \[\leadsto \frac{\color{blue}{\mathsf{hypot}\left(b_2, \sqrt{-a \cdot c}\right)}}{a} - \frac{b_2}{a} \]
      5. *-commutative63.0%

        \[\leadsto \frac{\mathsf{hypot}\left(b_2, \sqrt{-\color{blue}{c \cdot a}}\right)}{a} - \frac{b_2}{a} \]
      6. distribute-rgt-neg-in63.0%

        \[\leadsto \frac{\mathsf{hypot}\left(b_2, \sqrt{\color{blue}{c \cdot \left(-a\right)}}\right)}{a} - \frac{b_2}{a} \]
    5. Applied egg-rr63.0%

      \[\leadsto \color{blue}{\frac{\mathsf{hypot}\left(b_2, \sqrt{c \cdot \left(-a\right)}\right)}{a} - \frac{b_2}{a}} \]
    6. Taylor expanded in b_2 around -inf 0.0%

      \[\leadsto \color{blue}{\left(-1 \cdot \frac{b_2}{a} + -0.5 \cdot \frac{c \cdot {\left(\sqrt{-1}\right)}^{2}}{b_2}\right)} - \frac{b_2}{a} \]
    7. Step-by-step derivation
      1. neg-mul-10.0%

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

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

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

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

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

        \[\leadsto \left(-0.5 \cdot \frac{\color{blue}{-1} \cdot c}{b_2} - \frac{b_2}{a}\right) - \frac{b_2}{a} \]
      7. mul-1-neg67.6%

        \[\leadsto \left(-0.5 \cdot \frac{\color{blue}{-c}}{b_2} - \frac{b_2}{a}\right) - \frac{b_2}{a} \]
    8. Simplified67.6%

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

    if -4.999999999999985e-310 < b_2

    1. Initial program 39.8%

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

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} + \left(-b_2\right)}}{a} \]
      2. unsub-neg39.8%

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a} \]
    3. Simplified39.8%

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}} \]
    4. Step-by-step derivation
      1. pow1/239.8%

        \[\leadsto \frac{\color{blue}{{\left(b_2 \cdot b_2 - a \cdot c\right)}^{0.5}} - b_2}{a} \]
      2. pow-to-exp36.5%

        \[\leadsto \frac{\color{blue}{e^{\log \left(b_2 \cdot b_2 - a \cdot c\right) \cdot 0.5}} - b_2}{a} \]
      3. fma-neg36.5%

        \[\leadsto \frac{e^{\log \color{blue}{\left(\mathsf{fma}\left(b_2, b_2, -a \cdot c\right)\right)} \cdot 0.5} - b_2}{a} \]
      4. *-commutative36.5%

        \[\leadsto \frac{e^{\log \left(\mathsf{fma}\left(b_2, b_2, -\color{blue}{c \cdot a}\right)\right) \cdot 0.5} - b_2}{a} \]
      5. distribute-rgt-neg-in36.5%

        \[\leadsto \frac{e^{\log \left(\mathsf{fma}\left(b_2, b_2, \color{blue}{c \cdot \left(-a\right)}\right)\right) \cdot 0.5} - b_2}{a} \]
    5. Applied egg-rr36.5%

      \[\leadsto \frac{\color{blue}{e^{\log \left(\mathsf{fma}\left(b_2, b_2, c \cdot \left(-a\right)\right)\right) \cdot 0.5}} - b_2}{a} \]
    6. Taylor expanded in b_2 around inf 54.6%

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b_2}} \]
    7. Step-by-step derivation
      1. associate-*r/54.6%

        \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b_2}} \]
    8. Simplified54.6%

      \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b_2}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification61.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\left(\left(-\frac{c}{b_2} \cdot -0.5\right) - \frac{b_2}{a}\right) - \frac{b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b_2}\\ \end{array} \]

Alternative 5: 68.3% accurate, 8.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -5 \cdot 10^{-310}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\

\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\


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

    1. Initial program 70.6%

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

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

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a} \]
    3. Simplified70.6%

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}} \]
    4. Taylor expanded in b_2 around -inf 67.6%

      \[\leadsto \color{blue}{-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}} \]

    if -4.999999999999985e-310 < b_2

    1. Initial program 39.8%

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

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} + \left(-b_2\right)}}{a} \]
      2. unsub-neg39.8%

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a} \]
    3. Simplified39.8%

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}} \]
    4. Step-by-step derivation
      1. pow1/239.8%

        \[\leadsto \frac{\color{blue}{{\left(b_2 \cdot b_2 - a \cdot c\right)}^{0.5}} - b_2}{a} \]
      2. pow-to-exp36.5%

        \[\leadsto \frac{\color{blue}{e^{\log \left(b_2 \cdot b_2 - a \cdot c\right) \cdot 0.5}} - b_2}{a} \]
      3. fma-neg36.5%

        \[\leadsto \frac{e^{\log \color{blue}{\left(\mathsf{fma}\left(b_2, b_2, -a \cdot c\right)\right)} \cdot 0.5} - b_2}{a} \]
      4. *-commutative36.5%

        \[\leadsto \frac{e^{\log \left(\mathsf{fma}\left(b_2, b_2, -\color{blue}{c \cdot a}\right)\right) \cdot 0.5} - b_2}{a} \]
      5. distribute-rgt-neg-in36.5%

        \[\leadsto \frac{e^{\log \left(\mathsf{fma}\left(b_2, b_2, \color{blue}{c \cdot \left(-a\right)}\right)\right) \cdot 0.5} - b_2}{a} \]
    5. Applied egg-rr36.5%

      \[\leadsto \frac{\color{blue}{e^{\log \left(\mathsf{fma}\left(b_2, b_2, c \cdot \left(-a\right)\right)\right) \cdot 0.5}} - b_2}{a} \]
    6. Taylor expanded in b_2 around inf 54.6%

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b_2}} \]
    7. Step-by-step derivation
      1. associate-*r/54.6%

        \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b_2}} \]
    8. Simplified54.6%

      \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b_2}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification61.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -5 \cdot 10^{-310}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b_2}\\ \end{array} \]

Alternative 6: 44.3% accurate, 15.9× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;0\\


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

    1. Initial program 70.6%

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

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

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a} \]
    3. Simplified70.6%

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}} \]
    4. Taylor expanded in b_2 around -inf 67.4%

      \[\leadsto \color{blue}{-2 \cdot \frac{b_2}{a}} \]

    if -4.999999999999985e-310 < b_2

    1. Initial program 39.8%

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

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} + \left(-b_2\right)}}{a} \]
      2. unsub-neg39.8%

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a} \]
    3. Simplified39.8%

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}} \]
    4. Step-by-step derivation
      1. add-sqr-sqrt39.5%

        \[\leadsto \frac{\color{blue}{\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}} \cdot \sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}} - b_2}{a} \]
      2. pow239.5%

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

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

        \[\leadsto \frac{{\color{blue}{\left({\left(b_2 \cdot b_2 - a \cdot c\right)}^{\left(\frac{0.5}{2}\right)}\right)}}^{2} - b_2}{a} \]
      5. fma-neg39.6%

        \[\leadsto \frac{{\left({\color{blue}{\left(\mathsf{fma}\left(b_2, b_2, -a \cdot c\right)\right)}}^{\left(\frac{0.5}{2}\right)}\right)}^{2} - b_2}{a} \]
      6. *-commutative39.6%

        \[\leadsto \frac{{\left({\left(\mathsf{fma}\left(b_2, b_2, -\color{blue}{c \cdot a}\right)\right)}^{\left(\frac{0.5}{2}\right)}\right)}^{2} - b_2}{a} \]
      7. distribute-rgt-neg-in39.6%

        \[\leadsto \frac{{\left({\left(\mathsf{fma}\left(b_2, b_2, \color{blue}{c \cdot \left(-a\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)}\right)}^{2} - b_2}{a} \]
      8. metadata-eval39.6%

        \[\leadsto \frac{{\left({\left(\mathsf{fma}\left(b_2, b_2, c \cdot \left(-a\right)\right)\right)}^{\color{blue}{0.25}}\right)}^{2} - b_2}{a} \]
    5. Applied egg-rr39.6%

      \[\leadsto \frac{\color{blue}{{\left({\left(\mathsf{fma}\left(b_2, b_2, c \cdot \left(-a\right)\right)\right)}^{0.25}\right)}^{2}} - b_2}{a} \]
    6. Taylor expanded in b_2 around inf 12.5%

      \[\leadsto \color{blue}{-1 \cdot \frac{b_2}{a} + \left(-0.5 \cdot \frac{c}{b_2} + \frac{b_2}{a}\right)} \]
    7. Taylor expanded in a around 0 17.6%

      \[\leadsto \color{blue}{\frac{b_2 + -1 \cdot b_2}{a}} \]
    8. Step-by-step derivation
      1. distribute-rgt1-in17.6%

        \[\leadsto \frac{\color{blue}{\left(-1 + 1\right) \cdot b_2}}{a} \]
      2. metadata-eval17.6%

        \[\leadsto \frac{\color{blue}{0} \cdot b_2}{a} \]
      3. metadata-eval17.6%

        \[\leadsto \frac{\color{blue}{\log 1} \cdot b_2}{a} \]
      4. associate-*r/11.1%

        \[\leadsto \color{blue}{\log 1 \cdot \frac{b_2}{a}} \]
      5. metadata-eval11.1%

        \[\leadsto \color{blue}{0} \cdot \frac{b_2}{a} \]
      6. mul0-lft17.6%

        \[\leadsto \color{blue}{0} \]
    9. Simplified17.6%

      \[\leadsto \color{blue}{0} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification42.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -5 \cdot 10^{-310}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]

Alternative 7: 68.1% accurate, 15.9× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{c}{b_2} \cdot -0.5\\


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

    1. Initial program 70.6%

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

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

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a} \]
    3. Simplified70.6%

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}} \]
    4. Taylor expanded in b_2 around -inf 67.4%

      \[\leadsto \color{blue}{-2 \cdot \frac{b_2}{a}} \]

    if -4.999999999999985e-310 < b_2

    1. Initial program 39.8%

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

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} + \left(-b_2\right)}}{a} \]
      2. unsub-neg39.8%

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a} \]
    3. Simplified39.8%

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}} \]
    4. Taylor expanded in b_2 around inf 54.6%

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b_2}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification60.9%

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

Alternative 8: 68.1% accurate, 15.9× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\


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

    1. Initial program 70.6%

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

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

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a} \]
    3. Simplified70.6%

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}} \]
    4. Taylor expanded in b_2 around -inf 67.4%

      \[\leadsto \color{blue}{-2 \cdot \frac{b_2}{a}} \]

    if -4.999999999999985e-310 < b_2

    1. Initial program 39.8%

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

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} + \left(-b_2\right)}}{a} \]
      2. unsub-neg39.8%

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a} \]
    3. Simplified39.8%

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}} \]
    4. Step-by-step derivation
      1. pow1/239.8%

        \[\leadsto \frac{\color{blue}{{\left(b_2 \cdot b_2 - a \cdot c\right)}^{0.5}} - b_2}{a} \]
      2. pow-to-exp36.5%

        \[\leadsto \frac{\color{blue}{e^{\log \left(b_2 \cdot b_2 - a \cdot c\right) \cdot 0.5}} - b_2}{a} \]
      3. fma-neg36.5%

        \[\leadsto \frac{e^{\log \color{blue}{\left(\mathsf{fma}\left(b_2, b_2, -a \cdot c\right)\right)} \cdot 0.5} - b_2}{a} \]
      4. *-commutative36.5%

        \[\leadsto \frac{e^{\log \left(\mathsf{fma}\left(b_2, b_2, -\color{blue}{c \cdot a}\right)\right) \cdot 0.5} - b_2}{a} \]
      5. distribute-rgt-neg-in36.5%

        \[\leadsto \frac{e^{\log \left(\mathsf{fma}\left(b_2, b_2, \color{blue}{c \cdot \left(-a\right)}\right)\right) \cdot 0.5} - b_2}{a} \]
    5. Applied egg-rr36.5%

      \[\leadsto \frac{\color{blue}{e^{\log \left(\mathsf{fma}\left(b_2, b_2, c \cdot \left(-a\right)\right)\right) \cdot 0.5}} - b_2}{a} \]
    6. Taylor expanded in b_2 around inf 54.6%

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b_2}} \]
    7. Step-by-step derivation
      1. associate-*r/54.6%

        \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b_2}} \]
    8. Simplified54.6%

      \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b_2}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification60.9%

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

Alternative 9: 24.2% accurate, 18.5× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;0\\


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

    1. Initial program 70.6%

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

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

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a} \]
    3. Simplified70.6%

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}} \]
    4. Step-by-step derivation
      1. pow1/270.6%

        \[\leadsto \frac{\color{blue}{{\left(b_2 \cdot b_2 - a \cdot c\right)}^{0.5}} - b_2}{a} \]
      2. pow-to-exp67.7%

        \[\leadsto \frac{\color{blue}{e^{\log \left(b_2 \cdot b_2 - a \cdot c\right) \cdot 0.5}} - b_2}{a} \]
      3. fma-neg67.7%

        \[\leadsto \frac{e^{\log \color{blue}{\left(\mathsf{fma}\left(b_2, b_2, -a \cdot c\right)\right)} \cdot 0.5} - b_2}{a} \]
      4. *-commutative67.7%

        \[\leadsto \frac{e^{\log \left(\mathsf{fma}\left(b_2, b_2, -\color{blue}{c \cdot a}\right)\right) \cdot 0.5} - b_2}{a} \]
      5. distribute-rgt-neg-in67.7%

        \[\leadsto \frac{e^{\log \left(\mathsf{fma}\left(b_2, b_2, \color{blue}{c \cdot \left(-a\right)}\right)\right) \cdot 0.5} - b_2}{a} \]
    5. Applied egg-rr67.7%

      \[\leadsto \frac{\color{blue}{e^{\log \left(\mathsf{fma}\left(b_2, b_2, c \cdot \left(-a\right)\right)\right) \cdot 0.5}} - b_2}{a} \]
    6. Taylor expanded in a around -inf 22.2%

      \[\leadsto \frac{e^{\color{blue}{\left(\log c + -1 \cdot \log \left(\frac{-1}{a}\right)\right)} \cdot 0.5} - b_2}{a} \]
    7. Step-by-step derivation
      1. mul-1-neg22.2%

        \[\leadsto \frac{e^{\left(\log c + \color{blue}{\left(-\log \left(\frac{-1}{a}\right)\right)}\right) \cdot 0.5} - b_2}{a} \]
      2. unsub-neg22.2%

        \[\leadsto \frac{e^{\color{blue}{\left(\log c - \log \left(\frac{-1}{a}\right)\right)} \cdot 0.5} - b_2}{a} \]
    8. Simplified22.2%

      \[\leadsto \frac{e^{\color{blue}{\left(\log c - \log \left(\frac{-1}{a}\right)\right)} \cdot 0.5} - b_2}{a} \]
    9. Taylor expanded in b_2 around inf 28.5%

      \[\leadsto \color{blue}{-1 \cdot \frac{b_2}{a}} \]
    10. Step-by-step derivation
      1. neg-mul-128.5%

        \[\leadsto \color{blue}{-\frac{b_2}{a}} \]
      2. distribute-neg-frac28.5%

        \[\leadsto \color{blue}{\frac{-b_2}{a}} \]
    11. Simplified28.5%

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

    if -4.999999999999985e-310 < b_2

    1. Initial program 39.8%

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

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} + \left(-b_2\right)}}{a} \]
      2. unsub-neg39.8%

        \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a} \]
    3. Simplified39.8%

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}} \]
    4. Step-by-step derivation
      1. add-sqr-sqrt39.5%

        \[\leadsto \frac{\color{blue}{\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}} \cdot \sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}} - b_2}{a} \]
      2. pow239.5%

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

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

        \[\leadsto \frac{{\color{blue}{\left({\left(b_2 \cdot b_2 - a \cdot c\right)}^{\left(\frac{0.5}{2}\right)}\right)}}^{2} - b_2}{a} \]
      5. fma-neg39.6%

        \[\leadsto \frac{{\left({\color{blue}{\left(\mathsf{fma}\left(b_2, b_2, -a \cdot c\right)\right)}}^{\left(\frac{0.5}{2}\right)}\right)}^{2} - b_2}{a} \]
      6. *-commutative39.6%

        \[\leadsto \frac{{\left({\left(\mathsf{fma}\left(b_2, b_2, -\color{blue}{c \cdot a}\right)\right)}^{\left(\frac{0.5}{2}\right)}\right)}^{2} - b_2}{a} \]
      7. distribute-rgt-neg-in39.6%

        \[\leadsto \frac{{\left({\left(\mathsf{fma}\left(b_2, b_2, \color{blue}{c \cdot \left(-a\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)}\right)}^{2} - b_2}{a} \]
      8. metadata-eval39.6%

        \[\leadsto \frac{{\left({\left(\mathsf{fma}\left(b_2, b_2, c \cdot \left(-a\right)\right)\right)}^{\color{blue}{0.25}}\right)}^{2} - b_2}{a} \]
    5. Applied egg-rr39.6%

      \[\leadsto \frac{\color{blue}{{\left({\left(\mathsf{fma}\left(b_2, b_2, c \cdot \left(-a\right)\right)\right)}^{0.25}\right)}^{2}} - b_2}{a} \]
    6. Taylor expanded in b_2 around inf 12.5%

      \[\leadsto \color{blue}{-1 \cdot \frac{b_2}{a} + \left(-0.5 \cdot \frac{c}{b_2} + \frac{b_2}{a}\right)} \]
    7. Taylor expanded in a around 0 17.6%

      \[\leadsto \color{blue}{\frac{b_2 + -1 \cdot b_2}{a}} \]
    8. Step-by-step derivation
      1. distribute-rgt1-in17.6%

        \[\leadsto \frac{\color{blue}{\left(-1 + 1\right) \cdot b_2}}{a} \]
      2. metadata-eval17.6%

        \[\leadsto \frac{\color{blue}{0} \cdot b_2}{a} \]
      3. metadata-eval17.6%

        \[\leadsto \frac{\color{blue}{\log 1} \cdot b_2}{a} \]
      4. associate-*r/11.1%

        \[\leadsto \color{blue}{\log 1 \cdot \frac{b_2}{a}} \]
      5. metadata-eval11.1%

        \[\leadsto \color{blue}{0} \cdot \frac{b_2}{a} \]
      6. mul0-lft17.6%

        \[\leadsto \color{blue}{0} \]
    9. Simplified17.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\frac{-b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]

Alternative 10: 11.3% accurate, 112.0× speedup?

\[\begin{array}{l} \\ 0 \end{array} \]
(FPCore (a b_2 c) :precision binary64 0.0)
double code(double a, double b_2, double c) {
	return 0.0;
}
real(8) function code(a, b_2, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b_2
    real(8), intent (in) :: c
    code = 0.0d0
end function
public static double code(double a, double b_2, double c) {
	return 0.0;
}
def code(a, b_2, c):
	return 0.0
function code(a, b_2, c)
	return 0.0
end
function tmp = code(a, b_2, c)
	tmp = 0.0;
end
code[a_, b$95$2_, c_] := 0.0
\begin{array}{l}

\\
0
\end{array}
Derivation
  1. Initial program 54.9%

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

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

      \[\leadsto \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a} \]
  3. Simplified54.9%

    \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}} \]
  4. Step-by-step derivation
    1. add-sqr-sqrt54.7%

      \[\leadsto \frac{\color{blue}{\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}} \cdot \sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}} - b_2}{a} \]
    2. pow254.7%

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

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

      \[\leadsto \frac{{\color{blue}{\left({\left(b_2 \cdot b_2 - a \cdot c\right)}^{\left(\frac{0.5}{2}\right)}\right)}}^{2} - b_2}{a} \]
    5. fma-neg54.7%

      \[\leadsto \frac{{\left({\color{blue}{\left(\mathsf{fma}\left(b_2, b_2, -a \cdot c\right)\right)}}^{\left(\frac{0.5}{2}\right)}\right)}^{2} - b_2}{a} \]
    6. *-commutative54.7%

      \[\leadsto \frac{{\left({\left(\mathsf{fma}\left(b_2, b_2, -\color{blue}{c \cdot a}\right)\right)}^{\left(\frac{0.5}{2}\right)}\right)}^{2} - b_2}{a} \]
    7. distribute-rgt-neg-in54.7%

      \[\leadsto \frac{{\left({\left(\mathsf{fma}\left(b_2, b_2, \color{blue}{c \cdot \left(-a\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)}\right)}^{2} - b_2}{a} \]
    8. metadata-eval54.7%

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

    \[\leadsto \frac{\color{blue}{{\left({\left(\mathsf{fma}\left(b_2, b_2, c \cdot \left(-a\right)\right)\right)}^{0.25}\right)}^{2}} - b_2}{a} \]
  6. Taylor expanded in b_2 around inf 7.2%

    \[\leadsto \color{blue}{-1 \cdot \frac{b_2}{a} + \left(-0.5 \cdot \frac{c}{b_2} + \frac{b_2}{a}\right)} \]
  7. Taylor expanded in a around 0 10.3%

    \[\leadsto \color{blue}{\frac{b_2 + -1 \cdot b_2}{a}} \]
  8. Step-by-step derivation
    1. distribute-rgt1-in10.3%

      \[\leadsto \frac{\color{blue}{\left(-1 + 1\right) \cdot b_2}}{a} \]
    2. metadata-eval10.3%

      \[\leadsto \frac{\color{blue}{0} \cdot b_2}{a} \]
    3. metadata-eval10.3%

      \[\leadsto \frac{\color{blue}{\log 1} \cdot b_2}{a} \]
    4. associate-*r/6.8%

      \[\leadsto \color{blue}{\log 1 \cdot \frac{b_2}{a}} \]
    5. metadata-eval6.8%

      \[\leadsto \color{blue}{0} \cdot \frac{b_2}{a} \]
    6. mul0-lft10.3%

      \[\leadsto \color{blue}{0} \]
  9. Simplified10.3%

    \[\leadsto \color{blue}{0} \]
  10. Final simplification10.3%

    \[\leadsto 0 \]

Reproduce

?
herbie shell --seed 2023271 
(FPCore (a b_2 c)
  :name "quad2p (problem 3.2.1, positive)"
  :precision binary64
  (/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))