Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am doing some calculation with summation and the Kronecker symbol. Here are my steps :

$Assumptions = 
  k1 ∈ Reals &&  k2 ∈ Reals &&  k3 ∈ Reals &&  p1 ∈ Reals &&  p2 ∈ Reals &&  p3 ∈ Reals
k = {k1, k2, k3};
p = {p1, p2, p3};
d[i_, j_] := KroneckerDelta[i, j]
proj[i_, j_, k1_, k2_, k3_] := 
  d[i, j] - 
   (d[i, 1]*k1 + d[i, 2]*k2 + d[i, 3]*k3)*
   (d[j, 1]*k1 + d[j, 2]*k2 + d[j, 3]*k3)/
   (k1^2 + k2^2 + k3^2)
test1 = proj[i, j, k1, k2, k3]*proj[i, j, p1, p2, p3];
test2 = Sum[Sum[test1, {i, 1, 3}], {j, 1, 3}]
test2 // Expand

To explain the steps:

1) I define $\vec{k}$ and $\vec{p}$ with real components.
2) I define a projector $P_{ij} \left( \vec{k} \right) = \delta_{ij} - \frac{k_i k_j}{k^2}$.
3) I compute a summation on the repeated subscript.

After the last step, I have a relatively big expression, the product of k and p components. It looks like $$3-\frac{a}{a+b+c} - \frac{b}{a+b+c} - \frac{c}{a+b+c} +...-...$$ The a, b and c stands for k1, k2 and k3 (or p1, 2, 3).

Now the question: why doesn't Mathematica make the simplification because, as anyone can see, the preceding expression can be simplified to $2 +...-...$

Is the problem linked to the Expand operation? How can I make the simplification I want?. I thought of using /. to do it, but that doesn't work either.

I hope someone will understand my question!

share|improve this question
    
You can try using Simplify and related, but what you think it's a simpler expression will not necessarily match Mathematica's. –  b.gatessucks Feb 15 '13 at 10:23
    
+1 just for formatting your code:) Simplify@test2 works nicely and returns (2 k2 k3 p2 p3 + 2 k1 p1 (k2 p2 + k3 p3) + k1^2 (2 p1^2 + p2^2 + p3^2) + k2^2 (p1^2 + 2 p2^2 + p3^2) + k3^2 (p1^2 + p2^2 + 2 p3^2))/((k1^2 + k2^2 + k3^2) (p1^2 + p2^2 + p3^2)) –  Ajasja Feb 15 '13 at 10:34

3 Answers 3

up vote 1 down vote accepted

You have to explicitly tell Mathematica to simplify expressions. You can do this using Simplify or FullSimplify

Simplify@test2

(2 k2 k3 p2 p3 + 2 k1 p1 (k2 p2 + k3 p3) + 
   k1^2 (2 p1^2 + p2^2 + p3^2) + k2^2 (p1^2 + 2 p2^2 + p3^2) + 
   k3^2 (p1^2 + p2^2 + 2 p3^2))/((k1^2 + k2^2 + k3^2) (p1^2 + p2^2 + 
     p3^2))
share|improve this answer
    
Thank you for your answers. The problem when I use Simplify is that the form of the result is not "usable". I mean in the sense I want to use it. Because the calculation must lead to $1 - (\vec{k}.\vec{p})^2/(k^2*p^2)$. And with simplify, Mathematica doesn't do the factorization I want. I think I have to find an other way to do it, I may already have an idea. I thought I forget an assumption to enable Mathematica to do automatically this simplification. But it won't do what I didn't ask ! –  Lalylulelo Feb 15 '13 at 10:52

Not sure precisely what you want, but maybe it's this:

x = test2 // Expand;
x1 = PolynomialReduce[
   Numerator[Together[x]], {Denominator[Together[x]]}, Variables[x]];
x2 = PolynomialReduce[x1[[2]], {k1^2 + k2^2 + k3^2}, Variables[x]];
x3 = PolynomialReduce[x2[[2]], {p1^2 + p2^2 + p3^2}, Variables[x]];
y = x1[[1, 1]] + x2[[1, 1]]/(p1^2 + p2^2 + p3^2) + 
  x3[[1, 1]]/(k1^2 + k2^2 + k3^2) + 
  x3[[2]]/((p1^2 + p2^2 + p3^2) (k1^2 + k2^2 + k3^2))

Here's the output in reverse order; there's an issue with copy/paste:

$\frac{2 \text{k1} \text{k2} \text{p1} \text{p2}+2 \text{k1} \text{k3} \text{p1} \text{p3}+2 \text{k2}^2 \text{p2}^2+\text{k2}^2 \text{p3}^2+2 \text{k2} \text{k3} \text{p2} \text{p3}+\text{k3}^2 \text{p2}^2+2 \text{k3}^2 \text{p3}^2}{\left(\text{k1}^2+\text{k2}^2+\text{k3}^2\right) \left(\text{p1}^2+\text{p2}^2+\text{p3}^2\right)}+\frac{-\text{k2}^2-\text{k3}^2}{\text{k1}^2+\text{k2}^2+\text{k3}^2}+\frac{-\text{p2}^2-\text{p3}^2}{\text{p1}^2+\text{p2}^2+\text{p3}^2}+2$

share|improve this answer

If you know approximately what denominators are obtained, you coud use command Collect[expression, factor].

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.