Quadratic roots, narrow range

Percentage Accurate: 55.5% → 99.5%
Time: 9.9s
Alternatives: 6
Speedup: 29.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 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: 55.5% accurate, 1.0× speedup?

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

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

Alternative 1: 99.5% accurate, 0.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 2: 84.8% accurate, 0.5× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2} \leq -0.0062:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b} - a \cdot \frac{c}{\frac{{b}^{3}}{c}}\\ \end{array} \end{array} \]
    (FPCore (a b c)
     :precision binary64
     (if (<= (/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* a 2.0)) -0.0062)
       (/ (- (sqrt (- (* b b) (* (* c a) 4.0))) b) (* a 2.0))
       (- (/ (- c) b) (* a (/ c (/ (pow b 3.0) c))))))
    double code(double a, double b, double c) {
    	double tmp;
    	if (((sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0)) <= -0.0062) {
    		tmp = (sqrt(((b * b) - ((c * a) * 4.0))) - b) / (a * 2.0);
    	} else {
    		tmp = (-c / b) - (a * (c / (pow(b, 3.0) / c)));
    	}
    	return tmp;
    }
    
    real(8) function code(a, b, c)
        real(8), intent (in) :: a
        real(8), intent (in) :: b
        real(8), intent (in) :: c
        real(8) :: tmp
        if (((sqrt(((b * b) - (c * (a * 4.0d0)))) - b) / (a * 2.0d0)) <= (-0.0062d0)) then
            tmp = (sqrt(((b * b) - ((c * a) * 4.0d0))) - b) / (a * 2.0d0)
        else
            tmp = (-c / b) - (a * (c / ((b ** 3.0d0) / c)))
        end if
        code = tmp
    end function
    
    public static double code(double a, double b, double c) {
    	double tmp;
    	if (((Math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0)) <= -0.0062) {
    		tmp = (Math.sqrt(((b * b) - ((c * a) * 4.0))) - b) / (a * 2.0);
    	} else {
    		tmp = (-c / b) - (a * (c / (Math.pow(b, 3.0) / c)));
    	}
    	return tmp;
    }
    
    def code(a, b, c):
    	tmp = 0
    	if ((math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0)) <= -0.0062:
    		tmp = (math.sqrt(((b * b) - ((c * a) * 4.0))) - b) / (a * 2.0)
    	else:
    		tmp = (-c / b) - (a * (c / (math.pow(b, 3.0) / c)))
    	return tmp
    
    function code(a, b, c)
    	tmp = 0.0
    	if (Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(a * 2.0)) <= -0.0062)
    		tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(c * a) * 4.0))) - b) / Float64(a * 2.0));
    	else
    		tmp = Float64(Float64(Float64(-c) / b) - Float64(a * Float64(c / Float64((b ^ 3.0) / c))));
    	end
    	return tmp
    end
    
    function tmp_2 = code(a, b, c)
    	tmp = 0.0;
    	if (((sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0)) <= -0.0062)
    		tmp = (sqrt(((b * b) - ((c * a) * 4.0))) - b) / (a * 2.0);
    	else
    		tmp = (-c / b) - (a * (c / ((b ^ 3.0) / c)));
    	end
    	tmp_2 = tmp;
    end
    
    code[a_, b_, c_] := If[LessEqual[N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], -0.0062], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(c * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[((-c) / b), $MachinePrecision] - N[(a * N[(c / N[(N[Power[b, 3.0], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2} \leq -0.0062:\\
    \;\;\;\;\frac{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b}{a \cdot 2}\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{-c}{b} - a \cdot \frac{c}{\frac{{b}^{3}}{c}}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a)) < -0.00619999999999999978

      1. Initial program 80.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. Simplified80.5%

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

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

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

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

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

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

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

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

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

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

        1. Initial program 47.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

      Alternative 3: 99.3% accurate, 1.0× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(c \cdot a\right) \cdot -4\\ \frac{\frac{t_0}{b + \sqrt{t_0 + b \cdot b}}}{a \cdot 2} \end{array} \end{array} \]
      (FPCore (a b c)
       :precision binary64
       (let* ((t_0 (* (* c a) -4.0)))
         (/ (/ t_0 (+ b (sqrt (+ t_0 (* b b))))) (* a 2.0))))
      double code(double a, double b, double c) {
      	double t_0 = (c * a) * -4.0;
      	return (t_0 / (b + sqrt((t_0 + (b * b))))) / (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
          real(8) :: t_0
          t_0 = (c * a) * (-4.0d0)
          code = (t_0 / (b + sqrt((t_0 + (b * b))))) / (a * 2.0d0)
      end function
      
      public static double code(double a, double b, double c) {
      	double t_0 = (c * a) * -4.0;
      	return (t_0 / (b + Math.sqrt((t_0 + (b * b))))) / (a * 2.0);
      }
      
      def code(a, b, c):
      	t_0 = (c * a) * -4.0
      	return (t_0 / (b + math.sqrt((t_0 + (b * b))))) / (a * 2.0)
      
      function code(a, b, c)
      	t_0 = Float64(Float64(c * a) * -4.0)
      	return Float64(Float64(t_0 / Float64(b + sqrt(Float64(t_0 + Float64(b * b))))) / Float64(a * 2.0))
      end
      
      function tmp = code(a, b, c)
      	t_0 = (c * a) * -4.0;
      	tmp = (t_0 / (b + sqrt((t_0 + (b * b))))) / (a * 2.0);
      end
      
      code[a_, b_, c_] := Block[{t$95$0 = N[(N[(c * a), $MachinePrecision] * -4.0), $MachinePrecision]}, N[(N[(t$95$0 / N[(b + N[Sqrt[N[(t$95$0 + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := \left(c \cdot a\right) \cdot -4\\
      \frac{\frac{t_0}{b + \sqrt{t_0 + b \cdot b}}}{a \cdot 2}
      \end{array}
      \end{array}
      
      Derivation
      1. Initial program 58.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. Simplified58.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        Alternative 4: 81.6% 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 58.2%

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \frac{-c}{b} - \color{blue}{\frac{c}{\frac{{b}^{3}}{c}}} \cdot a \]
        4. Simplified78.8%

          \[\leadsto \color{blue}{\frac{-c}{b} - \frac{c}{\frac{{b}^{3}}{c}} \cdot a} \]
        5. Final simplification78.8%

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

        Alternative 5: 64.3% 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 58.2%

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

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

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

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

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

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

        Alternative 6: 3.2% accurate, 38.7× speedup?

        \[\begin{array}{l} \\ \frac{0}{a} \end{array} \]
        (FPCore (a b c) :precision binary64 (/ 0.0 a))
        double code(double a, double b, double c) {
        	return 0.0 / a;
        }
        
        real(8) function code(a, b, c)
            real(8), intent (in) :: a
            real(8), intent (in) :: b
            real(8), intent (in) :: c
            code = 0.0d0 / a
        end function
        
        public static double code(double a, double b, double c) {
        	return 0.0 / a;
        }
        
        def code(a, b, c):
        	return 0.0 / a
        
        function code(a, b, c)
        	return Float64(0.0 / a)
        end
        
        function tmp = code(a, b, c)
        	tmp = 0.0 / a;
        end
        
        code[a_, b_, c_] := N[(0.0 / a), $MachinePrecision]
        
        \begin{array}{l}
        
        \\
        \frac{0}{a}
        \end{array}
        
        Derivation
        1. Initial program 58.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. add-sqr-sqrt58.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{0.25 \cdot \frac{-2 \cdot \sqrt{c \cdot a} + 2 \cdot \sqrt{c \cdot a}}{a}} \]
        7. Step-by-step derivation
          1. associate-*r/3.2%

            \[\leadsto \color{blue}{\frac{0.25 \cdot \left(-2 \cdot \sqrt{c \cdot a} + 2 \cdot \sqrt{c \cdot a}\right)}{a}} \]
          2. distribute-rgt-out3.2%

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

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

            \[\leadsto \frac{0.25 \cdot \left(\sqrt{a \cdot c} \cdot \color{blue}{0}\right)}{a} \]
          5. mul0-rgt3.2%

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

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

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

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

        Reproduce

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