Quadratic roots, medium range

Percentage Accurate: 31.2% → 99.7%
Time: 9.4s
Alternatives: 4
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 4 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.2% accurate, 1.0× speedup?

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

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

Alternative 1: 99.7% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

    \[\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. *-commutative99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 90.8% accurate, 1.0× speedup?

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

\\
\frac{-c}{b} - a \cdot \frac{c}{\frac{{b}^{3}}{c}}
\end{array}
Derivation
  1. Initial program 31.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. *-commutative31.2%

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

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

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

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

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

      \[\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-in31.3%

      \[\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-eval31.3%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{-c}{b} - \color{blue}{\frac{{c}^{2}}{\frac{{b}^{3}}{a}}} \]
    7. associate-/r/91.9%

      \[\leadsto \frac{-c}{b} - \color{blue}{\frac{{c}^{2}}{{b}^{3}} \cdot a} \]
    8. unpow291.9%

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

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

    \[\leadsto \color{blue}{\frac{-c}{b} - \frac{c}{\frac{{b}^{3}}{c}} \cdot a} \]
  7. Final simplification91.9%

    \[\leadsto \frac{-c}{b} - a \cdot \frac{c}{\frac{{b}^{3}}{c}} \]

Alternative 3: 90.8% accurate, 1.0× speedup?

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

\\
\left(-\frac{c \cdot \left(c \cdot a\right)}{{b}^{3}}\right) - \frac{c}{b}
\end{array}
Derivation
  1. Initial program 31.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. flip-+31.1%

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

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

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

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

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

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

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

    \[\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. *-commutative99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{-\color{blue}{c \cdot \left(c \cdot a\right)}}{{b}^{3}} - \frac{c}{b} \]
  13. Simplified91.9%

    \[\leadsto \color{blue}{\frac{-c \cdot \left(c \cdot a\right)}{{b}^{3}} - \frac{c}{b}} \]
  14. Final simplification91.9%

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

Alternative 4: 81.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 31.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. *-commutative31.2%

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

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

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

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

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

      \[\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-in31.3%

      \[\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-eval31.3%

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

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

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

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

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

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

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

Reproduce

?
herbie shell --seed 2023240 
(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)))