The quadratic formula (r2)

Percentage Accurate: 51.4% → 85.9%
Time: 14.9s
Alternatives: 9
Speedup: 19.1×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 9 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 51.4% accurate, 1.0× speedup?

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

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

Alternative 1: 85.9% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -6.6 \cdot 10^{-92}:\\
\;\;\;\;\frac{-c}{b}\\

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

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


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

    1. Initial program 13.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.59999999999999996e-92 < b < 1.9e71

    1. Initial program 78.4%

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

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

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

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

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

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

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

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

    if 1.9e71 < b

    1. Initial program 54.7%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -0.5 \cdot \frac{b + \sqrt{\color{blue}{\mathsf{fma}\left(a, \left(-c\right) \cdot 4, b \cdot b\right)}}}{a} \]
      13. distribute-lft-neg-in54.7%

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

        \[\leadsto -0.5 \cdot \frac{b + \sqrt{\mathsf{fma}\left(a, \color{blue}{c \cdot \left(-4\right)}, b \cdot b\right)}}{a} \]
      15. metadata-eval54.7%

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

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

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

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

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

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

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

Alternative 2: 85.8% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -8.3 \cdot 10^{-103}:\\
\;\;\;\;\frac{-c}{b}\\

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

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


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

    1. Initial program 13.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.30000000000000006e-103 < b < 2.0000000000000001e71

    1. Initial program 78.4%

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

    if 2.0000000000000001e71 < b

    1. Initial program 54.7%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -0.5 \cdot \frac{b + \sqrt{\color{blue}{\mathsf{fma}\left(a, \left(-c\right) \cdot 4, b \cdot b\right)}}}{a} \]
      13. distribute-lft-neg-in54.7%

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

        \[\leadsto -0.5 \cdot \frac{b + \sqrt{\mathsf{fma}\left(a, \color{blue}{c \cdot \left(-4\right)}, b \cdot b\right)}}{a} \]
      15. metadata-eval54.7%

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

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

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

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

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

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

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

Alternative 3: 80.7% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -6.8 \cdot 10^{-102}:\\
\;\;\;\;\frac{-c}{b}\\

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

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


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

    1. Initial program 13.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.80000000000000026e-102 < b < 1.8999999999999999e-95

    1. Initial program 75.8%

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

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

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

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

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

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

        \[\leadsto \frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{a \cdot 2}} \]
    3. Simplified75.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 0 69.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.8999999999999999e-95 < b

    1. Initial program 64.1%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -0.5 \cdot \frac{b + \sqrt{\color{blue}{\mathsf{fma}\left(a, \left(-c\right) \cdot 4, b \cdot b\right)}}}{a} \]
      13. distribute-lft-neg-in64.1%

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

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

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

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

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

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

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

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

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

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

Alternative 4: 81.2% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.65 \cdot 10^{-102}:\\
\;\;\;\;\frac{-c}{b}\\

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

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


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

    1. Initial program 13.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.65e-102 < b < 2.1e-88

    1. Initial program 76.4%

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

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

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

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

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

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

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

      \[\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 69.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.1e-88 < b

    1. Initial program 63.3%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -0.5 \cdot \frac{b + \sqrt{\color{blue}{\mathsf{fma}\left(a, \left(-c\right) \cdot 4, b \cdot b\right)}}}{a} \]
      13. distribute-lft-neg-in63.3%

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

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

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

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

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

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

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

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

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

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

Alternative 5: 68.3% accurate, 12.8× speedup?

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

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

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


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

    1. Initial program 30.2%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -0.5 \cdot \frac{b + \sqrt{\color{blue}{\mathsf{fma}\left(a, \left(-c\right) \cdot 4, b \cdot b\right)}}}{a} \]
      13. distribute-lft-neg-in30.3%

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

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

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

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

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

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

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

    if -3.999999999999988e-310 < b

    1. Initial program 69.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 68.2% accurate, 19.1× speedup?

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

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

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


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

    1. Initial program 30.2%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -0.5 \cdot \frac{b + \sqrt{\color{blue}{\mathsf{fma}\left(a, \left(-c\right) \cdot 4, b \cdot b\right)}}}{a} \]
      13. distribute-lft-neg-in30.3%

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

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

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

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

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

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

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

    if -3.999999999999988e-310 < b

    1. Initial program 69.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 35.6% accurate, 29.0× speedup?

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

\\
\frac{-c}{b}
\end{array}
Derivation
  1. Initial program 48.7%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto -0.5 \cdot \frac{b + \sqrt{\color{blue}{\mathsf{fma}\left(a, \left(-c\right) \cdot 4, b \cdot b\right)}}}{a} \]
    13. distribute-lft-neg-in48.7%

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

      \[\leadsto -0.5 \cdot \frac{b + \sqrt{\mathsf{fma}\left(a, \color{blue}{c \cdot \left(-4\right)}, b \cdot b\right)}}{a} \]
    15. metadata-eval48.7%

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

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

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

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

    \[\leadsto \color{blue}{-\frac{c}{b}} \]
  7. Final simplification36.1%

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

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 48.7%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto -0.5 \cdot \frac{b + \sqrt{\color{blue}{\mathsf{fma}\left(a, \left(-c\right) \cdot 4, b \cdot b\right)}}}{a} \]
    13. distribute-lft-neg-in48.7%

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

      \[\leadsto -0.5 \cdot \frac{b + \sqrt{\mathsf{fma}\left(a, \color{blue}{c \cdot \left(-4\right)}, b \cdot b\right)}}{a} \]
    15. metadata-eval48.7%

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

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

      \[\leadsto -0.5 \cdot \color{blue}{\frac{1}{\frac{a}{b + \sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}}}} \]
    2. un-div-inv48.7%

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

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

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

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

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

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

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

      \[\leadsto \frac{-0.5}{\frac{-1}{\color{blue}{\left(-b\right) + \left(-\sqrt{\mathsf{fma}\left(a, c \cdot -4, {b}^{2}\right)}\right)}} \cdot a} \]
    6. add-sqr-sqrt15.4%

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

      \[\leadsto \frac{-0.5}{\frac{-1}{\color{blue}{\sqrt{\left(-b\right) \cdot \left(-b\right)}} + \left(-\sqrt{\mathsf{fma}\left(a, c \cdot -4, {b}^{2}\right)}\right)} \cdot a} \]
    8. sqr-neg26.6%

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

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

      \[\leadsto \frac{-0.5}{\frac{-1}{\color{blue}{b} + \left(-\sqrt{\mathsf{fma}\left(a, c \cdot -4, {b}^{2}\right)}\right)} \cdot a} \]
    11. sub-neg32.0%

      \[\leadsto \frac{-0.5}{\frac{-1}{\color{blue}{b - \sqrt{\mathsf{fma}\left(a, c \cdot -4, {b}^{2}\right)}}} \cdot a} \]
    12. fma-udef32.0%

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

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

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

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

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

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

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

Alternative 9: 11.2% accurate, 38.7× speedup?

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

\\
\frac{c}{b}
\end{array}
Derivation
  1. Initial program 48.7%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto -0.5 \cdot \frac{b + \sqrt{\color{blue}{\mathsf{fma}\left(a, \left(-c\right) \cdot 4, b \cdot b\right)}}}{a} \]
    13. distribute-lft-neg-in48.7%

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

      \[\leadsto -0.5 \cdot \frac{b + \sqrt{\mathsf{fma}\left(a, \color{blue}{c \cdot \left(-4\right)}, b \cdot b\right)}}{a} \]
    15. metadata-eval48.7%

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

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

      \[\leadsto -0.5 \cdot \color{blue}{\frac{1}{\frac{a}{b + \sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}}}} \]
    2. un-div-inv48.7%

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

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

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

    \[\leadsto \frac{-0.5}{\frac{a}{\color{blue}{-2 \cdot \frac{a \cdot c}{b} + 2 \cdot b}}} \]
  7. Taylor expanded in a around inf 12.5%

    \[\leadsto \color{blue}{\frac{c}{b}} \]
  8. Final simplification12.5%

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

Developer target: 70.1% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\\
\mathbf{if}\;b < 0:\\
\;\;\;\;\frac{c}{a \cdot \frac{\left(-b\right) + t_0}{2 \cdot a}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) - t_0}{2 \cdot a}\\


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2023334 
(FPCore (a b c)
  :name "The quadratic formula (r2)"
  :precision binary64

  :herbie-target
  (if (< b 0.0) (/ c (* a (/ (+ (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))) (/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))

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