Quantcast
Channel: PTC Community: Message List
Viewing all articles
Browse latest Browse all 11560

Re: Christoffel symbols and symbolic variables

$
0
0

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.


Viewing all articles
Browse latest Browse all 11560

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>