# How to use Assumptions in a Series Expansion

I want to series expansion the expression $\frac{1}{2} \left(e_1+e_2-\sqrt{e_1^2-2e_1e_2+e_2^2+4V_{12}^2} \right)$ up to second order in $V_{12}$ using the assumption $e_1>e_2$. So I tried

Series[1/2 (e1 + e2 - Sqrt[e1^2 - 2 e1 e2 + e2^2 + 4 V12^2]), {V12, 0, 2},
Assumptions -> e1 > e2] // FullSimplify


But there is still $\sqrt{(e_1-e_2)^2}$ terms in the results. What should I do to make the assumption $e_1>e_2$ work?

-
You have to enter the expression in Mathematica code, not TeX code. –  Michael E2 Jun 30 '14 at 14:37
@MichaelE2 fyi, Wolfram alpha was smart enough to parse part of this command even in Latex! It gave back Series Sqrt, ok not exactly the full command, but very impressive none-the-less !Mathematica graphics may be in the future with more AI it will be able to process full latex input as well. –  Nasser Jun 30 '14 at 14:54
@Nasser ToExpression["\\frac {1} {2}\\left (e_ 1+e_ 2- \\sqrt {e_ 1^2-2 e_ 1 e_ 2+e_ 2^2+4 V_ {12}^2} \\right)", TeXForm] -- have to add the extra backslashes by hand, I guess. :( –  Michael E2 Jun 30 '14 at 15:23
I only enter the tex code for display purpose. Thank you anyway! –  Kevin Powell Jun 30 '14 at 15:23
But "display purpose" is not nearly as useful as cut-and-pasteable, if people are to attempt any diagnosis. –  Daniel Lichtblau Jun 30 '14 at 15:37

Assumptions given to Series are not used by FullSimplify that you have in your code.

To pass Asumptions to all functions in given expression, wrap said expression with Assuming:

Assuming[e1 > e2,
Series[1/2 (e1 + e2 - Sqrt[e1^2 - 2 e1 e2 + e2^2 + 4 V12^2] ), {V12, 0, 2}] // Simplify
]
(* e2 + V12^2/(-e1+e2) + O[V12]^3*)


Or, if you want to always use those assumptions in given session, assign them to $Assumptions: $Assumptions = e1 > e2;
Series[1/2 (e1 + e2 - Sqrt[e1^2 - 2 e1 e2 + e2^2 + 4 V12^2] ), {V12, 0, 2}] // Simplify
(* e2 + V12^2/(-e1+e2) + O[V12]^3*)

-
Yeah, that make sense! awesome reply! –  Kevin Powell Jun 30 '14 at 15:29

If we remove the subscripts from the converted TeX,

ToExpression[
"\\frac{1}{2} \\left(e_1+e_2-\\sqrt{e_1^2-2e_1e_2+e_2^2+4V_{12}^2} \\right)",
TeXForm] /. Subscript[b_, e_] :> b[e]
(*
1/2 (e[1] + e[2] - Sqrt[e[1]^2 - 2 e[1] e[2] + e[2]^2 + 4 V[12]^2])
*)


we can simply use PowerExpand:

Series[
1/2 (e[1] + e[2] - Sqrt[e[1]^2 - 2 e[1] e[2] + e[2]^2 + 4 V[12]^2]),
{V[12], 0, 2}] // PowerExpand
(*
e[2] - V[12]^2 / (e[1] - e[2]) + O[V[12]]^3
*)

PowerExpand[
Series[1/2 (e[1] + e[2] - Sqrt[e[1]^2 - 2 e[1] e[2] + e[2]^2 + 4 V[12]^2]), {V[12], 0, 2}],
Assumptions -> e[1] > e[2]
]
(* same as above *)


See the link for the explanation in the PowerExpand documentation.

-
I can convert my code between mathematica and Tex! That's really cool! Thanks! However, how comes it got the correct answer without the assumption e[1]>e[2], is this implicit in using the functions? –  Kevin Powell Jun 30 '14 at 18:06
@KevinPowell That was my sloppiness and my luck. The link explains it. PowerExpand just picks one way if the assumptions are not specified. I should have specified the assumptions. –  Michael E2 Jun 30 '14 at 18:21