Quadratic roots, narrow range

Percentage Accurate: 55.2% → 91.7%
Time: 16.4s
Alternatives: 11
Speedup: 29.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 11 alternatives:

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

Initial Program: 55.2% 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: 91.7% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(a \cdot \left(c \cdot -4\right), {b}^{-2}, 1\right)\\ \mathbf{if}\;b \leq 6:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left({b}^{2}, t\_0, -{b}^{2}\right)}{\mathsf{fma}\left(\left|b\right|, \sqrt{t\_0}, b\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(a \cdot \left(-2 \cdot \frac{{c}^{3}}{{b}^{5}} + -5 \cdot \frac{a \cdot {c}^{4}}{{b}^{7}}\right) - \frac{c \cdot c}{{b}^{3}}\right) - \frac{c}{b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (fma (* a (* c -4.0)) (pow b -2.0) 1.0)))
   (if (<= b 6.0)
     (/
      (/ (fma (pow b 2.0) t_0 (- (pow b 2.0))) (fma (fabs b) (sqrt t_0) b))
      (* 2.0 a))
     (-
      (*
       a
       (-
        (*
         a
         (+
          (* -2.0 (/ (pow c 3.0) (pow b 5.0)))
          (* -5.0 (/ (* a (pow c 4.0)) (pow b 7.0)))))
        (/ (* c c) (pow b 3.0))))
      (/ c b)))))
double code(double a, double b, double c) {
	double t_0 = fma((a * (c * -4.0)), pow(b, -2.0), 1.0);
	double tmp;
	if (b <= 6.0) {
		tmp = (fma(pow(b, 2.0), t_0, -pow(b, 2.0)) / fma(fabs(b), sqrt(t_0), b)) / (2.0 * a);
	} else {
		tmp = (a * ((a * ((-2.0 * (pow(c, 3.0) / pow(b, 5.0))) + (-5.0 * ((a * pow(c, 4.0)) / pow(b, 7.0))))) - ((c * c) / pow(b, 3.0)))) - (c / b);
	}
	return tmp;
}
function code(a, b, c)
	t_0 = fma(Float64(a * Float64(c * -4.0)), (b ^ -2.0), 1.0)
	tmp = 0.0
	if (b <= 6.0)
		tmp = Float64(Float64(fma((b ^ 2.0), t_0, Float64(-(b ^ 2.0))) / fma(abs(b), sqrt(t_0), b)) / Float64(2.0 * a));
	else
		tmp = Float64(Float64(a * Float64(Float64(a * Float64(Float64(-2.0 * Float64((c ^ 3.0) / (b ^ 5.0))) + Float64(-5.0 * Float64(Float64(a * (c ^ 4.0)) / (b ^ 7.0))))) - Float64(Float64(c * c) / (b ^ 3.0)))) - Float64(c / b));
	end
	return tmp
end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision] * N[Power[b, -2.0], $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[b, 6.0], N[(N[(N[(N[Power[b, 2.0], $MachinePrecision] * t$95$0 + (-N[Power[b, 2.0], $MachinePrecision])), $MachinePrecision] / N[(N[Abs[b], $MachinePrecision] * N[Sqrt[t$95$0], $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(a * N[(N[(a * N[(N[(-2.0 * N[(N[Power[c, 3.0], $MachinePrecision] / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-5.0 * N[(N[(a * N[Power[c, 4.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(c * c), $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(a \cdot \left(c \cdot -4\right), {b}^{-2}, 1\right)\\
\mathbf{if}\;b \leq 6:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left({b}^{2}, t\_0, -{b}^{2}\right)}{\mathsf{fma}\left(\left|b\right|, \sqrt{t\_0}, b\right)}}{2 \cdot a}\\

\mathbf{else}:\\
\;\;\;\;a \cdot \left(a \cdot \left(-2 \cdot \frac{{c}^{3}}{{b}^{5}} + -5 \cdot \frac{a \cdot {c}^{4}}{{b}^{7}}\right) - \frac{c \cdot c}{{b}^{3}}\right) - \frac{c}{b}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 6

    1. Initial program 85.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6 < b

    1. Initial program 49.9%

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b} + a \cdot \left(-1 \cdot \frac{{c}^{2}}{{b}^{3}} + a \cdot \left(-2 \cdot \frac{{c}^{3}}{{b}^{5}} + -0.25 \cdot \frac{a \cdot \left(4 \cdot \frac{{c}^{4}}{{b}^{6}} + 16 \cdot \frac{{c}^{4}}{{b}^{6}}\right)}{b}\right)\right)} \]
    6. Taylor expanded in c around 0 94.0%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{-c}{b}} + a \cdot \left(-1 \cdot \frac{c \cdot c}{{b}^{3}} + a \cdot \left(-2 \cdot \frac{{c}^{3}}{{b}^{5}} + -5 \cdot \frac{a \cdot {c}^{4}}{{b}^{7}}\right)\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification92.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 6:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left({b}^{2}, \mathsf{fma}\left(a \cdot \left(c \cdot -4\right), {b}^{-2}, 1\right), -{b}^{2}\right)}{\mathsf{fma}\left(\left|b\right|, \sqrt{\mathsf{fma}\left(a \cdot \left(c \cdot -4\right), {b}^{-2}, 1\right)}, b\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(a \cdot \left(-2 \cdot \frac{{c}^{3}}{{b}^{5}} + -5 \cdot \frac{a \cdot {c}^{4}}{{b}^{7}}\right) - \frac{c \cdot c}{{b}^{3}}\right) - \frac{c}{b}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 91.5% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(c, -4, \frac{{b}^{2}}{a}\right)\\ \mathbf{if}\;b \leq 6.2:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(a, t\_0, -{b}^{2}\right)}{\mathsf{fma}\left(\sqrt{a}, \sqrt{t\_0}, b\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(a \cdot \left(-2 \cdot \frac{{c}^{3}}{{b}^{5}} + -5 \cdot \frac{a \cdot {c}^{4}}{{b}^{7}}\right) - \frac{c \cdot c}{{b}^{3}}\right) - \frac{c}{b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (fma c -4.0 (/ (pow b 2.0) a))))
   (if (<= b 6.2)
     (/ (/ (fma a t_0 (- (pow b 2.0))) (fma (sqrt a) (sqrt t_0) b)) (* 2.0 a))
     (-
      (*
       a
       (-
        (*
         a
         (+
          (* -2.0 (/ (pow c 3.0) (pow b 5.0)))
          (* -5.0 (/ (* a (pow c 4.0)) (pow b 7.0)))))
        (/ (* c c) (pow b 3.0))))
      (/ c b)))))
double code(double a, double b, double c) {
	double t_0 = fma(c, -4.0, (pow(b, 2.0) / a));
	double tmp;
	if (b <= 6.2) {
		tmp = (fma(a, t_0, -pow(b, 2.0)) / fma(sqrt(a), sqrt(t_0), b)) / (2.0 * a);
	} else {
		tmp = (a * ((a * ((-2.0 * (pow(c, 3.0) / pow(b, 5.0))) + (-5.0 * ((a * pow(c, 4.0)) / pow(b, 7.0))))) - ((c * c) / pow(b, 3.0)))) - (c / b);
	}
	return tmp;
}
function code(a, b, c)
	t_0 = fma(c, -4.0, Float64((b ^ 2.0) / a))
	tmp = 0.0
	if (b <= 6.2)
		tmp = Float64(Float64(fma(a, t_0, Float64(-(b ^ 2.0))) / fma(sqrt(a), sqrt(t_0), b)) / Float64(2.0 * a));
	else
		tmp = Float64(Float64(a * Float64(Float64(a * Float64(Float64(-2.0 * Float64((c ^ 3.0) / (b ^ 5.0))) + Float64(-5.0 * Float64(Float64(a * (c ^ 4.0)) / (b ^ 7.0))))) - Float64(Float64(c * c) / (b ^ 3.0)))) - Float64(c / b));
	end
	return tmp
end
code[a_, b_, c_] := Block[{t$95$0 = N[(c * -4.0 + N[(N[Power[b, 2.0], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, 6.2], N[(N[(N[(a * t$95$0 + (-N[Power[b, 2.0], $MachinePrecision])), $MachinePrecision] / N[(N[Sqrt[a], $MachinePrecision] * N[Sqrt[t$95$0], $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(a * N[(N[(a * N[(N[(-2.0 * N[(N[Power[c, 3.0], $MachinePrecision] / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-5.0 * N[(N[(a * N[Power[c, 4.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(c * c), $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(c, -4, \frac{{b}^{2}}{a}\right)\\
\mathbf{if}\;b \leq 6.2:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(a, t\_0, -{b}^{2}\right)}{\mathsf{fma}\left(\sqrt{a}, \sqrt{t\_0}, b\right)}}{2 \cdot a}\\

\mathbf{else}:\\
\;\;\;\;a \cdot \left(a \cdot \left(-2 \cdot \frac{{c}^{3}}{{b}^{5}} + -5 \cdot \frac{a \cdot {c}^{4}}{{b}^{7}}\right) - \frac{c \cdot c}{{b}^{3}}\right) - \frac{c}{b}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 6.20000000000000018

    1. Initial program 85.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.20000000000000018 < b

    1. Initial program 49.9%

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b} + a \cdot \left(-1 \cdot \frac{{c}^{2}}{{b}^{3}} + a \cdot \left(-2 \cdot \frac{{c}^{3}}{{b}^{5}} + -0.25 \cdot \frac{a \cdot \left(4 \cdot \frac{{c}^{4}}{{b}^{6}} + 16 \cdot \frac{{c}^{4}}{{b}^{6}}\right)}{b}\right)\right)} \]
    6. Taylor expanded in c around 0 94.0%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{-c}{b}} + a \cdot \left(-1 \cdot \frac{c \cdot c}{{b}^{3}} + a \cdot \left(-2 \cdot \frac{{c}^{3}}{{b}^{5}} + -5 \cdot \frac{a \cdot {c}^{4}}{{b}^{7}}\right)\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification92.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 6.2:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(a, \mathsf{fma}\left(c, -4, \frac{{b}^{2}}{a}\right), -{b}^{2}\right)}{\mathsf{fma}\left(\sqrt{a}, \sqrt{\mathsf{fma}\left(c, -4, \frac{{b}^{2}}{a}\right)}, b\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(a \cdot \left(-2 \cdot \frac{{c}^{3}}{{b}^{5}} + -5 \cdot \frac{a \cdot {c}^{4}}{{b}^{7}}\right) - \frac{c \cdot c}{{b}^{3}}\right) - \frac{c}{b}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 91.4% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(c, -4, \frac{{b}^{2}}{a}\right)\\ \mathbf{if}\;b \leq 6:\\ \;\;\;\;\frac{\frac{a \cdot t\_0 - {b}^{2}}{\mathsf{fma}\left(\sqrt{a}, \sqrt{t\_0}, b\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(a \cdot \left(-2 \cdot \frac{{c}^{3}}{{b}^{5}} + -5 \cdot \frac{a \cdot {c}^{4}}{{b}^{7}}\right) - \frac{c \cdot c}{{b}^{3}}\right) - \frac{c}{b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (fma c -4.0 (/ (pow b 2.0) a))))
   (if (<= b 6.0)
     (/ (/ (- (* a t_0) (pow b 2.0)) (fma (sqrt a) (sqrt t_0) b)) (* 2.0 a))
     (-
      (*
       a
       (-
        (*
         a
         (+
          (* -2.0 (/ (pow c 3.0) (pow b 5.0)))
          (* -5.0 (/ (* a (pow c 4.0)) (pow b 7.0)))))
        (/ (* c c) (pow b 3.0))))
      (/ c b)))))
double code(double a, double b, double c) {
	double t_0 = fma(c, -4.0, (pow(b, 2.0) / a));
	double tmp;
	if (b <= 6.0) {
		tmp = (((a * t_0) - pow(b, 2.0)) / fma(sqrt(a), sqrt(t_0), b)) / (2.0 * a);
	} else {
		tmp = (a * ((a * ((-2.0 * (pow(c, 3.0) / pow(b, 5.0))) + (-5.0 * ((a * pow(c, 4.0)) / pow(b, 7.0))))) - ((c * c) / pow(b, 3.0)))) - (c / b);
	}
	return tmp;
}
function code(a, b, c)
	t_0 = fma(c, -4.0, Float64((b ^ 2.0) / a))
	tmp = 0.0
	if (b <= 6.0)
		tmp = Float64(Float64(Float64(Float64(a * t_0) - (b ^ 2.0)) / fma(sqrt(a), sqrt(t_0), b)) / Float64(2.0 * a));
	else
		tmp = Float64(Float64(a * Float64(Float64(a * Float64(Float64(-2.0 * Float64((c ^ 3.0) / (b ^ 5.0))) + Float64(-5.0 * Float64(Float64(a * (c ^ 4.0)) / (b ^ 7.0))))) - Float64(Float64(c * c) / (b ^ 3.0)))) - Float64(c / b));
	end
	return tmp
end
code[a_, b_, c_] := Block[{t$95$0 = N[(c * -4.0 + N[(N[Power[b, 2.0], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, 6.0], N[(N[(N[(N[(a * t$95$0), $MachinePrecision] - N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[a], $MachinePrecision] * N[Sqrt[t$95$0], $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(a * N[(N[(a * N[(N[(-2.0 * N[(N[Power[c, 3.0], $MachinePrecision] / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-5.0 * N[(N[(a * N[Power[c, 4.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(c * c), $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(c, -4, \frac{{b}^{2}}{a}\right)\\
\mathbf{if}\;b \leq 6:\\
\;\;\;\;\frac{\frac{a \cdot t\_0 - {b}^{2}}{\mathsf{fma}\left(\sqrt{a}, \sqrt{t\_0}, b\right)}}{2 \cdot a}\\

\mathbf{else}:\\
\;\;\;\;a \cdot \left(a \cdot \left(-2 \cdot \frac{{c}^{3}}{{b}^{5}} + -5 \cdot \frac{a \cdot {c}^{4}}{{b}^{7}}\right) - \frac{c \cdot c}{{b}^{3}}\right) - \frac{c}{b}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 6

    1. Initial program 85.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6 < b

    1. Initial program 49.9%

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b} + a \cdot \left(-1 \cdot \frac{{c}^{2}}{{b}^{3}} + a \cdot \left(-2 \cdot \frac{{c}^{3}}{{b}^{5}} + -0.25 \cdot \frac{a \cdot \left(4 \cdot \frac{{c}^{4}}{{b}^{6}} + 16 \cdot \frac{{c}^{4}}{{b}^{6}}\right)}{b}\right)\right)} \]
    6. Taylor expanded in c around 0 94.0%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{-c}{b}} + a \cdot \left(-1 \cdot \frac{c \cdot c}{{b}^{3}} + a \cdot \left(-2 \cdot \frac{{c}^{3}}{{b}^{5}} + -5 \cdot \frac{a \cdot {c}^{4}}{{b}^{7}}\right)\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification92.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 6:\\ \;\;\;\;\frac{\frac{a \cdot \mathsf{fma}\left(c, -4, \frac{{b}^{2}}{a}\right) - {b}^{2}}{\mathsf{fma}\left(\sqrt{a}, \sqrt{\mathsf{fma}\left(c, -4, \frac{{b}^{2}}{a}\right)}, b\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(a \cdot \left(-2 \cdot \frac{{c}^{3}}{{b}^{5}} + -5 \cdot \frac{a \cdot {c}^{4}}{{b}^{7}}\right) - \frac{c \cdot c}{{b}^{3}}\right) - \frac{c}{b}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 91.3% accurate, 0.2× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;a \cdot \left(a \cdot \left(-2 \cdot \frac{{c}^{3}}{{b}^{5}} + -5 \cdot \frac{a \cdot {c}^{4}}{{b}^{7}}\right) - \frac{c \cdot c}{{b}^{3}}\right) - \frac{c}{b}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 6

    1. Initial program 85.4%

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

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

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

    if 6 < b

    1. Initial program 49.9%

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b} + a \cdot \left(-1 \cdot \frac{{c}^{2}}{{b}^{3}} + a \cdot \left(-2 \cdot \frac{{c}^{3}}{{b}^{5}} + -0.25 \cdot \frac{a \cdot \left(4 \cdot \frac{{c}^{4}}{{b}^{6}} + 16 \cdot \frac{{c}^{4}}{{b}^{6}}\right)}{b}\right)\right)} \]
    6. Taylor expanded in c around 0 94.0%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{-c}{b}} + a \cdot \left(-1 \cdot \frac{c \cdot c}{{b}^{3}} + a \cdot \left(-2 \cdot \frac{{c}^{3}}{{b}^{5}} + -5 \cdot \frac{a \cdot {c}^{4}}{{b}^{7}}\right)\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification92.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 6:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)} - b}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(a \cdot \left(-2 \cdot \frac{{c}^{3}}{{b}^{5}} + -5 \cdot \frac{a \cdot {c}^{4}}{{b}^{7}}\right) - \frac{c \cdot c}{{b}^{3}}\right) - \frac{c}{b}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 85.6% accurate, 0.3× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{\left(-c\right) - a \cdot {\left(\frac{c}{b}\right)}^{2}}{b}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) < -0.010200000000000001

    1. Initial program 80.7%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \log \left(1 + \mathsf{expm1}\left(\frac{\sqrt{{b}^{2} \cdot \color{blue}{\left(\frac{\left(a \cdot -4\right) \cdot c}{{b}^{2}} + 1\right)}} - b}{a \cdot 2}\right)\right) \]
      4. div-inv53.8%

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

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

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

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

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

      \[\leadsto \color{blue}{\log \left(1 + \mathsf{expm1}\left(\frac{\sqrt{{b}^{2} \cdot \mathsf{fma}\left(a \cdot \left(-4 \cdot c\right), {b}^{-2}, 1\right)} - b}{a \cdot 2}\right)\right)} \]
    10. Step-by-step derivation
      1. add-sqr-sqrt53.5%

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

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

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

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

      \[\leadsto \color{blue}{2 \cdot \log \left(\sqrt{\sqrt{e^{\frac{\sqrt{{b}^{2} \cdot \mathsf{fma}\left(a \cdot \left(c \cdot -4\right), {b}^{-2}, 1\right)} - b}{a}}}}\right)} \]
    14. Taylor expanded in c around inf 80.5%

      \[\leadsto \color{blue}{0.5 \cdot \frac{b \cdot \sqrt{1 + -4 \cdot \frac{a \cdot c}{{b}^{2}}} - b}{a}} \]
    15. Step-by-step derivation
      1. fmm-def81.2%

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

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

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

    if -0.010200000000000001 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a))

    1. Initial program 46.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. *-commutative46.1%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\left(-c\right) - a \cdot \frac{{c}^{2}}{{b}^{2}}}{b}} \]
    8. Step-by-step derivation
      1. expm1-log1p-u70.7%

        \[\leadsto \frac{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(-c\right) - a \cdot \frac{{c}^{2}}{{b}^{2}}\right)\right)}}{b} \]
      2. div-inv70.7%

        \[\leadsto \frac{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(-c\right) - a \cdot \color{blue}{\left({c}^{2} \cdot \frac{1}{{b}^{2}}\right)}\right)\right)}{b} \]
      3. pow-flip70.7%

        \[\leadsto \frac{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(-c\right) - a \cdot \left({c}^{2} \cdot \color{blue}{{b}^{\left(-2\right)}}\right)\right)\right)}{b} \]
      4. metadata-eval70.7%

        \[\leadsto \frac{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(-c\right) - a \cdot \left({c}^{2} \cdot {b}^{\color{blue}{-2}}\right)\right)\right)}{b} \]
    9. Applied egg-rr70.7%

      \[\leadsto \frac{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(-c\right) - a \cdot \left({c}^{2} \cdot {b}^{-2}\right)\right)\right)}}{b} \]
    10. Step-by-step derivation
      1. expm1-undefine59.6%

        \[\leadsto \frac{\color{blue}{e^{\mathsf{log1p}\left(\left(-c\right) - a \cdot \left({c}^{2} \cdot {b}^{-2}\right)\right)} - 1}}{b} \]
      2. sub-neg59.6%

        \[\leadsto \frac{\color{blue}{e^{\mathsf{log1p}\left(\left(-c\right) - a \cdot \left({c}^{2} \cdot {b}^{-2}\right)\right)} + \left(-1\right)}}{b} \]
      3. log1p-undefine59.6%

        \[\leadsto \frac{e^{\color{blue}{\log \left(1 + \left(\left(-c\right) - a \cdot \left({c}^{2} \cdot {b}^{-2}\right)\right)\right)}} + \left(-1\right)}{b} \]
      4. rem-exp-log77.4%

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{2}} - c}}{b} \]
    13. Step-by-step derivation
      1. sub-neg88.5%

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

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

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

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

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

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

        \[\leadsto \frac{\left(-c\right) - a \cdot \frac{c \cdot c}{\color{blue}{b \cdot b}}}{b} \]
      8. times-frac88.5%

        \[\leadsto \frac{\left(-c\right) - a \cdot \color{blue}{\left(\frac{c}{b} \cdot \frac{c}{b}\right)}}{b} \]
      9. unpow188.5%

        \[\leadsto \frac{\left(-c\right) - a \cdot \left(\color{blue}{{\left(\frac{c}{b}\right)}^{1}} \cdot \frac{c}{b}\right)}{b} \]
      10. pow-plus88.5%

        \[\leadsto \frac{\left(-c\right) - a \cdot \color{blue}{{\left(\frac{c}{b}\right)}^{\left(1 + 1\right)}}}{b} \]
      11. metadata-eval88.5%

        \[\leadsto \frac{\left(-c\right) - a \cdot {\left(\frac{c}{b}\right)}^{\color{blue}{2}}}{b} \]
    14. Simplified88.5%

      \[\leadsto \frac{\color{blue}{\left(-c\right) - a \cdot {\left(\frac{c}{b}\right)}^{2}}}{b} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification86.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{2 \cdot a} \leq -0.0102:\\ \;\;\;\;0.5 \cdot \frac{\mathsf{fma}\left(b, \sqrt{1 + -4 \cdot \frac{a \cdot c}{{b}^{2}}}, -b\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-c\right) - a \cdot {\left(\frac{c}{b}\right)}^{2}}{b}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 89.4% accurate, 0.3× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;a \cdot \left(\frac{-2 \cdot \left(a \cdot {c}^{3}\right)}{{b}^{5}} - \frac{{c}^{2}}{{b}^{3}}\right) - \frac{c}{b}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 6

    1. Initial program 85.4%

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

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

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

    if 6 < b

    1. Initial program 49.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{a \cdot \left(\frac{-2 \cdot \left(a \cdot {c}^{3}\right)}{{b}^{5}} - \frac{{c}^{2}}{{b}^{3}}\right) - \frac{c}{b}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification90.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 6:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)} - b}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(\frac{-2 \cdot \left(a \cdot {c}^{3}\right)}{{b}^{5}} - \frac{{c}^{2}}{{b}^{3}}\right) - \frac{c}{b}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 85.5% accurate, 0.3× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{\left(-c\right) - a \cdot {\left(\frac{c}{b}\right)}^{2}}{b}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) < -0.010200000000000001

    1. Initial program 80.7%

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

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

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

    if -0.010200000000000001 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a))

    1. Initial program 46.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. *-commutative46.1%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\left(-c\right) - a \cdot \frac{{c}^{2}}{{b}^{2}}}{b}} \]
    8. Step-by-step derivation
      1. expm1-log1p-u70.7%

        \[\leadsto \frac{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(-c\right) - a \cdot \frac{{c}^{2}}{{b}^{2}}\right)\right)}}{b} \]
      2. div-inv70.7%

        \[\leadsto \frac{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(-c\right) - a \cdot \color{blue}{\left({c}^{2} \cdot \frac{1}{{b}^{2}}\right)}\right)\right)}{b} \]
      3. pow-flip70.7%

        \[\leadsto \frac{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(-c\right) - a \cdot \left({c}^{2} \cdot \color{blue}{{b}^{\left(-2\right)}}\right)\right)\right)}{b} \]
      4. metadata-eval70.7%

        \[\leadsto \frac{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(-c\right) - a \cdot \left({c}^{2} \cdot {b}^{\color{blue}{-2}}\right)\right)\right)}{b} \]
    9. Applied egg-rr70.7%

      \[\leadsto \frac{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(-c\right) - a \cdot \left({c}^{2} \cdot {b}^{-2}\right)\right)\right)}}{b} \]
    10. Step-by-step derivation
      1. expm1-undefine59.6%

        \[\leadsto \frac{\color{blue}{e^{\mathsf{log1p}\left(\left(-c\right) - a \cdot \left({c}^{2} \cdot {b}^{-2}\right)\right)} - 1}}{b} \]
      2. sub-neg59.6%

        \[\leadsto \frac{\color{blue}{e^{\mathsf{log1p}\left(\left(-c\right) - a \cdot \left({c}^{2} \cdot {b}^{-2}\right)\right)} + \left(-1\right)}}{b} \]
      3. log1p-undefine59.6%

        \[\leadsto \frac{e^{\color{blue}{\log \left(1 + \left(\left(-c\right) - a \cdot \left({c}^{2} \cdot {b}^{-2}\right)\right)\right)}} + \left(-1\right)}{b} \]
      4. rem-exp-log77.4%

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{2}} - c}}{b} \]
    13. Step-by-step derivation
      1. sub-neg88.5%

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

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

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

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

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

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

        \[\leadsto \frac{\left(-c\right) - a \cdot \frac{c \cdot c}{\color{blue}{b \cdot b}}}{b} \]
      8. times-frac88.5%

        \[\leadsto \frac{\left(-c\right) - a \cdot \color{blue}{\left(\frac{c}{b} \cdot \frac{c}{b}\right)}}{b} \]
      9. unpow188.5%

        \[\leadsto \frac{\left(-c\right) - a \cdot \left(\color{blue}{{\left(\frac{c}{b}\right)}^{1}} \cdot \frac{c}{b}\right)}{b} \]
      10. pow-plus88.5%

        \[\leadsto \frac{\left(-c\right) - a \cdot \color{blue}{{\left(\frac{c}{b}\right)}^{\left(1 + 1\right)}}}{b} \]
      11. metadata-eval88.5%

        \[\leadsto \frac{\left(-c\right) - a \cdot {\left(\frac{c}{b}\right)}^{\color{blue}{2}}}{b} \]
    14. Simplified88.5%

      \[\leadsto \frac{\color{blue}{\left(-c\right) - a \cdot {\left(\frac{c}{b}\right)}^{2}}}{b} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification86.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{2 \cdot a} \leq -0.0102:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)} - b}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-c\right) - a \cdot {\left(\frac{c}{b}\right)}^{2}}{b}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 89.3% accurate, 0.4× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;c \cdot \left(c \cdot \left(-2 \cdot \frac{c \cdot {a}^{2}}{{b}^{5}} - \frac{a}{{b}^{3}}\right) + \frac{-1}{b}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 6

    1. Initial program 85.4%

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

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

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

    if 6 < b

    1. Initial program 49.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{c \cdot \left(c \cdot \left(-2 \cdot \frac{c \cdot {a}^{2}}{{b}^{5}} - \frac{a}{{b}^{3}}\right) - \frac{1}{b}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification90.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 6:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)} - b}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;c \cdot \left(c \cdot \left(-2 \cdot \frac{c \cdot {a}^{2}}{{b}^{5}} - \frac{a}{{b}^{3}}\right) + \frac{-1}{b}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 85.3% accurate, 1.0× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{\left(-c\right) - a \cdot {\left(\frac{c}{b}\right)}^{2}}{b}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 6

    1. Initial program 85.4%

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

    if 6 < b

    1. Initial program 49.9%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\left(-c\right) - a \cdot \frac{{c}^{2}}{{b}^{2}}}{b}} \]
    8. Step-by-step derivation
      1. expm1-log1p-u53.6%

        \[\leadsto \frac{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(-c\right) - a \cdot \frac{{c}^{2}}{{b}^{2}}\right)\right)}}{b} \]
      2. div-inv53.6%

        \[\leadsto \frac{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(-c\right) - a \cdot \color{blue}{\left({c}^{2} \cdot \frac{1}{{b}^{2}}\right)}\right)\right)}{b} \]
      3. pow-flip53.6%

        \[\leadsto \frac{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(-c\right) - a \cdot \left({c}^{2} \cdot \color{blue}{{b}^{\left(-2\right)}}\right)\right)\right)}{b} \]
      4. metadata-eval53.6%

        \[\leadsto \frac{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(-c\right) - a \cdot \left({c}^{2} \cdot {b}^{\color{blue}{-2}}\right)\right)\right)}{b} \]
    9. Applied egg-rr53.6%

      \[\leadsto \frac{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(-c\right) - a \cdot \left({c}^{2} \cdot {b}^{-2}\right)\right)\right)}}{b} \]
    10. Step-by-step derivation
      1. expm1-undefine44.8%

        \[\leadsto \frac{\color{blue}{e^{\mathsf{log1p}\left(\left(-c\right) - a \cdot \left({c}^{2} \cdot {b}^{-2}\right)\right)} - 1}}{b} \]
      2. sub-neg44.8%

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

        \[\leadsto \frac{e^{\color{blue}{\log \left(1 + \left(\left(-c\right) - a \cdot \left({c}^{2} \cdot {b}^{-2}\right)\right)\right)}} + \left(-1\right)}{b} \]
      4. rem-exp-log77.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-c\right) - a \cdot \frac{c \cdot c}{\color{blue}{b \cdot b}}}{b} \]
      8. times-frac86.3%

        \[\leadsto \frac{\left(-c\right) - a \cdot \color{blue}{\left(\frac{c}{b} \cdot \frac{c}{b}\right)}}{b} \]
      9. unpow186.3%

        \[\leadsto \frac{\left(-c\right) - a \cdot \left(\color{blue}{{\left(\frac{c}{b}\right)}^{1}} \cdot \frac{c}{b}\right)}{b} \]
      10. pow-plus86.3%

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

        \[\leadsto \frac{\left(-c\right) - a \cdot {\left(\frac{c}{b}\right)}^{\color{blue}{2}}}{b} \]
    14. Simplified86.3%

      \[\leadsto \frac{\color{blue}{\left(-c\right) - a \cdot {\left(\frac{c}{b}\right)}^{2}}}{b} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification86.1%

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

Alternative 10: 81.9% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\left(-c\right) - a \cdot \frac{{c}^{2}}{{b}^{2}}}{b}} \]
  8. Step-by-step derivation
    1. expm1-log1p-u52.1%

      \[\leadsto \frac{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(-c\right) - a \cdot \frac{{c}^{2}}{{b}^{2}}\right)\right)}}{b} \]
    2. div-inv52.1%

      \[\leadsto \frac{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(-c\right) - a \cdot \color{blue}{\left({c}^{2} \cdot \frac{1}{{b}^{2}}\right)}\right)\right)}{b} \]
    3. pow-flip52.1%

      \[\leadsto \frac{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(-c\right) - a \cdot \left({c}^{2} \cdot \color{blue}{{b}^{\left(-2\right)}}\right)\right)\right)}{b} \]
    4. metadata-eval52.1%

      \[\leadsto \frac{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(-c\right) - a \cdot \left({c}^{2} \cdot {b}^{\color{blue}{-2}}\right)\right)\right)}{b} \]
  9. Applied egg-rr52.1%

    \[\leadsto \frac{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(-c\right) - a \cdot \left({c}^{2} \cdot {b}^{-2}\right)\right)\right)}}{b} \]
  10. Step-by-step derivation
    1. expm1-undefine44.3%

      \[\leadsto \frac{\color{blue}{e^{\mathsf{log1p}\left(\left(-c\right) - a \cdot \left({c}^{2} \cdot {b}^{-2}\right)\right)} - 1}}{b} \]
    2. sub-neg44.3%

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

      \[\leadsto \frac{e^{\color{blue}{\log \left(1 + \left(\left(-c\right) - a \cdot \left({c}^{2} \cdot {b}^{-2}\right)\right)\right)}} + \left(-1\right)}{b} \]
    4. rem-exp-log72.2%

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

      \[\leadsto \frac{\left(1 + \color{blue}{\left(\left(-c\right) + \left(-a \cdot \left({c}^{2} \cdot {b}^{-2}\right)\right)\right)}\right) + \left(-1\right)}{b} \]
    6. distribute-neg-out72.2%

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

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

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

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

    \[\leadsto \frac{\color{blue}{-1 \cdot \frac{a \cdot {c}^{2}}{{b}^{2}} - c}}{b} \]
  13. Step-by-step derivation
    1. sub-neg80.0%

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

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

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

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

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

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

      \[\leadsto \frac{\left(-c\right) - a \cdot \frac{c \cdot c}{\color{blue}{b \cdot b}}}{b} \]
    8. times-frac80.0%

      \[\leadsto \frac{\left(-c\right) - a \cdot \color{blue}{\left(\frac{c}{b} \cdot \frac{c}{b}\right)}}{b} \]
    9. unpow180.0%

      \[\leadsto \frac{\left(-c\right) - a \cdot \left(\color{blue}{{\left(\frac{c}{b}\right)}^{1}} \cdot \frac{c}{b}\right)}{b} \]
    10. pow-plus80.0%

      \[\leadsto \frac{\left(-c\right) - a \cdot \color{blue}{{\left(\frac{c}{b}\right)}^{\left(1 + 1\right)}}}{b} \]
    11. metadata-eval80.0%

      \[\leadsto \frac{\left(-c\right) - a \cdot {\left(\frac{c}{b}\right)}^{\color{blue}{2}}}{b} \]
  14. Simplified80.0%

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

Alternative 11: 64.6% accurate, 29.0× speedup?

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

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

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

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

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

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

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

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

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

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

Reproduce

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