Quadratic roots, medium range

Percentage Accurate: 31.8% → 99.6%
Time: 9.9s
Alternatives: 9
Speedup: 3.6×

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 9 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.8% accurate, 1.0× speedup?

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

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

Alternative 1: 99.6% accurate, 0.7× speedup?

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

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

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift--.f64N/A

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a} \]
    2. lift-*.f64N/A

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{\left(4 \cdot a\right) \cdot c}}}{2 \cdot a} \]
    3. fp-cancel-sub-sign-invN/A

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{b \cdot b + \left(\mathsf{neg}\left(4 \cdot a\right)\right) \cdot c}}}{2 \cdot a} \]
    4. +-commutativeN/A

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\left(\mathsf{neg}\left(4 \cdot a\right)\right) \cdot c + b \cdot b}}}{2 \cdot a} \]
    5. lift-*.f64N/A

      \[\leadsto \frac{\left(-b\right) + \sqrt{\left(\mathsf{neg}\left(\color{blue}{4 \cdot a}\right)\right) \cdot c + b \cdot b}}{2 \cdot a} \]
    6. distribute-lft-neg-inN/A

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\left(\left(\mathsf{neg}\left(4\right)\right) \cdot a\right)} \cdot c + b \cdot b}}{2 \cdot a} \]
    7. associate-*r*N/A

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\left(\mathsf{neg}\left(4\right)\right) \cdot \left(a \cdot c\right)} + b \cdot b}}{2 \cdot a} \]
    8. *-commutativeN/A

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\left(a \cdot c\right) \cdot \left(\mathsf{neg}\left(4\right)\right)} + b \cdot b}}{2 \cdot a} \]
    9. lower-fma.f64N/A

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\mathsf{fma}\left(a \cdot c, \mathsf{neg}\left(4\right), b \cdot b\right)}}}{2 \cdot a} \]
    10. *-commutativeN/A

      \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(\color{blue}{c \cdot a}, \mathsf{neg}\left(4\right), b \cdot b\right)}}{2 \cdot a} \]
    11. lower-*.f64N/A

      \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(\color{blue}{c \cdot a}, \mathsf{neg}\left(4\right), b \cdot b\right)}}{2 \cdot a} \]
    12. metadata-eval34.1

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

    \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\mathsf{fma}\left(c \cdot a, -4, b \cdot b\right)}}}{2 \cdot a} \]
  5. Step-by-step derivation
    1. lift-/.f64N/A

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

      \[\leadsto \frac{\color{blue}{\left(-b\right) + \sqrt{\mathsf{fma}\left(c \cdot a, -4, b \cdot b\right)}}}{2 \cdot a} \]
    3. flip-+N/A

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.4% accurate, 0.8× speedup?

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

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

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift--.f64N/A

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a} \]
    2. lift-*.f64N/A

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{\left(4 \cdot a\right) \cdot c}}}{2 \cdot a} \]
    3. fp-cancel-sub-sign-invN/A

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{b \cdot b + \left(\mathsf{neg}\left(4 \cdot a\right)\right) \cdot c}}}{2 \cdot a} \]
    4. +-commutativeN/A

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\left(\mathsf{neg}\left(4 \cdot a\right)\right) \cdot c + b \cdot b}}}{2 \cdot a} \]
    5. lift-*.f64N/A

      \[\leadsto \frac{\left(-b\right) + \sqrt{\left(\mathsf{neg}\left(\color{blue}{4 \cdot a}\right)\right) \cdot c + b \cdot b}}{2 \cdot a} \]
    6. distribute-lft-neg-inN/A

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\left(\left(\mathsf{neg}\left(4\right)\right) \cdot a\right)} \cdot c + b \cdot b}}{2 \cdot a} \]
    7. associate-*r*N/A

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\left(\mathsf{neg}\left(4\right)\right) \cdot \left(a \cdot c\right)} + b \cdot b}}{2 \cdot a} \]
    8. *-commutativeN/A

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\left(a \cdot c\right) \cdot \left(\mathsf{neg}\left(4\right)\right)} + b \cdot b}}{2 \cdot a} \]
    9. lower-fma.f64N/A

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\mathsf{fma}\left(a \cdot c, \mathsf{neg}\left(4\right), b \cdot b\right)}}}{2 \cdot a} \]
    10. *-commutativeN/A

      \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(\color{blue}{c \cdot a}, \mathsf{neg}\left(4\right), b \cdot b\right)}}{2 \cdot a} \]
    11. lower-*.f64N/A

      \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(\color{blue}{c \cdot a}, \mathsf{neg}\left(4\right), b \cdot b\right)}}{2 \cdot a} \]
    12. metadata-eval34.1

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

    \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\mathsf{fma}\left(c \cdot a, -4, b \cdot b\right)}}}{2 \cdot a} \]
  5. Step-by-step derivation
    1. lift-/.f64N/A

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

      \[\leadsto \frac{\color{blue}{\left(-b\right) + \sqrt{\mathsf{fma}\left(c \cdot a, -4, b \cdot b\right)}}}{2 \cdot a} \]
    3. div-addN/A

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

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

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

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

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

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

    \[\leadsto \frac{\color{blue}{\frac{c}{a}}}{\frac{\left(-b\right) - \sqrt{\mathsf{fma}\left(-4, a \cdot c, b \cdot b\right)}}{2 \cdot a}} \]
  10. Step-by-step derivation
    1. lift-/.f64N/A

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

      \[\leadsto \frac{\frac{c}{a}}{\color{blue}{\frac{\left(-b\right) - \sqrt{\mathsf{fma}\left(-4, a \cdot c, b \cdot b\right)}}{2 \cdot a}}} \]
    3. associate-/r/N/A

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

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

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

      \[\leadsto \color{blue}{\left(\frac{\frac{c}{a}}{\left(-b\right) - \sqrt{\mathsf{fma}\left(-4, a \cdot c, b \cdot b\right)}} \cdot a\right) \cdot 2} \]
    7. lower-*.f64N/A

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

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

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

Alternative 3: 99.4% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \frac{\left(c \cdot a\right) \cdot 4}{\left(\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -4\right)}\right) \cdot \left(2 \cdot a\right)} \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(c * a) * 4.0) / Float64(Float64(Float64(-b) - sqrt(fma(b, b, Float64(Float64(c * a) * -4.0)))) * Float64(2.0 * a)))
end
code[a_, b_, c_] := N[(N[(N[(c * a), $MachinePrecision] * 4.0), $MachinePrecision] / N[(N[((-b) - N[Sqrt[N[(b * b + N[(N[(c * a), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(2.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift--.f64N/A

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a} \]
    2. lift-*.f64N/A

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{\left(4 \cdot a\right) \cdot c}}}{2 \cdot a} \]
    3. fp-cancel-sub-sign-invN/A

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{b \cdot b + \left(\mathsf{neg}\left(4 \cdot a\right)\right) \cdot c}}}{2 \cdot a} \]
    4. +-commutativeN/A

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\left(\mathsf{neg}\left(4 \cdot a\right)\right) \cdot c + b \cdot b}}}{2 \cdot a} \]
    5. lift-*.f64N/A

      \[\leadsto \frac{\left(-b\right) + \sqrt{\left(\mathsf{neg}\left(\color{blue}{4 \cdot a}\right)\right) \cdot c + b \cdot b}}{2 \cdot a} \]
    6. distribute-lft-neg-inN/A

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\left(\left(\mathsf{neg}\left(4\right)\right) \cdot a\right)} \cdot c + b \cdot b}}{2 \cdot a} \]
    7. associate-*r*N/A

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\left(\mathsf{neg}\left(4\right)\right) \cdot \left(a \cdot c\right)} + b \cdot b}}{2 \cdot a} \]
    8. *-commutativeN/A

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\left(a \cdot c\right) \cdot \left(\mathsf{neg}\left(4\right)\right)} + b \cdot b}}{2 \cdot a} \]
    9. lower-fma.f64N/A

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\mathsf{fma}\left(a \cdot c, \mathsf{neg}\left(4\right), b \cdot b\right)}}}{2 \cdot a} \]
    10. *-commutativeN/A

      \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(\color{blue}{c \cdot a}, \mathsf{neg}\left(4\right), b \cdot b\right)}}{2 \cdot a} \]
    11. lower-*.f64N/A

      \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(\color{blue}{c \cdot a}, \mathsf{neg}\left(4\right), b \cdot b\right)}}{2 \cdot a} \]
    12. metadata-eval34.1

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

    \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\mathsf{fma}\left(c \cdot a, -4, b \cdot b\right)}}}{2 \cdot a} \]
  5. Step-by-step derivation
    1. lift-/.f64N/A

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

      \[\leadsto \frac{\color{blue}{\left(-b\right) + \sqrt{\mathsf{fma}\left(c \cdot a, -4, b \cdot b\right)}}}{2 \cdot a} \]
    3. flip-+N/A

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\color{blue}{\left(c \cdot a\right) \cdot 4}}{\left(\left(-b\right) - \sqrt{\mathsf{fma}\left(-4, a \cdot c, b \cdot b\right)}\right) \cdot \left(2 \cdot a\right)} \]
  10. Step-by-step derivation
    1. lift-*.f64N/A

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

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

      \[\leadsto \frac{\left(c \cdot a\right) \cdot 4}{\left(\left(-b\right) - \sqrt{\color{blue}{b \cdot b + -4 \cdot \left(a \cdot c\right)}}\right) \cdot \left(2 \cdot a\right)} \]
    4. lower-fma.f64N/A

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

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

      \[\leadsto \frac{\left(c \cdot a\right) \cdot 4}{\left(\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, \color{blue}{\left(a \cdot c\right) \cdot -4}\right)}\right) \cdot \left(2 \cdot a\right)} \]
    7. lift-*.f64N/A

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

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

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

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

Alternative 4: 99.4% accurate, 0.8× speedup?

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

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

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift--.f64N/A

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a} \]
    2. lift-*.f64N/A

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{\left(4 \cdot a\right) \cdot c}}}{2 \cdot a} \]
    3. fp-cancel-sub-sign-invN/A

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{b \cdot b + \left(\mathsf{neg}\left(4 \cdot a\right)\right) \cdot c}}}{2 \cdot a} \]
    4. +-commutativeN/A

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\left(\mathsf{neg}\left(4 \cdot a\right)\right) \cdot c + b \cdot b}}}{2 \cdot a} \]
    5. lift-*.f64N/A

      \[\leadsto \frac{\left(-b\right) + \sqrt{\left(\mathsf{neg}\left(\color{blue}{4 \cdot a}\right)\right) \cdot c + b \cdot b}}{2 \cdot a} \]
    6. distribute-lft-neg-inN/A

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\left(\left(\mathsf{neg}\left(4\right)\right) \cdot a\right)} \cdot c + b \cdot b}}{2 \cdot a} \]
    7. associate-*r*N/A

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\left(\mathsf{neg}\left(4\right)\right) \cdot \left(a \cdot c\right)} + b \cdot b}}{2 \cdot a} \]
    8. *-commutativeN/A

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\left(a \cdot c\right) \cdot \left(\mathsf{neg}\left(4\right)\right)} + b \cdot b}}{2 \cdot a} \]
    9. lower-fma.f64N/A

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\mathsf{fma}\left(a \cdot c, \mathsf{neg}\left(4\right), b \cdot b\right)}}}{2 \cdot a} \]
    10. *-commutativeN/A

      \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(\color{blue}{c \cdot a}, \mathsf{neg}\left(4\right), b \cdot b\right)}}{2 \cdot a} \]
    11. lower-*.f64N/A

      \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(\color{blue}{c \cdot a}, \mathsf{neg}\left(4\right), b \cdot b\right)}}{2 \cdot a} \]
    12. metadata-eval34.1

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

    \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\mathsf{fma}\left(c \cdot a, -4, b \cdot b\right)}}}{2 \cdot a} \]
  5. Step-by-step derivation
    1. lift-/.f64N/A

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

      \[\leadsto \frac{\color{blue}{\left(-b\right) + \sqrt{\mathsf{fma}\left(c \cdot a, -4, b \cdot b\right)}}}{2 \cdot a} \]
    3. flip-+N/A

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

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

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

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

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

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

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

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

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

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

Alternative 5: 90.7% accurate, 0.9× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;-\mathsf{fma}\left(\frac{a}{b \cdot b}, \frac{c \cdot c}{b}, \frac{c}{b}\right)\\


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

    1. Initial program 78.0%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{\left(4 \cdot a\right) \cdot c}}}{2 \cdot a} \]
      3. fp-cancel-sub-sign-invN/A

        \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{b \cdot b + \left(\mathsf{neg}\left(4 \cdot a\right)\right) \cdot c}}}{2 \cdot a} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{b \cdot b} + \left(\mathsf{neg}\left(4 \cdot a\right)\right) \cdot c}}{2 \cdot a} \]
      5. lower-fma.f64N/A

        \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\mathsf{fma}\left(b, b, \left(\mathsf{neg}\left(4 \cdot a\right)\right) \cdot c\right)}}}{2 \cdot a} \]
      6. lower-*.f64N/A

        \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, \color{blue}{\left(\mathsf{neg}\left(4 \cdot a\right)\right) \cdot c}\right)}}{2 \cdot a} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, \left(\mathsf{neg}\left(\color{blue}{4 \cdot a}\right)\right) \cdot c\right)}}{2 \cdot a} \]
      8. distribute-lft-neg-inN/A

        \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, \color{blue}{\left(\left(\mathsf{neg}\left(4\right)\right) \cdot a\right)} \cdot c\right)}}{2 \cdot a} \]
      9. lower-*.f64N/A

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

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

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

    if 7.79999999999999986e-4 < b

    1. Initial program 30.0%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
    2. Add Preprocessing
    3. Taylor expanded in a around 0

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b} + a \cdot \left(-1 \cdot \frac{{c}^{2}}{{b}^{3}} + a \cdot \left(-2 \cdot \frac{{c}^{3}}{{b}^{5}} + \frac{-1}{4} \cdot \frac{a \cdot \left(4 \cdot \frac{{c}^{4}}{{b}^{6}} + 16 \cdot \frac{{c}^{4}}{{b}^{6}}\right)}{b}\right)\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{a \cdot \left(-1 \cdot \frac{{c}^{2}}{{b}^{3}} + a \cdot \left(-2 \cdot \frac{{c}^{3}}{{b}^{5}} + \frac{-1}{4} \cdot \frac{a \cdot \left(4 \cdot \frac{{c}^{4}}{{b}^{6}} + 16 \cdot \frac{{c}^{4}}{{b}^{6}}\right)}{b}\right)\right) + -1 \cdot \frac{c}{b}} \]
      2. *-commutativeN/A

        \[\leadsto \color{blue}{\left(-1 \cdot \frac{{c}^{2}}{{b}^{3}} + a \cdot \left(-2 \cdot \frac{{c}^{3}}{{b}^{5}} + \frac{-1}{4} \cdot \frac{a \cdot \left(4 \cdot \frac{{c}^{4}}{{b}^{6}} + 16 \cdot \frac{{c}^{4}}{{b}^{6}}\right)}{b}\right)\right) \cdot a} + -1 \cdot \frac{c}{b} \]
      3. lower-fma.f64N/A

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.25 \cdot a, \frac{{c}^{4}}{{b}^{6}} \cdot \frac{20}{b}, \frac{{c}^{3} \cdot -2}{{b}^{5}}\right), a, \frac{\left(-c\right) \cdot c}{{b}^{3}}\right), a, \frac{-c}{b}\right)} \]
    6. Taylor expanded in a around 0

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

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

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\frac{a \cdot {c}^{2}}{{b}^{3}}\right)\right)} + -1 \cdot \frac{c}{b} \]
      3. mul-1-negN/A

        \[\leadsto \left(\mathsf{neg}\left(\frac{a \cdot {c}^{2}}{{b}^{3}}\right)\right) + \color{blue}{\left(\mathsf{neg}\left(\frac{c}{b}\right)\right)} \]
      4. distribute-neg-outN/A

        \[\leadsto \color{blue}{\mathsf{neg}\left(\left(\frac{a \cdot {c}^{2}}{{b}^{3}} + \frac{c}{b}\right)\right)} \]
      5. lower-neg.f64N/A

        \[\leadsto \color{blue}{-\left(\frac{a \cdot {c}^{2}}{{b}^{3}} + \frac{c}{b}\right)} \]
      6. associate-/l*N/A

        \[\leadsto -\left(\color{blue}{a \cdot \frac{{c}^{2}}{{b}^{3}}} + \frac{c}{b}\right) \]
      7. lower-fma.f64N/A

        \[\leadsto -\color{blue}{\mathsf{fma}\left(a, \frac{{c}^{2}}{{b}^{3}}, \frac{c}{b}\right)} \]
      8. lower-/.f64N/A

        \[\leadsto -\mathsf{fma}\left(a, \color{blue}{\frac{{c}^{2}}{{b}^{3}}}, \frac{c}{b}\right) \]
      9. unpow2N/A

        \[\leadsto -\mathsf{fma}\left(a, \frac{\color{blue}{c \cdot c}}{{b}^{3}}, \frac{c}{b}\right) \]
      10. lower-*.f64N/A

        \[\leadsto -\mathsf{fma}\left(a, \frac{\color{blue}{c \cdot c}}{{b}^{3}}, \frac{c}{b}\right) \]
      11. lower-pow.f64N/A

        \[\leadsto -\mathsf{fma}\left(a, \frac{c \cdot c}{\color{blue}{{b}^{3}}}, \frac{c}{b}\right) \]
      12. lower-/.f6492.3

        \[\leadsto -\mathsf{fma}\left(a, \frac{c \cdot c}{{b}^{3}}, \color{blue}{\frac{c}{b}}\right) \]
    8. Applied rewrites92.3%

      \[\leadsto \color{blue}{-\mathsf{fma}\left(a, \frac{c \cdot c}{{b}^{3}}, \frac{c}{b}\right)} \]
    9. Step-by-step derivation
      1. Applied rewrites92.3%

        \[\leadsto -\mathsf{fma}\left(\frac{a}{b \cdot b}, \frac{c \cdot c}{b}, \frac{c}{b}\right) \]
    10. Recombined 2 regimes into one program.
    11. Add Preprocessing

    Alternative 6: 90.6% accurate, 0.9× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 0.00078:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, \left(-4 \cdot a\right) \cdot c\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{c}{a}}{\mathsf{fma}\left(\frac{b}{a}, -1, \frac{c}{b}\right)}\\ \end{array} \end{array} \]
    (FPCore (a b c)
     :precision binary64
     (if (<= b 0.00078)
       (/ (+ (- b) (sqrt (fma b b (* (* -4.0 a) c)))) (* 2.0 a))
       (/ (/ c a) (fma (/ b a) -1.0 (/ c b)))))
    double code(double a, double b, double c) {
    	double tmp;
    	if (b <= 0.00078) {
    		tmp = (-b + sqrt(fma(b, b, ((-4.0 * a) * c)))) / (2.0 * a);
    	} else {
    		tmp = (c / a) / fma((b / a), -1.0, (c / b));
    	}
    	return tmp;
    }
    
    function code(a, b, c)
    	tmp = 0.0
    	if (b <= 0.00078)
    		tmp = Float64(Float64(Float64(-b) + sqrt(fma(b, b, Float64(Float64(-4.0 * a) * c)))) / Float64(2.0 * a));
    	else
    		tmp = Float64(Float64(c / a) / fma(Float64(b / a), -1.0, Float64(c / b)));
    	end
    	return tmp
    end
    
    code[a_, b_, c_] := If[LessEqual[b, 0.00078], N[(N[((-b) + N[Sqrt[N[(b * b + N[(N[(-4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c / a), $MachinePrecision] / N[(N[(b / a), $MachinePrecision] * -1.0 + N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;b \leq 0.00078:\\
    \;\;\;\;\frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, \left(-4 \cdot a\right) \cdot c\right)}}{2 \cdot a}\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{\frac{c}{a}}{\mathsf{fma}\left(\frac{b}{a}, -1, \frac{c}{b}\right)}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if b < 7.79999999999999986e-4

      1. Initial program 78.0%

        \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
      2. Add Preprocessing
      3. Step-by-step derivation
        1. lift--.f64N/A

          \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a} \]
        2. lift-*.f64N/A

          \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{\left(4 \cdot a\right) \cdot c}}}{2 \cdot a} \]
        3. fp-cancel-sub-sign-invN/A

          \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{b \cdot b + \left(\mathsf{neg}\left(4 \cdot a\right)\right) \cdot c}}}{2 \cdot a} \]
        4. lift-*.f64N/A

          \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{b \cdot b} + \left(\mathsf{neg}\left(4 \cdot a\right)\right) \cdot c}}{2 \cdot a} \]
        5. lower-fma.f64N/A

          \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\mathsf{fma}\left(b, b, \left(\mathsf{neg}\left(4 \cdot a\right)\right) \cdot c\right)}}}{2 \cdot a} \]
        6. lower-*.f64N/A

          \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, \color{blue}{\left(\mathsf{neg}\left(4 \cdot a\right)\right) \cdot c}\right)}}{2 \cdot a} \]
        7. lift-*.f64N/A

          \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, \left(\mathsf{neg}\left(\color{blue}{4 \cdot a}\right)\right) \cdot c\right)}}{2 \cdot a} \]
        8. distribute-lft-neg-inN/A

          \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, \color{blue}{\left(\left(\mathsf{neg}\left(4\right)\right) \cdot a\right)} \cdot c\right)}}{2 \cdot a} \]
        9. lower-*.f64N/A

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

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

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

      if 7.79999999999999986e-4 < b

      1. Initial program 30.0%

        \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
      2. Add Preprocessing
      3. Step-by-step derivation
        1. lift--.f64N/A

          \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a} \]
        2. lift-*.f64N/A

          \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{\left(4 \cdot a\right) \cdot c}}}{2 \cdot a} \]
        3. fp-cancel-sub-sign-invN/A

          \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{b \cdot b + \left(\mathsf{neg}\left(4 \cdot a\right)\right) \cdot c}}}{2 \cdot a} \]
        4. +-commutativeN/A

          \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\left(\mathsf{neg}\left(4 \cdot a\right)\right) \cdot c + b \cdot b}}}{2 \cdot a} \]
        5. lift-*.f64N/A

          \[\leadsto \frac{\left(-b\right) + \sqrt{\left(\mathsf{neg}\left(\color{blue}{4 \cdot a}\right)\right) \cdot c + b \cdot b}}{2 \cdot a} \]
        6. distribute-lft-neg-inN/A

          \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\left(\left(\mathsf{neg}\left(4\right)\right) \cdot a\right)} \cdot c + b \cdot b}}{2 \cdot a} \]
        7. associate-*r*N/A

          \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\left(\mathsf{neg}\left(4\right)\right) \cdot \left(a \cdot c\right)} + b \cdot b}}{2 \cdot a} \]
        8. *-commutativeN/A

          \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\left(a \cdot c\right) \cdot \left(\mathsf{neg}\left(4\right)\right)} + b \cdot b}}{2 \cdot a} \]
        9. lower-fma.f64N/A

          \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\mathsf{fma}\left(a \cdot c, \mathsf{neg}\left(4\right), b \cdot b\right)}}}{2 \cdot a} \]
        10. *-commutativeN/A

          \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(\color{blue}{c \cdot a}, \mathsf{neg}\left(4\right), b \cdot b\right)}}{2 \cdot a} \]
        11. lower-*.f64N/A

          \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(\color{blue}{c \cdot a}, \mathsf{neg}\left(4\right), b \cdot b\right)}}{2 \cdot a} \]
        12. metadata-eval30.0

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

        \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\mathsf{fma}\left(c \cdot a, -4, b \cdot b\right)}}}{2 \cdot a} \]
      5. Step-by-step derivation
        1. lift-/.f64N/A

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

          \[\leadsto \frac{\color{blue}{\left(-b\right) + \sqrt{\mathsf{fma}\left(c \cdot a, -4, b \cdot b\right)}}}{2 \cdot a} \]
        3. div-addN/A

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{c}{a}}{\color{blue}{-1 \cdot \frac{b}{a} + \frac{c}{b}}} \]
      11. Step-by-step derivation
        1. *-commutativeN/A

          \[\leadsto \frac{\frac{c}{a}}{\color{blue}{\frac{b}{a} \cdot -1} + \frac{c}{b}} \]
        2. lower-fma.f64N/A

          \[\leadsto \frac{\frac{c}{a}}{\color{blue}{\mathsf{fma}\left(\frac{b}{a}, -1, \frac{c}{b}\right)}} \]
        3. lower-/.f64N/A

          \[\leadsto \frac{\frac{c}{a}}{\mathsf{fma}\left(\color{blue}{\frac{b}{a}}, -1, \frac{c}{b}\right)} \]
        4. lower-/.f6492.3

          \[\leadsto \frac{\frac{c}{a}}{\mathsf{fma}\left(\frac{b}{a}, -1, \color{blue}{\frac{c}{b}}\right)} \]
      12. Applied rewrites92.3%

        \[\leadsto \frac{\frac{c}{a}}{\color{blue}{\mathsf{fma}\left(\frac{b}{a}, -1, \frac{c}{b}\right)}} \]
    3. Recombined 2 regimes into one program.
    4. Add Preprocessing

    Alternative 7: 90.7% accurate, 0.9× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 0.00078:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, \left(-4 \cdot a\right) \cdot c\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\left(c \cdot c\right) \cdot a}{\left(-b\right) \cdot b} - c}{b}\\ \end{array} \end{array} \]
    (FPCore (a b c)
     :precision binary64
     (if (<= b 0.00078)
       (/ (+ (- b) (sqrt (fma b b (* (* -4.0 a) c)))) (* 2.0 a))
       (/ (- (/ (* (* c c) a) (* (- b) b)) c) b)))
    double code(double a, double b, double c) {
    	double tmp;
    	if (b <= 0.00078) {
    		tmp = (-b + sqrt(fma(b, b, ((-4.0 * a) * c)))) / (2.0 * a);
    	} else {
    		tmp = ((((c * c) * a) / (-b * b)) - c) / b;
    	}
    	return tmp;
    }
    
    function code(a, b, c)
    	tmp = 0.0
    	if (b <= 0.00078)
    		tmp = Float64(Float64(Float64(-b) + sqrt(fma(b, b, Float64(Float64(-4.0 * a) * c)))) / Float64(2.0 * a));
    	else
    		tmp = Float64(Float64(Float64(Float64(Float64(c * c) * a) / Float64(Float64(-b) * b)) - c) / b);
    	end
    	return tmp
    end
    
    code[a_, b_, c_] := If[LessEqual[b, 0.00078], N[(N[((-b) + N[Sqrt[N[(b * b + N[(N[(-4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(c * c), $MachinePrecision] * a), $MachinePrecision] / N[((-b) * b), $MachinePrecision]), $MachinePrecision] - c), $MachinePrecision] / b), $MachinePrecision]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;b \leq 0.00078:\\
    \;\;\;\;\frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, \left(-4 \cdot a\right) \cdot c\right)}}{2 \cdot a}\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{\frac{\left(c \cdot c\right) \cdot a}{\left(-b\right) \cdot b} - c}{b}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if b < 7.79999999999999986e-4

      1. Initial program 78.0%

        \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
      2. Add Preprocessing
      3. Step-by-step derivation
        1. lift--.f64N/A

          \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a} \]
        2. lift-*.f64N/A

          \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{\left(4 \cdot a\right) \cdot c}}}{2 \cdot a} \]
        3. fp-cancel-sub-sign-invN/A

          \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{b \cdot b + \left(\mathsf{neg}\left(4 \cdot a\right)\right) \cdot c}}}{2 \cdot a} \]
        4. lift-*.f64N/A

          \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{b \cdot b} + \left(\mathsf{neg}\left(4 \cdot a\right)\right) \cdot c}}{2 \cdot a} \]
        5. lower-fma.f64N/A

          \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\mathsf{fma}\left(b, b, \left(\mathsf{neg}\left(4 \cdot a\right)\right) \cdot c\right)}}}{2 \cdot a} \]
        6. lower-*.f64N/A

          \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, \color{blue}{\left(\mathsf{neg}\left(4 \cdot a\right)\right) \cdot c}\right)}}{2 \cdot a} \]
        7. lift-*.f64N/A

          \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, \left(\mathsf{neg}\left(\color{blue}{4 \cdot a}\right)\right) \cdot c\right)}}{2 \cdot a} \]
        8. distribute-lft-neg-inN/A

          \[\leadsto \frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, \color{blue}{\left(\left(\mathsf{neg}\left(4\right)\right) \cdot a\right)} \cdot c\right)}}{2 \cdot a} \]
        9. lower-*.f64N/A

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

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

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

      if 7.79999999999999986e-4 < b

      1. Initial program 30.0%

        \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
      2. Add Preprocessing
      3. Taylor expanded in a around 0

        \[\leadsto \color{blue}{-1 \cdot \frac{c}{b} + a \cdot \left(-1 \cdot \frac{{c}^{2}}{{b}^{3}} + a \cdot \left(-2 \cdot \frac{{c}^{3}}{{b}^{5}} + \frac{-1}{4} \cdot \frac{a \cdot \left(4 \cdot \frac{{c}^{4}}{{b}^{6}} + 16 \cdot \frac{{c}^{4}}{{b}^{6}}\right)}{b}\right)\right)} \]
      4. Step-by-step derivation
        1. +-commutativeN/A

          \[\leadsto \color{blue}{a \cdot \left(-1 \cdot \frac{{c}^{2}}{{b}^{3}} + a \cdot \left(-2 \cdot \frac{{c}^{3}}{{b}^{5}} + \frac{-1}{4} \cdot \frac{a \cdot \left(4 \cdot \frac{{c}^{4}}{{b}^{6}} + 16 \cdot \frac{{c}^{4}}{{b}^{6}}\right)}{b}\right)\right) + -1 \cdot \frac{c}{b}} \]
        2. *-commutativeN/A

          \[\leadsto \color{blue}{\left(-1 \cdot \frac{{c}^{2}}{{b}^{3}} + a \cdot \left(-2 \cdot \frac{{c}^{3}}{{b}^{5}} + \frac{-1}{4} \cdot \frac{a \cdot \left(4 \cdot \frac{{c}^{4}}{{b}^{6}} + 16 \cdot \frac{{c}^{4}}{{b}^{6}}\right)}{b}\right)\right) \cdot a} + -1 \cdot \frac{c}{b} \]
        3. lower-fma.f64N/A

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.25 \cdot a, \frac{{c}^{4}}{{b}^{6}} \cdot \frac{20}{b}, \frac{{c}^{3} \cdot -2}{{b}^{5}}\right), a, \frac{\left(-c\right) \cdot c}{{b}^{3}}\right), a, \frac{-c}{b}\right)} \]
      6. Taylor expanded in a around 0

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

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

          \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\frac{a \cdot {c}^{2}}{{b}^{3}}\right)\right)} + -1 \cdot \frac{c}{b} \]
        3. mul-1-negN/A

          \[\leadsto \left(\mathsf{neg}\left(\frac{a \cdot {c}^{2}}{{b}^{3}}\right)\right) + \color{blue}{\left(\mathsf{neg}\left(\frac{c}{b}\right)\right)} \]
        4. distribute-neg-outN/A

          \[\leadsto \color{blue}{\mathsf{neg}\left(\left(\frac{a \cdot {c}^{2}}{{b}^{3}} + \frac{c}{b}\right)\right)} \]
        5. lower-neg.f64N/A

          \[\leadsto \color{blue}{-\left(\frac{a \cdot {c}^{2}}{{b}^{3}} + \frac{c}{b}\right)} \]
        6. associate-/l*N/A

          \[\leadsto -\left(\color{blue}{a \cdot \frac{{c}^{2}}{{b}^{3}}} + \frac{c}{b}\right) \]
        7. lower-fma.f64N/A

          \[\leadsto -\color{blue}{\mathsf{fma}\left(a, \frac{{c}^{2}}{{b}^{3}}, \frac{c}{b}\right)} \]
        8. lower-/.f64N/A

          \[\leadsto -\mathsf{fma}\left(a, \color{blue}{\frac{{c}^{2}}{{b}^{3}}}, \frac{c}{b}\right) \]
        9. unpow2N/A

          \[\leadsto -\mathsf{fma}\left(a, \frac{\color{blue}{c \cdot c}}{{b}^{3}}, \frac{c}{b}\right) \]
        10. lower-*.f64N/A

          \[\leadsto -\mathsf{fma}\left(a, \frac{\color{blue}{c \cdot c}}{{b}^{3}}, \frac{c}{b}\right) \]
        11. lower-pow.f64N/A

          \[\leadsto -\mathsf{fma}\left(a, \frac{c \cdot c}{\color{blue}{{b}^{3}}}, \frac{c}{b}\right) \]
        12. lower-/.f6492.3

          \[\leadsto -\mathsf{fma}\left(a, \frac{c \cdot c}{{b}^{3}}, \color{blue}{\frac{c}{b}}\right) \]
      8. Applied rewrites92.3%

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

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

          \[\leadsto \frac{\frac{\left(c \cdot c\right) \cdot a}{\left(-b\right) \cdot b} - c}{\color{blue}{b}} \]
      11. Recombined 2 regimes into one program.
      12. Add Preprocessing

      Alternative 8: 90.7% accurate, 1.2× speedup?

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

        \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
      2. Add Preprocessing
      3. Taylor expanded in a around 0

        \[\leadsto \color{blue}{-1 \cdot \frac{c}{b} + a \cdot \left(-1 \cdot \frac{{c}^{2}}{{b}^{3}} + a \cdot \left(-2 \cdot \frac{{c}^{3}}{{b}^{5}} + \frac{-1}{4} \cdot \frac{a \cdot \left(4 \cdot \frac{{c}^{4}}{{b}^{6}} + 16 \cdot \frac{{c}^{4}}{{b}^{6}}\right)}{b}\right)\right)} \]
      4. Step-by-step derivation
        1. +-commutativeN/A

          \[\leadsto \color{blue}{a \cdot \left(-1 \cdot \frac{{c}^{2}}{{b}^{3}} + a \cdot \left(-2 \cdot \frac{{c}^{3}}{{b}^{5}} + \frac{-1}{4} \cdot \frac{a \cdot \left(4 \cdot \frac{{c}^{4}}{{b}^{6}} + 16 \cdot \frac{{c}^{4}}{{b}^{6}}\right)}{b}\right)\right) + -1 \cdot \frac{c}{b}} \]
        2. *-commutativeN/A

          \[\leadsto \color{blue}{\left(-1 \cdot \frac{{c}^{2}}{{b}^{3}} + a \cdot \left(-2 \cdot \frac{{c}^{3}}{{b}^{5}} + \frac{-1}{4} \cdot \frac{a \cdot \left(4 \cdot \frac{{c}^{4}}{{b}^{6}} + 16 \cdot \frac{{c}^{4}}{{b}^{6}}\right)}{b}\right)\right) \cdot a} + -1 \cdot \frac{c}{b} \]
        3. lower-fma.f64N/A

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.25 \cdot a, \frac{{c}^{4}}{{b}^{6}} \cdot \frac{20}{b}, \frac{{c}^{3} \cdot -2}{{b}^{5}}\right), a, \frac{\left(-c\right) \cdot c}{{b}^{3}}\right), a, \frac{-c}{b}\right)} \]
      6. Taylor expanded in a around 0

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

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

          \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\frac{a \cdot {c}^{2}}{{b}^{3}}\right)\right)} + -1 \cdot \frac{c}{b} \]
        3. mul-1-negN/A

          \[\leadsto \left(\mathsf{neg}\left(\frac{a \cdot {c}^{2}}{{b}^{3}}\right)\right) + \color{blue}{\left(\mathsf{neg}\left(\frac{c}{b}\right)\right)} \]
        4. distribute-neg-outN/A

          \[\leadsto \color{blue}{\mathsf{neg}\left(\left(\frac{a \cdot {c}^{2}}{{b}^{3}} + \frac{c}{b}\right)\right)} \]
        5. lower-neg.f64N/A

          \[\leadsto \color{blue}{-\left(\frac{a \cdot {c}^{2}}{{b}^{3}} + \frac{c}{b}\right)} \]
        6. associate-/l*N/A

          \[\leadsto -\left(\color{blue}{a \cdot \frac{{c}^{2}}{{b}^{3}}} + \frac{c}{b}\right) \]
        7. lower-fma.f64N/A

          \[\leadsto -\color{blue}{\mathsf{fma}\left(a, \frac{{c}^{2}}{{b}^{3}}, \frac{c}{b}\right)} \]
        8. lower-/.f64N/A

          \[\leadsto -\mathsf{fma}\left(a, \color{blue}{\frac{{c}^{2}}{{b}^{3}}}, \frac{c}{b}\right) \]
        9. unpow2N/A

          \[\leadsto -\mathsf{fma}\left(a, \frac{\color{blue}{c \cdot c}}{{b}^{3}}, \frac{c}{b}\right) \]
        10. lower-*.f64N/A

          \[\leadsto -\mathsf{fma}\left(a, \frac{\color{blue}{c \cdot c}}{{b}^{3}}, \frac{c}{b}\right) \]
        11. lower-pow.f64N/A

          \[\leadsto -\mathsf{fma}\left(a, \frac{c \cdot c}{\color{blue}{{b}^{3}}}, \frac{c}{b}\right) \]
        12. lower-/.f6489.5

          \[\leadsto -\mathsf{fma}\left(a, \frac{c \cdot c}{{b}^{3}}, \color{blue}{\frac{c}{b}}\right) \]
      8. Applied rewrites89.5%

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

        \[\leadsto \frac{-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{2}} - c}{\color{blue}{b}} \]
      10. Step-by-step derivation
        1. Applied rewrites89.4%

          \[\leadsto \frac{\frac{\left(c \cdot c\right) \cdot a}{\left(-b\right) \cdot b} - c}{\color{blue}{b}} \]
        2. Add Preprocessing

        Alternative 9: 81.1% accurate, 3.6× 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 34.1%

          \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
        2. Add Preprocessing
        3. Taylor expanded in a around 0

          \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}} \]
        4. Step-by-step derivation
          1. associate-*r/N/A

            \[\leadsto \color{blue}{\frac{-1 \cdot c}{b}} \]
          2. mul-1-negN/A

            \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(c\right)}}{b} \]
          3. lower-/.f64N/A

            \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(c\right)}{b}} \]
          4. lower-neg.f6479.3

            \[\leadsto \frac{\color{blue}{-c}}{b} \]
        5. Applied rewrites79.3%

          \[\leadsto \color{blue}{\frac{-c}{b}} \]
        6. Add Preprocessing

        Reproduce

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