Quadratic roots, full range

Percentage Accurate: 52.2% → 86.2%
Time: 16.5s
Alternatives: 8
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 8 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.2% 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: 86.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -3 \cdot 10^{+120}:\\ \;\;\;\;\frac{-b}{a}\\ \mathbf{elif}\;b \leq 1.55 \cdot 10^{-53}:\\ \;\;\;\;\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 -3e+120)
   (/ (- b) a)
   (if (<= b 1.55e-53)
     (/ (- (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 <= -3e+120) {
		tmp = -b / a;
	} else if (b <= 1.55e-53) {
		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 <= (-3d+120)) then
        tmp = -b / a
    else if (b <= 1.55d-53) 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 <= -3e+120) {
		tmp = -b / a;
	} else if (b <= 1.55e-53) {
		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 <= -3e+120:
		tmp = -b / a
	elif b <= 1.55e-53:
		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 <= -3e+120)
		tmp = Float64(Float64(-b) / a);
	elseif (b <= 1.55e-53)
		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 <= -3e+120)
		tmp = -b / a;
	elseif (b <= 1.55e-53)
		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, -3e+120], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 1.55e-53], 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 -3 \cdot 10^{+120}:\\
\;\;\;\;\frac{-b}{a}\\

\mathbf{elif}\;b \leq 1.55 \cdot 10^{-53}:\\
\;\;\;\;\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 < -3e120

    1. Initial program 45.5%

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

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

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

        \[\leadsto \frac{\color{blue}{-b}}{a} \]
    4. Simplified98.1%

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

    if -3e120 < b < 1.55000000000000008e-53

    1. Initial program 87.5%

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

    if 1.55000000000000008e-53 < b

    1. Initial program 15.6%

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

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

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

        \[\leadsto \frac{\color{blue}{-c}}{b} \]
    4. Simplified85.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -3 \cdot 10^{+120}:\\ \;\;\;\;\frac{-b}{a}\\ \mathbf{elif}\;b \leq 1.55 \cdot 10^{-53}:\\ \;\;\;\;\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.4% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;b \leq 4.4 \cdot 10^{-59}:\\
\;\;\;\;\left(\sqrt{a \cdot \left(c \cdot -4\right)} - b\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.20000000000000025e-41

    1. Initial program 69.2%

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

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

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

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

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

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

    if -4.20000000000000025e-41 < b < 4.3999999999999998e-59

    1. Initial program 82.5%

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

        \[\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}}}}{2 \cdot a} \]
      2. pow282.2%

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

        \[\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}}{2 \cdot a} \]
      4. sqrt-pow182.2%

        \[\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}}{2 \cdot a} \]
      5. fma-neg82.2%

        \[\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}}{2 \cdot a} \]
      6. *-commutative82.2%

        \[\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}}{2 \cdot a} \]
      7. distribute-rgt-neg-in82.2%

        \[\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}}{2 \cdot a} \]
      8. *-commutative82.2%

        \[\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}}{2 \cdot a} \]
      9. distribute-rgt-neg-in82.2%

        \[\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}}{2 \cdot a} \]
      10. metadata-eval82.2%

        \[\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}}{2 \cdot a} \]
      11. metadata-eval82.2%

        \[\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}}{2 \cdot a} \]
    3. Applied egg-rr82.2%

      \[\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}}}{2 \cdot a} \]
    4. Taylor expanded in b around 0 77.2%

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

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

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

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

    if 4.3999999999999998e-59 < b

    1. Initial program 15.6%

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

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

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

        \[\leadsto \frac{\color{blue}{-c}}{b} \]
    4. Simplified85.0%

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

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

Alternative 3: 81.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -7 \cdot 10^{-41}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \leq 1.8 \cdot 10^{-55}:\\ \;\;\;\;\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 -7e-41)
   (- (/ c b) (/ b a))
   (if (<= b 1.8e-55)
     (/ (- (sqrt (* -4.0 (* a c))) b) (* a 2.0))
     (/ (- c) b))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= -7e-41) {
		tmp = (c / b) - (b / a);
	} else if (b <= 1.8e-55) {
		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 <= (-7d-41)) then
        tmp = (c / b) - (b / a)
    else if (b <= 1.8d-55) 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 <= -7e-41) {
		tmp = (c / b) - (b / a);
	} else if (b <= 1.8e-55) {
		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 <= -7e-41:
		tmp = (c / b) - (b / a)
	elif b <= 1.8e-55:
		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 <= -7e-41)
		tmp = Float64(Float64(c / b) - Float64(b / a));
	elseif (b <= 1.8e-55)
		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 <= -7e-41)
		tmp = (c / b) - (b / a);
	elseif (b <= 1.8e-55)
		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, -7e-41], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.8e-55], 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 -7 \cdot 10^{-41}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\

\mathbf{elif}\;b \leq 1.8 \cdot 10^{-55}:\\
\;\;\;\;\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 < -6.9999999999999999e-41

    1. Initial program 69.2%

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

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

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

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

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

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

    if -6.9999999999999999e-41 < b < 1.8e-55

    1. Initial program 82.5%

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

        \[\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}}}}{2 \cdot a} \]
      2. pow282.2%

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

        \[\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}}{2 \cdot a} \]
      4. sqrt-pow182.2%

        \[\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}}{2 \cdot a} \]
      5. fma-neg82.2%

        \[\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}}{2 \cdot a} \]
      6. *-commutative82.2%

        \[\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}}{2 \cdot a} \]
      7. distribute-rgt-neg-in82.2%

        \[\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}}{2 \cdot a} \]
      8. *-commutative82.2%

        \[\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}}{2 \cdot a} \]
      9. distribute-rgt-neg-in82.2%

        \[\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}}{2 \cdot a} \]
      10. metadata-eval82.2%

        \[\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}}{2 \cdot a} \]
      11. metadata-eval82.2%

        \[\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}}{2 \cdot a} \]
    3. Applied egg-rr82.2%

      \[\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}}}{2 \cdot a} \]
    4. Taylor expanded in c around inf 50.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}}{2 \cdot a} \]
    5. Step-by-step derivation
      1. Simplified77.5%

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

      if 1.8e-55 < b

      1. Initial program 15.6%

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

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

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

          \[\leadsto \frac{\color{blue}{-c}}{b} \]
      4. Simplified85.0%

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

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

    Alternative 4: 81.4% accurate, 1.0× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -4.4 \cdot 10^{-41}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \leq 2.8 \cdot 10^{-49}:\\ \;\;\;\;\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 -4.4e-41)
       (- (/ c b) (/ b a))
       (if (<= b 2.8e-49)
         (/ (- (sqrt (* a (* c -4.0))) b) (* a 2.0))
         (/ (- c) b))))
    double code(double a, double b, double c) {
    	double tmp;
    	if (b <= -4.4e-41) {
    		tmp = (c / b) - (b / a);
    	} else if (b <= 2.8e-49) {
    		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 <= (-4.4d-41)) then
            tmp = (c / b) - (b / a)
        else if (b <= 2.8d-49) 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 <= -4.4e-41) {
    		tmp = (c / b) - (b / a);
    	} else if (b <= 2.8e-49) {
    		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 <= -4.4e-41:
    		tmp = (c / b) - (b / a)
    	elif b <= 2.8e-49:
    		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 <= -4.4e-41)
    		tmp = Float64(Float64(c / b) - Float64(b / a));
    	elseif (b <= 2.8e-49)
    		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 <= -4.4e-41)
    		tmp = (c / b) - (b / a);
    	elseif (b <= 2.8e-49)
    		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, -4.4e-41], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.8e-49], 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 -4.4 \cdot 10^{-41}:\\
    \;\;\;\;\frac{c}{b} - \frac{b}{a}\\
    
    \mathbf{elif}\;b \leq 2.8 \cdot 10^{-49}:\\
    \;\;\;\;\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 < -4.4e-41

      1. Initial program 69.2%

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

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

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

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

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

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

      if -4.4e-41 < b < 2.79999999999999997e-49

      1. Initial program 82.5%

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

          \[\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}}}}{2 \cdot a} \]
        2. pow282.2%

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

          \[\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}}{2 \cdot a} \]
        4. sqrt-pow182.2%

          \[\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}}{2 \cdot a} \]
        5. fma-neg82.2%

          \[\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}}{2 \cdot a} \]
        6. *-commutative82.2%

          \[\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}}{2 \cdot a} \]
        7. distribute-rgt-neg-in82.2%

          \[\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}}{2 \cdot a} \]
        8. *-commutative82.2%

          \[\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}}{2 \cdot a} \]
        9. distribute-rgt-neg-in82.2%

          \[\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}}{2 \cdot a} \]
        10. metadata-eval82.2%

          \[\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}}{2 \cdot a} \]
        11. metadata-eval82.2%

          \[\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}}{2 \cdot a} \]
      3. Applied egg-rr82.2%

        \[\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}}}{2 \cdot a} \]
      4. Taylor expanded in b around 0 77.2%

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

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

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

          \[\leadsto \frac{{\left(e^{0.25 \cdot \color{blue}{\log \left(a \cdot \left(c \cdot -4\right)\right)}}\right)}^{2} - b}{2 \cdot a} \]
        3. log-pow72.5%

          \[\leadsto \frac{{\left(e^{\color{blue}{\log \left({\left(a \cdot \left(c \cdot -4\right)\right)}^{0.25}\right)}}\right)}^{2} - b}{2 \cdot a} \]
        4. rem-exp-log77.3%

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

          \[\leadsto \frac{\color{blue}{{\left(a \cdot \left(c \cdot -4\right)\right)}^{0.25} \cdot {\left(a \cdot \left(c \cdot -4\right)\right)}^{0.25}} - b}{2 \cdot a} \]
        6. pow-sqr77.6%

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

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

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

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

      if 2.79999999999999997e-49 < b

      1. Initial program 15.6%

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

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

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

          \[\leadsto \frac{\color{blue}{-c}}{b} \]
      4. Simplified85.0%

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

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

    Alternative 5: 68.3% accurate, 12.8× speedup?

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

      1. Initial program 73.8%

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

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

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

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

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

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

      if -9.99999999999948e-312 < b

      1. Initial program 33.5%

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

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

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

          \[\leadsto \frac{\color{blue}{-c}}{b} \]
      4. Simplified65.2%

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

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

    Alternative 6: 68.2% accurate, 19.1× speedup?

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

      1. Initial program 73.8%

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

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

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

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

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

      if -9.99999999999948e-312 < b

      1. Initial program 33.5%

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

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

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

          \[\leadsto \frac{\color{blue}{-c}}{b} \]
      4. Simplified65.2%

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

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

    Alternative 7: 35.6% 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 53.4%

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

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

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

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

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

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

    Alternative 8: 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 53.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. clear-num53.3%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{0.5}{a} \cdot \left(b + \mathsf{hypot}\left(b, \sqrt{-\color{blue}{c \cdot \left(4 \cdot a\right)}}\right)\right) \]
      14. distribute-rgt-neg-in28.2%

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

        \[\leadsto \frac{0.5}{a} \cdot \left(b + \mathsf{hypot}\left(b, \sqrt{c \cdot \left(-\color{blue}{a \cdot 4}\right)}\right)\right) \]
      16. distribute-rgt-neg-in28.2%

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

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

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

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

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

    Reproduce

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