Quadratic roots, medium range

Percentage Accurate: 31.6% → 99.6%
Time: 11.4s
Alternatives: 6
Speedup: 29.0×

Specification

?
\[\left(\left(1.1102230246251565 \cdot 10^{-16} < a \land a < 9007199254740992\right) \land \left(1.1102230246251565 \cdot 10^{-16} < b \land b < 9007199254740992\right)\right) \land \left(1.1102230246251565 \cdot 10^{-16} < c \land c < 9007199254740992\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 6 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: 31.6% 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.6% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := c \cdot \left(a \cdot 4\right)\\ \frac{\frac{a \cdot c}{a} \cdot 2}{\left(-b\right) - \sqrt{\frac{\mathsf{fma}\left(-64, {\left(a \cdot c\right)}^{3}, {b}^{6}\right)}{\mathsf{fma}\left(t_0, \mathsf{fma}\left(b, b, t_0\right), {b}^{4}\right)}}} \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (* c (* a 4.0))))
   (/
    (* (/ (* a c) a) 2.0)
    (-
     (- b)
     (sqrt
      (/
       (fma -64.0 (pow (* a c) 3.0) (pow b 6.0))
       (fma t_0 (fma b b t_0) (pow b 4.0))))))))
double code(double a, double b, double c) {
	double t_0 = c * (a * 4.0);
	return (((a * c) / a) * 2.0) / (-b - sqrt((fma(-64.0, pow((a * c), 3.0), pow(b, 6.0)) / fma(t_0, fma(b, b, t_0), pow(b, 4.0)))));
}
function code(a, b, c)
	t_0 = Float64(c * Float64(a * 4.0))
	return Float64(Float64(Float64(Float64(a * c) / a) * 2.0) / Float64(Float64(-b) - sqrt(Float64(fma(-64.0, (Float64(a * c) ^ 3.0), (b ^ 6.0)) / fma(t_0, fma(b, b, t_0), (b ^ 4.0))))))
end
code[a_, b_, c_] := Block[{t$95$0 = N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(N[(a * c), $MachinePrecision] / a), $MachinePrecision] * 2.0), $MachinePrecision] / N[((-b) - N[Sqrt[N[(N[(-64.0 * N[Power[N[(a * c), $MachinePrecision], 3.0], $MachinePrecision] + N[Power[b, 6.0], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 * N[(b * b + t$95$0), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := c \cdot \left(a \cdot 4\right)\\
\frac{\frac{a \cdot c}{a} \cdot 2}{\left(-b\right) - \sqrt{\frac{\mathsf{fma}\left(-64, {\left(a \cdot c\right)}^{3}, {b}^{6}\right)}{\mathsf{fma}\left(t_0, \mathsf{fma}\left(b, b, t_0\right), {b}^{4}\right)}}}
\end{array}
\end{array}
Derivation
  1. Initial program 28.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. *-commutative28.8%

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

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

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

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

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

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

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{\left({b}^{6} - {\color{blue}{\left(4 \cdot \left(a \cdot c\right)\right)}}^{3}\right) \cdot \frac{1}{\left(b \cdot b\right) \cdot \left(b \cdot b\right) + \left(\left(\left(4 \cdot a\right) \cdot c\right) \cdot \left(\left(4 \cdot a\right) \cdot c\right) + \left(b \cdot b\right) \cdot \left(\left(4 \cdot a\right) \cdot c\right)\right)}}}{a \cdot 2} \]
    7. unpow-prod-down28.9%

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

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{\left({b}^{6} - 64 \cdot {\left(a \cdot c\right)}^{3}\right) \cdot \frac{1}{\color{blue}{{b}^{2}} \cdot \left(b \cdot b\right) + \left(\left(\left(4 \cdot a\right) \cdot c\right) \cdot \left(\left(4 \cdot a\right) \cdot c\right) + \left(b \cdot b\right) \cdot \left(\left(4 \cdot a\right) \cdot c\right)\right)}}}{a \cdot 2} \]
    10. pow228.9%

      \[\leadsto \frac{\left(-b\right) + \sqrt{\left({b}^{6} - 64 \cdot {\left(a \cdot c\right)}^{3}\right) \cdot \frac{1}{{b}^{2} \cdot \color{blue}{{b}^{2}} + \left(\left(\left(4 \cdot a\right) \cdot c\right) \cdot \left(\left(4 \cdot a\right) \cdot c\right) + \left(b \cdot b\right) \cdot \left(\left(4 \cdot a\right) \cdot c\right)\right)}}}{a \cdot 2} \]
    11. pow-prod-up28.8%

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{\left({b}^{6} - 64 \cdot {\left(a \cdot c\right)}^{3}\right) \cdot \frac{1}{{b}^{\color{blue}{4}} + \left(\left(\left(4 \cdot a\right) \cdot c\right) \cdot \left(\left(4 \cdot a\right) \cdot c\right) + \left(b \cdot b\right) \cdot \left(\left(4 \cdot a\right) \cdot c\right)\right)}}}{a \cdot 2} \]
    13. distribute-rgt-out28.8%

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

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

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

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

    \[\leadsto \frac{\frac{\color{blue}{4 \cdot \left(a \cdot c\right)}}{\left(-b\right) - \sqrt{\frac{{b}^{6} + -64 \cdot {\left(a \cdot c\right)}^{3}}{\mathsf{fma}\left(4 \cdot \left(a \cdot c\right), \mathsf{fma}\left(b, b, 4 \cdot \left(a \cdot c\right)\right), {b}^{4}\right)}}}}{a \cdot 2} \]
  9. Step-by-step derivation
    1. associate-*r*99.4%

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

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

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

    \[\leadsto \frac{\frac{\color{blue}{c \cdot \left(a \cdot 4\right)}}{\left(-b\right) - \sqrt{\frac{{b}^{6} + -64 \cdot {\left(a \cdot c\right)}^{3}}{\mathsf{fma}\left(4 \cdot \left(a \cdot c\right), \mathsf{fma}\left(b, b, 4 \cdot \left(a \cdot c\right)\right), {b}^{4}\right)}}}}{a \cdot 2} \]
  11. Applied egg-rr37.2%

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{c \cdot \left(a \cdot 4\right)}{\left(a \cdot 2\right) \cdot \left(\left(-b\right) - \sqrt{\frac{\mathsf{fma}\left(-64, {\left(c \cdot a\right)}^{3}, {b}^{6}\right)}{\mathsf{fma}\left(c \cdot \left(a \cdot 4\right), \mathsf{fma}\left(b, b, c \cdot \left(a \cdot 4\right)\right), {b}^{4}\right)}}\right)}\right)} - 1} \]
  12. Step-by-step derivation
    1. expm1-def86.1%

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

      \[\leadsto \color{blue}{\frac{c \cdot \left(a \cdot 4\right)}{\left(a \cdot 2\right) \cdot \left(\left(-b\right) - \sqrt{\frac{\mathsf{fma}\left(-64, {\left(c \cdot a\right)}^{3}, {b}^{6}\right)}{\mathsf{fma}\left(c \cdot \left(a \cdot 4\right), \mathsf{fma}\left(b, b, c \cdot \left(a \cdot 4\right)\right), {b}^{4}\right)}}\right)}} \]
    3. associate-/r*99.6%

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

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

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

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

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

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

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

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

Alternative 2: 83.4% accurate, 0.5× speedup?

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

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

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


\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)) < -2.00000000000000007e-10

    1. Initial program 67.2%

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

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

    1. Initial program 9.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. *-commutative9.4%

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

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

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

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

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

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

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

Alternative 3: 99.4% accurate, 0.5× speedup?

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{\left({b}^{6} - {\color{blue}{\left(4 \cdot \left(a \cdot c\right)\right)}}^{3}\right) \cdot \frac{1}{\left(b \cdot b\right) \cdot \left(b \cdot b\right) + \left(\left(\left(4 \cdot a\right) \cdot c\right) \cdot \left(\left(4 \cdot a\right) \cdot c\right) + \left(b \cdot b\right) \cdot \left(\left(4 \cdot a\right) \cdot c\right)\right)}}}{a \cdot 2} \]
    7. unpow-prod-down28.9%

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

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{\left({b}^{6} - 64 \cdot {\left(a \cdot c\right)}^{3}\right) \cdot \frac{1}{\color{blue}{{b}^{2}} \cdot \left(b \cdot b\right) + \left(\left(\left(4 \cdot a\right) \cdot c\right) \cdot \left(\left(4 \cdot a\right) \cdot c\right) + \left(b \cdot b\right) \cdot \left(\left(4 \cdot a\right) \cdot c\right)\right)}}}{a \cdot 2} \]
    10. pow228.9%

      \[\leadsto \frac{\left(-b\right) + \sqrt{\left({b}^{6} - 64 \cdot {\left(a \cdot c\right)}^{3}\right) \cdot \frac{1}{{b}^{2} \cdot \color{blue}{{b}^{2}} + \left(\left(\left(4 \cdot a\right) \cdot c\right) \cdot \left(\left(4 \cdot a\right) \cdot c\right) + \left(b \cdot b\right) \cdot \left(\left(4 \cdot a\right) \cdot c\right)\right)}}}{a \cdot 2} \]
    11. pow-prod-up28.8%

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{\left({b}^{6} - 64 \cdot {\left(a \cdot c\right)}^{3}\right) \cdot \frac{1}{{b}^{\color{blue}{4}} + \left(\left(\left(4 \cdot a\right) \cdot c\right) \cdot \left(\left(4 \cdot a\right) \cdot c\right) + \left(b \cdot b\right) \cdot \left(\left(4 \cdot a\right) \cdot c\right)\right)}}}{a \cdot 2} \]
    13. distribute-rgt-out28.8%

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

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

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

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

    \[\leadsto \frac{\frac{\color{blue}{4 \cdot \left(a \cdot c\right)}}{\left(-b\right) - \sqrt{\frac{{b}^{6} + -64 \cdot {\left(a \cdot c\right)}^{3}}{\mathsf{fma}\left(4 \cdot \left(a \cdot c\right), \mathsf{fma}\left(b, b, 4 \cdot \left(a \cdot c\right)\right), {b}^{4}\right)}}}}{a \cdot 2} \]
  9. Step-by-step derivation
    1. associate-*r*99.4%

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

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

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

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

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

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

Alternative 4: 91.0% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 0.000225:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b} - \frac{a}{\frac{{b}^{3}}{{c}^{2}}}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b 0.000225)
   (/ (- (sqrt (fma b b (* c (* a -4.0)))) b) (* a 2.0))
   (- (/ (- c) b) (/ a (/ (pow b 3.0) (pow c 2.0))))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= 0.000225) {
		tmp = (sqrt(fma(b, b, (c * (a * -4.0)))) - b) / (a * 2.0);
	} else {
		tmp = (-c / b) - (a / (pow(b, 3.0) / pow(c, 2.0)));
	}
	return tmp;
}
function code(a, b, c)
	tmp = 0.0
	if (b <= 0.000225)
		tmp = Float64(Float64(sqrt(fma(b, b, Float64(c * Float64(a * -4.0)))) - b) / Float64(a * 2.0));
	else
		tmp = Float64(Float64(Float64(-c) / b) - Float64(a / Float64((b ^ 3.0) / (c ^ 2.0))));
	end
	return tmp
end
code[a_, b_, c_] := If[LessEqual[b, 0.000225], N[(N[(N[Sqrt[N[(b * b + N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[((-c) / b), $MachinePrecision] - N[(a / N[(N[Power[b, 3.0], $MachinePrecision] / N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 81.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. Simplified81.3%

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

      if 2.2499999999999999e-4 < b

      1. Initial program 24.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. *-commutative24.4%

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

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

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

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

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

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

          \[\leadsto \color{blue}{\frac{-c}{b}} - \frac{a \cdot {c}^{2}}{{b}^{3}} \]
        5. associate-/l*94.5%

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 0.000225:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b} - \frac{a}{\frac{{b}^{3}}{{c}^{2}}}\\ \end{array} \]

    Alternative 5: 90.9% accurate, 0.5× speedup?

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

      1. Initial program 81.2%

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

      if 2.2499999999999999e-4 < b

      1. Initial program 24.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. *-commutative24.4%

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

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

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

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

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

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

          \[\leadsto \color{blue}{\frac{-c}{b}} - \frac{a \cdot {c}^{2}}{{b}^{3}} \]
        5. associate-/l*94.5%

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

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

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

    Alternative 6: 81.2% 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 28.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. *-commutative28.8%

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

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

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

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

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

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

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

    Reproduce

    ?
    herbie shell --seed 2023309 
    (FPCore (a b c)
      :name "Quadratic roots, medium range"
      :precision binary64
      :pre (and (and (and (< 1.1102230246251565e-16 a) (< a 9007199254740992.0)) (and (< 1.1102230246251565e-16 b) (< b 9007199254740992.0))) (and (< 1.1102230246251565e-16 c) (< c 9007199254740992.0)))
      (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))