Hi!
On Jun 4, 1:24 am, JBates <
bat...@wfu.edu> wrote:
> Hi, everyone! I'm a new user to xAct working my way up the learning
> curve, but I've run into a problem I haven't been able to solve
> involving trying to break up a large tensor expression using the
> Coefficient command. The relevant portion of the code is this:
>
> NKR[a_, b_, i_, j_] = NKX[a, b, i, j];
> Do[
> Print[ToValues[A[{n, -Zs}]]];
> ComponentValue[B[{n, Zs}, a, b, i, j],
> Coefficient[NKR[a, b, i, j], ToValues[A[{n, -Zs}]]]];
> Tmp[a_, b_, i_, j_] =
> ToValues[A[{n, -Zs}]]*ToValues[B[{n, Zs}, a, b, i, j]] // Expand;
> NKR[a_, b_, i_, j_] = NKR[a, b, i, j] - Tmp[a, b, i, j];,
> {n, 1, 2}];
I don't understand why you use ToValues in the previous code. Is the A
tensor explicitly present in your NKR expression or not? Is the result
of ToValues[A[...]] a complicated expression? Note that Coefficient[ a
x + b x, a + b ] does not return x.
Have you tried to play with Mathematica's Collect ? It is very useful
when trying to isolate the respective coefficients of a given list of
expressions.
I see that you use NKR as temporary storage. As you mention further
down, you do not need a tensor expression for that. A simple variable
is enough.
Does n go only to 2 in your real example, or is this only an example?
If you are looking for just 2 coefficients, perhaps it is simpler to
replace by hand the respective expressions by 0 in the original full
expression.
> The NKX tensor is the one I would like to break up into the form
> NKX=A_n * B^n, where A is the list of coefficients and B is the list
> of associated tensors. The problem is that NKX is a very large
> expression, and as written I cannot get this to evaluate in a
> reasonable timeframe.
>
> However, if I don't define NKR as a tensor, and and write the
> expression as
>
> NKR = NKX[a, b, i, j];
> Do[
> Print[ToValues[A[{n, -Zs}]]];
> ComponentValue[B[{n, Zs}, a, b, i, j],
> Coefficient[NKR, ToValues[A[{n, -Zs}]]]];
> Tmp[a_, b_, i_, j_] =
> ToValues[A[{n, -Zs}]]*ToValues[B[{n, Zs}, a, b, i, j]] // Expand;
> NKR = NKR - Tmp[a, b, i, j];,
> {n, 1, 2}];
>
> then it works fine. (This way takes about ten minutes to evaluate on
> my system.) Unfortunately, when I do things this way, xCoba no longer
> recognizes the B elements as tensors.
I'm confused again. ComponentValue expects all indices to be basis-
indices. Otherwise we do not really have a component. I mean, your
indices a,b,i,j must also be basis-indices, not abstract indices.
> Is there a way around this?
My impression is that you are not using ToValues and/or ComponentValue
correctly, but I cannot really tell with the information provided.
Cheers,
Jose.