quadp (p42, positive)

Percentage Accurate: 52.0% → 84.8%
Time: 13.7s
Alternatives: 9
Speedup: 19.1×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 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: 52.0% 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: 84.8% accurate, 0.5× speedup?

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

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

\mathbf{elif}\;b \leq 1.35 \cdot 10^{-126}:\\
\;\;\;\;\frac{1}{\frac{a}{\left(b - \sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}\right) \cdot -0.5}}\\

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


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

    1. Initial program 56.1%

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.49999999999999992e33 < b < 1.34999999999999998e-126

    1. Initial program 84.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. neg-sub084.3%

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

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

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

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

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

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

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

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

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

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

    if 1.34999999999999998e-126 < b

    1. Initial program 21.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. neg-sub021.4%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -1.5 \cdot 10^{+33}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \leq 1.35 \cdot 10^{-126}:\\ \;\;\;\;\frac{1}{\frac{a}{\left(b - \sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}\right) \cdot -0.5}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array} \]

Alternative 2: 85.0% accurate, 0.5× speedup?

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

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

\mathbf{elif}\;b \leq 1.85 \cdot 10^{-126}:\\
\;\;\;\;\left(b - \sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}\right) \cdot \frac{-0.5}{a}\\

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


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

    1. Initial program 55.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. neg-sub055.0%

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

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

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

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

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

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

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

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

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

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

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

    if -4.10000000000000012e45 < b < 1.85e-126

    1. Initial program 84.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. neg-sub084.7%

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

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

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

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

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

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

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

    if 1.85e-126 < b

    1. Initial program 21.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. neg-sub021.4%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -4.1 \cdot 10^{+45}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \leq 1.85 \cdot 10^{-126}:\\ \;\;\;\;\left(b - \sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}\right) \cdot \frac{-0.5}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array} \]

Alternative 3: 85.0% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 55.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. neg-sub055.0%

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

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

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

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

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

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

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

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

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

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

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

    if -4.90000000000000035e44 < b < 1.8999999999999999e-126

    1. Initial program 84.7%

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

    if 1.8999999999999999e-126 < b

    1. Initial program 21.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. neg-sub021.4%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 80.7% accurate, 1.0× speedup?

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

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

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

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


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

    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. neg-sub064.4%

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

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

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

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

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

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

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

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

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

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

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

    if -2.1e-69 < b < 1.8999999999999999e-126

    1. Initial program 81.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. neg-sub081.4%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(b - \sqrt{\left(a \cdot c\right) \cdot \color{blue}{\left(-4\right)} + b \cdot b}\right) \cdot \frac{-0.5}{a} \]
      4. distribute-rgt-neg-in81.3%

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

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

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

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

        \[\leadsto \left(b - \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)}}}\right) \cdot \frac{-0.5}{a} \]
      9. pow280.8%

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

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

      \[\leadsto \color{blue}{-0.5 \cdot \frac{b - {\left(e^{0.25 \cdot \left(-1 \cdot \log \left(\frac{1}{a}\right) + \log \left(-4 \cdot c\right)\right)}\right)}^{2}}{a}} \]
    7. Step-by-step derivation
      1. Simplified75.6%

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

      if 1.8999999999999999e-126 < b

      1. Initial program 21.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. neg-sub021.4%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -2.1 \cdot 10^{-69}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \leq 1.9 \cdot 10^{-126}:\\ \;\;\;\;-0.5 \cdot \frac{b - \sqrt{a \cdot \left(c \cdot -4\right)}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array} \]

    Alternative 5: 80.6% accurate, 1.0× speedup?

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

      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. neg-sub064.4%

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

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

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

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

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

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

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

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

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

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

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

      if -3.0999999999999999e-69 < b < 1.15000000000000005e-126

      1. Initial program 81.4%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-0.5}{a} \cdot \left(b - \sqrt{a \cdot \left(c \cdot -4\right)}\right)} \]
      9. Step-by-step derivation
        1. add-sqr-sqrt75.0%

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

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

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

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

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

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

          \[\leadsto \frac{-0.5}{a} \cdot \left(b - {\left({\left(a \cdot \left(c \cdot -4\right)\right)}^{\color{blue}{0.25}}\right)}^{2}\right) \]
      10. Applied egg-rr75.1%

        \[\leadsto \frac{-0.5}{a} \cdot \left(b - \color{blue}{{\left({\left(a \cdot \left(c \cdot -4\right)\right)}^{0.25}\right)}^{2}}\right) \]
      11. Taylor expanded in a around 0 39.2%

        \[\leadsto \color{blue}{-0.5 \cdot \frac{b - {\left(e^{0.25 \cdot \left(\log \left(-4 \cdot c\right) + \log a\right)}\right)}^{2}}{a}} \]
      12. Simplified75.6%

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

      if 1.15000000000000005e-126 < b

      1. Initial program 21.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. neg-sub021.4%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -3.1 \cdot 10^{-69}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \leq 1.15 \cdot 10^{-126}:\\ \;\;\;\;\frac{-0.5}{\frac{a}{b - \sqrt{c \cdot \left(a \cdot -4\right)}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array} \]

    Alternative 6: 68.6% accurate, 12.8× speedup?

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

      1. Initial program 70.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. neg-sub070.0%

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

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

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

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

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

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

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

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

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

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

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

      if -1.999999999999994e-310 < b

      1. Initial program 34.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. neg-sub034.3%

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 7: 68.4% accurate, 19.1× 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 70.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. neg-sub070.0%

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

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

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

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

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

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

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

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

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

          \[\leadsto \frac{\color{blue}{-b}}{a} \]
      6. Simplified71.4%

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

      if -1.999999999999994e-310 < b

      1. Initial program 34.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. neg-sub034.3%

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 8: 35.8% 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 54.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. neg-sub054.8%

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 9: 2.5% accurate, 38.7× speedup?

    \[\begin{array}{l} \\ \frac{b}{a} \end{array} \]
    (FPCore (a b c) :precision binary64 (/ b a))
    double code(double a, double b, double c) {
    	return b / a;
    }
    
    real(8) function code(a, b, c)
        real(8), intent (in) :: a
        real(8), intent (in) :: b
        real(8), intent (in) :: c
        code = b / a
    end function
    
    public static double code(double a, double b, double c) {
    	return b / a;
    }
    
    def code(a, b, c):
    	return b / a
    
    function code(a, b, c)
    	return Float64(b / a)
    end
    
    function tmp = code(a, b, c)
    	tmp = b / a;
    end
    
    code[a_, b_, c_] := N[(b / a), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \frac{b}{a}
    \end{array}
    
    Derivation
    1. Initial program 54.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. neg-sub054.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{\frac{a}{b} - \frac{b}{c}}} \]
    9. Taylor expanded in a around inf 2.4%

      \[\leadsto \color{blue}{\frac{b}{a}} \]
    10. Final simplification2.4%

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

    Developer target: 70.1% accurate, 1.0× speedup?

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

    Reproduce

    ?
    herbie shell --seed 2023187 
    (FPCore (a b c)
      :name "quadp (p42, positive)"
      :precision binary64
    
      :herbie-target
      (if (< b 0.0) (/ (+ (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)) (/ c (* a (/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))))
    
      (/ (+ (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))