Quadratic roots, medium range

Percentage Accurate: 31.3% → 99.7%
Time: 16.5s
Alternatives: 5
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 5 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.3% 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, 0.4× speedup?

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

\\
\frac{c \cdot 2}{\left(-b\right) - \sqrt{\mathsf{fma}\left(-4, c \cdot a, {b}^{2}\right)}}
\end{array}
Derivation
  1. Initial program 30.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{0 - {b}^{2}}{\color{blue}{b}} + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a \cdot 2} \]
  6. Applied egg-rr30.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(c, a \cdot 4, 0\right)}{\left(-b\right) - \sqrt{{b}^{2} - c \cdot \left(a \cdot 4\right)}} \cdot \frac{1}{2 \cdot a}} \]
  15. Step-by-step derivation
    1. associate-*l/99.4%

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

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

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

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

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

      \[\leadsto \frac{\mathsf{fma}\left(c, 4 \cdot a, 0\right) \cdot \frac{0.5}{a}}{\left(-b\right) - \sqrt{{b}^{2} - \color{blue}{\left(4 \cdot a\right)} \cdot c}} \]
    7. associate-*r*99.4%

      \[\leadsto \frac{\mathsf{fma}\left(c, 4 \cdot a, 0\right) \cdot \frac{0.5}{a}}{\left(-b\right) - \sqrt{{b}^{2} - \color{blue}{4 \cdot \left(a \cdot c\right)}}} \]
    8. cancel-sign-sub-inv99.4%

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

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

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

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

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

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

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

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

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

Alternative 2: 99.4% accurate, 0.5× speedup?

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

\\
\frac{\frac{\left(c \cdot a\right) \cdot 4}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot \left(-4\right)\right)\right)}}}{2 \cdot a}
\end{array}
Derivation
  1. Initial program 30.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{0 - {b}^{2}}{\color{blue}{b}} + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a \cdot 2} \]
  6. Applied egg-rr30.7%

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\color{blue}{\frac{\left({b}^{2} - {b}^{2}\right) + c \cdot \left(a \cdot 4\right)}{\left(-b\right) - \sqrt{{b}^{2} - c \cdot \left(a \cdot 4\right)}}}}{a \cdot 2} \]
  13. Step-by-step derivation
    1. cancel-sign-sub-inv99.4%

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

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

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

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

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

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

Alternative 3: 99.4% accurate, 0.5× speedup?

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

\\
\frac{\frac{\left(c \cdot a\right) \cdot 4}{\left(-b\right) - \sqrt{{b}^{2} - c \cdot \left(a \cdot 4\right)}}}{2 \cdot a}
\end{array}
Derivation
  1. Initial program 30.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{0 - {b}^{2}}{\color{blue}{b}} + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a \cdot 2} \]
  6. Applied egg-rr30.7%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 90.7% accurate, 12.9× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{0 - {b}^{2}}{\color{blue}{b}} + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a \cdot 2} \]
  6. Applied egg-rr30.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{1}{\color{blue}{-1 \cdot \frac{b}{c} + \frac{a}{b}}} \]
  14. Final simplification91.4%

    \[\leadsto \frac{1}{\frac{a}{b} - \frac{b}{c}} \]
  15. Add Preprocessing

Alternative 5: 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(c / Float64(-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 30.7%

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

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

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

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

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

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

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

    \[\leadsto \frac{c}{-b} \]
  9. Add Preprocessing

Reproduce

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