# Merge Roots of Polynomial

How can I make mathematica "merge" solutions of a polynomial by using $\pm$ instead of listing the two solutions fully with only one sign difference?

In particular, I am looking to "compactify" the result of the following computation:

Solve[v1^2 + v2^2 + (t1^2 + t2^2)/\[Lambda]^2 + (
2 t1 v1 + 2 t2 v2)/\[Lambda] + 2 t1 Conjugate[t1] +
2 t2 Conjugate[
t2] + \[Lambda] (2 v1 Conjugate[t1] +
2 v2 Conjugate[t2]) + \[Lambda]^2 (Conjugate[t1]^2 +
Conjugate[t2]^2) ==
ET^2, \[Lambda]] /. {(v1 Conjugate[t1] + v2 Conjugate[t2]) ->
vDts} /. {(t1 v1 + t2 v2) -> vDt} /. {(v1^2 + v2^2) ->
vDv} /. {(2 t1 Conjugate[t1] + 2 t2 Conjugate[t2]) ->
2 tDts} /. {(Conjugate[t1]^2 + Conjugate[t2]^2) ->
tsDts} /. {(t1^2 + t2^2) -> tDt}


Something like

roots = λ /. Solve[v1^2 + v2^2 + (t1^2 + t2^2)/λ^2 + (
2 t1 v1 + 2 t2 v2)/λ + 2 t1 Conjugate[t1] +
2 t2 Conjugate[
t2] + λ (2 v1 Conjugate[t1] +
2 v2 Conjugate[t2]) + λ^2 (Conjugate[t1]^2 +
Conjugate[t2]^2) ==
ET^2, λ] /. {(v1 Conjugate[t1] + v2 Conjugate[t2]) ->
vDts} /. {(t1 v1 + t2 v2) -> vDt} /. {(v1^2 + v2^2) ->
vDv} /. {(2 t1 Conjugate[t1] + 2 t2 Conjugate[t2]) ->
2 tDts} /. {(Conjugate[t1]^2 + Conjugate[t2]^2) ->
tsDts} /. {(t1^2 + t2^2) -> tDt};

compact = roots //. {a___, b_ + c_, d___, b_ + e_, f___} /; c + e == 0 :>
{a, b \[PlusMinus] If[InternalSyntacticNegativeQ[e], c, e], d, f};

{Length[roots], Length[compact]}

{4, 2}
`
• Hi, thanks for your help. I am not sure how to apply your recipe to what I have. I was guessing I would write something like roots = Solve[...] with my above equation, and then apply the code you provided. However, the result was simply {4, 4} which doesn't make sense to me.. – PPR Jan 9 '15 at 16:46
• @PPR See my edit. – Chip Hurst Jan 9 '15 at 16:50