Quadratic roots, full range

Percentage Accurate: 51.5% → 85.5%
Time: 12.7s
Alternatives: 9
Speedup: 19.1×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 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: 51.5% accurate, 1.0× speedup?

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

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

Alternative 1: 85.5% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -4 \cdot 10^{+154}:\\ \;\;\;\;\frac{-b}{a}\\ \mathbf{elif}\;b \leq 8.5 \cdot 10^{-119} \lor \neg \left(b \leq 6.5 \cdot 10^{-61}\right) \land b \leq 2.9 \cdot 10^{-34}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b -4e+154)
   (/ (- b) a)
   (if (or (<= b 8.5e-119) (and (not (<= b 6.5e-61)) (<= b 2.9e-34)))
     (/ (- (sqrt (- (* b b) (* (* a 4.0) c))) b) (* a 2.0))
     (/ (- c) b))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -4e+154) {
		tmp = -b / a;
	} else if ((b <= 8.5e-119) || (!(b <= 6.5e-61) && (b <= 2.9e-34))) {
		tmp = (sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a * 2.0);
	} else {
		tmp = -c / b;
	}
	return tmp;
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8) :: tmp
    if (b <= (-4d+154)) then
        tmp = -b / a
    else if ((b <= 8.5d-119) .or. (.not. (b <= 6.5d-61)) .and. (b <= 2.9d-34)) then
        tmp = (sqrt(((b * b) - ((a * 4.0d0) * c))) - b) / (a * 2.0d0)
    else
        tmp = -c / b
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	double tmp;
	if (b <= -4e+154) {
		tmp = -b / a;
	} else if ((b <= 8.5e-119) || (!(b <= 6.5e-61) && (b <= 2.9e-34))) {
		tmp = (Math.sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a * 2.0);
	} else {
		tmp = -c / b;
	}
	return tmp;
}
def code(a, b, c):
	tmp = 0
	if b <= -4e+154:
		tmp = -b / a
	elif (b <= 8.5e-119) or (not (b <= 6.5e-61) and (b <= 2.9e-34)):
		tmp = (math.sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a * 2.0)
	else:
		tmp = -c / b
	return tmp
function code(a, b, c)
	tmp = 0.0
	if (b <= -4e+154)
		tmp = Float64(Float64(-b) / a);
	elseif ((b <= 8.5e-119) || (!(b <= 6.5e-61) && (b <= 2.9e-34)))
		tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 4.0) * c))) - 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 <= -4e+154)
		tmp = -b / a;
	elseif ((b <= 8.5e-119) || (~((b <= 6.5e-61)) && (b <= 2.9e-34)))
		tmp = (sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a * 2.0);
	else
		tmp = -c / b;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := If[LessEqual[b, -4e+154], N[((-b) / a), $MachinePrecision], If[Or[LessEqual[b, 8.5e-119], And[N[Not[LessEqual[b, 6.5e-61]], $MachinePrecision], LessEqual[b, 2.9e-34]]], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(a * 4.0), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;b \leq 8.5 \cdot 10^{-119} \lor \neg \left(b \leq 6.5 \cdot 10^{-61}\right) \land b \leq 2.9 \cdot 10^{-34}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c} - b}{a \cdot 2}\\

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


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

    1. Initial program 41.2%

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

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

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

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

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

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

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

    if -4.00000000000000015e154 < b < 8.49999999999999977e-119 or 6.4999999999999994e-61 < b < 2.9000000000000002e-34

    1. Initial program 82.3%

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

    if 8.49999999999999977e-119 < b < 6.4999999999999994e-61 or 2.9000000000000002e-34 < b

    1. Initial program 17.4%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -4 \cdot 10^{+154}:\\ \;\;\;\;\frac{-b}{a}\\ \mathbf{elif}\;b \leq 8.5 \cdot 10^{-119} \lor \neg \left(b \leq 6.5 \cdot 10^{-61}\right) \land b \leq 2.9 \cdot 10^{-34}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array} \]

Alternative 2: 81.0% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 67.6%

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

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

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

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

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

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

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

    if -2.6e-82 < b < 4.70000000000000002e-119

    1. Initial program 73.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      if 4.70000000000000002e-119 < b

      1. Initial program 22.1%

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

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

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

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

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

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

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

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

    Alternative 3: 81.0% accurate, 1.0× speedup?

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

      1. Initial program 67.6%

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

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

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

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

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

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

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

      if -4.9999999999999998e-82 < b < 8.49999999999999977e-119

      1. Initial program 73.9%

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

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

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

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

      if 8.49999999999999977e-119 < b

      1. Initial program 22.1%

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

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

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

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

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

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

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

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

    Alternative 4: 68.2% accurate, 12.8× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -5 \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 -5e-310) (- (/ c b) (/ b a)) (/ (- c) b)))
    double code(double a, double b, double c) {
    	double tmp;
    	if (b <= -5e-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 <= (-5d-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 <= -5e-310) {
    		tmp = (c / b) - (b / a);
    	} else {
    		tmp = -c / b;
    	}
    	return tmp;
    }
    
    def code(a, b, c):
    	tmp = 0
    	if b <= -5e-310:
    		tmp = (c / b) - (b / a)
    	else:
    		tmp = -c / b
    	return tmp
    
    function code(a, b, c)
    	tmp = 0.0
    	if (b <= -5e-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 <= -5e-310)
    		tmp = (c / b) - (b / a);
    	else
    		tmp = -c / b;
    	end
    	tmp_2 = tmp;
    end
    
    code[a_, b_, c_] := If[LessEqual[b, -5e-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 -5 \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 < -4.999999999999985e-310

      1. Initial program 71.2%

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

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

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

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

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

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

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

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

      if -4.999999999999985e-310 < b

      1. Initial program 31.8%

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

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

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

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

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

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

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

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

    Alternative 5: 42.7% accurate, 19.1× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 4.8 \cdot 10^{+44}:\\ \;\;\;\;\frac{-b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b}\\ \end{array} \end{array} \]
    (FPCore (a b c) :precision binary64 (if (<= b 4.8e+44) (/ (- b) a) (/ c b)))
    double code(double a, double b, double c) {
    	double tmp;
    	if (b <= 4.8e+44) {
    		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 <= 4.8d+44) 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 <= 4.8e+44) {
    		tmp = -b / a;
    	} else {
    		tmp = c / b;
    	}
    	return tmp;
    }
    
    def code(a, b, c):
    	tmp = 0
    	if b <= 4.8e+44:
    		tmp = -b / a
    	else:
    		tmp = c / b
    	return tmp
    
    function code(a, b, c)
    	tmp = 0.0
    	if (b <= 4.8e+44)
    		tmp = Float64(Float64(-b) / a);
    	else
    		tmp = Float64(c / b);
    	end
    	return tmp
    end
    
    function tmp_2 = code(a, b, c)
    	tmp = 0.0;
    	if (b <= 4.8e+44)
    		tmp = -b / a;
    	else
    		tmp = c / b;
    	end
    	tmp_2 = tmp;
    end
    
    code[a_, b_, c_] := If[LessEqual[b, 4.8e+44], N[((-b) / a), $MachinePrecision], N[(c / b), $MachinePrecision]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;b \leq 4.8 \cdot 10^{+44}:\\
    \;\;\;\;\frac{-b}{a}\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{c}{b}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if b < 4.80000000000000026e44

      1. Initial program 63.3%

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

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

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

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

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

          \[\leadsto \frac{\color{blue}{-b}}{a} \]
      6. Simplified43.9%

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

      if 4.80000000000000026e44 < b

      1. Initial program 15.9%

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

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

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

        \[\leadsto \frac{\color{blue}{-2 \cdot b + 2 \cdot \frac{a \cdot c}{b}}}{a \cdot 2} \]
      5. Taylor expanded in b around 0 32.3%

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

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

    Alternative 6: 68.0% accurate, 19.1× speedup?

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

      1. Initial program 70.1%

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

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

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

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

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

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

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

      if 6.4999999999999997e-299 < b

      1. Initial program 32.2%

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

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

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

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

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

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

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

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

    Alternative 7: 13.2% accurate, 22.9× speedup?

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

      1. Initial program 63.1%

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

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

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

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

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

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

        \[\leadsto {\left(\frac{2}{\frac{b + \color{blue}{b}}{a}}\right)}^{-1} \]
      7. Step-by-step derivation
        1. expm1-log1p-u2.3%

          \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(\frac{2}{\frac{b + b}{a}}\right)}^{-1}\right)\right)} \]
        2. expm1-udef2.2%

          \[\leadsto \color{blue}{e^{\mathsf{log1p}\left({\left(\frac{2}{\frac{b + b}{a}}\right)}^{-1}\right)} - 1} \]
        3. unpow-12.2%

          \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{1}{\frac{2}{\frac{b + b}{a}}}}\right)} - 1 \]
        4. clear-num2.2%

          \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{\frac{b + b}{a}}{2}}\right)} - 1 \]
        5. div-inv2.2%

          \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{b + b}{a} \cdot \frac{1}{2}}\right)} - 1 \]
        6. flip-+0.0%

          \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\frac{b \cdot b - b \cdot b}{b - b}}}{a} \cdot \frac{1}{2}\right)} - 1 \]
        7. +-inverses0.0%

          \[\leadsto e^{\mathsf{log1p}\left(\frac{\frac{\color{blue}{0}}{b - b}}{a} \cdot \frac{1}{2}\right)} - 1 \]
        8. +-inverses0.0%

          \[\leadsto e^{\mathsf{log1p}\left(\frac{\frac{0}{\color{blue}{0}}}{a} \cdot \frac{1}{2}\right)} - 1 \]
        9. metadata-eval0.0%

          \[\leadsto e^{\mathsf{log1p}\left(\frac{\frac{0}{0}}{a} \cdot \color{blue}{0.5}\right)} - 1 \]
      8. Applied egg-rr0.0%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\frac{0}{0}}{a} \cdot 0.5\right)} - 1} \]
      9. Simplified5.6%

        \[\leadsto \color{blue}{\frac{0.5}{a}} \]

      if 1.15000000000000007e56 < b

      1. Initial program 14.8%

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

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

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

        \[\leadsto \frac{\color{blue}{-2 \cdot b + 2 \cdot \frac{a \cdot c}{b}}}{a \cdot 2} \]
      5. Taylor expanded in b around 0 33.2%

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 1.15 \cdot 10^{+56}:\\ \;\;\;\;\frac{0.5}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b}\\ \end{array} \]

    Alternative 8: 2.3% accurate, 38.7× speedup?

    \[\begin{array}{l} \\ \frac{-0.5}{a} \end{array} \]
    (FPCore (a b c) :precision binary64 (/ -0.5 a))
    double code(double a, double b, double c) {
    	return -0.5 / a;
    }
    
    real(8) function code(a, b, c)
        real(8), intent (in) :: a
        real(8), intent (in) :: b
        real(8), intent (in) :: c
        code = (-0.5d0) / a
    end function
    
    public static double code(double a, double b, double c) {
    	return -0.5 / a;
    }
    
    def code(a, b, c):
    	return -0.5 / a
    
    function code(a, b, c)
    	return Float64(-0.5 / a)
    end
    
    function tmp = code(a, b, c)
    	tmp = -0.5 / a;
    end
    
    code[a_, b_, c_] := N[(-0.5 / a), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \frac{-0.5}{a}
    \end{array}
    
    Derivation
    1. Initial program 50.9%

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

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

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

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

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

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

      \[\leadsto {\left(\frac{2}{\frac{b + \color{blue}{b}}{a}}\right)}^{-1} \]
    7. Step-by-step derivation
      1. unpow-12.7%

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

        \[\leadsto \frac{1}{\color{blue}{\frac{-2}{-\frac{b + b}{a}}}} \]
      3. metadata-eval2.7%

        \[\leadsto \frac{1}{\frac{\color{blue}{-2}}{-\frac{b + b}{a}}} \]
      4. associate-/r/2.7%

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

        \[\leadsto \color{blue}{-0.5} \cdot \left(-\frac{b + b}{a}\right) \]
      6. distribute-neg-frac2.7%

        \[\leadsto -0.5 \cdot \color{blue}{\frac{-\left(b + b\right)}{a}} \]
      7. flip-+0.0%

        \[\leadsto -0.5 \cdot \frac{-\color{blue}{\frac{b \cdot b - b \cdot b}{b - b}}}{a} \]
      8. +-inverses0.0%

        \[\leadsto -0.5 \cdot \frac{-\frac{\color{blue}{0}}{b - b}}{a} \]
      9. +-inverses0.0%

        \[\leadsto -0.5 \cdot \frac{-\frac{0}{\color{blue}{0}}}{a} \]
      10. distribute-neg-frac0.0%

        \[\leadsto -0.5 \cdot \frac{\color{blue}{\frac{-0}{0}}}{a} \]
      11. metadata-eval0.0%

        \[\leadsto -0.5 \cdot \frac{\frac{\color{blue}{0}}{0}}{a} \]
    8. Applied egg-rr0.0%

      \[\leadsto \color{blue}{-0.5 \cdot \frac{\frac{0}{0}}{a}} \]
    9. Simplified2.3%

      \[\leadsto \color{blue}{\frac{-0.5}{a}} \]
    10. Final simplification2.3%

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

    Alternative 9: 5.3% accurate, 38.7× speedup?

    \[\begin{array}{l} \\ \frac{0.5}{a} \end{array} \]
    (FPCore (a b c) :precision binary64 (/ 0.5 a))
    double code(double a, double b, double c) {
    	return 0.5 / a;
    }
    
    real(8) function code(a, b, c)
        real(8), intent (in) :: a
        real(8), intent (in) :: b
        real(8), intent (in) :: c
        code = 0.5d0 / a
    end function
    
    public static double code(double a, double b, double c) {
    	return 0.5 / a;
    }
    
    def code(a, b, c):
    	return 0.5 / a
    
    function code(a, b, c)
    	return Float64(0.5 / a)
    end
    
    function tmp = code(a, b, c)
    	tmp = 0.5 / a;
    end
    
    code[a_, b_, c_] := N[(0.5 / a), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \frac{0.5}{a}
    \end{array}
    
    Derivation
    1. Initial program 50.9%

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

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

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

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

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

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

      \[\leadsto {\left(\frac{2}{\frac{b + \color{blue}{b}}{a}}\right)}^{-1} \]
    7. Step-by-step derivation
      1. expm1-log1p-u2.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(\frac{2}{\frac{b + b}{a}}\right)}^{-1}\right)\right)} \]
      2. expm1-udef2.5%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left({\left(\frac{2}{\frac{b + b}{a}}\right)}^{-1}\right)} - 1} \]
      3. unpow-12.5%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{1}{\frac{2}{\frac{b + b}{a}}}}\right)} - 1 \]
      4. clear-num2.5%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{\frac{b + b}{a}}{2}}\right)} - 1 \]
      5. div-inv2.5%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{b + b}{a} \cdot \frac{1}{2}}\right)} - 1 \]
      6. flip-+0.0%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\frac{b \cdot b - b \cdot b}{b - b}}}{a} \cdot \frac{1}{2}\right)} - 1 \]
      7. +-inverses0.0%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\frac{\color{blue}{0}}{b - b}}{a} \cdot \frac{1}{2}\right)} - 1 \]
      8. +-inverses0.0%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\frac{0}{\color{blue}{0}}}{a} \cdot \frac{1}{2}\right)} - 1 \]
      9. metadata-eval0.0%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\frac{0}{0}}{a} \cdot \color{blue}{0.5}\right)} - 1 \]
    8. Applied egg-rr0.0%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\frac{0}{0}}{a} \cdot 0.5\right)} - 1} \]
    9. Simplified5.2%

      \[\leadsto \color{blue}{\frac{0.5}{a}} \]
    10. Final simplification5.2%

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

    Reproduce

    ?
    herbie shell --seed 2023332 
    (FPCore (a b c)
      :name "Quadratic roots, full range"
      :precision binary64
      (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))