Quadratic roots, medium range

Percentage Accurate: 31.7% → 99.6%
Time: 10.2s
Alternatives: 6
Speedup: 29.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 6 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 31.7% 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.5× speedup?

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

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

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
  2. Step-by-step derivation
    1. /-rgt-identity31.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\color{blue}{c \cdot \left(a \cdot -4\right)}}{b + \sqrt{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -4\right)}} \cdot \frac{0.5}{a} \]
  13. Step-by-step derivation
    1. associate-*r/99.3%

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

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

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

    \[\leadsto \color{blue}{\frac{\frac{c}{\frac{b + \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)}}{a \cdot -4}} \cdot 0.5}{a}} \]
  15. Step-by-step derivation
    1. associate-/r/99.6%

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

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

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

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

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

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

Alternative 2: 99.4% accurate, 0.5× speedup?

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

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

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
  2. Step-by-step derivation
    1. /-rgt-identity31.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 90.9% accurate, 1.0× speedup?

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

\\
\frac{-c}{b} - a \cdot \frac{c}{\frac{{b}^{3}}{c}}
\end{array}
Derivation
  1. Initial program 31.3%

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
  2. Step-by-step derivation
    1. /-rgt-identity31.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 90.8% accurate, 5.5× speedup?

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

\\
\frac{c \cdot \left(a \cdot -4\right)}{b + \left(b + -2 \cdot \frac{c \cdot a}{b}\right)} \cdot \frac{0.5}{a}
\end{array}
Derivation
  1. Initial program 31.3%

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
  2. Step-by-step derivation
    1. /-rgt-identity31.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 81.2% accurate, 29.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 1.6% accurate, 38.7× speedup?

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

\\
\frac{b}{a}
\end{array}
Derivation
  1. Initial program 31.3%

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
  2. Step-by-step derivation
    1. /-rgt-identity31.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{b}{a}} \]
  12. Final simplification1.6%

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

Reproduce

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