Quadratic roots, wide range

Percentage Accurate: 18.4% → 99.7%
Time: 11.3s
Alternatives: 6
Speedup: 29.0×

Specification

?
\[\left(\left(4.930380657631324 \cdot 10^{-32} < a \land a < 2.028240960365167 \cdot 10^{+31}\right) \land \left(4.930380657631324 \cdot 10^{-32} < b \land b < 2.028240960365167 \cdot 10^{+31}\right)\right) \land \left(4.930380657631324 \cdot 10^{-32} < c \land c < 2.028240960365167 \cdot 10^{+31}\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: 18.4% accurate, 1.0× speedup?

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

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

Alternative 1: 99.7% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(c \cdot 4\right) \cdot a\\ \frac{\frac{t_0}{a \cdot 2}}{\left(-b\right) - {\left(\frac{\mathsf{fma}\left(t_0, \mathsf{fma}\left(b, b, t_0\right), {b}^{4}\right)}{\mathsf{fma}\left(-64, {\left(c \cdot a\right)}^{3}, {b}^{6}\right)}\right)}^{-0.5}} \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (* (* c 4.0) a)))
   (/
    (/ t_0 (* a 2.0))
    (-
     (- b)
     (pow
      (/
       (fma t_0 (fma b b t_0) (pow b 4.0))
       (fma -64.0 (pow (* c a) 3.0) (pow b 6.0)))
      -0.5)))))
double code(double a, double b, double c) {
	double t_0 = (c * 4.0) * a;
	return (t_0 / (a * 2.0)) / (-b - pow((fma(t_0, fma(b, b, t_0), pow(b, 4.0)) / fma(-64.0, pow((c * a), 3.0), pow(b, 6.0))), -0.5));
}
function code(a, b, c)
	t_0 = Float64(Float64(c * 4.0) * a)
	return Float64(Float64(t_0 / Float64(a * 2.0)) / Float64(Float64(-b) - (Float64(fma(t_0, fma(b, b, t_0), (b ^ 4.0)) / fma(-64.0, (Float64(c * a) ^ 3.0), (b ^ 6.0))) ^ -0.5)))
end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(c * 4.0), $MachinePrecision] * a), $MachinePrecision]}, N[(N[(t$95$0 / N[(a * 2.0), $MachinePrecision]), $MachinePrecision] / N[((-b) - N[Power[N[(N[(t$95$0 * N[(b * b + t$95$0), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision] / N[(-64.0 * N[Power[N[(c * a), $MachinePrecision], 3.0], $MachinePrecision] + N[Power[b, 6.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(c \cdot 4\right) \cdot a\\
\frac{\frac{t_0}{a \cdot 2}}{\left(-b\right) - {\left(\frac{\mathsf{fma}\left(t_0, \mathsf{fma}\left(b, b, t_0\right), {b}^{4}\right)}{\mathsf{fma}\left(-64, {\left(c \cdot a\right)}^{3}, {b}^{6}\right)}\right)}^{-0.5}}
\end{array}
\end{array}
Derivation
  1. Initial program 16.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\frac{\color{blue}{\left(4 \cdot c\right) \cdot a}}{\left(-b\right) - {\left(\frac{\mathsf{fma}\left(\left(4 \cdot a\right) \cdot c, \mathsf{fma}\left(b, b, \left(4 \cdot a\right) \cdot c\right), {b}^{4}\right)}{{b}^{6} + -64 \cdot {\left(a \cdot c\right)}^{3}}\right)}^{-0.5}}}{a \cdot 2} \]
  11. Step-by-step derivation
    1. expm1-log1p-u83.5%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\frac{\left(4 \cdot c\right) \cdot a}{\left(-b\right) - {\left(\frac{\mathsf{fma}\left(\left(4 \cdot a\right) \cdot c, \mathsf{fma}\left(b, b, \left(4 \cdot a\right) \cdot c\right), {b}^{4}\right)}{{b}^{6} + -64 \cdot {\left(a \cdot c\right)}^{3}}\right)}^{-0.5}}}{a \cdot 2}\right)\right)} \]
    2. expm1-udef20.5%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\frac{\left(4 \cdot c\right) \cdot a}{\left(-b\right) - {\left(\frac{\mathsf{fma}\left(\left(4 \cdot a\right) \cdot c, \mathsf{fma}\left(b, b, \left(4 \cdot a\right) \cdot c\right), {b}^{4}\right)}{{b}^{6} + -64 \cdot {\left(a \cdot c\right)}^{3}}\right)}^{-0.5}}}{a \cdot 2}\right)} - 1} \]
  12. Applied egg-rr20.5%

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{c \cdot \left(4 \cdot a\right)}{\left(a \cdot 2\right) \cdot \left(\left(-b\right) - {\left(\frac{\mathsf{fma}\left(c \cdot \left(4 \cdot a\right), \mathsf{fma}\left(b, b, c \cdot \left(4 \cdot a\right)\right), {b}^{4}\right)}{\mathsf{fma}\left(-64, {\left(c \cdot a\right)}^{3}, {b}^{6}\right)}\right)}^{-0.5}\right)}\right)} - 1} \]
  13. Step-by-step derivation
    1. expm1-def83.5%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{c \cdot \left(4 \cdot a\right)}{\left(a \cdot 2\right) \cdot \left(\left(-b\right) - {\left(\frac{\mathsf{fma}\left(c \cdot \left(4 \cdot a\right), \mathsf{fma}\left(b, b, c \cdot \left(4 \cdot a\right)\right), {b}^{4}\right)}{\mathsf{fma}\left(-64, {\left(c \cdot a\right)}^{3}, {b}^{6}\right)}\right)}^{-0.5}\right)}\right)\right)} \]
    2. expm1-log1p99.4%

      \[\leadsto \color{blue}{\frac{c \cdot \left(4 \cdot a\right)}{\left(a \cdot 2\right) \cdot \left(\left(-b\right) - {\left(\frac{\mathsf{fma}\left(c \cdot \left(4 \cdot a\right), \mathsf{fma}\left(b, b, c \cdot \left(4 \cdot a\right)\right), {b}^{4}\right)}{\mathsf{fma}\left(-64, {\left(c \cdot a\right)}^{3}, {b}^{6}\right)}\right)}^{-0.5}\right)}} \]
    3. associate-/r*99.8%

      \[\leadsto \color{blue}{\frac{\frac{c \cdot \left(4 \cdot a\right)}{a \cdot 2}}{\left(-b\right) - {\left(\frac{\mathsf{fma}\left(c \cdot \left(4 \cdot a\right), \mathsf{fma}\left(b, b, c \cdot \left(4 \cdot a\right)\right), {b}^{4}\right)}{\mathsf{fma}\left(-64, {\left(c \cdot a\right)}^{3}, {b}^{6}\right)}\right)}^{-0.5}}} \]
    4. associate-*r*99.8%

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

      \[\leadsto \frac{\frac{\left(c \cdot 4\right) \cdot a}{\color{blue}{2 \cdot a}}}{\left(-b\right) - {\left(\frac{\mathsf{fma}\left(c \cdot \left(4 \cdot a\right), \mathsf{fma}\left(b, b, c \cdot \left(4 \cdot a\right)\right), {b}^{4}\right)}{\mathsf{fma}\left(-64, {\left(c \cdot a\right)}^{3}, {b}^{6}\right)}\right)}^{-0.5}} \]
    6. associate-*r*99.8%

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

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

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

    \[\leadsto \frac{\frac{\left(c \cdot 4\right) \cdot a}{a \cdot 2}}{\left(-b\right) - {\left(\frac{\mathsf{fma}\left(\left(c \cdot 4\right) \cdot a, \mathsf{fma}\left(b, b, \left(c \cdot 4\right) \cdot a\right), {b}^{4}\right)}{\mathsf{fma}\left(-64, {\left(c \cdot a\right)}^{3}, {b}^{6}\right)}\right)}^{-0.5}} \]

Alternative 2: 99.4% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := c \cdot \left(4 \cdot a\right)\\ \frac{\frac{\left(c \cdot 4\right) \cdot a}{\left(-b\right) - {\left(\frac{\mathsf{fma}\left(t_0, \mathsf{fma}\left(b, b, t_0\right), {b}^{4}\right)}{{b}^{6} + -64 \cdot {\left(c \cdot a\right)}^{3}}\right)}^{-0.5}}}{a \cdot 2} \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (* c (* 4.0 a))))
   (/
    (/
     (* (* c 4.0) a)
     (-
      (- b)
      (pow
       (/
        (fma t_0 (fma b b t_0) (pow b 4.0))
        (+ (pow b 6.0) (* -64.0 (pow (* c a) 3.0))))
       -0.5)))
    (* a 2.0))))
double code(double a, double b, double c) {
	double t_0 = c * (4.0 * a);
	return (((c * 4.0) * a) / (-b - pow((fma(t_0, fma(b, b, t_0), pow(b, 4.0)) / (pow(b, 6.0) + (-64.0 * pow((c * a), 3.0)))), -0.5))) / (a * 2.0);
}
function code(a, b, c)
	t_0 = Float64(c * Float64(4.0 * a))
	return Float64(Float64(Float64(Float64(c * 4.0) * a) / Float64(Float64(-b) - (Float64(fma(t_0, fma(b, b, t_0), (b ^ 4.0)) / Float64((b ^ 6.0) + Float64(-64.0 * (Float64(c * a) ^ 3.0)))) ^ -0.5))) / Float64(a * 2.0))
end
code[a_, b_, c_] := Block[{t$95$0 = N[(c * N[(4.0 * a), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(N[(c * 4.0), $MachinePrecision] * a), $MachinePrecision] / N[((-b) - N[Power[N[(N[(t$95$0 * N[(b * b + t$95$0), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision] / N[(N[Power[b, 6.0], $MachinePrecision] + N[(-64.0 * N[Power[N[(c * a), $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := c \cdot \left(4 \cdot a\right)\\
\frac{\frac{\left(c \cdot 4\right) \cdot a}{\left(-b\right) - {\left(\frac{\mathsf{fma}\left(t_0, \mathsf{fma}\left(b, b, t_0\right), {b}^{4}\right)}{{b}^{6} + -64 \cdot {\left(c \cdot a\right)}^{3}}\right)}^{-0.5}}}{a \cdot 2}
\end{array}
\end{array}
Derivation
  1. Initial program 16.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\frac{\left(c \cdot 4\right) \cdot a}{\left(-b\right) - {\left(\frac{\mathsf{fma}\left(c \cdot \left(4 \cdot a\right), \mathsf{fma}\left(b, b, c \cdot \left(4 \cdot a\right)\right), {b}^{4}\right)}{{b}^{6} + -64 \cdot {\left(c \cdot a\right)}^{3}}\right)}^{-0.5}}}{a \cdot 2} \]

Alternative 3: 96.7% accurate, 0.2× speedup?

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

\\
\left(-2 \cdot \frac{{c}^{3}}{\frac{{b}^{5}}{{a}^{2}}} - \frac{c}{b}\right) - \frac{a}{{b}^{3}} \cdot {c}^{2}
\end{array}
Derivation
  1. Initial program 16.1%

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

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

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

    \[\leadsto \color{blue}{-2 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-1 \cdot \frac{c}{b} + -1 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}}\right)} \]
  5. Step-by-step derivation
    1. associate-+r+96.8%

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

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

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

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

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

      \[\leadsto \left(-2 \cdot \frac{\color{blue}{{c}^{3} \cdot {a}^{2}}}{{b}^{5}} - \frac{c}{b}\right) - \frac{a \cdot {c}^{2}}{{b}^{3}} \]
    7. associate-/l*96.8%

      \[\leadsto \left(-2 \cdot \color{blue}{\frac{{c}^{3}}{\frac{{b}^{5}}{{a}^{2}}}} - \frac{c}{b}\right) - \frac{a \cdot {c}^{2}}{{b}^{3}} \]
    8. associate-/l*96.8%

      \[\leadsto \left(-2 \cdot \frac{{c}^{3}}{\frac{{b}^{5}}{{a}^{2}}} - \frac{c}{b}\right) - \color{blue}{\frac{a}{\frac{{b}^{3}}{{c}^{2}}}} \]
    9. associate-/r/96.8%

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

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

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

Alternative 4: 95.0% accurate, 0.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 90.0% 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 16.1%

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

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

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

    \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}} \]
  5. Step-by-step derivation
    1. mul-1-neg91.4%

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

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

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

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

Alternative 6: 3.3% accurate, 116.0× speedup?

\[\begin{array}{l} \\ 0 \end{array} \]
(FPCore (a b c) :precision binary64 0.0)
double code(double a, double b, double c) {
	return 0.0;
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    code = 0.0d0
end function
public static double code(double a, double b, double c) {
	return 0.0;
}
def code(a, b, c):
	return 0.0
function code(a, b, c)
	return 0.0
end
function tmp = code(a, b, c)
	tmp = 0.0;
end
code[a_, b_, c_] := 0.0
\begin{array}{l}

\\
0
\end{array}
Derivation
  1. Initial program 16.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{-2 \cdot \frac{c}{b} + 2 \cdot \frac{c}{b}} \]
  12. Step-by-step derivation
    1. distribute-rgt-out3.3%

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

      \[\leadsto \frac{c}{b} \cdot \color{blue}{0} \]
    3. mul0-rgt3.3%

      \[\leadsto \color{blue}{0} \]
  13. Simplified3.3%

    \[\leadsto \color{blue}{0} \]
  14. Final simplification3.3%

    \[\leadsto 0 \]

Reproduce

?
herbie shell --seed 2023333 
(FPCore (a b c)
  :name "Quadratic roots, wide range"
  :precision binary64
  :pre (and (and (and (< 4.930380657631324e-32 a) (< a 2.028240960365167e+31)) (and (< 4.930380657631324e-32 b) (< b 2.028240960365167e+31))) (and (< 4.930380657631324e-32 c) (< c 2.028240960365167e+31)))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))