Skip to main content
3-Newcomer
March 4, 2014
Solved

Christoffel symbols and symbolic variables

  • March 4, 2014
  • 3 replies
  • 7177 views

Quite some time ago, I did some work with symbolics that led mt to try to create Christoffel symbols in Mathcad. (I can do it in Mathematica, though I am not very good with it, and I can do it in MATLAB, using MATLAB symbolics, but it is not very clean, and certainly not very readable.) I gave it several shots in M15, and have attached the results.

The pieces seem to work, but not the aggregate...should I just do it in Mathematica instead of beating myself up here? Part of the problem here seems to be that symbolics are not handled as well as in Mathematica and MATLAB, at least as far as initial declarations go. I tried simply not declaring t,r,theta,phi, and living with the undeclared complaint, but no joy there either.

~R~

Best answer by Werner_E

It seemed that the func make_gamma (and others) does not need the dimension (t,r,...) names passed on the parm list. I deleted them, and the result was the same.

Yes, thats true. Personally I like to create generic functions and use them to calculate variable values rather than assigning programs directlyto variables as you do in your sheet. A matter of personal taste I guess and no harm, if the evaluation is needed only once in the sheet. Using a function you could evalaute easily for different matrices in the same sheet which obviously is not needed in your case. That was also the reason I made the four dimension names customizeable at the price of a more clumsy argument list. If you are sure you never will change them from t,r,theta and phi to anything else its sure OK to delete them in the argument list. My idea when writing a generic utility function is that everything the routine is using should be either a local variable or be passed as argument to the routine. The routine should not rely on anything outside, not on that a variable with a specific name exists on the worksheet level nor that functions used (in g for example) are using specific argument names (t,r,theta and phi in this case).

I noticed that in the worksheet I posted not all symbolical evals in the program are necessary - only the two using the substitute are.

Then I thought that I'd try your method of substituting. I see now why it works, I think, and it is a

Its tricky and I don't know if it would work in Prime - I fear, no, but I haven't tried so far. I think I used this way of substitution (is necessary because the variable you differentiate wrt can't be a true variable but must be "hardcoded") was when I wrote a routine to solve simple linear ODEs of first order symbolically automatically..

But it doesn't work full for me. It seems to do the first substitution correctly,

No, it doesn't. It looks correct on first sight, but you are assigning g[i,j to g.ij and then you symbolically evaluate that assignment. That way g.ij is assigned the expression without any substitution. Whats needed is to evaluate and substitute g[i,j symbolically first and only thereafter assign the result to g.ij. The same error in the next line, you must first substitute and then assign.

See the attached sheet for a corrected and an even shorter version.

Afterthought: Instead of the simple z as variable to differentiate wrt its adviseable to take something more complicated, preferrably constructed using special character inserted via CTRL-K to be on the safe side. The program would fail if a variable of name z is assigned a value in the worksheet before the definition of the routine. And we can't do a z:=z inside a program. z <-- z would simply assign the value of the worksheet variable z (RHS) to a local variable z.

3 replies

12-Amethyst
March 4, 2014

Hi,

Not sure, exactly, what the output should be.

Attached are a few ideas to try.

Can you show examples of the results that you get from Matlab?

Regards

Andy

Ninetrees3-NewcomerAuthor
3-Newcomer
March 4, 2014

Following your example, I eventually got to the correct solution. I forgot that M15 would not do more than 2D matrices. It let's one /specify/ 3 indices, and looks like it's running OK, but the results are bogus. I had hoped to avoid all this work, but the items that made it more work are the shortcomings of M15 handling symbolics, and the restriction on matrix indicies.

The result is that I must read each page of the result, and "decode" it into the correct multipliers that I need.

Thanks to all who responded...I do appreciate the time and effort.

~R~

19-Tanzanite
March 4, 2014
25-Diamond I
March 4, 2014

And here is mine.

Compared to the others is look quite too tricky, though.

I was a bit confused about the definition of the Christoffel symbol in your sheet - would have rather used the definition Andy had chosen (w/o using gi) as it seems you are looking for the Christoffel symbols of first kind.

But even if I would replace the sum(gi) for 1/2 as Andy did, I would not get matrices consisting of all zeros!?

EDIT: Replace attachment by a (very slightly) more efficient routine

Ninetrees3-NewcomerAuthor
3-Newcomer
March 4, 2014

I think that your results are the same as mine, but I have not compared the trig results.There are some good techniques in the file, if I can understand them 😉

~R~