Quadratic roots, narrow range

Percentage Accurate: 55.4% → 99.5%
Time: 11.1s
Alternatives: 8
Speedup: 29.0×

Specification

?
\[\left(\left(1.0536712127723509 \cdot 10^{-8} < a \land a < 94906265.62425156\right) \land \left(1.0536712127723509 \cdot 10^{-8} < b \land b < 94906265.62425156\right)\right) \land \left(1.0536712127723509 \cdot 10^{-8} < c \land c < 94906265.62425156\right)\]
\[\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: 55.4% 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: 99.5% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \frac{2 \cdot c}{\left(-b\right) - \sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (/ (* 2.0 c) (- (- b) (sqrt (fma a (* c -4.0) (* b b))))))
double code(double a, double b, double c) {
	return (2.0 * c) / (-b - sqrt(fma(a, (c * -4.0), (b * b))));
}
function code(a, b, c)
	return Float64(Float64(2.0 * c) / Float64(Float64(-b) - sqrt(fma(a, Float64(c * -4.0), Float64(b * b)))))
end
code[a_, b_, c_] := N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{2 \cdot c}{\left(-b\right) - \sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)}}
\end{array}
Derivation
  1. Initial program 56.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. flip-+56.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 86.0% accurate, 0.5× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a)) < -0.025000000000000001

    1. Initial program 81.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. *-commutative81.9%

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

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

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

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

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

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

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

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

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

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

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

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

    if -0.025000000000000001 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a))

    1. Initial program 47.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 99.4% accurate, 1.0× speedup?

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

\\
\frac{2 \cdot \frac{c \cdot a}{a}}{\left(-b\right) - \sqrt{b \cdot b + -4 \cdot \left(c \cdot a\right)}}
\end{array}
Derivation
  1. Initial program 56.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. flip-+56.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 85.4% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq 7.6:\\
\;\;\;\;\left(\sqrt{b \cdot b + -4 \cdot \left(c \cdot a\right)} - b\right) \cdot \frac{0.5}{a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 7.5999999999999996

    1. Initial program 84.1%

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

        \[\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-eval84.1%

        \[\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*84.1%

        \[\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/84.0%

        \[\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. +-commutative84.0%

        \[\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-neg84.0%

        \[\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-neg84.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*84.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. *-commutative84.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-in84.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-eval84.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*84.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-eval84.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-eval84.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. Simplified84.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. Step-by-step derivation
      1. fma-udef84.0%

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

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

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

    if 7.5999999999999996 < b

    1. Initial program 49.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. flip-+49.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 7.6:\\ \;\;\;\;\left(\sqrt{b \cdot b + -4 \cdot \left(c \cdot a\right)} - b\right) \cdot \frac{0.5}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot \frac{c \cdot a}{a}}{2 \cdot \frac{c \cdot a}{b} + b \cdot -2}\\ \end{array} \]

Alternative 5: 82.5% accurate, 6.1× speedup?

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

\\
\frac{2 \cdot \frac{c \cdot a}{a}}{2 \cdot \frac{c \cdot a}{b} + b \cdot -2}
\end{array}
Derivation
  1. Initial program 56.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. flip-+56.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{2 \cdot \frac{c \cdot a}{a}}{\color{blue}{2 \cdot \frac{c \cdot a}{b} + -2 \cdot b}} \]
  10. Final simplification79.9%

    \[\leadsto \frac{2 \cdot \frac{c \cdot a}{a}}{2 \cdot \frac{c \cdot a}{b} + b \cdot -2} \]

Alternative 6: 81.9% accurate, 7.3× speedup?

\[\begin{array}{l} \\ \frac{-c}{b} - \frac{c \cdot \left(c \cdot a\right)}{b \cdot \left(b \cdot b\right)} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (- (/ (- c) b) (/ (* c (* c a)) (* b (* b b)))))
double code(double a, double b, double c) {
	return (-c / b) - ((c * (c * a)) / (b * (b * 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) - ((c * (c * a)) / (b * (b * b)))
end function
public static double code(double a, double b, double c) {
	return (-c / b) - ((c * (c * a)) / (b * (b * b)));
}
def code(a, b, c):
	return (-c / b) - ((c * (c * a)) / (b * (b * b)))
function code(a, b, c)
	return Float64(Float64(Float64(-c) / b) - Float64(Float64(c * Float64(c * a)) / Float64(b * Float64(b * b))))
end
function tmp = code(a, b, c)
	tmp = (-c / b) - ((c * (c * a)) / (b * (b * b)));
end
code[a_, b_, c_] := N[(N[((-c) / b), $MachinePrecision] - N[(N[(c * N[(c * a), $MachinePrecision]), $MachinePrecision] / N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{-c}{b} - \frac{c \cdot \left(c \cdot a\right)}{b \cdot \left(b \cdot b\right)}
\end{array}
Derivation
  1. Initial program 56.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. neg-sub056.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b} - \frac{{c}^{2} \cdot a}{{b}^{3}}} \]
    4. associate-*r/79.2%

      \[\leadsto \color{blue}{\frac{-1 \cdot c}{b}} - \frac{{c}^{2} \cdot a}{{b}^{3}} \]
    5. neg-mul-179.2%

      \[\leadsto \frac{\color{blue}{-c}}{b} - \frac{{c}^{2} \cdot a}{{b}^{3}} \]
    6. unpow279.2%

      \[\leadsto \frac{-c}{b} - \frac{\color{blue}{\left(c \cdot c\right)} \cdot a}{{b}^{3}} \]
    7. associate-*l*79.2%

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

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

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

    \[\leadsto \frac{-c}{b} - \frac{c \cdot \left(c \cdot a\right)}{\color{blue}{\left(b \cdot b\right) \cdot b}} \]
  9. Final simplification79.2%

    \[\leadsto \frac{-c}{b} - \frac{c \cdot \left(c \cdot a\right)}{b \cdot \left(b \cdot b\right)} \]

Alternative 7: 64.4% 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 56.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. neg-sub056.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 3.2% accurate, 38.7× speedup?

\[\begin{array}{l} \\ \frac{0}{a} \end{array} \]
(FPCore (a b c) :precision binary64 (/ 0.0 a))
double code(double a, double b, double c) {
	return 0.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 = 0.0d0 / a
end function
public static double code(double a, double b, double c) {
	return 0.0 / a;
}
def code(a, b, c):
	return 0.0 / a
function code(a, b, c)
	return Float64(0.0 / a)
end
function tmp = code(a, b, c)
	tmp = 0.0 / a;
end
code[a_, b_, c_] := N[(0.0 / a), $MachinePrecision]
\begin{array}{l}

\\
\frac{0}{a}
\end{array}
Derivation
  1. Initial program 56.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. add-cube-cbrt56.8%

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{0.5 \cdot \left(\frac{b + -1 \cdot b}{a} \cdot {1}^{0.3333333333333333}\right)} \]
  5. Step-by-step derivation
    1. distribute-rgt1-in3.2%

      \[\leadsto 0.5 \cdot \left(\frac{\color{blue}{\left(-1 + 1\right) \cdot b}}{a} \cdot {1}^{0.3333333333333333}\right) \]
    2. metadata-eval3.2%

      \[\leadsto 0.5 \cdot \left(\frac{\color{blue}{0} \cdot b}{a} \cdot {1}^{0.3333333333333333}\right) \]
    3. mul0-lft3.2%

      \[\leadsto 0.5 \cdot \left(\frac{\color{blue}{0}}{a} \cdot {1}^{0.3333333333333333}\right) \]
    4. pow-base-13.2%

      \[\leadsto 0.5 \cdot \left(\frac{0}{a} \cdot \color{blue}{1}\right) \]
    5. associate-*l/3.2%

      \[\leadsto 0.5 \cdot \color{blue}{\frac{0 \cdot 1}{a}} \]
    6. metadata-eval3.2%

      \[\leadsto 0.5 \cdot \frac{\color{blue}{0}}{a} \]
    7. associate-*r/3.2%

      \[\leadsto \color{blue}{\frac{0.5 \cdot 0}{a}} \]
    8. metadata-eval3.2%

      \[\leadsto \frac{\color{blue}{0}}{a} \]
  6. Simplified3.2%

    \[\leadsto \color{blue}{\frac{0}{a}} \]
  7. Final simplification3.2%

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

Reproduce

?
herbie shell --seed 2023175 
(FPCore (a b c)
  :name "Quadratic roots, narrow range"
  :precision binary64
  :pre (and (and (and (< 1.0536712127723509e-8 a) (< a 94906265.62425156)) (and (< 1.0536712127723509e-8 b) (< b 94906265.62425156))) (and (< 1.0536712127723509e-8 c) (< c 94906265.62425156)))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))