quadp (p42, positive)

Percentage Accurate: 63.7% → 85.8%
Time: 21.0s
Alternatives: 9
Speedup: 11.6×

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 9 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: 63.7% 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: 85.8% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -7.8 \cdot 10^{+141}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \leq 1.7 \cdot 10^{-203}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} - b}{a \cdot 2}\\ \mathbf{elif}\;b \leq 2.2 \cdot 10^{-108}:\\ \;\;\;\;\frac{b - \mathsf{hypot}\left(b, \sqrt{c \cdot -4} \cdot \sqrt{a}\right)}{a \cdot -2}\\ \mathbf{elif}\;b \leq 1.5 \cdot 10^{+77}:\\ \;\;\;\;\left(b - \sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)}\right) \cdot \frac{1}{a \cdot -2}\\ \mathbf{else}:\\ \;\;\;\;\frac{0}{a \cdot 2}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b -7.8e+141)
   (- (/ c b) (/ b a))
   (if (<= b 1.7e-203)
     (/ (- (sqrt (- (* b b) (* 4.0 (* c a)))) b) (* a 2.0))
     (if (<= b 2.2e-108)
       (/ (- b (hypot b (* (sqrt (* c -4.0)) (sqrt a)))) (* a -2.0))
       (if (<= b 1.5e+77)
         (* (- b (sqrt (fma b b (* a (* c -4.0))))) (/ 1.0 (* a -2.0)))
         (/ 0.0 (* a 2.0)))))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -7.8e+141) {
		tmp = (c / b) - (b / a);
	} else if (b <= 1.7e-203) {
		tmp = (sqrt(((b * b) - (4.0 * (c * a)))) - b) / (a * 2.0);
	} else if (b <= 2.2e-108) {
		tmp = (b - hypot(b, (sqrt((c * -4.0)) * sqrt(a)))) / (a * -2.0);
	} else if (b <= 1.5e+77) {
		tmp = (b - sqrt(fma(b, b, (a * (c * -4.0))))) * (1.0 / (a * -2.0));
	} else {
		tmp = 0.0 / (a * 2.0);
	}
	return tmp;
}
function code(a, b, c)
	tmp = 0.0
	if (b <= -7.8e+141)
		tmp = Float64(Float64(c / b) - Float64(b / a));
	elseif (b <= 1.7e-203)
		tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(c * a)))) - b) / Float64(a * 2.0));
	elseif (b <= 2.2e-108)
		tmp = Float64(Float64(b - hypot(b, Float64(sqrt(Float64(c * -4.0)) * sqrt(a)))) / Float64(a * -2.0));
	elseif (b <= 1.5e+77)
		tmp = Float64(Float64(b - sqrt(fma(b, b, Float64(a * Float64(c * -4.0))))) * Float64(1.0 / Float64(a * -2.0)));
	else
		tmp = Float64(0.0 / Float64(a * 2.0));
	end
	return tmp
end
code[a_, b_, c_] := If[LessEqual[b, -7.8e+141], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.7e-203], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.2e-108], N[(N[(b - N[Sqrt[b ^ 2 + N[(N[Sqrt[N[(c * -4.0), $MachinePrecision]], $MachinePrecision] * N[Sqrt[a], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] / N[(a * -2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.5e+77], N[(N[(b - N[Sqrt[N[(b * b + N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(a * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.0 / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq -7.8 \cdot 10^{+141}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\

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

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

\mathbf{elif}\;b \leq 1.5 \cdot 10^{+77}:\\
\;\;\;\;\left(b - \sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)}\right) \cdot \frac{1}{a \cdot -2}\\

\mathbf{else}:\\
\;\;\;\;\frac{0}{a \cdot 2}\\


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if b < -7.79999999999999983e141

    1. Initial program 54.3%

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

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

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

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

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

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

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

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

    if -7.79999999999999983e141 < b < 1.6999999999999999e-203

    1. Initial program 85.7%

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

    if 1.6999999999999999e-203 < b < 2.2000000000000001e-108

    1. Initial program 39.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. *-commutative39.2%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(-0.5 \cdot \frac{b - \mathsf{hypot}\left(b, \sqrt{-4 \cdot \left(c \cdot a\right)}\right)}{a}\right)} - 1} \]
    9. Step-by-step derivation
      1. expm1-def51.4%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(-0.5 \cdot \frac{b - \mathsf{hypot}\left(b, \sqrt{-4 \cdot \left(c \cdot a\right)}\right)}{a}\right)\right)} \]
      2. expm1-log1p51.4%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b - \mathsf{hypot}\left(b, \sqrt{\color{blue}{-4 \cdot \left(c \cdot a\right)}}\right)}{a \cdot -2} \]
      3. associate-*r*51.4%

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

        \[\leadsto \frac{b - \mathsf{hypot}\left(b, \color{blue}{\sqrt{-4 \cdot c} \cdot \sqrt{a}}\right)}{a \cdot -2} \]
      5. *-commutative99.4%

        \[\leadsto \frac{b - \mathsf{hypot}\left(b, \sqrt{\color{blue}{c \cdot -4}} \cdot \sqrt{a}\right)}{a \cdot -2} \]
    12. Applied egg-rr99.4%

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

    if 2.2000000000000001e-108 < b < 1.4999999999999999e77

    1. Initial program 89.7%

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

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

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

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

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

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

    if 1.4999999999999999e77 < b

    1. Initial program 27.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. *-commutative27.0%

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

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

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

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

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

        \[\leadsto \frac{\left(-b\right) + {\color{blue}{\left({\left(b \cdot b - 4 \cdot \left(a \cdot c\right)\right)}^{\left(\frac{0.5}{2}\right)}\right)}}^{2}}{a \cdot 2} \]
      5. fma-neg9.8%

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

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

        \[\leadsto \frac{\left(-b\right) + {\left({\left(\mathsf{fma}\left(b, b, \left(-4\right) \cdot \color{blue}{\left(c \cdot a\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)}\right)}^{2}}{a \cdot 2} \]
      8. associate-*r*9.8%

        \[\leadsto \frac{\left(-b\right) + {\left({\left(\mathsf{fma}\left(b, b, \color{blue}{\left(\left(-4\right) \cdot c\right) \cdot a}\right)\right)}^{\left(\frac{0.5}{2}\right)}\right)}^{2}}{a \cdot 2} \]
      9. metadata-eval9.8%

        \[\leadsto \frac{\left(-b\right) + {\left({\left(\mathsf{fma}\left(b, b, \left(\color{blue}{-4} \cdot c\right) \cdot a\right)\right)}^{\left(\frac{0.5}{2}\right)}\right)}^{2}}{a \cdot 2} \]
      10. metadata-eval9.8%

        \[\leadsto \frac{\left(-b\right) + {\left({\left(\mathsf{fma}\left(b, b, \left(-4 \cdot c\right) \cdot a\right)\right)}^{\color{blue}{0.25}}\right)}^{2}}{a \cdot 2} \]
    6. Applied egg-rr9.8%

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

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

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

        \[\leadsto \frac{\color{blue}{0} \cdot b}{a \cdot 2} \]
      3. mul0-lft95.3%

        \[\leadsto \frac{\color{blue}{0}}{a \cdot 2} \]
    9. Simplified95.3%

      \[\leadsto \frac{\color{blue}{0}}{a \cdot 2} \]
  3. Recombined 5 regimes into one program.
  4. Final simplification91.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -7.8 \cdot 10^{+141}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \leq 1.7 \cdot 10^{-203}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} - b}{a \cdot 2}\\ \mathbf{elif}\;b \leq 2.2 \cdot 10^{-108}:\\ \;\;\;\;\frac{b - \mathsf{hypot}\left(b, \sqrt{c \cdot -4} \cdot \sqrt{a}\right)}{a \cdot -2}\\ \mathbf{elif}\;b \leq 1.5 \cdot 10^{+77}:\\ \;\;\;\;\left(b - \sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)}\right) \cdot \frac{1}{a \cdot -2}\\ \mathbf{else}:\\ \;\;\;\;\frac{0}{a \cdot 2}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 87.9% accurate, 0.9× speedup?

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

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

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

\mathbf{else}:\\
\;\;\;\;\frac{0}{a \cdot 2}\\


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

    1. Initial program 54.3%

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

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

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

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

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

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

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

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

    if -1.0499999999999999e141 < b < 1.4999999999999999e77

    1. Initial program 84.1%

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

    if 1.4999999999999999e77 < b

    1. Initial program 27.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. *-commutative27.0%

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

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

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

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

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

        \[\leadsto \frac{\left(-b\right) + {\color{blue}{\left({\left(b \cdot b - 4 \cdot \left(a \cdot c\right)\right)}^{\left(\frac{0.5}{2}\right)}\right)}}^{2}}{a \cdot 2} \]
      5. fma-neg9.8%

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

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

        \[\leadsto \frac{\left(-b\right) + {\left({\left(\mathsf{fma}\left(b, b, \left(-4\right) \cdot \color{blue}{\left(c \cdot a\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)}\right)}^{2}}{a \cdot 2} \]
      8. associate-*r*9.8%

        \[\leadsto \frac{\left(-b\right) + {\left({\left(\mathsf{fma}\left(b, b, \color{blue}{\left(\left(-4\right) \cdot c\right) \cdot a}\right)\right)}^{\left(\frac{0.5}{2}\right)}\right)}^{2}}{a \cdot 2} \]
      9. metadata-eval9.8%

        \[\leadsto \frac{\left(-b\right) + {\left({\left(\mathsf{fma}\left(b, b, \left(\color{blue}{-4} \cdot c\right) \cdot a\right)\right)}^{\left(\frac{0.5}{2}\right)}\right)}^{2}}{a \cdot 2} \]
      10. metadata-eval9.8%

        \[\leadsto \frac{\left(-b\right) + {\left({\left(\mathsf{fma}\left(b, b, \left(-4 \cdot c\right) \cdot a\right)\right)}^{\color{blue}{0.25}}\right)}^{2}}{a \cdot 2} \]
    6. Applied egg-rr9.8%

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

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

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

        \[\leadsto \frac{\color{blue}{0} \cdot b}{a \cdot 2} \]
      3. mul0-lft95.3%

        \[\leadsto \frac{\color{blue}{0}}{a \cdot 2} \]
    9. Simplified95.3%

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

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

Alternative 3: 77.1% accurate, 0.9× speedup?

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

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

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

\mathbf{else}:\\
\;\;\;\;\frac{0}{a \cdot 2}\\


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

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

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

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

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

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

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

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

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

    if -3.20000000000000006e-86 < b < 1.26e-182

    1. Initial program 76.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. *-commutative76.0%

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

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

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

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

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

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

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

      \[\leadsto \left(b - \sqrt{\color{blue}{\left(a \cdot c\right) \cdot -4}}\right) \cdot \frac{1}{a \cdot -2} \]
    10. Step-by-step derivation
      1. un-div-inv72.9%

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

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

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

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

    if 1.26e-182 < b

    1. Initial program 48.8%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-b\right) + {\left({\left(\mathsf{fma}\left(b, b, \left(-4\right) \cdot \color{blue}{\left(c \cdot a\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)}\right)}^{2}}{a \cdot 2} \]
      8. associate-*r*29.0%

        \[\leadsto \frac{\left(-b\right) + {\left({\left(\mathsf{fma}\left(b, b, \color{blue}{\left(\left(-4\right) \cdot c\right) \cdot a}\right)\right)}^{\left(\frac{0.5}{2}\right)}\right)}^{2}}{a \cdot 2} \]
      9. metadata-eval29.0%

        \[\leadsto \frac{\left(-b\right) + {\left({\left(\mathsf{fma}\left(b, b, \left(\color{blue}{-4} \cdot c\right) \cdot a\right)\right)}^{\left(\frac{0.5}{2}\right)}\right)}^{2}}{a \cdot 2} \]
      10. metadata-eval29.0%

        \[\leadsto \frac{\left(-b\right) + {\left({\left(\mathsf{fma}\left(b, b, \left(-4 \cdot c\right) \cdot a\right)\right)}^{\color{blue}{0.25}}\right)}^{2}}{a \cdot 2} \]
    6. Applied egg-rr29.0%

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

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

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

        \[\leadsto \frac{\color{blue}{0} \cdot b}{a \cdot 2} \]
      3. mul0-lft80.3%

        \[\leadsto \frac{\color{blue}{0}}{a \cdot 2} \]
    9. Simplified80.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -3.2 \cdot 10^{-86}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \leq 1.26 \cdot 10^{-182}:\\ \;\;\;\;\frac{1}{\frac{a \cdot -2}{b - \sqrt{a \cdot \left(c \cdot -4\right)}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{0}{a \cdot 2}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 77.2% accurate, 1.0× speedup?

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

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

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

\mathbf{else}:\\
\;\;\;\;\frac{0}{a \cdot 2}\\


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

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

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

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

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

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

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

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

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

    if -3.80000000000000011e-88 < b < 1.26e-182

    1. Initial program 76.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. *-commutative76.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto b \cdot \frac{-0.5}{a} + \left(-\sqrt{a \cdot \left(c \cdot -4\right)}\right) \cdot \frac{\color{blue}{-0.5}}{a} \]
    11. Applied egg-rr72.8%

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

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

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

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

    if 1.26e-182 < b

    1. Initial program 48.8%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-b\right) + {\left({\left(\mathsf{fma}\left(b, b, \left(-4\right) \cdot \color{blue}{\left(c \cdot a\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)}\right)}^{2}}{a \cdot 2} \]
      8. associate-*r*29.0%

        \[\leadsto \frac{\left(-b\right) + {\left({\left(\mathsf{fma}\left(b, b, \color{blue}{\left(\left(-4\right) \cdot c\right) \cdot a}\right)\right)}^{\left(\frac{0.5}{2}\right)}\right)}^{2}}{a \cdot 2} \]
      9. metadata-eval29.0%

        \[\leadsto \frac{\left(-b\right) + {\left({\left(\mathsf{fma}\left(b, b, \left(\color{blue}{-4} \cdot c\right) \cdot a\right)\right)}^{\left(\frac{0.5}{2}\right)}\right)}^{2}}{a \cdot 2} \]
      10. metadata-eval29.0%

        \[\leadsto \frac{\left(-b\right) + {\left({\left(\mathsf{fma}\left(b, b, \left(-4 \cdot c\right) \cdot a\right)\right)}^{\color{blue}{0.25}}\right)}^{2}}{a \cdot 2} \]
    6. Applied egg-rr29.0%

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

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

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

        \[\leadsto \frac{\color{blue}{0} \cdot b}{a \cdot 2} \]
      3. mul0-lft80.3%

        \[\leadsto \frac{\color{blue}{0}}{a \cdot 2} \]
    9. Simplified80.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -3.8 \cdot 10^{-88}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \leq 1.26 \cdot 10^{-182}:\\ \;\;\;\;\left(b - \sqrt{a \cdot \left(c \cdot -4\right)}\right) \cdot \frac{-0.5}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{0}{a \cdot 2}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 77.2% accurate, 1.0× speedup?

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

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

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

\mathbf{else}:\\
\;\;\;\;\frac{0}{a \cdot 2}\\


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

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

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

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

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

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

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

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

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

    if -9.5999999999999998e-87 < b < 1.26e-182

    1. Initial program 76.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. *-commutative76.0%

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

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

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

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

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

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

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

      \[\leadsto \left(b - \sqrt{\color{blue}{\left(a \cdot c\right) \cdot -4}}\right) \cdot \frac{1}{a \cdot -2} \]
    10. Step-by-step derivation
      1. un-div-inv72.9%

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

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

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

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

    if 1.26e-182 < b

    1. Initial program 48.8%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-b\right) + {\left({\left(\mathsf{fma}\left(b, b, \left(-4\right) \cdot \color{blue}{\left(c \cdot a\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)}\right)}^{2}}{a \cdot 2} \]
      8. associate-*r*29.0%

        \[\leadsto \frac{\left(-b\right) + {\left({\left(\mathsf{fma}\left(b, b, \color{blue}{\left(\left(-4\right) \cdot c\right) \cdot a}\right)\right)}^{\left(\frac{0.5}{2}\right)}\right)}^{2}}{a \cdot 2} \]
      9. metadata-eval29.0%

        \[\leadsto \frac{\left(-b\right) + {\left({\left(\mathsf{fma}\left(b, b, \left(\color{blue}{-4} \cdot c\right) \cdot a\right)\right)}^{\left(\frac{0.5}{2}\right)}\right)}^{2}}{a \cdot 2} \]
      10. metadata-eval29.0%

        \[\leadsto \frac{\left(-b\right) + {\left({\left(\mathsf{fma}\left(b, b, \left(-4 \cdot c\right) \cdot a\right)\right)}^{\color{blue}{0.25}}\right)}^{2}}{a \cdot 2} \]
    6. Applied egg-rr29.0%

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

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

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

        \[\leadsto \frac{\color{blue}{0} \cdot b}{a \cdot 2} \]
      3. mul0-lft80.3%

        \[\leadsto \frac{\color{blue}{0}}{a \cdot 2} \]
    9. Simplified80.3%

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

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

Alternative 6: 65.0% accurate, 9.7× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{0}{a \cdot 2}\\


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

    1. Initial program 73.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. *-commutative73.6%

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

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

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

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

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

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

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

    if -1.60000000000000006e-296 < b

    1. Initial program 54.3%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-b\right) + {\left({\left(\mathsf{fma}\left(b, b, \left(-4\right) \cdot \color{blue}{\left(c \cdot a\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)}\right)}^{2}}{a \cdot 2} \]
      8. associate-*r*37.6%

        \[\leadsto \frac{\left(-b\right) + {\left({\left(\mathsf{fma}\left(b, b, \color{blue}{\left(\left(-4\right) \cdot c\right) \cdot a}\right)\right)}^{\left(\frac{0.5}{2}\right)}\right)}^{2}}{a \cdot 2} \]
      9. metadata-eval37.6%

        \[\leadsto \frac{\left(-b\right) + {\left({\left(\mathsf{fma}\left(b, b, \left(\color{blue}{-4} \cdot c\right) \cdot a\right)\right)}^{\left(\frac{0.5}{2}\right)}\right)}^{2}}{a \cdot 2} \]
      10. metadata-eval37.6%

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

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

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

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

        \[\leadsto \frac{\color{blue}{0} \cdot b}{a \cdot 2} \]
      3. mul0-lft68.3%

        \[\leadsto \frac{\color{blue}{0}}{a \cdot 2} \]
    9. Simplified68.3%

      \[\leadsto \frac{\color{blue}{0}}{a \cdot 2} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification69.6%

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

Alternative 7: 64.8% accurate, 11.6× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{0}{a \cdot 2}\\


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

    1. Initial program 73.8%

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

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

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

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

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

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

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

    if -9.50000000000000032e-301 < b

    1. Initial program 54.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. *-commutative54.0%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-b\right) + {\left({\left(\mathsf{fma}\left(b, b, \left(-4\right) \cdot \color{blue}{\left(c \cdot a\right)}\right)\right)}^{\left(\frac{0.5}{2}\right)}\right)}^{2}}{a \cdot 2} \]
      8. associate-*r*37.0%

        \[\leadsto \frac{\left(-b\right) + {\left({\left(\mathsf{fma}\left(b, b, \color{blue}{\left(\left(-4\right) \cdot c\right) \cdot a}\right)\right)}^{\left(\frac{0.5}{2}\right)}\right)}^{2}}{a \cdot 2} \]
      9. metadata-eval37.0%

        \[\leadsto \frac{\left(-b\right) + {\left({\left(\mathsf{fma}\left(b, b, \left(\color{blue}{-4} \cdot c\right) \cdot a\right)\right)}^{\left(\frac{0.5}{2}\right)}\right)}^{2}}{a \cdot 2} \]
      10. metadata-eval37.0%

        \[\leadsto \frac{\left(-b\right) + {\left({\left(\mathsf{fma}\left(b, b, \left(-4 \cdot c\right) \cdot a\right)\right)}^{\color{blue}{0.25}}\right)}^{2}}{a \cdot 2} \]
    6. Applied egg-rr37.0%

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

      \[\leadsto \frac{\color{blue}{b + -1 \cdot b}}{a \cdot 2} \]
    8. Step-by-step derivation
      1. distribute-rgt1-in68.8%

        \[\leadsto \frac{\color{blue}{\left(-1 + 1\right) \cdot b}}{a \cdot 2} \]
      2. metadata-eval68.8%

        \[\leadsto \frac{\color{blue}{0} \cdot b}{a \cdot 2} \]
      3. mul0-lft68.8%

        \[\leadsto \frac{\color{blue}{0}}{a \cdot 2} \]
    9. Simplified68.8%

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

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

Alternative 8: 47.6% accurate, 12.9× speedup?

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

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

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


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

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

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

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

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

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

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

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

    if -1.999999999999994e-310 < b

    1. Initial program 53.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. *-commutative53.2%

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

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

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

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

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

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

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

Alternative 9: 35.4% 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 64.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. *-commutative64.4%

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{-b}{a}} \]
  8. Final simplification37.9%

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

Developer target: 79.2% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left|\frac{b}{2}\right|\\ t_1 := \sqrt{\left|a\right|} \cdot \sqrt{\left|c\right|}\\ t_2 := \begin{array}{l} \mathbf{if}\;\mathsf{copysign}\left(a, c\right) = a:\\ \;\;\;\;\sqrt{t_0 - t_1} \cdot \sqrt{t_0 + t_1}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{hypot}\left(\frac{b}{2}, t_1\right)\\ \end{array}\\ \mathbf{if}\;b < 0:\\ \;\;\;\;\frac{t_2 - \frac{b}{2}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{\frac{b}{2} + t_2}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (fabs (/ b 2.0)))
        (t_1 (* (sqrt (fabs a)) (sqrt (fabs c))))
        (t_2
         (if (== (copysign a c) a)
           (* (sqrt (- t_0 t_1)) (sqrt (+ t_0 t_1)))
           (hypot (/ b 2.0) t_1))))
   (if (< b 0.0) (/ (- t_2 (/ b 2.0)) a) (/ (- c) (+ (/ b 2.0) t_2)))))
double code(double a, double b, double c) {
	double t_0 = fabs((b / 2.0));
	double t_1 = sqrt(fabs(a)) * sqrt(fabs(c));
	double tmp;
	if (copysign(a, c) == a) {
		tmp = sqrt((t_0 - t_1)) * sqrt((t_0 + t_1));
	} else {
		tmp = hypot((b / 2.0), t_1);
	}
	double t_2 = tmp;
	double tmp_1;
	if (b < 0.0) {
		tmp_1 = (t_2 - (b / 2.0)) / a;
	} else {
		tmp_1 = -c / ((b / 2.0) + t_2);
	}
	return tmp_1;
}
public static double code(double a, double b, double c) {
	double t_0 = Math.abs((b / 2.0));
	double t_1 = Math.sqrt(Math.abs(a)) * Math.sqrt(Math.abs(c));
	double tmp;
	if (Math.copySign(a, c) == a) {
		tmp = Math.sqrt((t_0 - t_1)) * Math.sqrt((t_0 + t_1));
	} else {
		tmp = Math.hypot((b / 2.0), t_1);
	}
	double t_2 = tmp;
	double tmp_1;
	if (b < 0.0) {
		tmp_1 = (t_2 - (b / 2.0)) / a;
	} else {
		tmp_1 = -c / ((b / 2.0) + t_2);
	}
	return tmp_1;
}
def code(a, b, c):
	t_0 = math.fabs((b / 2.0))
	t_1 = math.sqrt(math.fabs(a)) * math.sqrt(math.fabs(c))
	tmp = 0
	if math.copysign(a, c) == a:
		tmp = math.sqrt((t_0 - t_1)) * math.sqrt((t_0 + t_1))
	else:
		tmp = math.hypot((b / 2.0), t_1)
	t_2 = tmp
	tmp_1 = 0
	if b < 0.0:
		tmp_1 = (t_2 - (b / 2.0)) / a
	else:
		tmp_1 = -c / ((b / 2.0) + t_2)
	return tmp_1
function code(a, b, c)
	t_0 = abs(Float64(b / 2.0))
	t_1 = Float64(sqrt(abs(a)) * sqrt(abs(c)))
	tmp = 0.0
	if (copysign(a, c) == a)
		tmp = Float64(sqrt(Float64(t_0 - t_1)) * sqrt(Float64(t_0 + t_1)));
	else
		tmp = hypot(Float64(b / 2.0), t_1);
	end
	t_2 = tmp
	tmp_1 = 0.0
	if (b < 0.0)
		tmp_1 = Float64(Float64(t_2 - Float64(b / 2.0)) / a);
	else
		tmp_1 = Float64(Float64(-c) / Float64(Float64(b / 2.0) + t_2));
	end
	return tmp_1
end
function tmp_3 = code(a, b, c)
	t_0 = abs((b / 2.0));
	t_1 = sqrt(abs(a)) * sqrt(abs(c));
	tmp = 0.0;
	if ((sign(c) * abs(a)) == a)
		tmp = sqrt((t_0 - t_1)) * sqrt((t_0 + t_1));
	else
		tmp = hypot((b / 2.0), t_1);
	end
	t_2 = tmp;
	tmp_2 = 0.0;
	if (b < 0.0)
		tmp_2 = (t_2 - (b / 2.0)) / a;
	else
		tmp_2 = -c / ((b / 2.0) + t_2);
	end
	tmp_3 = tmp_2;
end
code[a_, b_, c_] := Block[{t$95$0 = N[Abs[N[(b / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[N[Abs[a], $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[Abs[c], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = If[Equal[N[With[{TMP1 = Abs[a], TMP2 = Sign[c]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], a], N[(N[Sqrt[N[(t$95$0 - t$95$1), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(t$95$0 + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(b / 2.0), $MachinePrecision] ^ 2 + t$95$1 ^ 2], $MachinePrecision]]}, If[Less[b, 0.0], N[(N[(t$95$2 - N[(b / 2.0), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[((-c) / N[(N[(b / 2.0), $MachinePrecision] + t$95$2), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left|\frac{b}{2}\right|\\
t_1 := \sqrt{\left|a\right|} \cdot \sqrt{\left|c\right|}\\
t_2 := \begin{array}{l}
\mathbf{if}\;\mathsf{copysign}\left(a, c\right) = a:\\
\;\;\;\;\sqrt{t_0 - t_1} \cdot \sqrt{t_0 + t_1}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{hypot}\left(\frac{b}{2}, t_1\right)\\


\end{array}\\
\mathbf{if}\;b < 0:\\
\;\;\;\;\frac{t_2 - \frac{b}{2}}{a}\\

\mathbf{else}:\\
\;\;\;\;\frac{-c}{\frac{b}{2} + t_2}\\


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2024023 
(FPCore (a b c)
  :name "quadp (p42, positive)"
  :precision binary64
  :herbie-expected 10

  :herbie-target
  (if (< b 0.0) (/ (- (if (== (copysign a c) a) (* (sqrt (- (fabs (/ b 2.0)) (* (sqrt (fabs a)) (sqrt (fabs c))))) (sqrt (+ (fabs (/ b 2.0)) (* (sqrt (fabs a)) (sqrt (fabs c)))))) (hypot (/ b 2.0) (* (sqrt (fabs a)) (sqrt (fabs c))))) (/ b 2.0)) a) (/ (- c) (+ (/ b 2.0) (if (== (copysign a c) a) (* (sqrt (- (fabs (/ b 2.0)) (* (sqrt (fabs a)) (sqrt (fabs c))))) (sqrt (+ (fabs (/ b 2.0)) (* (sqrt (fabs a)) (sqrt (fabs c)))))) (hypot (/ b 2.0) (* (sqrt (fabs a)) (sqrt (fabs c))))))))

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