Quadratic roots, full range

Percentage Accurate: 52.5% → 85.0%
Time: 9.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.5% accurate, 1.0× speedup?

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

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

Alternative 1: 85.0% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;b \leq 5.8 \cdot 10^{-162}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \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 < -1.99999999999999996e123

    1. Initial program 58.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. /-rgt-identity58.4%

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

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

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

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

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

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

        \[\leadsto \left(\sqrt{\color{blue}{\mathsf{fma}\left(b, b, -\left(4 \cdot a\right) \cdot c\right)}} - b\right) \cdot \frac{--1}{2 \cdot a} \]
      8. associate-*l*58.3%

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

        \[\leadsto \left(\sqrt{\mathsf{fma}\left(b, b, -\color{blue}{\left(a \cdot c\right) \cdot 4}\right)} - b\right) \cdot \frac{--1}{2 \cdot a} \]
      10. distribute-rgt-neg-in58.3%

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

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

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

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

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

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

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

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

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

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

    if -1.99999999999999996e123 < b < 5.8000000000000002e-162

    1. Initial program 85.1%

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

    if 5.8000000000000002e-162 < b

    1. Initial program 22.2%

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

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

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

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

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

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

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

        \[\leadsto \left(\sqrt{\color{blue}{\mathsf{fma}\left(b, b, -\left(4 \cdot a\right) \cdot c\right)}} - b\right) \cdot \frac{--1}{2 \cdot a} \]
      8. associate-*l*22.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 80.1% accurate, 1.0× speedup?

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

\mathbf{elif}\;b \leq 5.8 \cdot 10^{-162}:\\
\;\;\;\;\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 < -3.70000000000000015e-39

    1. Initial program 71.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. /-rgt-identity71.5%

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

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

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

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

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

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

        \[\leadsto \left(\sqrt{\color{blue}{\mathsf{fma}\left(b, b, -\left(4 \cdot a\right) \cdot c\right)}} - b\right) \cdot \frac{--1}{2 \cdot a} \]
      8. associate-*l*71.2%

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.70000000000000015e-39 < b < 5.8000000000000002e-162

    1. Initial program 80.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. *-un-lft-identity80.4%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\mathsf{fma}\left(a, c \cdot -4 + c \cdot -4, \mathsf{fma}\left(b, b, -\left(a \cdot \left(c \cdot -4\right)\right) \cdot 1\right)\right)}}}{2 \cdot a} \]
      7. distribute-lft-out80.0%

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(a, c \cdot \color{blue}{-8}, \mathsf{fma}\left(b, b, -\left(a \cdot \left(c \cdot -4\right)\right) \cdot 1\right)\right)}}{2 \cdot a} \]
      9. *-rgt-identity80.0%

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(a, c \cdot -8, \mathsf{fma}\left(b, b, -\color{blue}{\left(a \cdot c\right) \cdot -4}\right)\right)}}{2 \cdot a} \]
      11. distribute-rgt-neg-in79.9%

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

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(a, c \cdot -8, \mathsf{fma}\left(b, b, \color{blue}{\left(c \cdot a\right)} \cdot 4\right)\right)}}{2 \cdot a} \]
      14. associate-*l*80.0%

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

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

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

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

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

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

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

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

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

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

    if 5.8000000000000002e-162 < b

    1. Initial program 22.2%

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

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

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

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

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

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

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

        \[\leadsto \left(\sqrt{\color{blue}{\mathsf{fma}\left(b, b, -\left(4 \cdot a\right) \cdot c\right)}} - b\right) \cdot \frac{--1}{2 \cdot a} \]
      8. associate-*l*22.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 79.7% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 71.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. /-rgt-identity71.5%

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

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

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

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

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

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

        \[\leadsto \left(\sqrt{\color{blue}{\mathsf{fma}\left(b, b, -\left(4 \cdot a\right) \cdot c\right)}} - b\right) \cdot \frac{--1}{2 \cdot a} \]
      8. associate-*l*71.2%

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.3500000000000001e-39 < b < 5.8000000000000002e-162

    1. Initial program 80.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. *-un-lft-identity80.4%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\mathsf{fma}\left(a, c \cdot -4 + c \cdot -4, \mathsf{fma}\left(b, b, -\left(a \cdot \left(c \cdot -4\right)\right) \cdot 1\right)\right)}}}{2 \cdot a} \]
      7. distribute-lft-out80.0%

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(a, c \cdot \color{blue}{-8}, \mathsf{fma}\left(b, b, -\left(a \cdot \left(c \cdot -4\right)\right) \cdot 1\right)\right)}}{2 \cdot a} \]
      9. *-rgt-identity80.0%

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(a, c \cdot -8, \mathsf{fma}\left(b, b, -\color{blue}{\left(a \cdot c\right) \cdot -4}\right)\right)}}{2 \cdot a} \]
      11. distribute-rgt-neg-in79.9%

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

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(a, c \cdot -8, \mathsf{fma}\left(b, b, \color{blue}{\left(c \cdot a\right)} \cdot 4\right)\right)}}{2 \cdot a} \]
      14. associate-*l*80.0%

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

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

      \[\leadsto \color{blue}{0.5 \cdot \left(\frac{1}{a} \cdot \sqrt{-8 \cdot \left(c \cdot a\right) + 4 \cdot \left(c \cdot a\right)}\right)} \]
    7. Step-by-step derivation
      1. associate-*l/68.5%

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

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

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

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

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

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

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

    if 5.8000000000000002e-162 < b

    1. Initial program 22.2%

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

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

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

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

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

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

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

        \[\leadsto \left(\sqrt{\color{blue}{\mathsf{fma}\left(b, b, -\left(4 \cdot a\right) \cdot c\right)}} - b\right) \cdot \frac{--1}{2 \cdot a} \]
      8. associate-*l*22.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 68.1% accurate, 12.8× speedup?

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

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

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


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

    1. Initial program 75.6%

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

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

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

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

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

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

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

        \[\leadsto \left(\sqrt{\color{blue}{\mathsf{fma}\left(b, b, -\left(4 \cdot a\right) \cdot c\right)}} - b\right) \cdot \frac{--1}{2 \cdot a} \]
      8. associate-*l*75.4%

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < b

    1. Initial program 27.9%

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

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

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

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

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

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

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

        \[\leadsto \left(\sqrt{\color{blue}{\mathsf{fma}\left(b, b, -\left(4 \cdot a\right) \cdot c\right)}} - b\right) \cdot \frac{--1}{2 \cdot a} \]
      8. associate-*l*27.8%

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

        \[\leadsto \left(\sqrt{\mathsf{fma}\left(b, b, -\color{blue}{\left(a \cdot c\right) \cdot 4}\right)} - b\right) \cdot \frac{--1}{2 \cdot a} \]
      10. distribute-rgt-neg-in27.8%

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 43.5% accurate, 19.1× speedup?

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

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

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


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

    1. Initial program 68.9%

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

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

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

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

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

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

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

        \[\leadsto \left(\sqrt{\color{blue}{\mathsf{fma}\left(b, b, -\left(4 \cdot a\right) \cdot c\right)}} - b\right) \cdot \frac{--1}{2 \cdot a} \]
      8. associate-*l*68.7%

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

        \[\leadsto \left(\sqrt{\mathsf{fma}\left(b, b, -\color{blue}{\left(a \cdot c\right) \cdot 4}\right)} - b\right) \cdot \frac{--1}{2 \cdot a} \]
      10. distribute-rgt-neg-in68.7%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-b}}{a} \]
    6. Simplified50.1%

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

    if 4.4000000000000002e-26 < b

    1. Initial program 15.3%

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

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

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

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

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

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

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

        \[\leadsto \left(\sqrt{\color{blue}{\mathsf{fma}\left(b, b, -\left(4 \cdot a\right) \cdot c\right)}} - b\right) \cdot \frac{--1}{2 \cdot a} \]
      8. associate-*l*15.3%

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

        \[\leadsto \left(\sqrt{\mathsf{fma}\left(b, b, -\color{blue}{\left(a \cdot c\right) \cdot 4}\right)} - b\right) \cdot \frac{--1}{2 \cdot a} \]
      10. distribute-rgt-neg-in15.3%

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

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

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

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

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

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

      \[\leadsto \left(\color{blue}{\left(2 \cdot \frac{c \cdot a}{b} + -1 \cdot b\right)} - b\right) \cdot \frac{0.5}{a} \]
    5. Step-by-step derivation
      1. mul-1-neg2.3%

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

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

        \[\leadsto \left(\left(\color{blue}{\frac{2 \cdot \left(c \cdot a\right)}{b}} - b\right) - b\right) \cdot \frac{0.5}{a} \]
    6. Simplified2.3%

      \[\leadsto \left(\color{blue}{\left(\frac{2 \cdot \left(c \cdot a\right)}{b} - b\right)} - b\right) \cdot \frac{0.5}{a} \]
    7. Taylor expanded in c around inf 34.6%

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

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

Alternative 6: 68.0% accurate, 19.1× speedup?

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

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

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


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

    1. Initial program 75.6%

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

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

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

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

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

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

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

        \[\leadsto \left(\sqrt{\color{blue}{\mathsf{fma}\left(b, b, -\left(4 \cdot a\right) \cdot c\right)}} - b\right) \cdot \frac{--1}{2 \cdot a} \]
      8. associate-*l*75.4%

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < b

    1. Initial program 27.9%

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

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

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

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

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

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

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

        \[\leadsto \left(\sqrt{\color{blue}{\mathsf{fma}\left(b, b, -\left(4 \cdot a\right) \cdot c\right)}} - b\right) \cdot \frac{--1}{2 \cdot a} \]
      8. associate-*l*27.8%

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

        \[\leadsto \left(\sqrt{\mathsf{fma}\left(b, b, -\color{blue}{\left(a \cdot c\right) \cdot 4}\right)} - b\right) \cdot \frac{--1}{2 \cdot a} \]
      10. distribute-rgt-neg-in27.8%

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 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.8%

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

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

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

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

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

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

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

      \[\leadsto \left(\sqrt{\color{blue}{\mathsf{fma}\left(b, b, -\left(4 \cdot a\right) \cdot c\right)}} - b\right) \cdot \frac{--1}{2 \cdot a} \]
    8. associate-*l*53.7%

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

      \[\leadsto \left(\sqrt{\mathsf{fma}\left(b, b, -\color{blue}{\left(a \cdot c\right) \cdot 4}\right)} - b\right) \cdot \frac{--1}{2 \cdot a} \]
    10. distribute-rgt-neg-in53.7%

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

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

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

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

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

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

    \[\leadsto \left(\color{blue}{\left(2 \cdot \frac{c \cdot a}{b} + -1 \cdot b\right)} - b\right) \cdot \frac{0.5}{a} \]
  5. Step-by-step derivation
    1. mul-1-neg36.2%

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

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

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

    \[\leadsto \left(\color{blue}{\left(\frac{2 \cdot \left(c \cdot a\right)}{b} - b\right)} - b\right) \cdot \frac{0.5}{a} \]
  7. Step-by-step derivation
    1. expm1-log1p-u19.0%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\left(\left(\frac{2 \cdot \left(c \cdot a\right)}{b} - b\right) - b\right) \cdot \frac{0.5}{a}\right)} - 1} \]
  8. Applied egg-rr2.7%

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{0.5}{a} \cdot \left(\left(\frac{2 \cdot \left(a \cdot c\right)}{b} + b\right) + b\right)\right)} - 1} \]
  9. Step-by-step derivation
    1. expm1-def1.5%

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

      \[\leadsto \color{blue}{\frac{0.5}{a} \cdot \left(\left(\frac{2 \cdot \left(a \cdot c\right)}{b} + b\right) + b\right)} \]
    3. associate-+l+2.2%

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

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

      \[\leadsto \frac{0.5}{a} \cdot \left(\color{blue}{2 \cdot \frac{c \cdot a}{b}} + \left(b + b\right)\right) \]
    6. associate-/l*2.2%

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

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

      \[\leadsto \frac{0.5}{a} \cdot \color{blue}{\left(2 \cdot \left(\frac{c}{\frac{b}{a}} + b\right)\right)} \]
    9. associate-/l*2.2%

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

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

    \[\leadsto \color{blue}{\frac{0.5}{a} \cdot \left(2 \cdot \left(\frac{a \cdot c}{b} + b\right)\right)} \]
  11. Taylor expanded in a around 0 2.3%

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

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

Alternative 8: 11.0% 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 53.8%

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

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

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

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

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

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

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

      \[\leadsto \left(\sqrt{\color{blue}{\mathsf{fma}\left(b, b, -\left(4 \cdot a\right) \cdot c\right)}} - b\right) \cdot \frac{--1}{2 \cdot a} \]
    8. associate-*l*53.7%

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

      \[\leadsto \left(\sqrt{\mathsf{fma}\left(b, b, -\color{blue}{\left(a \cdot c\right) \cdot 4}\right)} - b\right) \cdot \frac{--1}{2 \cdot a} \]
    10. distribute-rgt-neg-in53.7%

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

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

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

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

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

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

    \[\leadsto \left(\color{blue}{\left(2 \cdot \frac{c \cdot a}{b} + -1 \cdot b\right)} - b\right) \cdot \frac{0.5}{a} \]
  5. Step-by-step derivation
    1. mul-1-neg36.2%

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

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

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

    \[\leadsto \left(\color{blue}{\left(\frac{2 \cdot \left(c \cdot a\right)}{b} - b\right)} - b\right) \cdot \frac{0.5}{a} \]
  7. Taylor expanded in c around inf 12.1%

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

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

Reproduce

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