I am having some trouble simplifying expressions where a variable can only take a number of specific values. As an example, suppose I have the expression:
$ \lambda(m) = \frac{1+m}{2} \frac{1}{(a+b)} + \frac{1-m}{2} \frac{1}{(a - b)} $,
this can be simplified to
$ \lambda(m) = \frac{1}{(a+mb)} $.
In Mathematica, using the following code:
λ = (1 + m)/2 1/(a + b) + (1 - m)/2 1/(a - b)
FullSimplify[λ, { m == +1 || m == -1}]
the output is:
(a - b m)/(a^2 - b^2)
This expression is correct and does simplify further if a specific value of $m$ is given:
(a - b m)/(a^2 - b^2) /. {m -> +1} // FullSimplify
(a - b m)/(a^2 - b^2) /. {m -> -1} // FullSimplify
Output:
1/(a + b)
1/(a - b)
However, it is not in the fully simplified form given above. I would like to apply a similar procedure to more complex expressions, where it is not so obvious what the answer should be in advance, but I think in these cases I am also getting answers that are not fully simplified.
Any ideas why Mathematica can't simplify the expression in the example?
Additional Examples
A more complicated example where I also can work out the simplified version:
\[Lambda]1 = (Axx + Ayy)^2/(
Azz + 2 Bz (\[Gamma]c - \[Gamma]e) - 2 \[CapitalDelta]) + (
4 Axy^2 + (Axx - Ayy)^2)/(
Azz + 2 Bz (\[Gamma]c + \[Gamma]e) + 2 \[CapitalDelta]);
\[Lambda]2 = -((4 Axy^2 + (Axx - Ayy)^2)/(
Azz - 2 Bz (\[Gamma]c + \[Gamma]e) + 2 \[CapitalDelta])) - (Axx +
Ayy)^2/(Azz - 2 Bz (\[Gamma]c - \[Gamma]e) - 2 \[CapitalDelta]);
\[Lambda] = (1 + m)/2 \[Lambda]1 + (1 - m)/2 \[Lambda]2;
FullSimplify[\[Lambda], {m == +1 || m == -1}]
output:
1/2 (((Axx + Ayy)^2 (1 + m))/(
Azz + 2 Bz (\[Gamma]c - \[Gamma]e) -
2 \[CapitalDelta]) + ((4 Axy^2 + (Axx - Ayy)^2) (-1 + m))/(
Azz - 2 Bz (\[Gamma]c + \[Gamma]e) +
2 \[CapitalDelta]) + ((Axx + Ayy)^2 (-1 + m))/(
Azz - 2 (Bz (\[Gamma]c - \[Gamma]e) + \[CapitalDelta])) + ((4 \
Axy^2 + (Axx - Ayy)^2) (1 + m))/(
Azz + 2 (Bz (\[Gamma]c + \[Gamma]e) + \[CapitalDelta])))
Simplified version:
\[Lambda]simplified =
m (Axx + Ayy)^2/(
Azz + m 2 Bz (\[Gamma]c - \[Gamma]e) - 2 \[CapitalDelta]) +
m (4 Axy^2 + (Axx - Ayy)^2)/(
Azz + m 2 Bz (\[Gamma]c + \[Gamma]e) + 2 \[CapitalDelta]);
(\[Lambda]simplified == \[Lambda]) /. {m -> 1} // FullSimplify
(\[Lambda]simplified == \[Lambda]) /. {m -> -1} // FullSimplify
output:
True
True
A more complicated example where I don't know the solution:
\[Lambda]1 = (Axx + Ayy)^2/(
Azz + 2 Bz (\[Gamma]c - \[Gamma]e) - 2 \[CapitalDelta]) + (
4 Axy^2 + (Axx - Ayy)^2)/(
Azz + 2 Bz (\[Gamma]c + \[Gamma]e) + 2 \[CapitalDelta]);
\[Lambda]2 = -((4 Axy^2 + (Axx - Ayy)^2)/(
Azz - 2 Bz (\[Gamma]c + \[Gamma]e) + 2 \[CapitalDelta])) - (Axx +
Ayy)^2/(Azz - 2 Bz (\[Gamma]c - \[Gamma]e) - 2 \[CapitalDelta]);
\[Lambda]3 = (Axx + Ayy)^2/(
Azz + 2 Bz (\[Gamma]c - \[Gamma]e) - 2 \[CapitalDelta]) - (
4 Axy^2 + (Axx - Ayy)^2)/(
Azz - 2 Bz (\[Gamma]c + \[Gamma]e) +
2 \[CapitalDelta]) - (Axx + Ayy)^2/(
Azz - 2 Bz (\[Gamma]c - \[Gamma]e) - 2 \[CapitalDelta]) + (
4 Axy^2 + (Axx - Ayy)^2)/(
Azz + 2 Bz (\[Gamma]c + \[Gamma]e) + 2 \[CapitalDelta]);
\[Lambda] =
m (1 + m)/2 \[Lambda]1 +
m (1 - m)/2 \[Lambda]2 + (1 - m) (1 + m) \[Lambda]3;
FullSimplify[\[Lambda], {m == +1 || m == -1 || m == 0}]
output:
1/2 (-(((Axx + Ayy)^2 (-2 + m) (1 + m))/(
Azz + 2 Bz (\[Gamma]c - \[Gamma]e) -
2 \[CapitalDelta])) + ((4 Axy^2 + (Axx - Ayy)^2) (-1 + m) (2 +
3 m))/(Azz - 2 Bz (\[Gamma]c + \[Gamma]e) +
2 \[CapitalDelta]) + ((Axx + Ayy)^2 (-1 + m) (2 + 3 m))/(
Azz - 2 (Bz (\[Gamma]c - \[Gamma]e) + \[CapitalDelta])) - ((4 \
Axy^2 + (Axx - Ayy)^2) (-2 + m) (1 + m))/(
Azz + 2 (Bz (\[Gamma]c + \[Gamma]e) + \[CapitalDelta])))
Using FullSimplify[\[Lambda]]
gives the same result, indicating that the specific values for $m$ (-1,0,+1) are not used in the simplification.